comparison src/event/ngx_event.c @ 93:738fe44c70d5

nginx-0.0.1-2003-05-21-17:28:21 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 21 May 2003 13:28:21 +0000
parents 19cc647ecd91
children a23d010f356d
comparison
equal deleted inserted replaced
92:19cc647ecd91 93:738fe44c70d5
29 #include <ngx_iocp_module.h> 29 #include <ngx_iocp_module.h>
30 #endif 30 #endif
31 31
32 32
33 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy); 33 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy);
34 static char *ngx_event_set_type(ngx_conf_t *cf, ngx_command_t *cmd, char *conf); 34 static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, char *conf);
35 static void *ngx_event_create_conf(ngx_pool_t *pool); 35 static void *ngx_event_create_conf(ngx_pool_t *pool);
36 static char *ngx_event_init_conf(ngx_pool_t *pool, void *conf); 36 static char *ngx_event_init_conf(ngx_pool_t *pool, void *conf);
37 37
38 38
39 int ngx_event_flags; 39 int ngx_event_flags;
82 ngx_conf_set_num_slot, 82 ngx_conf_set_num_slot,
83 0, 83 0,
84 offsetof(ngx_event_conf_t, connections), 84 offsetof(ngx_event_conf_t, connections),
85 NULL}, 85 NULL},
86 86
87 {ngx_string("type"), 87 {ngx_string("use"),
88 NGX_EVENT_CONF|NGX_CONF_TAKE1, 88 NGX_EVENT_CONF|NGX_CONF_TAKE1,
89 ngx_event_set_type, 89 ngx_event_use,
90 0, 90 0,
91 0, 91 0,
92 NULL}, 92 NULL},
93 93
94 {ngx_string("timer_queues"), 94 {ngx_string("timer_queues"),
133 ngx_event_module_t *module; 133 ngx_event_module_t *module;
134 134
135 ecf = ngx_event_get_conf(ngx_event_module_ctx); 135 ecf = ngx_event_get_conf(ngx_event_module_ctx);
136 136
137 ngx_log_debug(log, "CONN: %d" _ ecf->connections); 137 ngx_log_debug(log, "CONN: %d" _ ecf->connections);
138 ngx_log_debug(log, "TYPE: %d" _ ecf->type); 138 ngx_log_debug(log, "TYPE: %d" _ ecf->use);
139 139
140 for (m = 0; ngx_modules[m]; m++) { 140 for (m = 0; ngx_modules[m]; m++) {
141 if (ngx_modules[m]->type != NGX_EVENT_MODULE_TYPE) { 141 if (ngx_modules[m]->type != NGX_EVENT_MODULE_TYPE) {
142 continue; 142 continue;
143 } 143 }
144 144
145 module = ngx_modules[m]->ctx; 145 module = ngx_modules[m]->ctx;
146 if (module->index == ecf->type) { 146 if (module->index == ecf->use) {
147 if (module->actions.init(log) == NGX_ERROR) { 147 if (module->actions.init(log) == NGX_ERROR) {
148 return NGX_ERROR; 148 return NGX_ERROR;
149 } 149 }
150 break; 150 break;
151 } 151 }
315 315
316 return NGX_CONF_OK; 316 return NGX_CONF_OK;
317 } 317 }
318 318
319 319
320 static char *ngx_event_set_type(ngx_conf_t *cf, ngx_command_t *cmd, char *conf) 320 static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
321 { 321 {
322 ngx_event_conf_t *ecf = (ngx_event_conf_t *) conf; 322 ngx_event_conf_t *ecf = (ngx_event_conf_t *) conf;
323 323
324 int m; 324 int m;
325 ngx_str_t *args; 325 ngx_str_t *args;
326 ngx_event_module_t *module; 326 ngx_event_module_t *module;
327 327
328 if (ecf->type != NGX_CONF_UNSET) { 328 if (ecf->use != NGX_CONF_UNSET) {
329 return "duplicate event type" ; 329 return "is duplicate" ;
330 } 330 }
331 331
332 args = cf->args->elts; 332 args = cf->args->elts;
333 333
334 for (m = 0; ngx_modules[m]; m++) { 334 for (m = 0; ngx_modules[m]; m++) {
337 } 337 }
338 338
339 module = ngx_modules[m]->ctx; 339 module = ngx_modules[m]->ctx;
340 if (module->name->len == args[1].len) { 340 if (module->name->len == args[1].len) {
341 if (ngx_strcmp(module->name->data, args[1].data) == 0) { 341 if (ngx_strcmp(module->name->data, args[1].data) == 0) {
342 ecf->type = module->index; 342 ecf->use = module->index;
343 return NGX_CONF_OK; 343 return NGX_CONF_OK;
344 } 344 }
345 } 345 }
346 } 346 }
347 347
356 ngx_test_null(ecf, ngx_palloc(pool, sizeof(ngx_event_conf_t)), 356 ngx_test_null(ecf, ngx_palloc(pool, sizeof(ngx_event_conf_t)),
357 NGX_CONF_ERROR); 357 NGX_CONF_ERROR);
358 358
359 ecf->connections = NGX_CONF_UNSET; 359 ecf->connections = NGX_CONF_UNSET;
360 ecf->timer_queues = NGX_CONF_UNSET; 360 ecf->timer_queues = NGX_CONF_UNSET;
361 ecf->type = NGX_CONF_UNSET; 361 ecf->use = NGX_CONF_UNSET;
362 362
363 return ecf; 363 return ecf;
364 } 364 }
365 365
366 366
378 } else if (ecf->connections > ngx_max_connections) { 378 } else if (ecf->connections > ngx_max_connections) {
379 } 379 }
380 #endif 380 #endif
381 381
382 ngx_conf_init_value(ecf->connections, DEF_CONNECTIONS); 382 ngx_conf_init_value(ecf->connections, DEF_CONNECTIONS);
383 ngx_conf_init_value(ecf->type, ngx_kqueue_module_ctx.index); 383 ngx_conf_init_value(ecf->use, ngx_kqueue_module_ctx.index);
384 384
385 #elif (HAVE_DEVPOLL) 385 #elif (HAVE_DEVPOLL)
386 386
387 ngx_conf_init_value(ecf->connections, DEF_CONNECTIONS); 387 ngx_conf_init_value(ecf->connections, DEF_CONNECTIONS);
388 ngx_conf_init_value(ecf->type, ngx_devpoll_module_ctx.index); 388 ngx_conf_init_value(ecf->use, ngx_devpoll_module_ctx.index);
389 389
390 #else /* HAVE_SELECT */ 390 #else /* HAVE_SELECT */
391 391
392 ngx_conf_init_value(ecf->connections, 392 ngx_conf_init_value(ecf->connections,
393 FD_SETSIZE < DEF_CONNECTIONS ? FD_SETSIZE : DEF_CONNECTIONS); 393 FD_SETSIZE < DEF_CONNECTIONS ? FD_SETSIZE : DEF_CONNECTIONS);
394 394
395 ngx_conf_init_value(ecf->type, ngx_select_module_ctx.index); 395 ngx_conf_init_value(ecf->use, ngx_select_module_ctx.index);
396 396
397 #endif 397 #endif
398 398
399 ngx_conf_init_value(ecf->timer_queues, 10); 399 ngx_conf_init_value(ecf->timer_queues, 10);
400 400