libmicrohttpd

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

commit be045a04763cabf3c3416427499060a3bf68fd1e
parent 6d522346279df691b52a654dc1d1b815feae58e2
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 10 Nov 2016 15:59:36 +0300

Prevent accidental double-cleanup

Diffstat:
Msrc/microhttpd/connection.c | 4++++
Msrc/microhttpd/internal.h | 6++++++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -2663,6 +2663,10 @@ cleanup_connection (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; + if (connection->in_cleanup) + return; /* Prevent double cleanup. */ + + connection->in_cleanup = !0; if (NULL != connection->response) { MHD_destroy_response (connection->response); diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -808,6 +808,12 @@ struct MHD_Connection */ int in_idle; + /** + * Are we currently inside the "idle" handler (to avoid recursively + * invoking it). + */ + bool in_cleanup; + #ifdef EPOLL_SUPPORT /** * What is the state of this socket in relation to epoll?