manoj 99/02/17 12:28:57
Modified: pthreads/src/main http_main.c Log: First, fix unbalanced locking and unlocking of the exit_mutex (which will hopefully go away when we switch to a single signal-handling thread). Also get rid of a malloc-free pair. Revision Changes Path 1.42 +13 -11 apache-apr/pthreads/src/main/http_main.c Index: http_main.c =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/main/http_main.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -u -r1.41 -r1.42 --- http_main.c 1999/02/17 18:42:01 1.41 +++ http_main.c 1999/02/17 20:28:56 1.42 @@ -176,7 +176,7 @@ int ap_listenbacklog; int ap_dump_settings = 0; int exiting_now = 0; -pthread_mutex_t *exit_mutex; +pthread_mutex_t exit_mutex = PTHREAD_MUTEX_INITIALIZER; API_VAR_EXPORT int ap_extended_status = 0; @@ -406,7 +406,6 @@ ap_destroy_pool(pchild); } - free(exit_mutex); exit(code); } @@ -2288,13 +2287,16 @@ } } ap_update_child_status(my_pid, my_tid, SERVER_DEAD, (request_rec *) NULL); - pthread_mutex_lock(exit_mutex); + pthread_mutex_lock(&exit_mutex); if (exiting_now == 0) { exiting_now++; - pthread_mutex_unlock(exit_mutex); + pthread_mutex_unlock(&exit_mutex); graceful_killer(); clean_child_exit(0); - } + } + else { + pthread_mutex_unlock(&exit_mutex); + } pthread_exit(NULL); } @@ -2323,13 +2325,16 @@ } ap_destroy_pool(ptrans); ap_update_child_status(my_pid, my_tid, SERVER_DEAD, (request_rec *) NULL); - pthread_mutex_lock(exit_mutex); + pthread_mutex_lock(&exit_mutex); if (exiting_now == 0) { exiting_now++; - pthread_mutex_unlock(exit_mutex); + pthread_mutex_unlock(&exit_mutex); graceful_killer(); clean_child_exit(0); - } + } + else { + pthread_mutex_unlock(&exit_mutex); + } pthread_exit(NULL); } @@ -2470,9 +2475,6 @@ requests_this_child = ap_max_requests_per_child; pchild = ap_make_sub_pool(pconf); - - exit_mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t)); - pthread_mutex_init(exit_mutex, NULL); /*stuff to do before we switch id's, so we have permissions.*/ reopen_scoreboard(pchild);