diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2021-04-12 19:51:53 +0100 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-04-12 18:54:18 +0000 |
commit | d403fd89501e60b8035e80e404a6fa6de9eeda75 (patch) | |
tree | 1fd73e103ac818d078a37a646c282a623f5dc7ac | |
parent | 366257d14bcd8db98d476498c2fb6e8e0a4ff589 (diff) |
glib: Windows socket fixes: WSAENETRESET, and FD_READ condition flag still set on recoverable UDP socket errors
Fixes https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/293
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/696>
3 files changed, 72 insertions, 0 deletions
diff --git a/recipes/glib.recipe b/recipes/glib.recipe index 6d54a653..e9bc0dbd 100644 --- a/recipes/glib.recipe +++ b/recipes/glib.recipe @@ -54,6 +54,10 @@ class Recipe(recipe.Recipe): 'glib/0001-macos-fix-frexpl-checks-in-cross-compilation.patch', # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1884 'glib/0001-gthread-win32-Use-SetThreadDescription-Win32-API-for.patch', + # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1616 + 'glib/0001-gioerror-Map-WSAENETRESET-on-Windows-to-G_IO_ERROR_C.patch', + # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1836 + 'glib/0001-Windows-fix-FD_READ-condition-flag-still-set-on-reco.patch', ] files_libs = [ diff --git a/recipes/glib/0001-Windows-fix-FD_READ-condition-flag-still-set-on-reco.patch b/recipes/glib/0001-Windows-fix-FD_READ-condition-flag-still-set-on-reco.patch new file mode 100644 index 00000000..c2a91d30 --- /dev/null +++ b/recipes/glib/0001-Windows-fix-FD_READ-condition-flag-still-set-on-reco.patch @@ -0,0 +1,34 @@ +From 6900d53ed863a3e3d7e4e36376ac811ab0cca531 Mon Sep 17 00:00:00 2001 +From: Marco Mastropaolo <marco@mastropaolo.com> +Date: Thu, 24 Dec 2020 09:08:40 +0000 +Subject: [PATCH] Windows: fix FD_READ condition flag still set on recoverable + UDP socket errors. + +Contrary to what the WSARecvFrom seem to imply, a UDP socket is perfectly recoverable and usable after a WSAECONNRESET error (and, I assume, WSAENETRESET). +However GSocket condition has the FD_READ bit set after a UDP socket fails with WSAECONNRESET, even if no data is available on the socket anymore; this causes select calls to report the socket as readable when, in fact, it's not. + +The change resets FD_READ flag on a socket upon the above error conditions; there's no 'if' to filter between datagram and stream sockets as the change should be harmless in the case of stream sockets which are, however, very unlikely to be usable after a WSAECONNRESET. +--- + gio/gsocket.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gio/gsocket.c b/gio/gsocket.c +index 0f8f9259f..e911de781 100644 +--- a/gio/gsocket.c ++++ b/gio/gsocket.c +@@ -5475,10 +5475,10 @@ g_socket_receive_message_with_timeout (GSocket *socket, + if (errsv == WSAEINTR) + continue; + ++ win32_unset_event_mask (socket, FD_READ); ++ + if (errsv == WSAEWOULDBLOCK) + { +- win32_unset_event_mask (socket, FD_READ); +- + if (timeout_us != 0) + { + if (!block_on_timeout (socket, G_IO_IN, timeout_us, +-- +2.31.0 + diff --git a/recipes/glib/0001-gioerror-Map-WSAENETRESET-on-Windows-to-G_IO_ERROR_C.patch b/recipes/glib/0001-gioerror-Map-WSAENETRESET-on-Windows-to-G_IO_ERROR_C.patch new file mode 100644 index 00000000..2ff28be9 --- /dev/null +++ b/recipes/glib/0001-gioerror-Map-WSAENETRESET-on-Windows-to-G_IO_ERROR_C.patch @@ -0,0 +1,34 @@ +From a8acbba46a3161add008d50830740fb0201f560a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com> +Date: Mon, 17 Aug 2020 13:11:22 +0300 +Subject: [PATCH] gioerror: Map WSAENETRESET on Windows to + G_IO_ERROR_CONNECTION_CLOSED + +This has almost the same semantics as WSAECONNRESET and for all +practical purposes is handled the same. The main difference is about +*who* reset the connection: the peer or something in the network. + +For UDP sockets this happens when receiving packets and previously sent +packets returned an ICMP "Time(-to-live) expired" message. This is +similar to WSAECONNRESET, which on UDP sockets happens when receiving +packets and previously sent packets returned an ICMP "Port Unreachable" +message. +--- + gio/gioerror.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gio/gioerror.c b/gio/gioerror.c +index 1ec120d98..477906c0c 100644 +--- a/gio/gioerror.c ++++ b/gio/gioerror.c +@@ -343,6 +343,7 @@ g_io_error_from_win32_error (gint error_code) + return G_IO_ERROR_NOT_SUPPORTED; + + case WSAECONNRESET: ++ case WSAENETRESET: + case WSAESHUTDOWN: + return G_IO_ERROR_CONNECTION_CLOSED; + +-- +2.31.0 + |