Mercurial > hg > nginx
comparison src/core/nginx.c @ 266:5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 23 Feb 2004 20:57:12 +0000 |
parents | 8e39cab6abd5 |
children | 83205e0b5522 |
comparison
equal
deleted
inserted
replaced
265:6468241715e6 | 266:5238e93961a1 |
---|---|
25 | 25 |
26 | 26 |
27 static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx); | 27 static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx); |
28 static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx); | 28 static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx); |
29 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data); | 29 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data); |
30 #if (NGX_THREADS) | |
31 static int ngx_worker_thread_cycle(void *data); | |
32 #endif | |
30 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp); | 33 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp); |
31 static ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv); | 34 static ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv); |
32 static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle); | 35 static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle); |
33 static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle); | 36 static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle); |
34 static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 37 static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
85 ngx_core_module_init, /* init module */ | 88 ngx_core_module_init, /* init module */ |
86 NULL /* init child */ | 89 NULL /* init child */ |
87 }; | 90 }; |
88 | 91 |
89 | 92 |
90 ngx_int_t ngx_max_module; | 93 ngx_int_t ngx_max_module; |
91 ngx_uint_t ngx_connection_counter; | 94 ngx_atomic_t ngx_connection_counter; |
92 | 95 |
93 ngx_int_t ngx_process; | 96 ngx_int_t ngx_process; |
94 ngx_pid_t ngx_pid; | 97 ngx_pid_t ngx_pid; |
95 ngx_pid_t ngx_new_binary; | 98 ngx_pid_t ngx_new_binary; |
96 | 99 |
97 ngx_int_t ngx_inherited; | 100 ngx_int_t ngx_inherited; |
98 ngx_int_t ngx_reap; | 101 ngx_int_t ngx_reap; |
99 ngx_int_t ngx_timer; | 102 ngx_int_t ngx_timer; |
100 ngx_int_t ngx_terminate; | 103 ngx_int_t ngx_terminate; |
101 ngx_int_t ngx_quit; | 104 ngx_int_t ngx_quit; |
102 ngx_int_t ngx_noaccept; | 105 ngx_int_t ngx_noaccept; |
103 ngx_int_t ngx_reconfigure; | 106 ngx_int_t ngx_reconfigure; |
104 ngx_int_t ngx_reopen; | 107 ngx_int_t ngx_reopen; |
105 ngx_int_t ngx_change_binary; | 108 ngx_int_t ngx_change_binary; |
106 | 109 |
107 | 110 |
108 int main(int argc, char *const *argv, char **envp) | 111 int main(int argc, char *const *argv, char **envp) |
109 { | 112 { |
110 ngx_fd_t fd; | 113 ngx_fd_t fd; |
575 { | 578 { |
576 sigset_t set; | 579 sigset_t set; |
577 ngx_int_t i; | 580 ngx_int_t i; |
578 ngx_listening_t *ls; | 581 ngx_listening_t *ls; |
579 ngx_core_conf_t *ccf; | 582 ngx_core_conf_t *ccf; |
583 #if (NGX_THREADS) | |
584 ngx_tid_t tid; | |
585 #endif | |
580 | 586 |
581 ngx_process = NGX_PROCESS_WORKER; | 587 ngx_process = NGX_PROCESS_WORKER; |
582 ngx_last_process = 0; | 588 ngx_last_process = 0; |
583 | 589 |
584 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 590 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
639 } | 645 } |
640 } | 646 } |
641 | 647 |
642 ngx_setproctitle("worker process"); | 648 ngx_setproctitle("worker process"); |
643 | 649 |
644 /* TODO: threads: start ngx_worker_thread_cycle() */ | 650 #if (NGX_THREADS) |
651 | |
652 ngx_init_threads(5, 128 * 1024 * 1024, cycle->log); | |
653 | |
654 for (i = 0; i < 1; i++) { | |
655 ngx_create_thread(&tid, ngx_worker_thread_cycle, cycle, cycle->log); | |
656 } | |
657 | |
658 #endif | |
645 | 659 |
646 for ( ;; ) { | 660 for ( ;; ) { |
647 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle"); | 661 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle"); |
648 | 662 |
649 ngx_process_events(cycle->log); | 663 ngx_process_events(cycle->log); |
684 ngx_reopen_files(cycle, -1); | 698 ngx_reopen_files(cycle, -1); |
685 ngx_reopen = 0; | 699 ngx_reopen = 0; |
686 } | 700 } |
687 } | 701 } |
688 } | 702 } |
703 | |
704 | |
705 #if (NGX_THREADS) | |
706 | |
707 int ngx_worker_thread_cycle(void *data) | |
708 { | |
709 ngx_cycle_t *cycle = data; | |
710 | |
711 struct timeval tv; | |
712 | |
713 /* STUB */ | |
714 | |
715 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, ngx_errno, | |
716 "thread %d started", ngx_thread_self()); | |
717 | |
718 ngx_setproctitle("worker thread"); | |
719 | |
720 sleep(5); | |
721 | |
722 ngx_gettimeofday(&tv); | |
723 ngx_time_update(tv.tv_sec); | |
724 | |
725 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, ngx_errno, | |
726 "thread %d done", ngx_thread_self()); | |
727 | |
728 return 1; | |
729 } | |
730 | |
731 #endif | |
689 | 732 |
690 | 733 |
691 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp) | 734 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp) |
692 { | 735 { |
693 char *p, *v; | 736 char *p, *v; |