comparison src/os/win32/ngx_process.c @ 2945:87da6664fb49 stable-0.7

merge r2897, r2898, r2899, r2901, r2902, r2904, r2905, r2906, r2907, r2909, r2910, r2922, r2923, r2924, r2925, r2929: various win32 fixes: *) use no-threads for Unix builds only *) Win32 returns ERROR_PATH_NOT_FOUND instead of ERROR_FILE_NOT_FOUND *) add trailing zero to a file name in ngx_win32_rename_file() *) fix logging in ngx_win32_rename_file() *) allow shared memory segments more than 4G *) fix memory leak in successful case *) log shared memory name in failure case *) test that zone has the same addresses in different processes *) add drive letter for Win32 root path *) log GetExitCodeProcess()'s errno *) test premature process termination *) fix debug logging *) exit if no workers could not be started *) do not quit old workers if no new workers could not be started *) a signaller process should stop configuration processing just after it is able to get pid file, this allows to not open log files, etc. *) win32 master process had aready closed listening sockets
author Igor Sysoev <igor@sysoev.ru>
date Mon, 15 Jun 2009 09:48:15 +0000
parents 1983932b8075
children d82993af1da0
comparison
equal deleted inserted replaced
2944:f892042956e3 2945:87da6664fb49
17 17
18 18
19 ngx_pid_t 19 ngx_pid_t
20 ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn) 20 ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn)
21 { 21 {
22 u_long rc, n; 22 u_long rc, n, code;
23 ngx_int_t s; 23 ngx_int_t s;
24 ngx_pid_t pid; 24 ngx_pid_t pid;
25 ngx_exec_ctx_t ctx; 25 ngx_exec_ctx_t ctx;
26 HANDLE events[2];
26 char file[MAX_PATH + 1]; 27 char file[MAX_PATH + 1];
27 28
28 if (respawn >= 0) { 29 if (respawn >= 0) {
29 s = respawn; 30 s = respawn;
30 31
77 ngx_sprintf(ngx_processes[s].term_event, "ngx_%s_term_%ul%Z", name, pid); 78 ngx_sprintf(ngx_processes[s].term_event, "ngx_%s_term_%ul%Z", name, pid);
78 ngx_sprintf(ngx_processes[s].quit_event, "ngx_%s_quit_%ul%Z", name, pid); 79 ngx_sprintf(ngx_processes[s].quit_event, "ngx_%s_quit_%ul%Z", name, pid);
79 ngx_sprintf(ngx_processes[s].reopen_event, "ngx_%s_reopen_%ul%Z", 80 ngx_sprintf(ngx_processes[s].reopen_event, "ngx_%s_reopen_%ul%Z",
80 name, pid); 81 name, pid);
81 82
82 rc = WaitForSingleObject(ngx_master_process_event, 5000); 83 events[0] = ngx_master_process_event;
84 events[1] = ctx.child;
85
86 rc = WaitForMultipleObjects(2, events, 0, 5000);
83 87
84 ngx_time_update(0, 0); 88 ngx_time_update(0, 0);
85 89
86 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, 90 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0,
87 "WaitForSingleObject: %ul", rc); 91 "WaitForMultipleObjects: %ul", rc);
88 92
89 switch (rc) { 93 switch (rc) {
90 94
91 case WAIT_OBJECT_0: 95 case WAIT_OBJECT_0:
92 96
123 ngx_master_process_event_name); 127 ngx_master_process_event_name);
124 goto failed; 128 goto failed;
125 } 129 }
126 130
127 break; 131 break;
132
133 case WAIT_OBJECT_0 + 1:
134 if (GetExitCodeProcess(ctx.child, &code) == 0) {
135 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
136 "GetExitCodeProcess(%P) failed", pid);
137 }
138
139 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
140 "%s process %P exited with code %Xul",
141 name, pid, code);
142
143 goto failed;
128 144
129 case WAIT_TIMEOUT: 145 case WAIT_TIMEOUT:
130 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, 146 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
131 "the event \"%s\" was not signaled for 5s", 147 "the event \"%s\" was not signaled for 5s",
132 ngx_master_process_event_name); 148 ngx_master_process_event_name);