From a57e698f01879189d2e7f8a2759579f53ab1c202 Mon Sep 17 00:00:00 2001 From: kalibera Date: Thu, 2 May 2024 12:40:59 +0000 Subject: [PATCH] Use a blocking socket in Rhttpd worker threads on Windows. git-svn-id: https://svn.r-project.org/R/trunk@86509 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/modules/internet/Rhttpd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/internet/Rhttpd.c b/src/modules/internet/Rhttpd.c index 35e27755fc9..70d4f722399 100644 --- a/src/modules/internet/Rhttpd.c +++ b/src/modules/internet/Rhttpd.c @@ -1292,6 +1292,13 @@ static void srv_input_handler(void *data) if (c->ih) c->ih->userData = c; add_worker(c); #else + /* The accepted socket inherits properties of the socket listened to. + The server socket is non-blocking, because WSAEventSelect has been used on it. + Make sure the accepted socket is blocking. */ + WSAEventSelect(c->sock, NULL, 0); + unsigned long mode = 0; + ioctlsocket(c->sock, FIONBIO, &mode); + if (!add_worker(c)) { /* create worker thread only if the worker * was accepted */ if (!(c->thread = CreateThread(NULL, 0, WorkerThreadProc,