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

(-)modules/fcgid/fcgid_mutex_unix.c (-1 / +6 lines)
Lines 114-120 Link Here
114
     * to a better place would require a directive to override it.  This
114
     * to a better place would require a directive to override it.  This
115
     * is resolved for httpd 2.3+ by hooking into the Mutex support.
115
     * is resolved for httpd 2.3+ by hooking into the Mutex support.
116
     */
116
     */
117
    lockfile = apr_palloc(pconf, L_tmpnam);
117
    if (*lockfilep == NULL) {
118
        lockfile = apr_palloc(pool, L_tmpnam);
119
    }
120
    else {
121
        lockfile = *lockfilep;
122
    }
118
    tmpnam(lockfile);
123
    tmpnam(lockfile);
119
    rv = apr_global_mutex_create(mutex, lockfile, mechanism, pconf);
124
    rv = apr_global_mutex_create(mutex, lockfile, mechanism, pconf);
120
    if (rv != APR_SUCCESS) {
125
    if (rv != APR_SUCCESS) {
(-)modules/fcgid/fcgid_proctbl_unix.c (-29 / +81 lines)
Lines 129-164 Link Here
129
apr_status_t
129
apr_status_t
130
proctable_post_config(server_rec * main_server, apr_pool_t * configpool)
130
proctable_post_config(server_rec * main_server, apr_pool_t * configpool)
131
{
131
{
132
    const char *userdata_mutex_key = "fcgid_proctbl_mutex";
133
    const char *userdata_filename_key = "fcgid_proctbl_mutex_file";
132
    size_t shmem_size = sizeof(fcgid_share);
134
    size_t shmem_size = sizeof(fcgid_share);
133
    fcgid_procnode *ptmpnode = NULL;
135
    fcgid_procnode *ptmpnode = NULL;
134
    int i;
136
    int i;
137
    int reused_shm = 0;
135
    apr_status_t rv;
138
    apr_status_t rv;
136
    fcgid_server_conf *sconf = ap_get_module_config(main_server->module_config,
139
    fcgid_server_conf *sconf = ap_get_module_config(main_server->module_config,
137
                                                    &fcgid_module);
140
                                                    &fcgid_module);
138
141
139
    /* Remove share memory first */
142
    g_sharelock_name = NULL;
140
    apr_shm_remove(sconf->shmname_path, main_server->process->pconf);
143
    g_sharemem = NULL;
144
    g_sharelock = NULL;
141
145
142
    /* Create share memory */
146
    /* Check to see if we can reclaim the mutex first
143
    if ((rv = apr_shm_create(&g_sharemem, shmem_size, sconf->shmname_path,
147
       All mutexes are going to persist across restarts */
144
                             main_server->process->pconf)) != APR_SUCCESS)
148
    apr_pool_userdata_get((void *) &g_sharelock, userdata_mutex_key,
145
    {
149
                          main_server->process->pool);
146
        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
150
    apr_pool_userdata_get((void *) &g_sharelock_name, userdata_filename_key,
147
                     "mod_fcgid: Can't create shared memory for size %" APR_SIZE_T_FMT " bytes",
151
                          main_server->process->pool);
148
                     shmem_size);
152
    if (g_sharelock == NULL || g_sharelock_name == NULL ) {
149
        exit(1);
153
        rv = fcgid_mutex_create(&g_sharelock, &g_sharelock_name,
154
                                g_sharelock_mutex_type,
155
                                main_server->process->pool, main_server);
156
        if (rv != APR_SUCCESS) {
157
            exit(1);
158
        }
159
        apr_pool_userdata_set(g_sharelock, userdata_mutex_key,
160
                              apr_pool_cleanup_null,
161
                              main_server->process->pool);
162
        apr_pool_userdata_set(g_sharelock_name, userdata_filename_key,
163
                              apr_pool_cleanup_null,
164
                              main_server->process->pool);
165
        
166
        /* Since we couldn't use the old mutex we're going to assume
167
           the old shared memory is also invalid */
168
        apr_shm_remove(sconf->shmname_path, main_server->process->pool);
150
    }
169
    }
