comparison src/os/win32/ngx_process_cycle.c @ 3751:a4755d4fd91b

add "Global\" prefix for signal events
author Igor Sysoev <igor@sysoev.ru>
date Thu, 02 Sep 2010 13:49:05 +0000
parents ab353d7dc182
children 59b99f217c6d
comparison
equal deleted inserted replaced
3750:ffbdaa3c70d6 3751:a4755d4fd91b
11 11
12 12
13 static void ngx_process_init(ngx_cycle_t *cycle); 13 static void ngx_process_init(ngx_cycle_t *cycle);
14 static void ngx_console_init(ngx_cycle_t *cycle); 14 static void ngx_console_init(ngx_cycle_t *cycle);
15 static int __stdcall ngx_console_handler(u_long type); 15 static int __stdcall ngx_console_handler(u_long type);
16 static ngx_int_t ngx_create_events(ngx_cycle_t *cycle); 16 static ngx_int_t ngx_create_signal_events(ngx_cycle_t *cycle);
17 static ngx_int_t ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type); 17 static ngx_int_t ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type);
18 static void ngx_reopen_worker_processes(ngx_cycle_t *cycle); 18 static void ngx_reopen_worker_processes(ngx_cycle_t *cycle);
19 static void ngx_quit_worker_processes(ngx_cycle_t *cycle, ngx_uint_t old); 19 static void ngx_quit_worker_processes(ngx_cycle_t *cycle, ngx_uint_t old);
20 static void ngx_terminate_worker_processes(ngx_cycle_t *cycle); 20 static void ngx_terminate_worker_processes(ngx_cycle_t *cycle);
21 static ngx_uint_t ngx_reap_worker(ngx_cycle_t *cycle, HANDLE h); 21 static ngx_uint_t ngx_reap_worker(ngx_cycle_t *cycle, HANDLE h);
92 "CreateEvent(\"%s\") failed", 92 "CreateEvent(\"%s\") failed",
93 ngx_master_process_event_name); 93 ngx_master_process_event_name);
94 exit(2); 94 exit(2);
95 } 95 }
96 96
97 if (ngx_create_events(cycle) != NGX_OK) { 97 if (ngx_create_signal_events(cycle) != NGX_OK) {
98 exit(2); 98 exit(2);
99 } 99 }
100 100
101 ngx_sprintf((u_char *) ngx_cache_manager_mutex_name, 101 ngx_sprintf((u_char *) ngx_cache_manager_mutex_name,
102 "ngx_cache_manager_mutex_%s%Z", ngx_unique); 102 "ngx_cache_manager_mutex_%s%Z", ngx_unique);
339 return 1; 339 return 1;
340 } 340 }
341 341
342 342
343 static ngx_int_t 343 static ngx_int_t
344 ngx_create_events(ngx_cycle_t *cycle) 344 ngx_create_signal_events(ngx_cycle_t *cycle)
345 { 345 {
346 ngx_sprintf((u_char *) ngx_stop_event_name, "ngx_stop_%s%Z", ngx_unique); 346 ngx_sprintf((u_char *) ngx_stop_event_name,
347 "Global\\ngx_stop_%s%Z", ngx_unique);
347 348
348 ngx_stop_event = CreateEvent(NULL, 1, 0, ngx_stop_event_name); 349 ngx_stop_event = CreateEvent(NULL, 1, 0, ngx_stop_event_name);
349 if (ngx_stop_event == NULL) { 350 if (ngx_stop_event == NULL) {
350 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, 351 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
351 "CreateEvent(\"%s\") failed", ngx_stop_event_name); 352 "CreateEvent(\"%s\") failed", ngx_stop_event_name);
352 return NGX_ERROR; 353 return NGX_ERROR;
353 } 354 }
354 355
355 356
356 ngx_sprintf((u_char *) ngx_quit_event_name, "ngx_quit_%s%Z", ngx_unique); 357 ngx_sprintf((u_char *) ngx_quit_event_name,
358 "Global\\ngx_quit_%s%Z", ngx_unique);
357 359
358 ngx_quit_event = CreateEvent(NULL, 1, 0, ngx_quit_event_name); 360 ngx_quit_event = CreateEvent(NULL, 1, 0, ngx_quit_event_name);
359 if (ngx_quit_event == NULL) { 361 if (ngx_quit_event == NULL) {
360 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, 362 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
361 "CreateEvent(\"%s\") failed", ngx_quit_event_name); 363 "CreateEvent(\"%s\") failed", ngx_quit_event_name);
362 return NGX_ERROR; 364 return NGX_ERROR;
363 } 365 }
364 366
365 367
366 ngx_sprintf((u_char *) ngx_reopen_event_name, 368 ngx_sprintf((u_char *) ngx_reopen_event_name,
367 "ngx_reopen_%s%Z", ngx_unique); 369 "Global\\ngx_reopen_%s%Z", ngx_unique);
368 370
369 ngx_reopen_event = CreateEvent(NULL, 1, 0, ngx_reopen_event_name); 371 ngx_reopen_event = CreateEvent(NULL, 1, 0, ngx_reopen_event_name);
370 if (ngx_reopen_event == NULL) { 372 if (ngx_reopen_event == NULL) {
371 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, 373 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
372 "CreateEvent(\"%s\") failed", ngx_reopen_event_name); 374 "CreateEvent(\"%s\") failed", ngx_reopen_event_name);
373 return NGX_ERROR; 375 return NGX_ERROR;
374 } 376 }
375 377
376 378
377 ngx_sprintf((u_char *) ngx_reload_event_name, 379 ngx_sprintf((u_char *) ngx_reload_event_name,
378 "ngx_reload_%s%Z", ngx_unique); 380 "Global\\ngx_reload_%s%Z", ngx_unique);
379 381
380 ngx_reload_event = CreateEvent(NULL, 1, 0, ngx_reload_event_name); 382 ngx_reload_event = CreateEvent(NULL, 1, 0, ngx_reload_event_name);
381 if (ngx_reload_event == NULL) { 383 if (ngx_reload_event == NULL) {
382 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, 384 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
383 "CreateEvent(\"%s\") failed", ngx_reload_event_name); 385 "CreateEvent(\"%s\") failed", ngx_reload_event_name);
1033 1035
1034 ngx_process_init(cycle); 1036 ngx_process_init(cycle);
1035 1037
1036 ngx_console_init(cycle); 1038 ngx_console_init(cycle);
1037 1039
1038 if (ngx_create_events(cycle) != NGX_OK) { 1040 if (ngx_create_signal_events(cycle) != NGX_OK) {
1039 exit(2); 1041 exit(2);
1040 } 1042 }
1041 1043
1042 if (ngx_create_thread(&tid, ngx_worker_thread, NULL, cycle->log) != 0) { 1044 if (ngx_create_thread(&tid, ngx_worker_thread, NULL, cycle->log) != 0) {
1043 /* fatal */ 1045 /* fatal */
1054 { 1056 {
1055 HANDLE ev; 1057 HANDLE ev;
1056 ngx_int_t rc; 1058 ngx_int_t rc;
1057 char evn[NGX_PROCESS_SYNC_NAME]; 1059 char evn[NGX_PROCESS_SYNC_NAME];
1058 1060
1059 ngx_sprintf((u_char *) evn, "ngx_%s_%ul%Z", sig, pid); 1061 ngx_sprintf((u_char *) evn, "Global\\ngx_%s_%ul%Z", sig, pid);
1060 1062
1061 ev = OpenEvent(EVENT_MODIFY_STATE, 0, evn); 1063 ev = OpenEvent(EVENT_MODIFY_STATE, 0, evn);
1062 if (ev == NULL) { 1064 if (ev == NULL) {
1063 ngx_log_error(NGX_LOG_ERR, cycle->log, ngx_errno, 1065 ngx_log_error(NGX_LOG_ERR, cycle->log, ngx_errno,
1064 "OpenEvent(\"%s\") failed", evn); 1066 "OpenEvent(\"%s\") failed", evn);