Переглянути джерело

print warning if application code performing connection POST processing is buggy

Christian Grothoff 9 роки тому
батько
коміт
dcc7066746
3 змінених файлів з 19 додано та 2 видалено
  1. 5 0
      ChangeLog
  2. 1 1
      src/include/microhttpd.h
  3. 13 1
      src/microhttpd/connection.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Sat Jul 16 21:54:49 CEST 2016
+	Warn user if they sent connection into blocking
+	state by not processing all POST data, not suspending,
+	and not running in external select mode. -CG
+
 Fri Jul  8 21:35:07 CEST 2016
 	Fix FIXME in tutorial. -CG
 

+ 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 0x00095000
+#define MHD_VERSION 0x00095001
 
 /**
  * MHD-internal return code for "YES".

+ 13 - 1
src/microhttpd/connection.c

@@ -1794,7 +1794,19 @@ process_request_body (struct MHD_Connection *connection)
 #endif
 		   );
       if (0 != processed)
-        instant_retry = MHD_NO; /* client did not process everything */
+	{
+	  instant_retry = MHD_NO; /* client did not process everything */
+#ifdef HAVE_MESSAGES
+	  /* client did not process all POST data, complain if
+	     the setup was incorrect, which may prevent us from
+	     handling the rest of the request */
+	  if ( ( (0 != (connection->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
+		 (0 != (connection->daemon->options & MHD_USE_SELECT_INTERNALLY)) ) &&
+	       (MHD_NO == connection->suspended) )
+	    MHD_DLOG (connection->daemon,
+		      "WARNING: incomplete POST processing and connection not suspended will result in hung connection.\n");
+	}
+#endif
       used -= processed;
       if (connection->have_chunked_upload == MHD_YES)
         connection->current_chunk_offset += used;