summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2015-08-18 13:33:23 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2015-08-18 13:33:23 +0100
commitad0003b48414c789a1191fd5f44fec41e694dfa0 (patch)
treeef807bd99b9531cbbb8bbfbc1a3c1202fbbd3b34
parente1f748cccacd81cce4db338d0203dc49bc915a30 (diff)
downloadlibnice-ad0003b48414c789a1191fd5f44fec41e694dfa0.tar.gz
socket: Handle ECONNRESET as EWOULDBLOCK on Windows
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
-rw-r--r--socket/udp-bsd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/socket/udp-bsd.c b/socket/udp-bsd.c
index d56f093..d7346ff 100644
--- a/socket/udp-bsd.c
+++ b/socket/udp-bsd.c
@@ -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;