瀏覽代碼

fix late counter-decrement issue reported by MD on the mailinglist

Christian Grothoff 10 年之前
父節點
當前提交
4d997941e3
共有 3 個文件被更改,包括 12 次插入3 次删除
  1. 9 0
      ChangeLog
  2. 1 1
      src/include/microhttpd.h
  3. 2 2
      src/microhttpd/daemon.c

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+Sat Jun 27 22:16:27 CEST 2015
+	Make sure to decrement connection counter before
+	calling connection notifier so that
+	MHD_DAEMON_INFO_CURRENT_CONNECTIONS does not
+	present stale information (relevant if this is
+	used for termination detection of a daemon
+	stopped via MHD_quiesce_daemon()). Thanks to
+	Markus Doppelbauer for reporting. -CG
+
 Fri Jun 26 23:17:20 CEST 2015
 	Fix (automatic) handling of HEAD requests with
 	MHD_create_response_from_callback() and HTTP/1.1

+ 1 - 1
src/include/microhttpd.h

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

+ 2 - 2
src/microhttpd/daemon.c

@@ -1019,7 +1019,7 @@ exit:
                                     &con->socket_context,
                                     MHD_CONNECTION_NOTIFY_CLOSED);
 
-  return (MHD_THRD_RTRN_TYPE_)0;
+  return (MHD_THRD_RTRN_TYPE_) 0;
 }
 
 
@@ -2039,6 +2039,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
       if (NULL != pos->tls_session)
 	gnutls_deinit (pos->tls_session);
 #endif
+      daemon->connections--;
       if (NULL != daemon->notify_connection)
         daemon->notify_connection (daemon->notify_connection_cls,
                                    pos,
@@ -2087,7 +2088,6 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
       if (NULL != pos->addr)
 	free (pos->addr);
       free (pos);
-      daemon->connections--;
     }
   if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
        (MHD_YES != MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) )