libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit dc96775e3210bce764284d46be5fd889d63ef0b8
parent 8da22ca0612e633aa76f145b879d83833dbdcdfe
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 30 Oct 2017 21:53:30 +0300

MHD_queue_response(): ignore response, but return OK if daemon is shut down.
This will avoid race condition: if daemon is shutting down in parallel,
response may be queued but aborted later.
Therefore, returning "MHD_OK" will unify situation from application
point of view.

Diffstat:
Msrc/microhttpd/connection.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -3880,6 +3880,11 @@ MHD_queue_response (struct MHD_Connection *connection, (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) ) return MHD_NO; daemon = connection->daemon; + + if (daemon->shutdown) + return MHD_YES; /* If daemon was shut down in parallel, + * response will be aborted now or on later stage. */ + if ( (!connection->suspended) && (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) && (!MHD_thread_ID_match_current_(connection->pid.ID)) )