joyent/node — pull request #4585 by wanderview (2013-01-13 19:14:26+00:00)
Title: streams2: increase highWaterMark for large read()

Automatically increase stream.Readable's highWaterMark if read() is called
for a very large buffer. Very large is defined as being larger than the
highWaterMark. This avoids a possible deadlock in push oriented streams like
net.Socket.

More specifically, if you issue a read() for a buffer larger than net.Socket's
highWaterMark you will never succeed because the underlying socket is
paused. In addition, there is no clear way to set the highWaterMark on
net.Socket instances provided by the net.Server 'connection' event.

This could be fixed directly in net.Socket instead of in the Readable base class,
but it seems possible that this problem could effect other Readable
implementations. Also, this seemed like the simplest place to fix the problem.

I'm interested to know if there is a better or more correct way to deal with this issue. Thank you.