Protect against spurious connection events.
authorEtienne Dechamps <etienne@edechamps.fr>
Fri, 27 Jun 2014 18:33:31 +0000 (19:33 +0100)
committerEtienne Dechamps <etienne@edechamps.fr>
Fri, 27 Jun 2014 18:39:30 +0000 (19:39 +0100)
The event loop does not guarantee that spurious write I/O events do not
happen; in fact, they are guaranteed to happen on Windows when
event_flush_output() is called. Because handle_meta_io() does not check
for spurious events, a metaconnection socket might appear connected even
though it's not, and will fail immediately when sending the ID request.

This commit fixes this issue by making handle_meta_io() check the
connection status before assuming the socket is connected. It seems that
the only reliable way to do that is to try to call connect() again and
look at the error code, which will be EISCONN if the socket is
connected, or EALREADY if it's not.


No differences found