From 05dcff358d2f815e7fb15fd800131b6d671440c9 Mon Sep 17 00:00:00 2001 From: Aaron Bannert Date: Wed, 19 Dec 2001 01:04:10 +0000 Subject: [PATCH] Clean up some of these magic numbers in perchild. Still doesn't actually 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 | 17 ++++++++++++----- server/mpm/perchild/perchild.c | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/server/mpm/experimental/perchild/perchild.c b/server/mpm/experimental/perchild/perchild.c index c7693d1f15..f942b6dfc4 100644 --- a/server/mpm/experimental/perchild/perchild.c +++ b/server/mpm/experimental/perchild/perchild.c @@ -107,6 +107,13 @@ #include /* 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], diff --git a/server/mpm/perchild/perchild.c b/server/mpm/perchild/perchild.c index c7693d1f15..f942b6dfc4 100644 --- a/server/mpm/perchild/perchild.c +++ b/server/mpm/perchild/perchild.c @@ -107,6 +107,13 @@ #include /* 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], -- 2.40.0