diff options
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r-- | src/daemon/daemon.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 5d4d20dd..72619c3d 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -2536,6 +2536,16 @@ MHD_start_daemon_va (unsigned int options, | |||
2536 | if (i < leftover_conns) | 2536 | if (i < leftover_conns) |
2537 | ++d->max_connections; | 2537 | ++d->max_connections; |
2538 | 2538 | ||
2539 | /* Must init cleanup connection mutex for each worker */ | ||
2540 | if (0 != pthread_mutex_init (&d->cleanup_connection_mutex, NULL)) | ||
2541 | { | ||
2542 | #if HAVE_MESSAGES | ||
2543 | MHD_DLOG (daemon, | ||
2544 | "MHD failed to initialize cleanup connection mutex for thread worker %d\n", i); | ||
2545 | #endif | ||
2546 | goto thread_failed; | ||
2547 | } | ||
2548 | |||
2539 | /* Spawn the worker thread */ | 2549 | /* Spawn the worker thread */ |
2540 | if (0 != (res_thread_create = create_thread (&d->pid, daemon, &MHD_select_thread, d))) | 2550 | if (0 != (res_thread_create = create_thread (&d->pid, daemon, &MHD_select_thread, d))) |
2541 | { | 2551 | { |
@@ -2546,6 +2556,7 @@ MHD_start_daemon_va (unsigned int options, | |||
2546 | #endif | 2556 | #endif |
2547 | /* Free memory for this worker; cleanup below handles | 2557 | /* Free memory for this worker; cleanup below handles |
2548 | * all previously-created workers. */ | 2558 | * all previously-created workers. */ |
2559 | pthread_mutex_destroy (&d->cleanup_connection_mutex); | ||
2549 | goto thread_failed; | 2560 | goto thread_failed; |
2550 | } | 2561 | } |
2551 | } | 2562 | } |
@@ -2707,6 +2718,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) | |||
2707 | MHD_PANIC ("Failed to join a thread\n"); | 2718 | MHD_PANIC ("Failed to join a thread\n"); |
2708 | } | 2719 | } |
2709 | close_all_connections (&daemon->worker_pool[i]); | 2720 | close_all_connections (&daemon->worker_pool[i]); |
2721 | pthread_mutex_destroy (&daemon->worker_pool[i].cleanup_connection_mutex); | ||
2710 | } | 2722 | } |
2711 | free (daemon->worker_pool); | 2723 | free (daemon->worker_pool); |
2712 | } | 2724 | } |