libmicrohttpd

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

commit 1619fda1d7740f62bd121dc070fc093b9a282252
parent 2590e0e8913bdf8cfa19113cb42d9738413c9d70
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 12 May 2022 15:50:43 +0300

Added asserts to check for non-master daemons only

Diffstat:
Msrc/microhttpd/connection.c | 4++++
Msrc/microhttpd/daemon.c | 8++++++++
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -3714,6 +3714,9 @@ void MHD_update_last_activity_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; +#if defined(MHD_USE_THREADS) + mhd_assert (NULL == daemon->worker_pool); +#endif /* MHD_USE_THREADS */ if (0 == connection->connection_timeout_ms) return; /* Skip update of activity for connections @@ -4307,6 +4310,7 @@ cleanup_connection (struct MHD_Connection *connection) #ifdef MHD_USE_THREADS mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ MHD_thread_ID_match_current_ (connection->pid) ); + mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ if (connection->in_cleanup) diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -2732,6 +2732,7 @@ new_connection_process_ (struct MHD_Daemon *daemon, * must be called only within daemon thread. */ mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ MHD_thread_ID_match_current_ (daemon->pid) ); + mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ /* Allocate memory pool in the processing thread so @@ -3079,6 +3080,7 @@ void internal_suspend_connection_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; + mhd_assert (NULL == daemon->worker_pool); #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ @@ -3223,6 +3225,9 @@ _MHD_EXTERN void MHD_resume_connection (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; +#if defined(MHD_USE_THREADS) + mhd_assert (NULL == daemon->worker_pool); +#endif /* MHD_USE_THREADS */ if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) MHD_PANIC (_ ( @@ -3599,6 +3604,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon) #ifdef MHD_USE_THREADS mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ MHD_thread_ID_match_current_ (daemon->pid) ); + mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ addrlen = sizeof (addrstorage); @@ -3779,6 +3785,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ MHD_thread_ID_match_current_ (daemon->pid) ); + mhd_assert (NULL == daemon->worker_pool); MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); #endif @@ -5497,6 +5504,7 @@ close_connection (struct MHD_Connection *pos) #ifdef MHD_USE_THREADS mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ MHD_thread_ID_match_current_ (daemon->pid) ); + mhd_assert (NULL == daemon->worker_pool); #endif /* MHD_USE_THREADS */ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))