comparison src/os/win32/ngx_process_cycle.c @ 3247:1f3cd08ebb82 stable-0.7

merge r3017, r3018, r3019, r3020, r3021, r3022, r3023, r3196: cache management fixes: *) separate cache loader process *) use real file cache length, this fixes cache size counting for responses without "Content-Length" header and 304 responses.
author Igor Sysoev <igor@sysoev.ru>
date Mon, 26 Oct 2009 17:23:49 +0000
parents 87da6664fb49
children 8c76116820f3
comparison
equal deleted inserted replaced
3246:eb555a9a57d4 3247:1f3cd08ebb82
23 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, char *mevn); 23 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, char *mevn);
24 static void ngx_worker_process_exit(ngx_cycle_t *cycle); 24 static void ngx_worker_process_exit(ngx_cycle_t *cycle);
25 static ngx_thread_value_t __stdcall ngx_worker_thread(void *data); 25 static ngx_thread_value_t __stdcall ngx_worker_thread(void *data);
26 static ngx_thread_value_t __stdcall ngx_cache_manager_thread(void *data); 26 static ngx_thread_value_t __stdcall ngx_cache_manager_thread(void *data);
27 static void ngx_cache_manager_process_handler(void); 27 static void ngx_cache_manager_process_handler(void);
28 static ngx_thread_value_t __stdcall ngx_cache_loader_thread(void *data);
28 29
29 30
30 ngx_uint_t ngx_process; 31 ngx_uint_t ngx_process;
31 ngx_pid_t ngx_pid; 32 ngx_pid_t ngx_pid;
32 ngx_uint_t ngx_threaded; 33 ngx_uint_t ngx_threaded;
438 "process: %d %P %p e:%d j:%d", 439 "process: %d %P %p e:%d j:%d",
439 n, 440 n,
440 ngx_processes[n].pid, 441 ngx_processes[n].pid,
441 ngx_processes[n].handle, 442 ngx_processes[n].handle,
442 ngx_processes[n].exiting, 443 ngx_processes[n].exiting,
443 ngx_processes[n].just_respawn); 444 ngx_processes[n].just_spawn);
444 445
445 if (old && ngx_processes[n].just_respawn) { 446 if (old && ngx_processes[n].just_spawn) {
446 ngx_processes[n].just_respawn = 0; 447 ngx_processes[n].just_spawn = 0;
447 continue; 448 continue;
448 } 449 }
449 450
450 if (ngx_processes[n].handle == NULL) { 451 if (ngx_processes[n].handle == NULL) {
451 continue; 452 continue;
548 "process: %d %P %p e:%d j:%d", 549 "process: %d %P %p e:%d j:%d",
549 n, 550 n,
550 ngx_processes[n].pid, 551 ngx_processes[n].pid,
551 ngx_processes[n].handle, 552 ngx_processes[n].handle,
552 ngx_processes[n].exiting, 553 ngx_processes[n].exiting,
553 ngx_processes[n].just_respawn); 554 ngx_processes[n].just_spawn);
554 555
555 if (ngx_processes[n].handle) { 556 if (ngx_processes[n].handle) {
556 return 1; 557 return 1;
557 } 558 }
558 } 559 }
665 if (ngx_create_thread(&wtid, ngx_worker_thread, NULL, log) != 0) { 666 if (ngx_create_thread(&wtid, ngx_worker_thread, NULL, log) != 0) {
666 goto failed; 667 goto failed;
667 } 668 }
668 669
669 if (ngx_create_thread(&cmtid, ngx_cache_manager_thread, NULL, log) != 0) { 670 if (ngx_create_thread(&cmtid, ngx_cache_manager_thread, NULL, log) != 0) {
671 goto failed;
672 }
673
674 if (ngx_create_thread(&cmtid, ngx_cache_loader_thread, NULL, log) != 0) {
670 goto failed; 675 goto failed;
671 } 676 }
672 677
673 for ( ;; ) { 678 for ( ;; ) {
674 ev = WaitForMultipleObjects(3, events, 0, INFINITE); 679 ev = WaitForMultipleObjects(3, events, 0, INFINITE);
923 if (ngx_terminate || ngx_quit) { 928 if (ngx_terminate || ngx_quit) {
924 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); 929 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
925 return 0; 930 return 0;
926 } 931 }
927 932
928 break; 933 break;
929 } 934 }
930 935
931 for ( ;; ) { 936 for ( ;; ) {
932 937
933 if (ngx_terminate || ngx_quit) { 938 if (ngx_terminate || ngx_quit) {
980 ngx_time_update(0, 0); 985 ngx_time_update(0, 0);
981 986
982 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, 987 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
983 "cache manager WaitForSingleObject: %ul", ev); 988 "cache manager WaitForSingleObject: %ul", ev);
984 } 989 }
990 }
991
992
993 static ngx_thread_value_t __stdcall
994 ngx_cache_loader_thread(void *data)
995 {
996 ngx_uint_t i;
997 ngx_path_t **path;
998 ngx_cycle_t *cycle;
999
1000 ngx_msleep(60000);
1001
1002 cycle = (ngx_cycle_t *) ngx_cycle;
1003
1004 path = cycle->pathes.elts;
1005 for (i = 0; i < cycle->pathes.nelts; i++) {
1006
1007 if (ngx_terminate || ngx_quit) {
1008 break;
1009 }
1010
1011 if (path[i]->loader) {
1012 path[i]->loader(path[i]->data);
1013 ngx_time_update(0, 0);
1014 }
1015 }
1016
1017 return 0;
985 } 1018 }
986 1019
987 1020
988 void 1021 void
989 ngx_single_process_cycle(ngx_cycle_t *cycle) 1022 ngx_single_process_cycle(ngx_cycle_t *cycle)