151
    _global_memory = apr_shm_baseaddr_get(g_sharemem);
170
    else {
171
        /* We reclaimed the old mutex so we'll try to also reclaim the old shared memory */
172
        if ((rv = apr_shm_attach(&g_sharemem, sconf->shmname_path, main_server->process->pool)) == APR_SUCCESS) {
173
            if ( apr_shm_size_get(g_sharemem) == shmem_size ) {
174
                /* TODO: Additional checks here that shm comes from the current server */
175
                _global_memory = apr_shm_baseaddr_get(g_sharemem);
176
                reused_shm = 1;
177
            }
178
            else {
179
                apr_shm_detach(g_sharemem);
180
            }
181
        }
182
        if (rv != APR_SUCCESS || g_sharemem == NULL) {
183
            /* Couldn't reuse the old shared memory, make sure the file is removed */
184
            apr_shm_remove(sconf->shmname_path, main_server->process->pool);
185
        }
186
    }
152
187
153
    /* Create global mutex */
188
    if (!reused_shm) {
154
    rv = fcgid_mutex_create(&g_sharelock, &g_sharelock_name,
189
        if ((rv = apr_shm_create(&g_sharemem, shmem_size, sconf->shmname_path,
155
                            g_sharelock_mutex_type,
190
                                 main_server->process->pool)) != APR_SUCCESS) {
156
                            main_server->process->pconf, main_server);
191
            ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
192
                         "mod_fcgid: Can't create shared memory for size %" APR_SIZE_T_FMT " bytes",
193
                         shmem_size);
194
            exit(1);
195
        }
196
        _global_memory = apr_shm_baseaddr_get(g_sharemem);
197
        memset(_global_memory, 0, shmem_size);
198
    }
199
    
200
    rv = proctable_lock_safe();
157
    if (rv != APR_SUCCESS) {
201
    if (rv != APR_SUCCESS) {
202
        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
203
                     "mod_fcgid: Can't lock process table for initialization");
158
        exit(1);
204
        exit(1);
159
    }
205
    }
160
206
        
161
    memset(_global_memory, 0, shmem_size);
162
    g_proc_array = _global_memory->procnode_array;
207
    g_proc_array = _global_memory->procnode_array;
163
    g_global_share = &_global_memory->global;
208
    g_global_share = &_global_memory->global;
164
209
Lines 169-180 Link Here
169
    g_busy_list_header = g_idle_list_header + 1;
214
    g_busy_list_header = g_idle_list_header + 1;
170
    g_error_list_header = g_busy_list_header + 1;
215
    g_error_list_header = g_busy_list_header + 1;
171
    g_free_list_header = g_error_list_header + 1;
216
    g_free_list_header = g_error_list_header + 1;
172
    ptmpnode = g_free_list_header;
217
    if (!reused_shm) {
173
    for (i = 0; i < FCGID_MAX_APPLICATION; i++) {
218
        /* This initially adds all nodes to the free list */
174
        ptmpnode->next_index = ptmpnode - g_proc_array + 1;
219
        ptmpnode = g_free_list_header;
175
        ptmpnode++;
220
        for (i = 0; i < FCGID_MAX_APPLICATION; i++) {
221
            ptmpnode->next_index = ptmpnode - g_proc_array + 1;
222
            ptmpnode++;
223
        }
176
    }
224
    }
225
    proctable_unlock_safe();
177
226
227
178
    return APR_SUCCESS;
228
    return APR_SUCCESS;
179
}
229
}
180
230
Lines 200-210 Link Here
200
    return apr_global_mutex_lock(g_sharelock);
250
    return apr_global_mutex_lock(g_sharelock);
