Lines 137-146
Link Here
|
137 |
int tpf_child = 0; |
137 |
int tpf_child = 0; |
138 |
char tpf_server_name[INETD_SERVNAME_LENGTH+1]; |
138 |
char tpf_server_name[INETD_SERVNAME_LENGTH+1]; |
139 |
#endif /* TPF */ |
139 |
#endif /* TPF */ |
140 |
|
140 |
|
141 |
static volatile int die_now = 0; |
141 |
static volatile int die_now = 0; |
|
|
142 |
static volatile int listeners_closed = 0; |
143 |
static int active_connection = 0; |
142 |
|
144 |
|
143 |
#ifdef GPROF |
145 |
#ifdef GPROF |
144 |
/* |
146 |
/* |
145 |
* change directory for gprof to plop the gmon.out file |
147 |
* change directory for gprof to plop the gmon.out file |
146 |
* configure in httpd.conf: |
148 |
* configure in httpd.conf: |
Lines 328-338
Link Here
|
328 |
clean_child_exit(0); |
330 |
clean_child_exit(0); |
329 |
} |
331 |
} |
330 |
|
332 |
|
331 |
static void stop_listening(int sig) |
333 |
static void stop_listening(int sig) |
332 |
{ |
334 |
{ |
333 |
ap_close_listeners(); |
335 |
if (active_connection) { |
|
|
336 |
ap_close_listeners(); |
337 |
listeners_closed = 1; |
338 |
} |
334 |
|
339 |
|
335 |
/* For a graceful stop, we want the child to exit when done */ |
340 |
/* For a graceful stop, we want the child to exit when done */ |
336 |
die_now = 1; |
341 |
die_now = 1; |
337 |
} |
342 |
} |
338 |
|
343 |
|
Lines 568-577
Link Here
|
568 |
/* multiple listening sockets - need to poll */ |
573 |
/* multiple listening sockets - need to poll */ |
569 |
for (;;) { |
574 |
for (;;) { |
570 |
apr_int32_t numdesc; |
575 |
apr_int32_t numdesc; |
571 |
const apr_pollfd_t *pdesc; |
576 |
const apr_pollfd_t *pdesc; |
572 |
|
577 |
|
|
|
578 |
if (die_now) { |
579 |
status = !APR_SUCCESS; |
580 |
goto unlock; |
581 |
} |
582 |
|
573 |
/* timeout == -1 == wait forever */ |
583 |
/* timeout == -1 == wait forever */ |
574 |
status = apr_pollset_poll(pollset, -1, &numdesc, &pdesc); |
584 |
status = apr_pollset_poll(pollset, -1, &numdesc, &pdesc); |
575 |
if (status != APR_SUCCESS) { |
585 |
if (status != APR_SUCCESS) { |
576 |
if (APR_STATUS_IS_EINTR(status)) { |
586 |
if (APR_STATUS_IS_EINTR(status)) { |
577 |
if (one_process && shutdown_pending) { |
587 |
if (one_process && shutdown_pending) { |
Lines 616-627
Link Here
|
616 |
} |
626 |
} |
617 |
got_fd: |
627 |
got_fd: |
618 |
/* if we accept() something we don't want to die, so we have to |
628 |
/* if we accept() something we don't want to die, so we have to |
619 |
* defer the exit |
629 |
* defer the exit |
620 |
*/ |
630 |
*/ |
621 |
status = lr->accept_func(&csd, lr, ptrans); |
631 |
if (!die_now) { |
|
|
632 |
status = lr->accept_func(&csd, lr, ptrans); |
633 |
} |
634 |
else { |
635 |
status = !APR_SUCCESS; |
636 |
} |
622 |
|
637 |
|
|
|
638 |
unlock: |
623 |
SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ |
639 |
SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ |
624 |
|
640 |
|
625 |
if (status == APR_EGENERAL) { |
641 |
if (status == APR_EGENERAL) { |
626 |
/* resource shortage or should-not-occur occured */ |
642 |
/* resource shortage or should-not-occur occured */ |
627 |
clean_child_exit(1); |
643 |
clean_child_exit(1); |
Lines 633-647
Link Here
|
633 |
/* |
649 |
/* |
634 |
* We now have a connection, so set it up with the appropriate |
650 |
* We now have a connection, so set it up with the appropriate |
635 |
* socket options, file descriptors, and read/write buffers. |
651 |
* socket options, file descriptors, and read/write buffers. |
636 |
*/ |
652 |
*/ |
637 |
|
653 |
|
|
|
654 |
active_connection = 1; |
655 |
if (die_now && !listeners_closed) { |
656 |
ap_close_listeners(); |
657 |
listeners_closed = 1; |
658 |
} |
659 |
|
638 |
current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh, bucket_alloc); |
660 |
current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh, bucket_alloc); |
639 |
if (current_conn) { |
661 |
if (current_conn) { |
640 |
ap_process_connection(current_conn, csd); |
662 |
ap_process_connection(current_conn, csd); |
641 |
ap_lingering_close(current_conn); |
663 |
ap_lingering_close(current_conn); |
642 |
} |
664 |
} |
|
|
665 |
active_connection = 0; |
643 |
|
666 |
|
644 |
/* Check the pod and the generation number after processing a |
667 |
/* Check the pod and the generation number after processing a |
645 |
* connection so that we'll go away if a graceful restart occurred |
668 |
* connection so that we'll go away if a graceful restart occurred |
646 |
* while we were processing the connection or we are the lucky |
669 |
* while we were processing the connection or we are the lucky |
647 |
* idle server process that gets to die. |
670 |
* idle server process that gets to die. |