From 74cca4b21635f92f517258fa183b1604bdf199d5 Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Tue, 20 Feb 2001 20:50:09 +0000 Subject: [PATCH] Migrate the threaded MPM to use all APR threading calls. This isn't quite perfect yet, because of the sigwait and sigmask calls. Those are going away next. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88252 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ server/mpm/threaded/threaded.c | 31 ++++++------------------------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/CHANGES b/CHANGES index 85a5724e28..f4c30ad837 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.12-dev + *) Make the threaded MPM use APR threads instead of pthreads. + [Ryan Bloom] + *) Get mod_tls to the point where it actually appears to work in all cases. [Ben Laurie] diff --git a/server/mpm/threaded/threaded.c b/server/mpm/threaded/threaded.c index 5a3cca570f..d4327a0ece 100644 --- a/server/mpm/threaded/threaded.c +++ b/server/mpm/threaded/threaded.c @@ -586,8 +586,8 @@ static void child_main(int child_num_arg) { sigset_t sig_mask; int signal_received; - pthread_t thread; - pthread_attr_t thread_attr; + apr_thread_t *thread; + apr_threadattr_t *thread_attr; int i; int my_child_num = child_num_arg; proc_info *my_info = NULL; @@ -651,16 +651,9 @@ static void child_main(int child_num_arg) NULL, pchild); apr_lock_create(&pipe_of_death_mutex, APR_MUTEX, APR_INTRAPROCESS, NULL, pchild); - pthread_attr_init(&thread_attr); -#ifdef PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR - { - int on = 1; + apr_threadattr_create(&thread_attr, pchild); + apr_threadattr_detach_set(thread_attr); - pthread_attr_setdetachstate(&thread_attr, &on); - } -#else - pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED); -#endif for (i=0; i < ap_threads_per_child; i++) { my_info = (proc_info *)malloc(sizeof(proc_info)); @@ -677,32 +670,20 @@ static void child_main(int child_num_arg) /* We are creating threads right now */ (void) ap_update_child_status(my_child_num, i, SERVER_STARTING, (request_rec *) NULL); -#ifndef NO_THREADS - if ((rv = pthread_create(&thread, &thread_attr, worker_thread, my_info))) { -#ifdef PTHREAD_SETS_ERRNO - rv = errno; -#endif + if ((rv = apr_thread_create(&thread, thread_attr, worker_thread, my_info, pchild))) { ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, - "pthread_create: unable to create worker thread"); + "apr_thread_create: unable to create worker thread"); /* In case system resources are maxxed out, we don't want Apache running away with the CPU trying to fork over and over and over again if we exit. */ sleep(10); clean_child_exit(APEXIT_CHILDFATAL); } -#else - worker_thread(my_info); - /* The SIGTERM shouldn't let us reach this point, but just in case... */ - clean_child_exit(APEXIT_OK); -#endif - /* We let each thread update it's own scoreboard entry. This is done * because it let's us deal with tid better. */ } - pthread_attr_destroy(&thread_attr); - /* This thread will be the one responsible for handling signals */ sigemptyset(&sig_mask); sigaddset(&sig_mask, SIGTERM); -- 2.50.0