201
}
251
}
202
252
253
apr_status_t proctable_lock_safe(void)
254
{
255
    return proctable_lock_internal();
256
}
257
203
static apr_status_t proctable_unlock_internal(void)
258
static apr_status_t proctable_unlock_internal(void)
204
{
259
{
205
    return apr_global_mutex_unlock(g_sharelock);
260
    return apr_global_mutex_unlock(g_sharelock);
206
}
261
}
207
262
263
apr_status_t proctable_unlock_safe(void)
264
{
265
    return proctable_unlock_internal();
266
}
267
208
fcgid_procnode *proctable_get_free_list(void)
268
fcgid_procnode *proctable_get_free_list(void)
209
{
269
{
210
    return g_free_list_header;
270
    return g_free_list_header;
Lines 272-285 Link Here
272
{
332
{
273
    apr_status_t rv;
333
    apr_status_t rv;
274
334
275
    if (g_global_share->must_exit) {
276
        ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s,
277
                     "mod_fcgid: server is restarted, pid %" APR_PID_T_FMT
278
                     " must exit",
279
                     getpid());
280
        kill(getpid(), SIGTERM);
281
    }
282
283
    /* Lock error is a fatal error */
335
    /* Lock error is a fatal error */
284
    if ((rv = proctable_lock_internal()) != APR_SUCCESS) {
336
    if ((rv = proctable_lock_internal()) != APR_SUCCESS) {
285
        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
337
        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
(-)modules/fcgid/fcgid_pm_main.c (-50 / +81 lines)
Lines 401-464 Link Here
401
    return 0;
401
    return 0;
402
}
402
}
403
403
404
static void kill_all_subprocess(server_rec *main_server)
404
static void kill_all_subprocess(server_rec * main_server, int graceful)
405
{
405
{
406
    apr_time_t waittime = 1024 * 16;
406
    int wait_attempts = 0;
407
    size_t i, table_size = proctable_get_table_size();
408
    int not_dead_yet;
409
    int cur_action, next_action;
410
    apr_time_t starttime = apr_time_now();
411
    struct {
412
        action_t action;
413
        apr_time_t action_time;
414
    } action_table[] = {
415
        {DO_NOTHING,      0}, /* dummy entry for iterations where
416
                              * we reap children but take no action
417
                              * against stragglers
418
                              */
419
        {KILL_GRACEFULLY, apr_time_from_sec(0)},
420
        {KILL_GRACEFULLY, apr_time_from_sec(1)},
421
        {KILL_FORCEFULLY, apr_time_from_sec(8)},
422
        {HARD_WAIT,       apr_time_from_sec(8)}
423
    };
424
    fcgid_procnode *proc_table = proctable_get_table_array();
407
    fcgid_procnode *proc_table = proctable_get_table_array();
408
    fcgid_procnode *free_list_header = proctable_get_free_list();
409
    fcgid_procnode *busy_list_header = proctable_get_busy_list();
410
    fcgid_procnode *idle_list_header = proctable_get_idle_list();
411
    fcgid_procnode *error_list_header = proctable_get_error_list();
412
    fcgid_procnode *previous_node, *current_node, *next_node;
425
413
426
    next_action = 1;
414
    /* We'll scan the idle and busy lists signaling each process to shut down
427
    do {
415
       The processes in the idle list will be moved to the error list
428
        apr_sleep(waittime);
416
       Processes in the busy list will be moved to the error list only during a hard shutdown/restart.
429
        /* don't let waittime get longer than 1 second; otherwise, we don't
417
       After we've moved everything to the error list that needs to die, we walk it until everything is cleaned up */
430
         * react quickly to the last child exiting, and taking action can
431
         * be delayed
432
         */
433
        waittime = waittime * 4;
434
        if (waittime > apr_time_from_sec(1)) {
435
            waittime = apr_time_from_sec(1);
436
        }
437
418
438
        /* see what action to take, if any */
419
     proctable_pm_lock(main_server);
439
        if (action_table[next_action].action_time <= apr_time_now() - starttime) {
420
440
            cur_action = next_action;
421
     /* signal all processes in the error list once */
441
            ++next_action;
422
    previous_node = error_list_header;
423
    current_node = &proc_table[previous_node->next_index];
424
    while (current_node != proc_table) {
425
        proc_kill_gracefully(current_node, main_server);               
426
        previous_node = current_node;
427
        current_node = &proc_table[current_node->next_index];
428
    }
429
430
    /* Previous node is going to be the tail end of the error list.  Attach all the idle list to it and signal those processes to exit */
431
    current_node = &proc_table[idle_list_header->next_index];
432
    if (current_node != proc_table) {
433
        previous_node->next_index = (current_node - proc_table);
434
        idle_list_header->next_index = 0;
435
        while ( current_node != proc_table ) {
436
            proc_kill_gracefully( current_node, main_server );
437
            current_node->diewhy = FCGID_DIE_SHUTDOWN;
438
            previous_node = current_node;
439
            current_node = &proc_table[ current_node->next_index ];
442
        }
440
        }
443
        else {
441
    }
444
            cur_action = 0; /* index of DO_NOTHING entry */
445
        }
446
442
447
        /* now see who is done */
443
    /* If this is a forced shutdown, link the busy list to the error list */
448
        not_dead_yet = 0;
444
    current_node = &proc_table[busy_list_header->next_index];
449
        for (i = 0; i < table_size; i++) {
445
    if (!graceful && current_node != proc_table) {
450
            if (!proc_table[i].proc_pool) {
446
        previous_node->next_index = (current_node - proc_table);
451
                continue; /* unused */
447
        busy_list_header->next_index = 0;
452
            }
448
    }
449
         
450
    /* Signal processes in the busy list */
451
    while (current_node != proc_table) {
452
        proc_kill_gracefully( current_node, main_server );
453
        current_node->diewhy = FCGID_DIE_SHUTDOWN;
454
        current_node = &proc_table[ current_node->next_index ];
455
    }
453
456
454
            if (!reclaim_one_pid(main_server, &proc_table[i],
457
    /* Now clear the error list into the free list...
455
                                 action_table[cur_action].action)) {
458
       We are blocking all the bridged processes from completing during this timeframe
456
                ++not_dead_yet;
459
       since they can't aquire the mutex to check the process tables.  This should be
460
       acceptable for both graceful and hard restarts.  This loop should end rapidly
461
       with graceful restarts and connection interruptions are going to happen regardless
462
       with hard restarts. */
463
   while (error_list_header->next_index != 0) {
464
       apr_sleep(apr_time_from_sec(1));
465
       wait_attempts++;
466
       previous_node = error_list_header;
467
       current_node = &proc_table[previous_node->next_index];
468
       while (current_node != proc_table) {
469
           next_node = &proc_table[current_node->next_index];
470
           if (proc_wait_process(main_server, current_node) == APR_CHILD_NOTDONE
471
                && wait_attempts < FCGID_PM_MAX_SHUTDOWN_WAIT_ATTEMPTS ) {
472
                /* kill it hard and check again in 1 second */
473
                proc_kill_force( current_node, main_server );
474
                previous_node = current_node;
475
            }else {
476
                /* Unlink from error list */
477
                previous_node->next_index = current_node->next_index;
478
479
                /* Link to free list */
480
                current_node->next_index = free_list_header->next_index;
481
                free_list_header->next_index = current_node - proc_table;
457
            }
482
            }
483
            current_node = next_node;
458
        }
484
        }
485
    }
486
 
487
    /* At this point in a graceful restart, the busy and free lists have all the process nodes */
488
    /* In a forced restart, all nodes are in the free list */
459
489
460
    } while (not_dead_yet &&
490
    proctable_pm_unlock(main_server);
461
             action_table[cur_action].action != HARD_WAIT);
462
}
491
}
463
492
464
/* This should be proposed as a stand-alone improvement to the httpd module,
493
/* This should be proposed as a stand-alone improvement to the httpd module,
Lines 578-584 Link Here
578
    procinfo.gid = command->gid;
607
    procinfo.gid = command->gid;
579
    procinfo.userdir = command->userdir;
608
    procinfo.userdir = command->userdir;
580
    if ((rv =
609
    if ((rv =
581
         apr_pool_create(&procnode->proc_pool, configpool)) != APR_SUCCESS
610
         apr_pool_create(&procnode->proc_pool, main_server->process->pool)) != APR_SUCCESS
582
        || (procinfo.proc_environ =
611
        || (procinfo.proc_environ =
583
            apr_table_make(procnode->proc_pool, INITENV_CNT)) == NULL) {
612
            apr_table_make(procnode->proc_pool, INITENV_CNT)) == NULL) {
584
        /* Link the node back to free list in this case */
613
        /* Link the node back to free list in this case */
Lines 591-596 Link Here
591
                     "mod_fcgid: can't create pool for process");
620
                     "mod_fcgid: can't create pool for process");
592
        return;
621
        return;
593
    }
