summaryrefslogtreecommitdiff
path: root/socket
diff options
context:
space:
mode:
authorJakub Adam <jakub.adam@collabora.com>2018-12-18 10:36:53 +0100
committerJakub Adam <jakub.adam@collabora.com>2018-12-18 18:34:19 +0100
commit83c5d0fce35edb481125e4ee51d12700cd8eb663 (patch)
treea55bf56b82a0e4a09215e67884ec66f1590f07b3 /socket
parentc5ef4700add00af16a5add34fb0768c5519f214e (diff)
downloadlibnice-83c5d0fce35edb481125e4ee51d12700cd8eb663.tar.gz
udp-bsd: Fix recv with small buffer on Windows
The underlying GSocket implementation on Windows returns an error when the user-provided buffer isn't large enough to fit the whole datagram received on a message-oriented socket. When this occurs, in order to preserve identical behavior of udp-bsd NiceSocket across platforms, we have to mute the error and set the received message length to the size of the provided NiceInputMessage. Any excess portion of the message gets discarded. Fixed udp-bsd test on Windows. GLib 2.48 is required in order to use G_IO_ERROR_MESSAGE_TOO_LARGE.
Diffstat (limited to 'socket')
-rw-r--r--socket/udp-bsd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/socket/udp-bsd.c b/socket/udp-bsd.c
index 0fa8dd7..6d55e15 100644
--- a/socket/udp-bsd.c
+++ b/socket/udp-bsd.c
@@ -206,20 +206,22 @@ socket_recv_messages (NiceSocket *sock,
recv_message->buffers, recv_message->n_buffers, NULL, NULL,
&flags, NULL, &gerr);
- recv_message->length = MAX (recvd, 0);
-
if (recvd < 0) {
/* 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 if (g_error_matches (gerr, G_IO_ERROR, G_IO_ERROR_MESSAGE_TOO_LARGE))
+ recvd = input_message_get_size (recv_message);
else
error = TRUE;
g_error_free (gerr);
}
+ recv_message->length = MAX (recvd, 0);
+
if (recvd > 0 && recv_message->from != NULL && gaddr != NULL) {
union {
struct sockaddr_storage storage;