Commit d403fd89 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠 Committed by GStreamer Marge Bot
Browse files

glib: Windows socket fixes: WSAENETRESET, and FD_READ condition flag still set...

glib: Windows socket fixes: WSAENETRESET, and FD_READ condition flag still set on recoverable UDP socket errors

Fixes #293

Part-of: <!696>
parent 366257d1
Pipeline #299907 passed with stages
in 69 minutes and 33 seconds
......@@ -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 = [
......
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
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment