View Issue Details

IDProjectCategoryView StatusLast Update
0001621libmicrohttpdthread poolpublic2010-12-25 23:22
Reporterjaredc Assigned ToChristian Grothoff  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.2 
Summary0001621: Socket gets shutdown, but not closed, when peer closes connection
DescriptionI am using THREAD_PER_CONNECTION. I ran a test where the peer closes the connection in the middle of a GET request. The socket never gets closed in this case, but it gets shutdown and read_closed set to true.

I think the issue is that the state machine is meant to actually close the connection, but since error is returned from do_read(), checking of the state never occurs again.

I think the solution is to simply change the return value in do_read() for this case, indicating that something has changed and allowing the state check to properly close the connection (and call final callbacks). I have submitted a very simple patch that does exactly this and resolves the issue.
TagsNo tags attached.
Attached Files
patch.diff (463 bytes)   
Index: src/daemon/connection.c
===================================================================
--- src/daemon/connection.c	(revision 13729)
+++ src/daemon/connection.c	(working copy)
@@ -1456,7 +1456,7 @@
       /* other side closed connection */
       connection->read_closed = MHD_YES;
       SHUTDOWN (connection->socket_fd, SHUT_RD);
-      return MHD_NO;
+      return MHD_YES;
     }
   connection->read_buffer_offset += bytes_read;
   return MHD_YES;
patch.diff (463 bytes)   

Activities

Christian Grothoff

2010-11-18 22:57

manager   ~0004175

Patched as suggested in SVN 13738. Note that I believe that the socket WILL be closed if you use timeouts for connections (which you should). But obviously that would be later than what would be desirable, so the patch is still good to have (but less critical then it may sound).

Issue History

Date Modified Username Field Change
2010-11-18 01:30 jaredc New Issue
2010-11-18 01:30 jaredc File Added: patch.diff
2010-11-18 22:57 Christian Grothoff Note Added: 0004175
2010-11-18 22:57 Christian Grothoff Status new => resolved
2010-11-18 22:57 Christian Grothoff Resolution open => fixed
2010-11-18 22:57 Christian Grothoff Assigned To => Christian Grothoff
2010-12-25 23:22 Christian Grothoff Status resolved => closed
2013-05-06 12:53 Christian Grothoff Category multi-threaded operation => libmicrohttpd multi-threaded operation
2024-01-21 13:25 Christian Grothoff Category libmicrohttpd multi-threaded operation => thread pool