622
    }
623
    
594
    /* Set up longer, system defaults before falling into parsing fixed-limit
624
    /* Set up longer, system defaults before falling into parsing fixed-limit
595
     * request-by-request variables, so if any are overriden, they preempt
625
     * request-by-request variables, so if any are overriden, they preempt
596
     * any system default assumptions
626
     * any system default assumptions
Lines 633-638 Link Here
633
apr_status_t pm_main(server_rec * main_server, apr_pool_t * configpool)
663
apr_status_t pm_main(server_rec * main_server, apr_pool_t * configpool)
634
{
664
{
635
    fcgid_command command;
665
    fcgid_command command;
666
    apr_status_t rv;
636
667
637
    while (1) {
668
    while (1) {
638
        if (procmgr_must_exit())
669
        if (procmgr_must_exit())
Lines 656-662 Link Here
656
    }
687
    }
657
688
658
    /* Stop all processes */
689
    /* Stop all processes */
659
    kill_all_subprocess(main_server);
690
    kill_all_subprocess(main_server, procmgr_graceful_restart());
660
691
661
    return APR_SUCCESS;
692
    return APR_SUCCESS;
662
}
693
}
(-)modules/fcgid/fcgid_proctbl.h (+2 lines)
Lines 96-101 Link Here
96
void proctable_pm_unlock(server_rec *s);
96
void proctable_pm_unlock(server_rec *s);
97
void proctable_lock(request_rec *r);
97
void proctable_lock(request_rec *r);
98
void proctable_unlock(request_rec *r);
98
void proctable_unlock(request_rec *r);
99
apr_status_t proctable_lock_safe(void);
100
apr_status_t proctable_unlock_safe(void);
99
101
100
/* Just for debug */
102
/* Just for debug */
101
void proctable_print_debug_info(server_rec * main_server);
103
void proctable_print_debug_info(server_rec * main_server);
(-)modules/fcgid/fcgid_pm_unix.c (-18 / +64 lines)
Lines 66-71 Link Here
66
static const char *g_pipelock_mutex_type = "fcgid-pipe";
66
static const char *g_pipelock_mutex_type = "fcgid-pipe";
67
67
68
static int volatile g_caughtSigTerm = 0;
68
static int volatile g_caughtSigTerm = 0;
69
static int volatile g_caughtSigUsr1 = 0;
69
static pid_t g_pm_pid;
70
static pid_t g_pm_pid;
70
static void signal_handler(int signo)
71
static void signal_handler(int signo)
71
{
72
{
Lines 76-86 Link Here
76
        return;
77
        return;
77
    }
78
    }
