comparison src/event/ngx_event.c @ 307:ce375c313e96

nginx-0.0.3-2004-04-08-19:58:25 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 08 Apr 2004 15:58:25 +0000
parents 6b91bfbc4123
children 2e899477243a
comparison
equal deleted inserted replaced
306:6b91bfbc4123 307:ce375c313e96
33 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 33 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
34 34
35 static char *ngx_event_connections(ngx_conf_t *cf, ngx_command_t *cmd, 35 static char *ngx_event_connections(ngx_conf_t *cf, ngx_command_t *cmd,
36 void *conf); 36 void *conf);
37 static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 37 static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
38 static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd,
39 void *conf);
38 40
39 static void *ngx_event_create_conf(ngx_cycle_t *cycle); 41 static void *ngx_event_create_conf(ngx_cycle_t *cycle);
40 static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf); 42 static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf);
41 43
42 44
113 { ngx_string("accept_mutex_delay"), 115 { ngx_string("accept_mutex_delay"),
114 NGX_EVENT_CONF|NGX_CONF_TAKE1, 116 NGX_EVENT_CONF|NGX_CONF_TAKE1,
115 ngx_conf_set_msec_slot, 117 ngx_conf_set_msec_slot,
116 0, 118 0,
117 offsetof(ngx_event_conf_t, accept_mutex_delay), 119 offsetof(ngx_event_conf_t, accept_mutex_delay),
120 NULL },
121
122 { ngx_string("debug_connection"),
123 NGX_EVENT_CONF|NGX_CONF_TAKE1,
124 ngx_event_debug_connection,
125 0,
126 0,
118 NULL }, 127 NULL },
119 128
120 ngx_null_command 129 ngx_null_command
121 }; 130 };
122 131
515 524
516 return NGX_CONF_ERROR; 525 return NGX_CONF_ERROR;
517 } 526 }
518 527
519 528
529 static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd,
530 void *conf)
531 {
532 #if (NGX_DEBUG)
533 ngx_event_conf_t *ecf = conf;
534
535 in_addr_t *addr;
536 ngx_str_t *value;
537 struct hostent *h;
538
539 value = cf->args->elts;
540
541 /* AF_INET only */
542
543 if (!(addr = ngx_push_array(&ecf->debug_connection))) {
544 return NGX_CONF_ERROR;
545 }
546
547 *addr = inet_addr((char *) value[1].data);
548
549 if (*addr != INADDR_NONE) {
550 return NGX_OK;
551 }
552
553 h = gethostbyname((char *) value[1].data);
554
555 if (h == NULL || h->h_addr_list[0] == NULL) {
556 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
557 "host %s not found", value[1].data);
558 return NGX_CONF_ERROR;
559 }
560
561 *addr = *(in_addr_t *)(h->h_addr_list[0]);
562
563 #else
564
565 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
566 "\"debug_connection\" is ignored, you need to rebuild "
567 "nginx using --with-debug option to enable it");
568
569 #endif
570
571 return NGX_OK;
572 }
573
574
520 static void *ngx_event_create_conf(ngx_cycle_t *cycle) 575 static void *ngx_event_create_conf(ngx_cycle_t *cycle)
521 { 576 {
522 ngx_event_conf_t *ecf; 577 ngx_event_conf_t *ecf;
523 578
524 ngx_test_null(ecf, ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t)), 579 ngx_test_null(ecf, ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t)),
529 ecf->multi_accept = NGX_CONF_UNSET; 584 ecf->multi_accept = NGX_CONF_UNSET;
530 ecf->accept_mutex = NGX_CONF_UNSET; 585 ecf->accept_mutex = NGX_CONF_UNSET;
531 ecf->accept_mutex_delay = NGX_CONF_UNSET_MSEC; 586 ecf->accept_mutex_delay = NGX_CONF_UNSET_MSEC;
532 ecf->name = (void *) NGX_CONF_UNSET; 587 ecf->name = (void *) NGX_CONF_UNSET;
533 588
589 #if (NGX_DEBUG)
590 ngx_init_array(ecf->debug_connection, cycle->pool, 5, sizeof(in_addr_t),
591 NGX_CONF_ERROR);
592 #endif
593
534 return ecf; 594 return ecf;
535 } 595 }
536 596
537 597
538 static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) 598 static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)