libmicrohttpd

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

commit 88374e04d2339297e75a34a798611bfb92225c4b
parent 53ffa669927c58685c9013d6512693ae633cace0
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 16 Mar 2017 20:37:57 +0300

Thread-safety: always lock mutex when modifying "cleanup" or "timeout" DL-lists

Diffstat:
MChangeLog | 7+++++++
Msrc/microhttpd/connection.c | 2++
Msrc/microhttpd/daemon.c | 5+++++
Msrc/microhttpd/internal.h | 3++-
4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,10 @@ +Thu Mar 16 20:35:59 MSK 2017 + Improved thread-safety for DL-lists. -EG + +Thu Mar 16 17:55:01 MSK 2017 + Fixed thread-safety of MHD_get_daemon_info() for + MHD_DAEMON_INFO_CURRENT_CONNECTIONS. -EG + Thu Mar 16 16:49:07 MSK 2017 Added ability to get actual daemon flags via MHD_get_daemon_info(). Fixed test_upgrade to work in request mode. diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -2382,6 +2382,7 @@ update_last_activity (struct MHD_Connection *connection) if (connection->connection_timeout != daemon->connection_timeout) return; /* custom timeout, no need to move it in "normal" DLL */ + MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); /* move connection to head of timeout list (by remove + add operation) */ XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, @@ -2389,6 +2390,7 @@ update_last_activity (struct MHD_Connection *connection) XDLL_insert (daemon->normal_timeout_head, daemon->normal_timeout_tail, connection); + MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -4403,6 +4403,9 @@ close_connection (struct MHD_Connection *pos) } MHD_connection_close_ (pos, MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); + + MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); + if (pos->connection_timeout == pos->daemon->connection_timeout) XDLL_remove (daemon->normal_timeout_head, daemon->normal_timeout_tail, @@ -4417,6 +4420,8 @@ close_connection (struct MHD_Connection *pos) DLL_insert (daemon->cleanup_head, daemon->cleanup_tail, pos); + + MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -1373,7 +1373,8 @@ struct MHD_Daemon MHD_mutex_ per_ip_connection_mutex; /** - * Mutex for (modifying) access to the "cleanup" connection DLL. + * Mutex for (modifying) access to the "cleanup", "normal_timeout" and + * "manual_timeout" DLLs. */ MHD_mutex_ cleanup_connection_mutex;