socket/win32: flush pending read before signaling HUP
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Fri, 10 Feb 2012 01:02:29 +0000 (02:02 +0100)
committerMarc-André Lureau <marcandre.lureau@gmail.com>
Fri, 10 Feb 2012 18:07:29 +0000 (19:07 +0100)
commit704a2ca02de0430786114e7d9bf7aa772c40b934
tree1a1cda5132a0bf6c9b59682bb3988c74447915dd
parent6ca817c3f2c14b39792b381466067f71e601f895
socket/win32: flush pending read before signaling HUP

Unix and Windows gio GSocket behaves differently when the socket is
closed by the peer. On Unix, the client receives pending data before
receiving HUP. But on Windows, the HUP may come before, resulting in
unreliable and racy code. We should have same behaviour on all
platforms.

According to MSDN documentation: "an application should check for
remaining data upon receipt of FD_CLOSE to avoid any possibility of
losing data."

https://bugzilla.gnome.org/show_bug.cgi?id=669810
gio/gsocket.c