78
79
79
    if ((signo == SIGTERM) || (signo == SIGUSR1) || (signo == SIGHUP)) {
80
    if ((signo == SIGTERM) || (signo == SIGHUP)) {
80
        g_caughtSigTerm = 1;
81
        g_caughtSigTerm = 1;
82
        g_caughtSigUsr1 = 0;
81
        /* Tell the world it's time to die */
83
        /* Tell the world it's time to die */
82
        proctable_get_globalshare()->must_exit = 1;
84
        proctable_get_globalshare()->must_exit = 1;
83
    }
85
    }
86
    if (signo == SIGUSR1 && !g_caughtSigTerm) {
87
        g_caughtSigUsr1 = 1;
88
        proctable_get_globalshare()->must_exit = 1;
89
    }
84
}
90
}
85
91
86
static apr_status_t init_signal(server_rec * main_server)
92
static apr_status_t init_signal(server_rec * main_server)
Lines 164-169 Link Here
164
        }
170
        }
165
        break;
171
        break;
166
    case APR_OC_REASON_RESTART:
172
    case APR_OC_REASON_RESTART:
173
        kill(proc->pid, SIGTERM);
167
        apr_proc_other_child_unregister(data);
174
        apr_proc_other_child_unregister(data);
168
        break;
175
        break;
