summaryrefslogtreecommitdiff
path: root/socket/udp-bsd.c
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2009-11-10 14:27:03 -0500
committerYouness Alaoui <youness.alaoui@collabora.co.uk>2009-11-10 14:27:03 -0500
commit834dcb91f4b7020b367e8359e05ea546ac7bae0e (patch)
tree34f47fedb292ebb6578dd2d8b3a191e3fb916573 /socket/udp-bsd.c
parentbe58253f0de3b89872105395b37a2e474645c6e8 (diff)
downloadlibnice-834dcb91f4b7020b367e8359e05ea546ac7bae0e.tar.gz
Even for UDP sockets, we should handle EAGAIN errors because it can happen.. Apparently recvfrom can return EAGAIN on udp sockets if for example there's a bad checksum in the packet or some other similar error
Diffstat (limited to 'socket/udp-bsd.c')
-rw-r--r--socket/udp-bsd.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/socket/udp-bsd.c b/socket/udp-bsd.c
index db302eb..f2fcb4d 100644
--- a/socket/udp-bsd.c
+++ b/socket/udp-bsd.c
@@ -160,6 +160,15 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
recvd = recvfrom (sock->fileno, buf, len, 0, (struct sockaddr *) &sa,
&from_len);
+ if (recvd < 0) {
+#ifdef G_OS_WIN32
+ if (WSAGetLastError () == WSAEWOULDBLOCK)
+#else
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
+#endif
+ return 0;
+ }
+
if (recvd > 0)
nice_address_set_from_sockaddr (from, (struct sockaddr *)&sa);