select + write edge cases
djk at tobit.co.uk
Mon Jan 8 13:12:27 GMT 2007
For a little while now, I have been getting reports of occasional node
hangs on my imitation chat server stuff. Well, over the weekend, it
finally happened to me (it's only taken a couple of years, so it comes
under the category of nuisance rather than serious).
I have a select handler working on (I try to set as) non blocking
sockets ($sock->blocking(0)). I select on output (carefully enabling and
disabling it as output is required to be sent and the queue runs out). I
also make sure that I take account of return values from syswrite() and
deal with things like EAGAIN etc.
However, it still manages to hang in __write_nocancel() (in my perl
5.8.8) on output when the operating system buffer for that socket.
The impression I am getting is that, even when a queue is full, select
may drop saying "output available" and then when I syswrite(), it hangs
instead of returning 0.
More information about the london.pm