From 4186d61137689d302b2b321d97bfa2963ddb4333 Mon Sep 17 00:00:00 2001 From: Manoj Kasichainula Date: Fri, 29 Oct 1999 20:42:49 +0000 Subject: [PATCH] Fix a couple of pool-related bugs that may or may not be causing actual problems. This makes sure that all interactions with the thread_pool_parent are mutexed, and makes ap_put_os_sock use the correct pool in worker_thread(). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84069 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/dexter/dexter.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/mpm/dexter/dexter.c b/server/mpm/dexter/dexter.c index e59d5d00ce..7736f4c09b 100644 --- a/server/mpm/dexter/dexter.c +++ b/server/mpm/dexter/dexter.c @@ -162,7 +162,7 @@ static other_child_rec *other_children; static ap_context_t *pconf; /* Pool for config stuff */ static ap_context_t *pchild; /* Pool for httpd child stuff */ static ap_context_t *thread_pool_parent; /* Parent of per-thread pools */ -static pthread_mutex_t thread_pool_create_mutex; +static pthread_mutex_t thread_pool_parent_mutex; static int child_num; static int my_pid; /* Linux getpid() doesn't work except in main thread. Use @@ -852,9 +852,9 @@ static void *worker_thread(void *arg) int thread_num = *((int *) arg); long conn_id = child_num * HARD_THREAD_LIMIT + thread_num; - pthread_mutex_lock(&thread_pool_create_mutex); + pthread_mutex_lock(&thread_pool_parent_mutex); ap_create_context(&tpool, thread_pool_parent); - pthread_mutex_unlock(&thread_pool_create_mutex); + pthread_mutex_unlock(&thread_pool_parent_mutex); ap_create_context(&ptrans, tpool); while (!workers_may_exit) { @@ -918,7 +918,7 @@ static void *worker_thread(void *arg) /* XXX: Should we check for POLLERR? */ if (listenfds[curr_pollfd].revents & POLLIN) { last_pollfd = curr_pollfd; - ap_put_os_sock(&sd, &listenfds[curr_pollfd].fd, tpool); + ap_put_os_sock(&sd, &listenfds[curr_pollfd].fd, ptrans); goto got_fd; } } while (curr_pollfd != last_pollfd); @@ -956,7 +956,9 @@ static void *worker_thread(void *arg) ap_clear_pool(ptrans); } - ap_destroy_pool(tpool); + pthread_mutex_lock(&thread_pool_parent_mutex); + ap_destroy_context(tpool); + pthread_mutex_unlock(&thread_pool_parent_mutex); pthread_mutex_lock(&worker_thread_count_mutex); worker_thread_count--; worker_thread_free_ids[worker_thread_count] = thread_num; @@ -1026,7 +1028,7 @@ static void child_main(int child_num_arg) worker_thread_free_ids[i] = i; } ap_create_context(&thread_pool_parent, pchild); - pthread_mutex_init(&thread_pool_create_mutex, NULL); + pthread_mutex_init(&thread_pool_parent_mutex, NULL); pthread_mutex_init(&idle_thread_count_mutex, NULL); pthread_mutex_init(&worker_thread_count_mutex, NULL); pthread_mutex_init(&pipe_of_death_mutex, NULL); -- 2.40.0