socket: Handle ECONNRESET as EWOULDBLOCK on Windows
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Tue, 18 Aug 2015 12:33:23 +0000 (13:33 +0100)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Tue, 18 Aug 2015 12:33:23 +0000 (13:33 +0100)
Some versions of Windows can return ECONNRESET for UDP recvmsg() calls
if they would otherwise block. Hence, handle the two equivalently; this
should not affect behaviour on Linux, which apparently does not return
ECONNRESET for UDP recvmsg() calls at all.

https://phabricator.freedesktop.org/T121

socket/udp-bsd.c

index d56f093..d7346ff 100644 (file)
@@ -204,7 +204,10 @@ socket_recv_messages (NiceSocket *sock,
     recv_message->length = MAX (recvd, 0);
 
     if (recvd < 0) {
-      if (g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
+      /* Handle ECONNRESET here as if it were EWOULDBLOCK; see
+       * https://phabricator.freedesktop.org/T121 */
+      if (g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK) ||
+          g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_CONNECTION_CLOSED))
         recvd = 0;
       else
         error = TRUE;