169
    case APR_OC_REASON_LOST:
176
    case APR_OC_REASON_LOST:
Lines 181-187 Link Here
181
        break;
188
        break;
182
    case APR_OC_REASON_UNREGISTER:
189
    case APR_OC_REASON_UNREGISTER:
183
        /* I don't think it's going to happen */
190
        /* I don't think it's going to happen */
184
        kill(proc->pid, SIGHUP);
191
        kill(proc->pid, SIGUSR1);
185
        break;
192
        break;
186
    }
193
    }
187
}
194
}
Lines 316-322 Link Here
316
    /* I am the parent
323
    /* I am the parent
317
       I will send the stop signal in procmgr_stop_procmgr() */
324
       I will send the stop signal in procmgr_stop_procmgr() */
318
    apr_pool_note_subprocess(configpool, g_process_manager,
325
    apr_pool_note_subprocess(configpool, g_process_manager,
319
                             APR_KILL_ONLY_ONCE);
326
                             APR_JUST_WAIT);
320
    apr_proc_other_child_register(g_process_manager, fcgid_maint,
327
    apr_proc_other_child_register(g_process_manager, fcgid_maint,
321
                                  g_process_manager, NULL, configpool);
328
                                  g_process_manager, NULL, configpool);
322
329
Lines 349-356 Link Here
349
apr_status_t
356
apr_status_t
350
procmgr_post_config(server_rec * main_server, apr_pool_t * configpool)
357
procmgr_post_config(server_rec * main_server, apr_pool_t * configpool)
351
{
358
{
359
    const char *userdata_mutex_key = "fcgid_procmgr_mutex";
360
    const char *userdata_filename_key = "fcgid_procmgr_mutex_file";
361
    const char *userdata_pipe_key[] = { "fcgid_pipe_pm_read", "fcgid_pipe_pm_write", "fcgid_pipe_ap_read", "fcgid_pipe_ap_write" };
362
    apr_file_t **userdata_pipe_handle[] = { &g_pm_read_pipe, &g_pm_write_pipe, &g_ap_read_pipe, &g_ap_write_pipe };
352
    apr_status_t rv;
363
    apr_status_t rv;
353
    apr_finfo_t finfo;
364
    apr_finfo_t finfo;
365
    size_t i;
366
    size_t j;
354
    fcgid_server_conf *sconf = ap_get_module_config(main_server->module_config,
367
    fcgid_server_conf *sconf = ap_get_module_config(main_server->module_config,
355
                                                    &fcgid_module);
368
                                                    &fcgid_module);
356
369
Lines 398-419 Link Here
398
        }
411
        }
399
    }
412
    }
400
413
401
    /* Create pipes to communicate between process manager and apache */
414
    /* Create pipes to communicate between process manager and apache
402
    if ((rv = apr_file_pipe_create(&g_pm_read_pipe, &g_ap_write_pipe,
415
       The pipes will last across restarts */
403
                                   configpool)) != APR_SUCCESS
