View | Details | Raw Unified | Return to bug 42829
Collapse All | Expand All

(-)server/mpm/prefork/prefork.c (-2 / +46 lines)
Lines 102-107 static int changed_limit_at_restart; Link Here
102
static int mpm_state = AP_MPMQ_STARTING;
102
static int mpm_state = AP_MPMQ_STARTING;
103
static ap_pod_t *pod;
103
static ap_pod_t *pod;
104
104
105
static int dummy_listener;
106
105
/*
107
/*
106
 * The max child slot ever assigned, preserved across restarts.  Necessary
108
 * The max child slot ever assigned, preserved across restarts.  Necessary
107
 * to deal with MaxClients changes across AP_SIG_GRACEFUL restarts.  We
109
 * to deal with MaxClients changes across AP_SIG_GRACEFUL restarts.  We
Lines 139-144 char tpf_server_name[INETD_SERVNAME_LENG Link Here
139
#endif /* TPF */
141
#endif /* TPF */
140
142
141
static volatile int die_now = 0;
143
static volatile int die_now = 0;
144
static volatile int listeners_closed = 0;
145
static int active_connection = 0;
142
146
143
#ifdef GPROF
147
#ifdef GPROF
144
/*
148
/*
Lines 330-336 static void just_die(int sig) Link Here
330
334
331
static void stop_listening(int sig)
335
static void stop_listening(int sig)
332
{
336
{
333
    ap_close_listeners();
337
    if (active_connection) {
338
        ap_listen_rec *lr;
339
340
        for (lr = ap_listeners; lr; lr = lr->next) {
341
            apr_os_sock_t fd;
342
343
            apr_os_sock_get(&fd, lr->sd);
344
345
            dup2(dummy_listener, fd);
346
        }
347
        listeners_closed = 1;
348
    }
334
349
335
    /* For a graceful stop, we want the child to exit when done */
350
    /* For a graceful stop, we want the child to exit when done */
336
    die_now = 1;
351
    die_now = 1;
Lines 573-578 static void child_main(int child_num_arg Link Here
573
                apr_int32_t numdesc;
588
                apr_int32_t numdesc;
574
                const apr_pollfd_t *pdesc;
589
                const apr_pollfd_t *pdesc;
575
590
591
                if (die_now) {
592
                    status = !APR_SUCCESS;
593
                    goto unlock;
594
                }
595
576
                /* timeout == -1 == wait forever */
596
                /* timeout == -1 == wait forever */
577
                status = apr_pollset_poll(pollset, -1, &numdesc, &pdesc);
597
                status = apr_pollset_poll(pollset, -1, &numdesc, &pdesc);
578
                if (status != APR_SUCCESS) {
598
                if (status != APR_SUCCESS) {
Lines 628-635 static void child_main(int child_num_arg Link Here
628
        /* if we accept() something we don't want to die, so we have to
648
        /* if we accept() something we don't want to die, so we have to
629
         * defer the exit
649
         * defer the exit
630
         */
650
         */
631
        status = lr->accept_func(&csd, lr, ptrans);
651
        if (!die_now) {
652
            status = lr->accept_func(&csd, lr, ptrans);
653
        }
654
        else {
655
            status = !APR_SUCCESS;
656
        }
632
657
658
    unlock:
633
        SAFE_ACCEPT(accept_mutex_off());      /* unlock after "accept" */
659
        SAFE_ACCEPT(accept_mutex_off());      /* unlock after "accept" */
634
660
635
        if (status == APR_EGENERAL) {
661
        if (status == APR_EGENERAL) {
Lines 645-655 static void child_main(int child_num_arg Link Here
645
         * socket options, file descriptors, and read/write buffers.
671
         * socket options, file descriptors, and read/write buffers.
646
         */
672
         */
647
673
674
        active_connection = 1;
675
        if (die_now && !listeners_closed) {
676
            ap_close_listeners();
677
            listeners_closed = 1;
678
        }
679
648
        current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh, bucket_alloc);
680
        current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh, bucket_alloc);
649
        if (current_conn) {
681
        if (current_conn) {
650
            ap_process_connection(current_conn, csd);
682
            ap_process_connection(current_conn, csd);
651
            ap_lingering_close(current_conn);
683
            ap_lingering_close(current_conn);
652
        }
684
        }
685
        active_connection = 0;
653
686
654
        /* Check the pod and the generation number after processing a
687
        /* Check the pod and the generation number after processing a
655
         * connection so that we'll go away if a graceful restart occurred
688
         * connection so that we'll go away if a graceful restart occurred
Lines 916-921 int ap_mpm_run(apr_pool_t *_pconf, apr_p Link Here
916
                     "ignored during restart");
949
                     "ignored during restart");
917
        changed_limit_at_restart = 0;
950
        changed_limit_at_restart = 0;
918
    }
951
    }
952
    
953
    if (dummy_listener == 0) {
954
        dummy_listener = socket(AF_INET, SOCK_STREAM, 0);
955
        if (dummy_listener < 0) {
956
            rv = errno;
957
            ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
958
                         "Couldn't create dummy listener socket");
959
            mpm_state = AP_MPMQ_STOPPING;
960
            return 1;
961
        }
962
    }        
919
963
920
    /* Initialize cross-process accept lock */
964
    /* Initialize cross-process accept lock */
921
    ap_lock_fname = apr_psprintf(_pconf, "%s.%" APR_PID_T_FMT,
965
    ap_lock_fname = apr_psprintf(_pconf, "%s.%" APR_PID_T_FMT,

Return to bug 42829