libmicrohttpd

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

commit c106ce2a4fe8df3fe82b5d13ae4ec8b4d42b811b
parent 0d6210fbfd9b6d3ddb17df767ad5b5bf4a8cac93
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 29 Jul 2021 21:04:51 +0300

MHD_connection_close_ (): changed clean-up order

* Mark connection as "ready for closure" only after clean-up
* Destroy response only after notifying of the client

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

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -720,13 +720,6 @@ MHD_connection_close_ (struct MHD_Connection *connection, mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ MHD_thread_ID_match_current_ (connection->pid) ); #endif /* MHD_USE_THREADS */ - - MHD_connection_mark_closed_ (connection); - if (NULL != resp) - { - connection->response = NULL; - MHD_destroy_response (resp); - } if ( (NULL != daemon->notify_completed) && (connection->client_aware) ) daemon->notify_completed (daemon->notify_completed_cls, @@ -734,6 +727,13 @@ MHD_connection_close_ (struct MHD_Connection *connection, &connection->client_context, termination_code); connection->client_aware = false; + if (NULL != resp) + { + connection->response = NULL; + MHD_destroy_response (resp); + } + + MHD_connection_mark_closed_ (connection); }