From 6ca160f41fb1c848565aa7be9c966371f8ddf9ed Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Sat, 31 Jul 2004 20:47:49 +0000 Subject: [PATCH] perchild MPM: Fix thread safety problem in the use of longjmp(). Submitted by: Tsuyoshi SASAMOTO Reviewed by: Jeff Trawick git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104436 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ server/mpm/experimental/perchild/perchild.c | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 5f2890ea21..0099764a40 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) perchild MPM: Fix thread safety problem in the use of longjmp(). + [Tsuyoshi SASAMOTO ] + *) Add load balancer support to the scoreboard in preparation for load balancing support in mod_proxy. [Mladen Turk] diff --git a/server/mpm/experimental/perchild/perchild.c b/server/mpm/experimental/perchild/perchild.c index 5e3522546b..c2bd609dca 100644 --- a/server/mpm/experimental/perchild/perchild.c +++ b/server/mpm/experimental/perchild/perchild.c @@ -137,7 +137,7 @@ static int workers_may_exit = 0; static int requests_this_child; static int num_listensocks = 0; static ap_pod_t *pod; -static jmp_buf jmpbuffer; +static jmp_buf *jmpbuffers; struct child_info_t { uid_t uid; @@ -758,7 +758,7 @@ static void *worker_thread(apr_thread_t *thd, void *arg) } } apr_thread_mutex_unlock(idle_thread_count_mutex); - if (setjmp(jmpbuffer) != 1) { + if (setjmp(jmpbuffers[thread_num]) != 1) { process_socket(ptrans, csd, conn_id, bucket_alloc); } else { @@ -1668,6 +1668,8 @@ static int perchild_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pte } ap_child_table = (ap_ctable *)apr_pcalloc(p, server_limit * sizeof(ap_ctable)); + jmpbuffers = (jmp_buf *)apr_palloc(p, thread_limit * sizeof(jmp_buf)); + return OK; } @@ -1704,7 +1706,7 @@ static int perchild_post_read(request_rec *r) ap_server_conf, "Could not pass request to proper " "child, request will not be honored."); } - longjmp(jmpbuffer, 1); + longjmp(jmpbuffers[thread_num], 1); } return OK; } -- 2.50.1