Mercurial > hg > nginx
comparison src/event/ngx_event.c @ 112:da763a85be66
nginx-0.0.1-2003-07-04-10:03:52 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 04 Jul 2003 06:03:52 +0000 |
parents | a9bc21d63fe4 |
children | d7f606e25b99 |
comparison
equal
deleted
inserted
replaced
111:1c002f2b77ed | 112:da763a85be66 |
---|---|
106 ngx_module_t ngx_event_core_module = { | 106 ngx_module_t ngx_event_core_module = { |
107 NGX_MODULE, | 107 NGX_MODULE, |
108 &ngx_event_core_module_ctx, /* module context */ | 108 &ngx_event_core_module_ctx, /* module context */ |
109 ngx_event_core_commands, /* module directives */ | 109 ngx_event_core_commands, /* module directives */ |
110 NGX_EVENT_MODULE, /* module type */ | 110 NGX_EVENT_MODULE, /* module type */ |
111 NULL /* init module */ | 111 ngx_event_init_module, /* init module */ |
112 ngx_event_commit, /* commit module */ | |
113 ngx_event_rollback, /* rollback module */ | |
114 ngx_event_init_child /* init child */ | |
112 }; | 115 }; |
113 | 116 |
114 | 117 |
115 | 118 |
116 int ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log) | 119 static int ngx_event_init_module(ngx_cycle_t *cycle, ngx_log_t *log) |
120 { | |
121 if (cycle->one_process) { | |
122 return ngx_event_init(cycle, log); | |
123 } | |
124 | |
125 return NGX_OK; | |
126 } | |
127 | |
128 | |
129 static int ngx_event_init_child(ngx_cycle_t *cycle) | |
130 { | |
131 if (!cycle->one_process) { | |
132 if (ngx_event_init(cycle, cycle->log) == NGX_ERROR) { | |
133 return NGX_ERROR; | |
134 } | |
135 ngx_event_commit(cycle, cycle->log); | |
136 } | |
137 | |
138 return NGX_OK; | |
139 } | |
140 | |
141 | |
142 static int ngx_event_init(ngx_cycle_t *cycle, ngx_log_t *log) | |
117 { | 143 { |
118 int m, i, fd; | 144 int m, i, fd; |
119 ngx_event_t *rev, *wev; | 145 ngx_event_t *rev, *wev; |
120 ngx_listening_t *s; | 146 ngx_listening_t *s; |
121 ngx_connection_t *c; | 147 ngx_connection_t *c; |
123 ngx_event_module_t *module; | 149 ngx_event_module_t *module; |
124 #if (WIN32) | 150 #if (WIN32) |
125 ngx_iocp_conf_t *iocpcf; | 151 ngx_iocp_conf_t *iocpcf; |
126 #endif | 152 #endif |
127 | 153 |
128 ecf = ngx_event_get_conf(ngx_event_core_module); | 154 ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module); |
129 | 155 |
130 ngx_log_debug(log, "CONN: %d" _ ecf->connections); | 156 ngx_log_debug(log, "CONN: %d" _ ecf->connections); |
131 ngx_log_debug(log, "TYPE: %d" _ ecf->use); | 157 ngx_log_debug(log, "TYPE: %d" _ ecf->use); |
132 | 158 |
133 for (m = 0; ngx_modules[m]; m++) { | 159 for (m = 0; ngx_modules[m]; m++) { |
140 if (module->actions.init(log) == NGX_ERROR) { | 166 if (module->actions.init(log) == NGX_ERROR) { |
141 return NGX_ERROR; | 167 return NGX_ERROR; |
142 } | 168 } |
143 break; | 169 break; |
144 } | 170 } |
171 } | |
172 | |
173 if (ecf->connections) { | |
145 } | 174 } |
146 | 175 |
147 ngx_test_null(ngx_connections, | 176 ngx_test_null(ngx_connections, |
148 ngx_alloc(sizeof(ngx_connection_t) * ecf->connections, log), | 177 ngx_alloc(sizeof(ngx_connection_t) * ecf->connections, log), |
149 NGX_ERROR); | 178 NGX_ERROR); |
233 | 262 |
234 return NGX_OK; | 263 return NGX_OK; |
235 } | 264 } |
236 | 265 |
237 | 266 |
267 static void ngx_event_commit(ngx_cycle_t *cycle, ngx_log_t *log) | |
268 { | |
269 } | |
270 | |
271 | |
272 static void ngx_event_rollback(ngx_cycle_t *cycle, ngx_log_t *log) | |
273 { | |
274 } | |
275 | |
276 | |
238 void ngx_worker(ngx_cycle_t *cycle) | 277 void ngx_worker(ngx_cycle_t *cycle) |
239 { | 278 { |
240 for ( ;; ) { | 279 for ( ;; ) { |
241 ngx_log_debug(cycle->log, "ngx_worker cycle"); | 280 ngx_log_debug(cycle->log, "ngx_worker cycle"); |
242 | 281 |