valotrading/silvertip — pull request #31 by jvirtanen (2012-11-06 12:21:05+00:00)
Title: Treat sockets writable by default

When sending data on a `Connection`, always attempt to explicitly write to the socket first and, if that is unsuccessful, add writing to the interest set and wake up the selector. Conversely, if the write is successful and the TX buffer becomes empty, remove writing from the interest set.

This fixes the following problem on Darwin: writing is initially in the ready set of a socket, and as long as the remote end does not send more data, the 'Selector#select' method always returns zero because the ready set does not change.

The problem is fixed, because now sockets are treated as writable by default. Only if writing to a socket would block, it is postponed and continued when writing is again in the ready set of the socket. Prior to the fix sockets were treated as non-writable by default, always postponing until a further notification. If the socket was writable from the beginning and did not receive more data, this notification never came.