Mercurial > hg > nginx
comparison src/core/nginx.c @ 209:e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 09 Dec 2003 15:08:11 +0000 |
parents | 6e0fef527732 |
children | 00cafae0bdf1 |
comparison
equal
deleted
inserted
replaced
208:0b67be7d4489 | 209:e1c815be05ae |
---|---|
22 | 22 |
23 static ngx_str_t core_name = ngx_string("core"); | 23 static ngx_str_t core_name = ngx_string("core"); |
24 | 24 |
25 static ngx_command_t ngx_core_commands[] = { | 25 static ngx_command_t ngx_core_commands[] = { |
26 | 26 |
27 {ngx_string("daemon"), | 27 { ngx_string("daemon"), |
28 NGX_MAIN_CONF|NGX_CONF_TAKE1, | 28 NGX_MAIN_CONF|NGX_CONF_TAKE1, |
29 ngx_conf_set_core_flag_slot, | 29 ngx_conf_set_core_flag_slot, |
30 0, | 30 0, |
31 offsetof(ngx_core_conf_t, daemon), | 31 offsetof(ngx_core_conf_t, daemon), |
32 NULL}, | 32 NULL }, |
33 | 33 |
34 ngx_null_command | 34 ngx_null_command |
35 }; | 35 }; |
36 | 36 |
37 | 37 |
38 ngx_module_t ngx_core_module = { | 38 ngx_module_t ngx_core_module = { |
39 NGX_MODULE, | 39 NGX_MODULE, |
236 | 236 |
237 | 237 |
238 static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log) | 238 static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log) |
239 { | 239 { |
240 int i, n, failed; | 240 int i, n, failed; |
241 ngx_fd_t fd; | |
241 ngx_str_t conf_file; | 242 ngx_str_t conf_file; |
242 ngx_conf_t conf; | 243 ngx_conf_t conf; |
243 ngx_pool_t *pool; | 244 ngx_pool_t *pool; |
244 ngx_cycle_t *cycle, **old; | 245 ngx_cycle_t *cycle, **old; |
245 ngx_core_conf_t *ccf; | 246 ngx_core_conf_t *ccf; |
388 for (n = 0; n < cycle->listening.nelts; n++) { | 389 for (n = 0; n < cycle->listening.nelts; n++) { |
389 for (i = 0; i < old_cycle->listening.nelts; i++) { | 390 for (i = 0; i < old_cycle->listening.nelts; i++) { |
390 if (ngx_memcmp(nls[n].sockaddr, | 391 if (ngx_memcmp(nls[n].sockaddr, |
391 ls[i].sockaddr, ls[i].socklen) == 0) | 392 ls[i].sockaddr, ls[i].socklen) == 0) |
392 { | 393 { |
394 fd = ls[i].fd; | |
395 #if (WIN32) | |
396 /* | |
397 * Winsock assignes a socket number divisible by 4 so | |
398 * to find a connection we divide a socket number by 4. | |
399 */ | |
400 | |
401 fd /= 4; | |
402 #endif | |
403 if (fd >= cycle->connection_n) { | |
404 ngx_log_error(NGX_LOG_EMERG, log, 0, | |
405 "%d connections is not enough to hold " | |
406 "an open listening socket on %s, " | |
407 "required at least %d connections", | |
408 cycle->connection_n, | |
409 ls[i].addr_text.data, fd); | |
410 failed = 1; | |
411 break; | |
412 } | |
413 | |
393 nls[n].fd = ls[i].fd; | 414 nls[n].fd = ls[i].fd; |
394 nls[i].remain = 1; | 415 nls[i].remain = 1; |
395 ls[i].remain = 1; | 416 ls[i].remain = 1; |
396 break; | 417 break; |
397 } | 418 } |
407 for (i = 0; i < cycle->listening.nelts; i++) { | 428 for (i = 0; i < cycle->listening.nelts; i++) { |
408 ls[i].new = 1; | 429 ls[i].new = 1; |
409 } | 430 } |
410 } | 431 } |
411 | 432 |
412 if (ngx_open_listening_sockets(cycle, log) == NGX_ERROR) { | 433 if (!failed) { |
413 failed = 1; | 434 if (ngx_open_listening_sockets(cycle, log) == NGX_ERROR) { |
435 failed = 1; | |
436 } | |
414 } | 437 } |
415 } | 438 } |
416 | 439 |
417 if (failed) { | 440 if (failed) { |
418 | 441 |
581 s = ngx_socket(ls[i].family, ls[i].type, ls[i].protocol, | 604 s = ngx_socket(ls[i].family, ls[i].type, ls[i].protocol, |
582 ls[i].flags); | 605 ls[i].flags); |
583 | 606 |
584 if (s == -1) { | 607 if (s == -1) { |
585 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, | 608 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
586 ngx_socket_n " %s falied", ls[i].addr_text.data); | 609 ngx_socket_n " %s failed", ls[i].addr_text.data); |
587 return NGX_ERROR; | 610 return NGX_ERROR; |
588 } | 611 } |
589 | 612 |
590 #if (WIN32) | 613 #if (WIN32) |
591 /* | 614 /* |