libmicrohttpd

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

commit de9b039ee54816165e05309fc158d3d67b6ed052
parent 5d9bc9ead9d0b5c4ef99e9c1df8a67a522a92f94
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  1 Mar 2013 00:12:59 +0000

the cleanup mutex struct should not be directly copied and share used
by multiple thread, which cause crash on some platform,
e.g. ios/darwin

Ulion



Diffstat:
MChangeLog | 3+++
Msrc/daemon/daemon.c | 12++++++++++++
2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,6 @@ +Fri Mar 1 01:11:57 CET 2013 + Fully initialize cleanup mutex struct for each thread. -Ulion + Wed Feb 6 01:51:52 CET 2013 Releasing libmicrohttpd 0.9.25. -CG diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -2536,6 +2536,16 @@ MHD_start_daemon_va (unsigned int options, if (i < leftover_conns) ++d->max_connections; + /* Must init cleanup connection mutex for each worker */ + if (0 != pthread_mutex_init (&d->cleanup_connection_mutex, NULL)) + { +#if HAVE_MESSAGES + MHD_DLOG (daemon, + "MHD failed to initialize cleanup connection mutex for thread worker %d\n", i); +#endif + goto thread_failed; + } + /* Spawn the worker thread */ if (0 != (res_thread_create = create_thread (&d->pid, daemon, &MHD_select_thread, d))) { @@ -2546,6 +2556,7 @@ MHD_start_daemon_va (unsigned int options, #endif /* Free memory for this worker; cleanup below handles * all previously-created workers. */ + pthread_mutex_destroy (&d->cleanup_connection_mutex); goto thread_failed; } } @@ -2707,6 +2718,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) MHD_PANIC ("Failed to join a thread\n"); } close_all_connections (&daemon->worker_pool[i]); + pthread_mutex_destroy (&daemon->worker_pool[i].cleanup_connection_mutex); } free (daemon->worker_pool); }