View Issue Details

IDProjectCategoryView StatusLast Update
0005278libmicrohttpdlibmicrohttpd internal selectpublic2018-11-06 19:46
ReportertexecAssigned ToChristian Grothoff 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.59 
Target Version0.9.60Fixed in Version0.9.60 
Summary0005278: Long running connections are aborted due to incomplete logic change
DescriptionCommit d9b6e400 added fd_set es to thread_main_handle_connection in daemon.c. Later in the case MHD_EVENT_LOOP_INFO_BLOCK the socket is added to &es via add_tod_fd_set. Previously it was added to &rs.
Then in line 1621 (d9b6e400) the following code is left unchanged:

      num_ready = MHD_SYS_select_ (maxsock + 1,
                                       &rs,
                                       &ws,
                                       NULL,
                                       tvp);

In 1654 FD_ISSET(…, &es) is passed as force_close argument to call_handlers. As &es is not cleared by the select call it's still set and the connection is always closed.

In our experience this leads to a closed connection 1-5 seconds after we sent our last data. Due to this delay/timeout the issue may not have been detected previously.

Using &es as argument to SYS_select_ instead of NULL fixes the problem for us.
Additional Informationd9b6e400 was released with 0.9.53.

(Current master (48dd53c7eb, gnunet) does not build on macOS, as the definition of MHD_socket_create_listen_ in mhd_sockets.h seems to be wrong (the function is called with a socket descriptor, not a boolean argument))
TagsNo tags attached.

Relationships

has duplicate 0005295 closedChristian Grothoff connection forcibly closed when response reader returns no data 

Activities

texec

2018-02-14 21:24

reporter  

issue-select-master.diff (524 bytes)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 639add58..141c89d4 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1937,7 +1937,7 @@ thread_main_handle_connection (void *data)
 	  num_ready = MHD_SYS_select_ (maxsock + 1,
                                        &rs,
                                        &ws,
-                                       NULL,
+                                       &es,
                                        tvp);
 	  if (num_ready < 0)
 	    {

Christian Grothoff

2018-02-16 05:03

manager   ~0012860

Fixed in Git master as suggested.

Issue History

Date Modified Username Field Change
2018-02-14 21:24 texec New Issue
2018-02-14 21:24 texec File Added: issue-select-master.diff
2018-02-16 05:03 Christian Grothoff Assigned To => Christian Grothoff
2018-02-16 05:03 Christian Grothoff Status new => resolved
2018-02-16 05:03 Christian Grothoff Resolution open => fixed
2018-02-16 05:03 Christian Grothoff Fixed in Version => 0.9.60
2018-02-16 05:03 Christian Grothoff Note Added: 0012860
2018-02-16 05:03 Christian Grothoff Target Version => 0.9.60
2018-03-23 22:22 Christian Grothoff Relationship added has duplicate 0005295
2018-11-06 19:46 Christian Grothoff Status resolved => closed