manoj 99/03/22 12:38:04
Modified: pthreads/src/main http_main.c
Log:
Revision Changes Path
1.66 +22 -12 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.65
retrieving revision 1.66
diff -u -u -r1.65 -r1.66
--- http_main.c 1999/03/22 20:10:41 1.65
+++ http_main.c 1999/03/22 20:38:03 1.66
@@ -218,6 +218,10 @@
/* The queue of sockets we've accepted */
static FDQueue csd_queue;
+/* Indicates that all acceptor threads are dead after SIGWINCH and the worker
+ * threads can now exit */
+static int workers_may_exit = 0;
+
/* stuff that needs thread local store in main */
typedef struct {
jmp_buf thread_exit;
@@ -417,7 +421,14 @@
void kill_workers(void)
{
+ int i;
+ int index = find_child_by_pid(getpid());
+ parent_score *ss = &ap_scoreboard_image->parent[index];
+
pthread_cond_broadcast(&(csd_queue.not_empty));
+ for (i = 0; i < ss->worker_threads; i++) {
+ pthread_join(ap_scoreboard_image->servers[index][i].tid, NULL);
+ }
}
/* Kill off any acceptor threads by kicking them out of what they are doing
@@ -428,6 +439,11 @@
void kill_acceptors(void)
{
listen_rec *lr;
+ int i;
+ int index = find_child_by_pid(getpid());
+ parent_score *ss = &ap_scoreboard_image->parent[index];
+
+
/* Kick acceptor threads out of accept */
lr = ap_listeners;
@@ -438,23 +454,18 @@
/* Kick any acceptor out of blocking on a full queue */
pthread_cond_broadcast(&(csd_queue.not_full));
+
+ for (i = ss->worker_threads; i < ss->worker_threads +
ss->acceptor_threads; i++) {
+ pthread_join(ap_scoreboard_image->servers[index][i].tid, NULL);
+ }
}
void graceful_killer(void)
{
- int i;
- int index = find_child_by_pid(getpid());
- parent_score *ss = &ap_scoreboard_image->parent[index];
-
/* The two functions to get all of our other threads to die off. */
kill_acceptors();
+ workers_may_exit = 1;
kill_workers();
-
- for (i = 0; i < ss->worker_threads + ss->acceptor_threads; i++) {
- if (ap_scoreboard_image->servers[index][i].status != SERVER_DEAD) {
- pthread_join(ap_scoreboard_image->servers[index][i].tid, NULL);
- }
- }
}
int ap_get_timeout(request_rec *r)
@@ -1865,8 +1876,7 @@
free(ti);
ptrans = ap_make_sub_pool(pchild);
- while ((ap_max_requests_per_child != 0 && requests_this_child > 0) ||
- (ap_max_requests_per_child == 0)) {
+ while (!(workers_may_exit && (queue_size(&csd_queue) == 0))) {
(void) ap_update_child_status(my_pid, my_tid, SERVER_READY,
(request_rec *) NULL);