libmicrohttpd

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

commit aadbe63575e1f2af75280d671fdf3da7ca31620b
parent 8df85c22f894cb339f64283029999be6587f0156
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Fri, 30 Jul 2021 11:54:25 +0300

connection cleanup: streamlined cleanup process

Diffstat:
Msrc/microhttpd/connection.c | 17++++++++++++-----
Msrc/microhttpd/internal.h | 3+--
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -677,8 +677,6 @@ MHD_connection_mark_closed_ (struct MHD_Connection *connection) { const struct MHD_Daemon *daemon = connection->daemon; - connection->state = MHD_CONNECTION_CLOSED; - connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; if (0 == (daemon->options & MHD_USE_TURBO)) { #ifdef HTTPS_SUPPORT @@ -698,6 +696,8 @@ MHD_connection_mark_closed_ (struct MHD_Connection *connection) shutdown (connection->socket_fd, SHUT_WR); } + connection->state = MHD_CONNECTION_CLOSED; + connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; } @@ -733,6 +733,11 @@ MHD_connection_close_ (struct MHD_Connection *connection, connection->response = NULL; MHD_destroy_response (resp); } + if (NULL != connection->pool) + { + MHD_pool_destroy (connection->pool); + connection->pool = NULL; + } MHD_connection_mark_closed_ (connection); } @@ -3743,14 +3748,16 @@ connection_reset (struct MHD_Connection *connection, if (! reuse) { /* Next function will destroy response, notify client, - * and set state "CLOSED" */ + * destroy memory pool, and set connection state to "CLOSED" */ MHD_connection_close_ (connection, MHD_REQUEST_TERMINATED_COMPLETED_OK); - MHD_pool_destroy (connection->pool); - c->pool = NULL; c->read_buffer = NULL; c->read_buffer_size = 0; c->read_buffer_offset = 0; + c->write_buffer = NULL; + c->write_buffer_size = 0; + c->write_buffer_send_offset = 0; + c->write_buffer_append_offset = 0; } else { diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -1182,8 +1182,7 @@ struct MHD_Connection bool in_idle; /** - * Are we currently inside the "idle" handler (to avoid recursively - * invoking it). + * Connection is in the cleanup DL-linked list. */ bool in_cleanup;