Loading server/mpm/winnt/mpm_winnt.c +26 −32 Original line number Diff line number Diff line Loading @@ -292,26 +292,39 @@ void setup_signal_names(char *prefix) "%s_restart", signal_name_prefix); } void signal_parent(int type) static int volatile is_graceful = 0; AP_DECLARE(int) ap_graceful_stop_signalled(void) { return is_graceful; } AP_DECLARE(void) ap_signal_parent(ap_signal_parent_e type) { HANDLE e; char *signal_name; /* after updating the shutdown_pending or restart flags, we need * to wake up the parent process so it can see the changes. The * parent will normally be waiting for either a child process * to die, or for a signal on the "spache-signal" event. So set the * "apache-signal" event here. */ if (one_process) { return; } switch(type) { case 0: signal_name = signal_shutdown_name; break; case 1: signal_name = signal_restart_name; break; default: return; case SIGNAL_PARENT_SHUTDOWN: { signal_name = signal_shutdown_name; break; } /* This MPM supports only graceful restarts right now */ case SIGNAL_PARENT_RESTART: case SIGNAL_PARENT_RESTART_GRACEFUL: { signal_name = signal_restart_name; is_graceful = 1; break; } default: return; } e = OpenEvent(EVENT_ALL_ACCESS, FALSE, signal_name); if (!e) { /* Um, problem, can't signal the parent, which means we can't Loading @@ -331,25 +344,6 @@ void signal_parent(int type) CloseHandle(e); } static int volatile is_graceful = 0; AP_DECLARE(int) ap_graceful_stop_signalled(void) { return is_graceful; } AP_DECLARE(void) ap_start_shutdown(void) { signal_parent(0); } AP_DECLARE(void) ap_start_restart(int gracefully) { is_graceful = gracefully; signal_parent(1); } /* * find_ready_listener() * Only used by Win9* and should go away when the win9*_accept() function is Loading Loading @@ -409,7 +403,7 @@ static int get_listeners_from_parent(server_rec *s) &BytesRead, (LPOVERLAPPED) NULL)) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), server_conf, "setup_inherited_listeners: Unable to read socket data from parent"); signal_parent(0); /* tell parent to die */ ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); exit(1); } ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, APR_SUCCESS, server_conf, Loading @@ -419,7 +413,7 @@ static int get_listeners_from_parent(server_rec *s) if (nsd == INVALID_SOCKET) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_netos_error(), server_conf, "Child %d: setup_inherited_listeners(), WSASocket failed to open the inherited socket.", my_pid); signal_parent(0); /* tell parent to die */ ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); exit(1); } apr_os_sock_put(&lr->sd, &nsd, pconf); Loading Loading @@ -992,7 +986,7 @@ static void child_main() if (status != APR_SUCCESS) { ap_log_error(APLOG_MARK,APLOG_ERR, status, server_conf, "Child %d: Failed to acquire the start_mutex. Process will exit.", my_pid); signal_parent(0); /* tell parent to die */ ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); exit(0); } ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf, Loading server/mpm/winnt/mpm_winnt.h +6 −4 Original line number Diff line number Diff line Loading @@ -117,12 +117,14 @@ void mpm_start_child_console_handler(void); extern OSVERSIONINFO osver; extern void clean_child_exit(int); AP_DECLARE(void) ap_start_shutdown(void); AP_DECLARE(void) ap_start_restart(int gracefully); void setup_signal_names(char *prefix); void signal_parent(int type); typedef enum { SIGNAL_PARENT_SHUTDOWN, SIGNAL_PARENT_RESTART, SIGNAL_PARENT_RESTART_GRACEFUL } ap_signal_parent_e; AP_DECLARE(void) ap_signal_parent(ap_signal_parent_e type); /* This code is stolen from the apr_private.h and misc/win32/misc.c * Please see those sources for detailed documentation. Loading server/mpm/winnt/service.c +8 −8 Original line number Diff line number Diff line Loading @@ -183,7 +183,7 @@ static LRESULT CALLBACK monitor_service_9x_proc(HWND hWnd, UINT msg, if ((msg == WM_ENDSESSION) && (die_on_logoff || (lParam != ENDSESSION_LOGOFF))) { signal_parent(0); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); if (wParam) /* Don't leave this message until we are dead! */ WaitForSingleObject(globdat.mpm_thread, 30000); Loading Loading @@ -274,7 +274,7 @@ static BOOL CALLBACK console_control_handler(DWORD ctrl_type) { case CTRL_BREAK_EVENT: fprintf(stderr, "Apache server restarting...\n"); signal_parent(1); ap_signal_parent(SIGNAL_PARENT_RESTART); return TRUE; case CTRL_C_EVENT: fprintf(stderr, "Apache server interrupted...\n"); Loading @@ -282,7 +282,7 @@ static BOOL CALLBACK console_control_handler(DWORD ctrl_type) * Tell the system we have dealt with the signal * without waiting for Apache to terminate. */ signal_parent(0); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); return TRUE; case CTRL_CLOSE_EVENT: Loading @@ -295,7 +295,7 @@ static BOOL CALLBACK console_control_handler(DWORD ctrl_type) * THESE EVENTS WILL NOT OCCUR UNDER WIN9x! */ fprintf(stderr, "Apache server shutdown initiated...\n"); signal_parent(0); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); Sleep(30000); return TRUE; } Loading Loading @@ -484,14 +484,14 @@ static VOID WINAPI service_nt_ctrl(DWORD dwCtrlCode) { if (dwCtrlCode == SERVICE_CONTROL_STOP) { ap_start_shutdown(); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); globdat.ssStatus.dwCurrentState = SERVICE_STOP_PENDING; ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 3000); return; } if (dwCtrlCode == SERVICE_APACHE_RESTART) { ap_start_restart(1); ap_signal_parent(SIGNAL_PARENT_RESTART); globdat.ssStatus.dwCurrentState = SERVICE_START_PENDING; ReportStatusToSCMgr(SERVICE_START_PENDING, NO_ERROR, 3000); return; Loading Loading @@ -1337,7 +1337,7 @@ void mpm_signal_service(apr_pool_t *ptemp, int signal) if (!signal) { int ticks = 60; ap_start_shutdown(); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); while (--ticks) { if (!IsWindow(hwnd)) { Loading @@ -1360,7 +1360,7 @@ void mpm_signal_service(apr_pool_t *ptemp, int signal) } else { success = TRUE; ap_start_restart(1); ap_signal_parent(SIGNAL_PARENT_RESTART); } } } Loading Loading
server/mpm/winnt/mpm_winnt.c +26 −32 Original line number Diff line number Diff line Loading @@ -292,26 +292,39 @@ void setup_signal_names(char *prefix) "%s_restart", signal_name_prefix); } void signal_parent(int type) static int volatile is_graceful = 0; AP_DECLARE(int) ap_graceful_stop_signalled(void) { return is_graceful; } AP_DECLARE(void) ap_signal_parent(ap_signal_parent_e type) { HANDLE e; char *signal_name; /* after updating the shutdown_pending or restart flags, we need * to wake up the parent process so it can see the changes. The * parent will normally be waiting for either a child process * to die, or for a signal on the "spache-signal" event. So set the * "apache-signal" event here. */ if (one_process) { return; } switch(type) { case 0: signal_name = signal_shutdown_name; break; case 1: signal_name = signal_restart_name; break; default: return; case SIGNAL_PARENT_SHUTDOWN: { signal_name = signal_shutdown_name; break; } /* This MPM supports only graceful restarts right now */ case SIGNAL_PARENT_RESTART: case SIGNAL_PARENT_RESTART_GRACEFUL: { signal_name = signal_restart_name; is_graceful = 1; break; } default: return; } e = OpenEvent(EVENT_ALL_ACCESS, FALSE, signal_name); if (!e) { /* Um, problem, can't signal the parent, which means we can't Loading @@ -331,25 +344,6 @@ void signal_parent(int type) CloseHandle(e); } static int volatile is_graceful = 0; AP_DECLARE(int) ap_graceful_stop_signalled(void) { return is_graceful; } AP_DECLARE(void) ap_start_shutdown(void) { signal_parent(0); } AP_DECLARE(void) ap_start_restart(int gracefully) { is_graceful = gracefully; signal_parent(1); } /* * find_ready_listener() * Only used by Win9* and should go away when the win9*_accept() function is Loading Loading @@ -409,7 +403,7 @@ static int get_listeners_from_parent(server_rec *s) &BytesRead, (LPOVERLAPPED) NULL)) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), server_conf, "setup_inherited_listeners: Unable to read socket data from parent"); signal_parent(0); /* tell parent to die */ ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); exit(1); } ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, APR_SUCCESS, server_conf, Loading @@ -419,7 +413,7 @@ static int get_listeners_from_parent(server_rec *s) if (nsd == INVALID_SOCKET) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_netos_error(), server_conf, "Child %d: setup_inherited_listeners(), WSASocket failed to open the inherited socket.", my_pid); signal_parent(0); /* tell parent to die */ ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); exit(1); } apr_os_sock_put(&lr->sd, &nsd, pconf); Loading Loading @@ -992,7 +986,7 @@ static void child_main() if (status != APR_SUCCESS) { ap_log_error(APLOG_MARK,APLOG_ERR, status, server_conf, "Child %d: Failed to acquire the start_mutex. Process will exit.", my_pid); signal_parent(0); /* tell parent to die */ ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); exit(0); } ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf, Loading
server/mpm/winnt/mpm_winnt.h +6 −4 Original line number Diff line number Diff line Loading @@ -117,12 +117,14 @@ void mpm_start_child_console_handler(void); extern OSVERSIONINFO osver; extern void clean_child_exit(int); AP_DECLARE(void) ap_start_shutdown(void); AP_DECLARE(void) ap_start_restart(int gracefully); void setup_signal_names(char *prefix); void signal_parent(int type); typedef enum { SIGNAL_PARENT_SHUTDOWN, SIGNAL_PARENT_RESTART, SIGNAL_PARENT_RESTART_GRACEFUL } ap_signal_parent_e; AP_DECLARE(void) ap_signal_parent(ap_signal_parent_e type); /* This code is stolen from the apr_private.h and misc/win32/misc.c * Please see those sources for detailed documentation. Loading
server/mpm/winnt/service.c +8 −8 Original line number Diff line number Diff line Loading @@ -183,7 +183,7 @@ static LRESULT CALLBACK monitor_service_9x_proc(HWND hWnd, UINT msg, if ((msg == WM_ENDSESSION) && (die_on_logoff || (lParam != ENDSESSION_LOGOFF))) { signal_parent(0); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); if (wParam) /* Don't leave this message until we are dead! */ WaitForSingleObject(globdat.mpm_thread, 30000); Loading Loading @@ -274,7 +274,7 @@ static BOOL CALLBACK console_control_handler(DWORD ctrl_type) { case CTRL_BREAK_EVENT: fprintf(stderr, "Apache server restarting...\n"); signal_parent(1); ap_signal_parent(SIGNAL_PARENT_RESTART); return TRUE; case CTRL_C_EVENT: fprintf(stderr, "Apache server interrupted...\n"); Loading @@ -282,7 +282,7 @@ static BOOL CALLBACK console_control_handler(DWORD ctrl_type) * Tell the system we have dealt with the signal * without waiting for Apache to terminate. */ signal_parent(0); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); return TRUE; case CTRL_CLOSE_EVENT: Loading @@ -295,7 +295,7 @@ static BOOL CALLBACK console_control_handler(DWORD ctrl_type) * THESE EVENTS WILL NOT OCCUR UNDER WIN9x! */ fprintf(stderr, "Apache server shutdown initiated...\n"); signal_parent(0); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); Sleep(30000); return TRUE; } Loading Loading @@ -484,14 +484,14 @@ static VOID WINAPI service_nt_ctrl(DWORD dwCtrlCode) { if (dwCtrlCode == SERVICE_CONTROL_STOP) { ap_start_shutdown(); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); globdat.ssStatus.dwCurrentState = SERVICE_STOP_PENDING; ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 3000); return; } if (dwCtrlCode == SERVICE_APACHE_RESTART) { ap_start_restart(1); ap_signal_parent(SIGNAL_PARENT_RESTART); globdat.ssStatus.dwCurrentState = SERVICE_START_PENDING; ReportStatusToSCMgr(SERVICE_START_PENDING, NO_ERROR, 3000); return; Loading Loading @@ -1337,7 +1337,7 @@ void mpm_signal_service(apr_pool_t *ptemp, int signal) if (!signal) { int ticks = 60; ap_start_shutdown(); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); while (--ticks) { if (!IsWindow(hwnd)) { Loading @@ -1360,7 +1360,7 @@ void mpm_signal_service(apr_pool_t *ptemp, int signal) } else { success = TRUE; ap_start_restart(1); ap_signal_parent(SIGNAL_PARENT_RESTART); } } } Loading