aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-02-08 14:28:42 +0100
committerChristian Grothoff <christian@grothoff.org>2023-02-08 14:28:49 +0100
commit4627d005d2ead3a3b7f34b25b9e6528d2f9ed99b (patch)
tree037ee8f004fcedfebdc45ecd6742dae8f03a9b28
parenta7c913850dd88d5ebb82e4b5013fdab1074dbaa8 (diff)
downloadlibmicrohttpd-4627d005d2ead3a3b7f34b25b9e6528d2f9ed99b.tar.gz
libmicrohttpd-4627d005d2ead3a3b7f34b25b9e6528d2f9ed99b.zip
add assertion to guard against bad behavior described in #7196, also document that after suspending one must return MHD_YES
-rw-r--r--doc/libmicrohttpd.texi5
-rw-r--r--src/microhttpd/connection.c1
2 files changed, 6 insertions, 0 deletions
diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi
index b1ae347d..e1fc05bd 100644
--- a/doc/libmicrohttpd.texi
+++ b/doc/libmicrohttpd.texi
@@ -3036,6 +3036,11 @@ The only safe time to suspend a connection is from the
3036response object must not be shared among multiple 3036response object must not be shared among multiple
3037connections). 3037connections).
3038 3038
3039When suspending from the @code{MHD_AccessHandlerCallback}
3040you MUST afterwards return @code{MHD_YES} from the access handler
3041callback (as MHD_NO would imply to both close and suspend
3042the connection, which is not allowed).
3043
3039Finally, it is an API violation to call @code{MHD_stop_daemon} while 3044Finally, it is an API violation to call @code{MHD_stop_daemon} while
3040having suspended connections (this will at least create memory and 3045having suspended connections (this will at least create memory and
3041socket leaks or lead to undefined behavior). You must explicitly 3046socket leaks or lead to undefined behavior). You must explicitly
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index b983e7ed..ddf62d77 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -868,6 +868,7 @@ MHD_connection_close_ (struct MHD_Connection *connection,
868 struct MHD_Daemon *daemon = connection->daemon; 868 struct MHD_Daemon *daemon = connection->daemon;
869 struct MHD_Response *resp = connection->rp.response; 869 struct MHD_Response *resp = connection->rp.response;
870 870
871 mhd_assert (! connection->suspended);
871#ifdef MHD_USE_THREADS 872#ifdef MHD_USE_THREADS
872 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 873 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
873 MHD_thread_ID_match_current_ (connection->pid) ); 874 MHD_thread_ID_match_current_ (connection->pid) );