]> granicus.if.org Git - apache/commitdiff
Migrate the threaded MPM to use all APR threading calls. This isn't quite
authorRyan Bloom <rbb@apache.org>
Tue, 20 Feb 2001 20:50:09 +0000 (20:50 +0000)
committerRyan Bloom <rbb@apache.org>
Tue, 20 Feb 2001 20:50:09 +0000 (20:50 +0000)
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
server/mpm/threaded/threaded.c

diff --git a/CHANGES b/CHANGES
index 85a5724e28da06899571dcacbaa61d49d427b781..f4c30ad837b3aedea52e89107b2f6fff7c65e9f3 100644 (file)
--- 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]
 
index 5a3cca570f495b71f1c87d055585c83306a23d47..d4327a0ece6fcbbe4d28c32d804585daa6e9ca65 100644 (file)
@@ -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);