|
From: | Paul-Albert Desmaisons |
Subject: | [libmicrohttpd] Hanging connections in windows |
Date: | Tue, 18 Jul 2017 07:04:26 +0000 |
Hello everybody.
I experienced the same random connection hanging connection bug described in this thread:
https://lists.gnu.org/archive/html/libmicrohttpd/2015-11/msg00011.html
I think the source of the problem is :
select() in windows does not return when the read set contains the connection socket and a read socket, if the connection socket is 1st in the set.
putting the connection socket a the end seems to fix this problem.
my proposed correction:
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -831,12 +831,21 @@ internal_get_fdset2 (struct MHD_Daemon *daemon,
struct MHD_Connection *posn;
int result = MHD_YES;
MHD_socket ls;
+ bool winSock = 0;/* win32 socket ? */
+#if defined(MHD_WINSOCK_SOCKETS)
+ /* win32 api workaround :
+ * w&& !winSock : win32 api socket does not unlock in a case of mixed "connect" and "read" socket
+ * if the connect socket if first in the list.
+ * workaround : put connection socket <ls> a the end of <read_fd_set> */
+ winSock = 1;
+#endif//MHD_WINSOCK_SOCKETS
if (daemon->shutdown)
return MHD_NO;
ls = daemon->listen_fd;
- if ( (MHD_INVALID_SOCKET != ls) &&
+ if ( !winSock &&
+ (MHD_INVALID_SOCKET != ls) &&
(! daemon->was_quiesced) &&
(! MHD_add_to_fd_set_ (ls,
read_fd_set,
@@ -893,6 +902,18 @@ internal_get_fdset2 (struct MHD_Daemon *daemon,
break;
|
[Prev in Thread] | Current Thread | [Next in Thread] |