Mercurial > hg > nginx
comparison src/event/ngx_event.c @ 90:37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 16 May 2003 15:27:48 +0000 |
parents | 5f6d848dcbef |
children | 637625a2acdb |
comparison
equal
deleted
inserted
replaced
89:29bf798b583f | 90:37530da31268 |
---|---|
7 #include <ngx_alloc.h> | 7 #include <ngx_alloc.h> |
8 #include <ngx_array.h> | 8 #include <ngx_array.h> |
9 #include <ngx_listen.h> | 9 #include <ngx_listen.h> |
10 #include <ngx_connection.h> | 10 #include <ngx_connection.h> |
11 #include <ngx_event.h> | 11 #include <ngx_event.h> |
12 #include <ngx_conf_file.h> | |
12 | 13 |
13 #include <ngx_select_module.h> | 14 #include <ngx_select_module.h> |
14 | 15 |
15 #if (HAVE_POLL) | 16 #if (HAVE_POLL) |
16 #include <ngx_poll_module.h> | 17 #include <ngx_poll_module.h> |
30 | 31 |
31 #if (HAVE_IOCP) | 32 #if (HAVE_IOCP) |
32 #include <ngx_event_acceptex.h> | 33 #include <ngx_event_acceptex.h> |
33 #include <ngx_iocp_module.h> | 34 #include <ngx_iocp_module.h> |
34 #endif | 35 #endif |
36 | |
37 | |
38 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy); | |
35 | 39 |
36 | 40 |
37 ngx_connection_t *ngx_connections; | 41 ngx_connection_t *ngx_connections; |
38 ngx_event_t *ngx_read_events, *ngx_write_events; | 42 ngx_event_t *ngx_read_events, *ngx_write_events; |
39 | 43 |
64 ngx_iocp_init | 68 ngx_iocp_init |
65 #endif | 69 #endif |
66 }; | 70 }; |
67 | 71 |
68 #endif /* USE_KQUEUE */ | 72 #endif /* USE_KQUEUE */ |
73 | |
74 | |
75 static int ngx_event_connections; | |
76 | |
77 | |
78 static ngx_str_t events_name = ngx_string("events"); | |
79 | |
80 static ngx_command_t ngx_events_commands[] = { | |
81 | |
82 {ngx_string("events"), | |
83 NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, | |
84 ngx_events_block, | |
85 0, | |
86 0, | |
87 NULL}, | |
88 | |
89 {ngx_string(""), 0, NULL, 0, 0, NULL} | |
90 }; | |
91 | |
92 | |
93 ngx_module_t ngx_events_module = { | |
94 &events_name, /* module context */ | |
95 0, /* module index */ | |
96 ngx_events_commands, /* module directives */ | |
97 NGX_CORE_MODULE_TYPE, /* module type */ | |
98 NULL /* init module */ | |
99 }; | |
100 | |
101 | |
102 | |
103 static ngx_command_t ngx_event_commands[] = { | |
104 | |
105 {ngx_string("connections"), | |
106 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
107 ngx_conf_set_num_slot, | |
108 0, | |
109 addressof(ngx_event_connections), | |
110 NULL}, | |
111 | |
112 #if 0 | |
113 {ngx_string("type"), | |
114 NGX_EVENT_CONF|NGX_CONF_TAKE1, | |
115 ngx_event_set_type, | |
116 0, | |
117 0, | |
118 NULL}, | |
119 #endif | |
120 | |
121 {ngx_string(""), 0, NULL, 0, 0, NULL} | |
122 }; | |
123 | |
124 | |
125 ngx_module_t ngx_event_module = { | |
126 NULL, /* module context */ | |
127 0, /* module index */ | |
128 ngx_events_commands, /* module directives */ | |
129 NGX_EVENT_MODULE_TYPE, /* module type */ | |
130 NULL /* init module */ | |
131 }; | |
132 | |
69 | 133 |
70 | 134 |
71 void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log) | 135 void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log) |
72 { | 136 { |
73 int i, fd; | 137 int i, fd; |
171 | 235 |
172 #endif | 236 #endif |
173 } | 237 } |
174 } | 238 } |
175 | 239 |
240 | |
176 void ngx_worker(ngx_log_t *log) | 241 void ngx_worker(ngx_log_t *log) |
177 { | 242 { |
178 for ( ;; ) { | 243 for ( ;; ) { |
179 ngx_log_debug(log, "ngx_worker cycle"); | 244 ngx_log_debug(log, "ngx_worker cycle"); |
180 | 245 |
181 ngx_process_events(log); | 246 ngx_process_events(log); |
182 } | 247 } |
183 } | 248 } |
249 | |
250 | |
251 static char *ngx_events_init(ngx_pool_t *pool) | |
252 { | |
253 ngx_event_connections = -1; | |
254 ngx_event_type = -1; | |
255 | |
256 return NGX_CONF_OK; | |
257 } | |
258 | |
259 | |
260 static char *ngx_events_postconf(ngx_pool_t *pool) | |
261 { | |
262 if (ngx_event_connections == -1) { | |
263 ngx_event_connections = 512; | |
264 } | |
265 | |
266 return NGX_CONF_OK; | |
267 } | |
268 | |
269 | |
270 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *conf) | |
271 { | |
272 char *rv; | |
273 ngx_conf_t pcf; | |
274 | |
275 #if 0 | |
276 *(ngx_events_conf_ctx_t **) conf = ctx; | |
277 #endif | |
278 | |
279 pcf = *cf; | |
280 cf->module_type = NGX_EVENT_MODULE_TYPE; | |
281 cf->cmd_type = NGX_EVENT_CONF; | |
282 rv = ngx_conf_parse(cf, NULL); | |
283 *cf = pcf; | |
284 | |
285 if (rv != NGX_CONF_OK) | |
286 return rv; | |
287 | |
288 return NGX_CONF_OK; | |
289 } |