416
    for (i = 0; i < 4; i++) {
404
        || (rv = apr_file_pipe_create(&g_ap_read_pipe, &g_pm_write_pipe,
417
        apr_pool_userdata_get((void *) userdata_pipe_handle[i], userdata_pipe_key[i],
405
                                      configpool))) {
418
                              main_server->process->pool);
406
        ap_log_error(APLOG_MARK, APLOG_ERR, rv, main_server,
419
        if (*userdata_pipe_handle[i] == NULL) {
407
                     "mod_fcgid: Can't create pipe between PM and stub");
420
            if ((rv = apr_file_pipe_create(&g_pm_read_pipe, &g_ap_write_pipe,
408
        return rv;
421
                                           main_server->process->pool)) != APR_SUCCESS
422
                || (rv = apr_file_pipe_create(&g_ap_read_pipe, &g_pm_write_pipe,
423
                                              main_server->process->pool))) {
424
                ap_log_error(APLOG_MARK, APLOG_ERR, rv, main_server,
425
                             "mod_fcgid: Can't create pipe between PM and stub");
426
                return rv;
427
            }
428
            for (j = 0; j < 4; j++) {
429
                apr_pool_userdata_set(*(userdata_pipe_handle[j]), userdata_pipe_key[j],
430
                                      apr_pool_cleanup_null,
431
                                      main_server->process->pool);
432
            }
433
            break;
434
        }
409
    }
435
    }
410
436
411
    /* Create mutex for pipe reading and writing */
437
    /* Create mutex for pipe reading and writing
412
    rv = fcgid_mutex_create(&g_pipelock, &g_pipelock_name,
438
       All mutexex are going to persist across restarts */
413
                            g_pipelock_mutex_type,
439
    g_pipelock = NULL;
414
                            main_server->process->pconf, main_server);
440
    g_pipelock_name = NULL;
415
    if (rv != APR_SUCCESS) {
441
    apr_pool_userdata_get((void *) &g_pipelock, userdata_mutex_key,
416
        exit(1);
442
                         main_server->process->pool);
443
    apr_pool_userdata_get((void *) &g_pipelock_name, userdata_filename_key,
444
                         main_server->process->pool);
445
    if (g_pipelock == NULL || g_pipelock_name == NULL) {
446
        rv = fcgid_mutex_create(&g_pipelock, &g_pipelock_name,
447
                                g_pipelock_mutex_type,
448
                                main_server->process->pool, main_server);
449
        if (rv != APR_SUCCESS) {
450
            exit(1);
451
        }
452
        apr_pool_userdata_set(g_pipelock, userdata_mutex_key,
453
                              apr_pool_cleanup_null,
454
                              main_server->process->pool);
455
        apr_pool_userdata_set(g_pipelock_name, userdata_filename_key,
456
                              apr_pool_cleanup_null,
457
                              main_server->process->pool);
417
    }
458
    }
418
459
419
    /* Create process manager process */
460
    /* Create process manager process */
Lines 548-556 Link Here
548
589
549
int procmgr_must_exit()
590
int procmgr_must_exit()
550
{
591
{
551
    return g_caughtSigTerm;
592
    return g_caughtSigTerm || g_caughtSigUsr1;
552
}
593
}
553
594
595
int procmgr_graceful_restart()
596
{
597
    return g_caughtSigUsr1;
598
}
599
554
apr_status_t procmgr_stop_procmgr(void *server)
600
apr_status_t procmgr_stop_procmgr(void *server)
555
{
601
{
556
    return APR_SUCCESS;
602
    return APR_SUCCESS;
(-)modules/fcgid/fcgid_pm.h (+1 lines)
Lines 56-60 Link Here
56
56
57
apr_status_t procmgr_stop_procmgr(void *dummy);
57
apr_status_t procmgr_stop_procmgr(void *dummy);
58
int procmgr_must_exit(void);
58
int procmgr_must_exit(void);
59
int procmgr_graceful_restart(void);
59
60
60
#endif
61
#endif

Return to bug 48769