Просмотр исходного кода

call completion handler also for upgrade connections

Christian Grothoff 8 лет назад
Родитель
Сommit
fc495439b4
5 измененных файлов с 18 добавлено и 9 удалено
  1. 4 0
      ChangeLog
  2. 1 1
      src/include/microhttpd.h
  3. 1 0
      src/lib/action_from_response.c
  4. 5 3
      src/lib/request_resume.c
  5. 7 5
      src/microhttpd/daemon.c

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+Tue Feb 27 23:27:02 CET 2018
+	Ensure MHD_RequestCompletedCallback is also called for
+	upgraded connections. -CG
+
 Fri Feb 16 03:09:33 CET 2018
 	Fixing #5278 as suggested by reporter. -CG/texec
 

+ 1 - 1
src/include/microhttpd.h

@@ -126,7 +126,7 @@ typedef intptr_t ssize_t;
  * Current version of the library.
  * 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00095901
+#define MHD_VERSION 0x00095902
 
 /**
  * MHD-internal return code for "YES".

+ 1 - 0
src/lib/action_from_response.c

@@ -23,6 +23,7 @@
  * @author Christian Grothoff
  */
 #include "internal.h"
+#include "connection_call_handlers.h"
 
 
 /**

+ 5 - 3
src/lib/request_resume.c

@@ -23,7 +23,7 @@
  * @author Christian Grothoff
  */
 #include "internal.h"
-
+#include "connection_close.h"
 
 /**
  * Resume handling of network data for suspended request.  It is
@@ -43,7 +43,7 @@ void
 MHD_request_resume (struct MHD_Request *request)
 {
   struct MHD_Daemon *daemon = request->daemon;
-  
+
   if (daemon->disallow_suspend_resume)
     MHD_PANIC (_("Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n"));
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
@@ -81,7 +81,7 @@ MHD_resume_suspended_connections_ (struct MHD_Daemon *daemon)
   struct MHD_Connection *prev = NULL;
   bool ret;
   const bool used_thr_p_c = (MHD_TM_THREAD_PER_CONNECTION == daemon->threading_model);
-  
+
   mhd_assert (NULL == daemon->worker_pool);
   ret = false;
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
@@ -159,6 +159,8 @@ MHD_resume_suspended_connections_ (struct MHD_Daemon *daemon)
           /* Data forwarding was finished (for TLS connections) AND
            * application was closed upgraded connection.
            * Insert connection into cleanup list. */
+          MHD_connection_close_ (pos,
+                                 MHD_CONNECTION_NOTIFY_CLOSED);
           DLL_insert (daemon->cleanup_head,
                       daemon->cleanup_tail,
                       pos);

+ 7 - 5
src/microhttpd/daemon.c

@@ -2678,7 +2678,7 @@ void
 MHD_resume_connection (struct MHD_Connection *connection)
 {
   struct MHD_Daemon *daemon = connection->daemon;
-  
+
   if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME))
     MHD_PANIC (_("Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n"));
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
@@ -2790,6 +2790,8 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
           /* Data forwarding was finished (for TLS connections) AND
            * application was closed upgraded connection.
            * Insert connection into cleanup list. */
+          MHD_connection_close_ (pos,
+                                 MHD_REQUEST_TERMINATED_COMPLETED_OK);
           DLL_insert (daemon->cleanup_head,
                       daemon->cleanup_tail,
                       pos);
@@ -5425,7 +5427,7 @@ MHD_start_daemon_va (unsigned int flags,
   MHD_DLOG (daemon,  _("Using debug build of libmicrohttpd.\n") );
 #endif /* HAVE_MESSAGES */
 #endif /* ! NDEBUG */
-  
+
   if ( (0 != (*pflags & MHD_USE_ITC)) &&
        (0 == daemon->worker_pool_size) )
     {
@@ -5527,7 +5529,7 @@ MHD_start_daemon_va (unsigned int flags,
     {
       /* try to open listen socket */
       int domain;
-      
+
 #ifdef HAVE_INET6
       domain = (*pflags & MHD_USE_IPv6) ? PF_INET6 : PF_INET;
 #else  /* ! HAVE_INET6 */
@@ -5535,7 +5537,7 @@ MHD_start_daemon_va (unsigned int flags,
 	goto free_and_fail;
       domain = PF_INET;
 #endif /* ! HAVE_INET6 */
-      
+
       listen_fd = MHD_socket_create_listen_(domain);
       if (MHD_INVALID_SOCKET == listen_fd)
 	{
@@ -6358,7 +6360,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
 #endif /* HAVE_LISTEN_SHUTDOWN */
 		mhd_assert (false); /* Should never happen */
 	    }
-	  
+
 	  if (! MHD_join_thread_ (daemon->pid.handle))
 	    {
 	      MHD_PANIC (_("Failed to join a thread\n"));