client connection should always be nonblocking
commit56b39b80740be3ce3a420aaf3b9ed67b6df4572f
authorEric Wong <e@80x24.org>
Thu, 6 Apr 2017 22:18:07 +0000 (6 22:18 +0000)
committerEric Wong <e@80x24.org>
Thu, 6 Apr 2017 22:18:07 +0000 (6 22:18 +0000)
tree12d4ca2d52725a8c0681f75ded2b99ff6d102732
parent6832b1b8514e2967c778bdfecec9f5f4b65567b8
client connection should always be nonblocking

On *BSD platforms, the accept()-ed clients inherit the
O_NONBLOCK file flag from the listen socket.

This is not true on Linux, and I noticed sockets blocking on
write() syscalls via strace.  Checking the octal 04000
(O_NONBLOCK) flag in /proc/$PID/fdinfo/$FD for client TCP
sockets confirms O_NONBLOCK was not set.

This also makes us resilient to spurious wakeups causing
event_read to get stuck, as documented in the Linux select(2)
manpage.
lib/MogileFS/Connection/Client.pm