add assertion to guard against bad behavior described in #7196, also document that after suspending one must return MHD_YES

This commit is contained in:
Christian Grothoff
2023-03-31 18:50:28 +02:00
parent a8d0893dee
commit 4dee893016
2 changed files with 6 additions and 0 deletions
+5
View File
@@ -3037,6 +3037,11 @@ The only safe time to suspend a connection is from the
response object must not be shared among multiple
connections).
When suspending from the @code{MHD_AccessHandlerCallback}
you MUST afterwards return @code{MHD_YES} from the access handler
callback (as MHD_NO would imply to both close and suspend
the connection, which is not allowed).
Finally, it is an API violation to call @code{MHD_stop_daemon} while
having suspended connections (this will at least create memory and
socket leaks or lead to undefined behavior). You must explicitly
+1
View File
@@ -833,6 +833,7 @@ MHD_connection_close_ (struct MHD_Connection *connection,
struct MHD_Daemon *daemon = connection->daemon;
struct MHD_Response *resp = connection->response;
mhd_assert (! connection->suspended);
#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (connection->pid) );