diff options
author | Graham Dumpleton <Graham.Dumpleton@gmail.com> | 2012-04-15 15:05:42 +1000 |
---|---|---|
committer | Graham Dumpleton <Graham.Dumpleton@gmail.com> | 2012-04-15 15:05:42 +1000 |
commit | 3867e2c18d79d2ea83ed48606dde0364c08ef7f4 (patch) | |
tree | ddf303514ea8b608d159e982cd46cfcabf8469b7 | |
parent | 4e5f57c5242f62c28be667c760142690586df9c4 (diff) | |
download | mod_wsgi-3867e2c18d79d2ea83ed48606dde0364c08ef7f4.tar.gz |
Fix bug where signal pipe not setup before signal handlers created.
-rw-r--r-- | mod_wsgi.c | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -10755,23 +10755,10 @@ static void wsgi_daemon_main(apr_pool_t *p, WSGIDaemonProcess *daemon) apr_int32_t poll_count = 0; /* - * Create pipe by which signal handler can notify the main - * thread that signal has arrived indicating that process - * needs to shutdown. + * Setup poll object for listening for shutdown notice from + * signal handler. */ - rv = apr_file_pipe_create(&wsgi_signal_pipe_in, &wsgi_signal_pipe_out, p); - - if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, WSGI_LOG_EMERG(rv), wsgi_server, - "mod_wsgi (pid=%d): Couldn't initialise signal " - "pipe in daemon process '%s'.", getpid(), - daemon->group->name); - sleep(20); - - return; - } - poll_fd.desc_type = APR_POLL_FILE; poll_fd.reqevents = APR_POLLIN; poll_fd.desc.f = wsgi_signal_pipe_in; @@ -11174,9 +11161,25 @@ static int wsgi_start_process(apr_pool_t *p, WSGIDaemonProcess *daemon) /* * Register signal handler to receive shutdown signal - * from Apache parent process. + * from Apache parent process. We need to first create + * pipe by which signal handler can notify the main + * thread that signal has arrived indicating that + * process needs to shutdown. */ + status = apr_file_pipe_create(&wsgi_signal_pipe_in, + &wsgi_signal_pipe_out, p); + + if (status != APR_SUCCESS) { + ap_log_error(APLOG_MARK, WSGI_LOG_EMERG(status), wsgi_server, + "mod_wsgi (pid=%d): Couldn't initialise signal " + "pipe in daemon process '%s'.", getpid(), + daemon->group->name); + sleep(20); + + exit(-1); + } + wsgi_daemon_shutdown = 0; apr_signal(SIGINT, wsgi_signal_handler); |