]> granicus.if.org Git - apache/commitdiff
Fix some problems with which error code to use after a pthread_ failure.
authorJeff Trawick <trawick@apache.org>
Mon, 31 Jul 2000 15:39:19 +0000 (15:39 +0000)
committerJeff Trawick <trawick@apache.org>
Mon, 31 Jul 2000 15:39:19 +0000 (15:39 +0000)
Most of the changes added support for PTHREAD_SETS_ERRNO; a few of the
changes fixed bugs in existing code which always used errno (which
doesn't get the right error code on most platforms).

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85963 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/dexter/dexter.c
server/mpm/experimental/perchild/perchild.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/perchild/perchild.c

index 7de8d0108d877d3ab46910fb39982e9054a16fa6..e0b8df672f5d18437a52346084e38ca75ea6cb2c 100644 (file)
@@ -434,12 +434,16 @@ static void *worker_thread(void *);
 static int start_thread(void)
 {
     pthread_t thread;
+    int rc;
 
     pthread_mutex_lock(&worker_thread_count_mutex);
     if (worker_thread_count < max_threads) {
-        if (pthread_create(&thread, &worker_thread_attr, worker_thread,
-         &worker_thread_free_ids[worker_thread_count])) {
-            ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
+        if ((rc = pthread_create(&thread, &worker_thread_attr, worker_thread,
+         &worker_thread_free_ids[worker_thread_count]))) {
+#ifdef PTHREAD_SETS_ERRNO
+            rc = errno;
+#endif
+            ap_log_error(APLOG_MARK, APLOG_ALERT, rc, ap_server_conf,
                          "pthread_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
@@ -694,8 +698,11 @@ static void child_main(int child_num_arg)
         ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, "sigprocmask");
     }
 #else
-    if (pthread_sigmask(SIG_SETMASK, &sig_mask, NULL) != 0) {
-        ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
+    if ((rv = pthread_sigmask(SIG_SETMASK, &sig_mask, NULL)) != 0) {
+#ifdef PTHREAD_SETS_ERRNO
+        rv = errno;
+#endif
+        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
                      "pthread_sigmask");
     }
 #endif
index 0a0051d45b94dee720fd6341bd45b17312d80fd4..bca25653fa9a675f856acc2934027cead9c03e4b 100644 (file)
@@ -467,12 +467,16 @@ static void *worker_thread(void *);
 static int start_thread(void)
 {
     pthread_t thread;
+    int rc;
 
     pthread_mutex_lock(&worker_thread_count_mutex);
     if (worker_thread_count < max_threads) {
-        if (pthread_create(&thread, &worker_thread_attr, worker_thread,
-         &worker_thread_free_ids[worker_thread_count])) {
-            ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
+        if ((rc = pthread_create(&thread, &worker_thread_attr, worker_thread,
+         &worker_thread_free_ids[worker_thread_count]))) {
+#ifdef PTHREAD_SETS_ERRNO
+            rc = errno;
+#endif
+            ap_log_error(APLOG_MARK, APLOG_ALERT, rc, ap_server_conf,
                          "pthread_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
@@ -858,8 +862,11 @@ static void child_main(int child_num_arg)
         ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, "sigprocmask");
     }
 #else
-    if (pthread_sigmask(SIG_SETMASK, &sig_mask, NULL) != 0) {
-        ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
+    if ((rv = pthread_sigmask(SIG_SETMASK, &sig_mask, NULL)) != 0) {
+#ifdef PTHREAD_SETS_ERRNO
+        rv = errno;
+#endif
+        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
                      "pthread_sigmask");
     }
 #endif
index 7142bc7b5467afee285f99dfaa414403b6d975e5..3aec08e7c6174386a4c12fa7f1ef2e75c6ea2193 100644 (file)
@@ -638,8 +638,11 @@ static void child_main(int child_num_arg)
         ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, "sigprocmask");
     }
 #else
-    if (pthread_sigmask(SIG_SETMASK, &sig_mask, NULL) != 0) {
-        ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, "pthread_sigmask");
+    if ((rv = pthread_sigmask(SIG_SETMASK, &sig_mask, NULL)) != 0) {
+#ifdef PTHREAD_SETS_ERRNO
+        rv = errno;
+#endif
+        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, "pthread_sigmask");
     }
 #endif
 
@@ -686,8 +689,11 @@ static void child_main(int child_num_arg)
        (void) ap_update_child_status(my_child_num, i, SERVER_STARTING, 
                                      (request_rec *) NULL);
 #ifndef NO_THREADS
-       if (pthread_create(&thread, &thread_attr, worker_thread, my_info)) {
-           ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
+       if ((rv = pthread_create(&thread, &thread_attr, worker_thread, my_info))) {
+#ifdef PTHREAD_SETS_ERRNO
+            rv = errno;
+#endif
+           ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
                         "pthread_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
index 0a0051d45b94dee720fd6341bd45b17312d80fd4..bca25653fa9a675f856acc2934027cead9c03e4b 100644 (file)
@@ -467,12 +467,16 @@ static void *worker_thread(void *);
 static int start_thread(void)
 {
     pthread_t thread;
+    int rc;
 
     pthread_mutex_lock(&worker_thread_count_mutex);
     if (worker_thread_count < max_threads) {
-        if (pthread_create(&thread, &worker_thread_attr, worker_thread,
-         &worker_thread_free_ids[worker_thread_count])) {
-            ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
+        if ((rc = pthread_create(&thread, &worker_thread_attr, worker_thread,
+         &worker_thread_free_ids[worker_thread_count]))) {
+#ifdef PTHREAD_SETS_ERRNO
+            rc = errno;
+#endif
+            ap_log_error(APLOG_MARK, APLOG_ALERT, rc, ap_server_conf,
                          "pthread_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
@@ -858,8 +862,11 @@ static void child_main(int child_num_arg)
         ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, "sigprocmask");
     }
 #else
-    if (pthread_sigmask(SIG_SETMASK, &sig_mask, NULL) != 0) {
-        ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf,
+    if ((rv = pthread_sigmask(SIG_SETMASK, &sig_mask, NULL)) != 0) {
+#ifdef PTHREAD_SETS_ERRNO
+        rv = errno;
+#endif
+        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
                      "pthread_sigmask");
     }
 #endif