]> granicus.if.org Git - apache/commitdiff
Clean up some of these magic numbers in perchild. Still doesn't actually
authorAaron Bannert <aaron@apache.org>
Wed, 19 Dec 2001 01:04:10 +0000 (01:04 +0000)
committerAaron Bannert <aaron@apache.org>
Wed, 19 Dec 2001 01:04:10 +0000 (01:04 +0000)
fix the build problems, but makes it more readable for me.

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

server/mpm/experimental/perchild/perchild.c
server/mpm/perchild/perchild.c

index c7693d1f15f1c9135fa11d7087bf60fb4f654a64..f942b6dfc4ae3c8820a4fe121a0203376038d53f 100644 (file)
 #include <sys/processor.h> /* for bindprocessor() */
 #endif
 
+/*
+ * Define some magic numbers that we use for the state of the incomming
+ * request. These must be < 0 so they don't collide with a file descriptor.
+ */
+#define AP_PERCHILD_THISCHILD -1
+#define AP_PERCHILD_OTHERCHILD -2
+
 #define AP_ID_FROM_CHILD_THREAD(c, t)    ((c * HARD_THREAD_LIMIT) + t)
 #define AP_CHILD_THREAD_FROM_ID(i)    (i / HARD_THREAD_LIMIT), (i % HARD_THREAD_LIMIT)
 
@@ -720,7 +727,7 @@ static void *worker_thread(apr_thread_t *thd, void *arg)
                  * We should set a flag here, and then below we will read
                  * two bytes (the socket number and the NULL byte.
                  */
-                thread_socket_table[thread_num] = -2;
+                thread_socket_table[thread_num] = AP_PERCHILD_OTHERCHILD;
                 goto got_from_other_child;
             }
 
@@ -772,7 +779,7 @@ static void *worker_thread(apr_thread_t *thd, void *arg)
             }
             apr_lock_release(idle_thread_count_mutex);
         got_from_other_child:
-            if (thread_socket_table[thread_num] == -2) {
+            if (thread_socket_table[thread_num] == AP_PERCHILD_OTHERCHILD) {
                 struct msghdr msg;
                 struct cmsghdr *cmsg;
                 char sockname[80];
@@ -804,7 +811,7 @@ static void *worker_thread(apr_thread_t *thd, void *arg)
                 process_socket(ptrans, csd, conn_id);
             }
             else {
-                thread_socket_table[thread_num] = -1;
+                thread_socket_table[thread_num] = AP_PERCHILD_THISCHILD;
             }  
             requests_this_child--;
         }
@@ -1439,7 +1446,7 @@ static void perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pte
         child_info_table[i].sd = -1;
     }
     for (i = 0; i < HARD_THREAD_LIMIT; i++) {
-        thread_socket_table[i] = -1;
+        thread_socket_table[i] = AP_PERCHILD_THISCHILD;
     }
 }
 
@@ -1569,7 +1576,7 @@ static int perchild_post_read(request_rec *r)
         f = f->next;
     }
 
-    if (thread_socket_table[thread_num] != -1) {
+    if (thread_socket_table[thread_num] != AP_PERCHILD_THISCHILD) {
         apr_socket_t *csd = NULL;
 
         apr_os_sock_put(&csd, &thread_socket_table[thread_num], 
index c7693d1f15f1c9135fa11d7087bf60fb4f654a64..f942b6dfc4ae3c8820a4fe121a0203376038d53f 100644 (file)
 #include <sys/processor.h> /* for bindprocessor() */
 #endif
 
+/*
+ * Define some magic numbers that we use for the state of the incomming
+ * request. These must be < 0 so they don't collide with a file descriptor.
+ */
+#define AP_PERCHILD_THISCHILD -1
+#define AP_PERCHILD_OTHERCHILD -2
+
 #define AP_ID_FROM_CHILD_THREAD(c, t)    ((c * HARD_THREAD_LIMIT) + t)
 #define AP_CHILD_THREAD_FROM_ID(i)    (i / HARD_THREAD_LIMIT), (i % HARD_THREAD_LIMIT)
 
@@ -720,7 +727,7 @@ static void *worker_thread(apr_thread_t *thd, void *arg)
                  * We should set a flag here, and then below we will read
                  * two bytes (the socket number and the NULL byte.
                  */
-                thread_socket_table[thread_num] = -2;
+                thread_socket_table[thread_num] = AP_PERCHILD_OTHERCHILD;
                 goto got_from_other_child;
             }
 
@@ -772,7 +779,7 @@ static void *worker_thread(apr_thread_t *thd, void *arg)
             }
             apr_lock_release(idle_thread_count_mutex);
         got_from_other_child:
-            if (thread_socket_table[thread_num] == -2) {
+            if (thread_socket_table[thread_num] == AP_PERCHILD_OTHERCHILD) {
                 struct msghdr msg;
                 struct cmsghdr *cmsg;
                 char sockname[80];
@@ -804,7 +811,7 @@ static void *worker_thread(apr_thread_t *thd, void *arg)
                 process_socket(ptrans, csd, conn_id);
             }
             else {
-                thread_socket_table[thread_num] = -1;
+                thread_socket_table[thread_num] = AP_PERCHILD_THISCHILD;
             }  
             requests_this_child--;
         }
@@ -1439,7 +1446,7 @@ static void perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pte
         child_info_table[i].sd = -1;
     }
     for (i = 0; i < HARD_THREAD_LIMIT; i++) {
-        thread_socket_table[i] = -1;
+        thread_socket_table[i] = AP_PERCHILD_THISCHILD;
     }
 }
 
@@ -1569,7 +1576,7 @@ static int perchild_post_read(request_rec *r)
         f = f->next;
     }
 
-    if (thread_socket_table[thread_num] != -1) {
+    if (thread_socket_table[thread_num] != AP_PERCHILD_THISCHILD) {
         apr_socket_t *csd = NULL;
 
         apr_os_sock_put(&csd, &thread_socket_table[thread_num],