Mercurial > hg > nginx-vendor-0-6
comparison src/event/ngx_event.c @ 110:dad2fe8ecf08 NGINX_0_3_2
nginx 0.3.2
*) Feature: the Sun Studio 10 C compiler support.
*) Feature: the "proxy_upstream_max_fails",
"proxy_upstream_fail_timeout", "fastcgi_upstream_max_fails", and
"fastcgi_upstream_fail_timeout" directives.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 12 Oct 2005 00:00:00 +0400 |
parents | 45945fa8b8ba |
children | 408f195b3482 |
comparison
equal
deleted
inserted
replaced
109:97da525033a1 | 110:dad2fe8ecf08 |
---|---|
38 | 38 |
39 ngx_uint_t ngx_event_flags; | 39 ngx_uint_t ngx_event_flags; |
40 ngx_event_actions_t ngx_event_actions; | 40 ngx_event_actions_t ngx_event_actions; |
41 | 41 |
42 | 42 |
43 ngx_atomic_t connection_counter; | 43 ngx_atomic_t connection_counter = 1; |
44 ngx_atomic_t *ngx_connection_counter = &connection_counter; | 44 ngx_atomic_t *ngx_connection_counter = &connection_counter; |
45 | 45 |
46 | 46 |
47 ngx_atomic_t *ngx_accept_mutex_ptr; | 47 ngx_atomic_t *ngx_accept_mutex_ptr; |
48 ngx_atomic_t *ngx_accept_mutex; | 48 ngx_atomic_t *ngx_accept_mutex; |
49 ngx_uint_t ngx_accept_mutex_held; | 49 ngx_uint_t ngx_accept_mutex_held; |
50 ngx_msec_t ngx_accept_mutex_delay; | 50 ngx_msec_t ngx_accept_mutex_delay; |
51 ngx_int_t ngx_accept_disabled; | 51 ngx_int_t ngx_accept_disabled; |
52 ngx_file_t ngx_accept_mutex_lock_file; | |
52 | 53 |
53 | 54 |
54 #if (NGX_STAT_STUB) | 55 #if (NGX_STAT_STUB) |
55 | 56 |
56 ngx_atomic_t ngx_stat_accepted0; | 57 ngx_atomic_t ngx_stat_accepted0; |
347 return NGX_ERROR; | 348 return NGX_ERROR; |
348 } | 349 } |
349 | 350 |
350 ecf = (*cf)[ngx_event_core_module.ctx_index]; | 351 ecf = (*cf)[ngx_event_core_module.ctx_index]; |
351 | 352 |
352 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, | 353 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, |
353 "using the \"%s\" event method", ecf->name); | 354 "using the \"%s\" event method", ecf->name); |
354 | 355 |
355 #if !(NGX_WIN32) | 356 #if !(NGX_WIN32) |
356 | 357 |
357 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 358 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
499 } | 500 } |
500 } | 501 } |
501 | 502 |
502 #endif | 503 #endif |
503 | 504 |
504 cycle->connections0 = ngx_alloc(sizeof(ngx_connection_t) * ecf->connections, | 505 cycle->connections = ngx_alloc(sizeof(ngx_connection_t) * ecf->connections, |
505 cycle->log); | 506 cycle->log); |
506 if (cycle->connections0 == NULL) { | 507 if (cycle->connections == NULL) { |
507 return NGX_ERROR; | 508 return NGX_ERROR; |
508 } | 509 } |
509 | 510 |
510 c = cycle->connections0; | 511 c = cycle->connections; |
511 | 512 |
512 cycle->read_events0 = ngx_alloc(sizeof(ngx_event_t) * ecf->connections, | 513 cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * ecf->connections, |
513 cycle->log); | 514 cycle->log); |
514 if (cycle->read_events0 == NULL) { | 515 if (cycle->read_events == NULL) { |
515 return NGX_ERROR; | 516 return NGX_ERROR; |
516 } | 517 } |
517 | 518 |
518 rev = cycle->read_events0; | 519 rev = cycle->read_events; |
519 for (i = 0; i < cycle->connection_n; i++) { | 520 for (i = 0; i < cycle->connection_n; i++) { |
520 rev[i].closed = 1; | 521 rev[i].closed = 1; |
521 rev[i].instance = 1; | 522 rev[i].instance = 1; |
522 #if (NGX_THREADS) | 523 #if (NGX_THREADS) |
523 rev[i].lock = &c[i].lock; | 524 rev[i].lock = &c[i].lock; |
524 rev[i].own_lock = &c[i].lock; | 525 rev[i].own_lock = &c[i].lock; |
525 #endif | 526 #endif |
526 } | 527 } |
527 | 528 |
528 cycle->write_events0 = ngx_alloc(sizeof(ngx_event_t) * ecf->connections, | 529 cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * ecf->connections, |
529 cycle->log); | 530 cycle->log); |
530 if (cycle->write_events0 == NULL) { | 531 if (cycle->write_events == NULL) { |
531 return NGX_ERROR; | 532 return NGX_ERROR; |
532 } | 533 } |
533 | 534 |
534 wev = cycle->write_events0; | 535 wev = cycle->write_events; |
535 for (i = 0; i < cycle->connection_n; i++) { | 536 for (i = 0; i < cycle->connection_n; i++) { |
536 wev[i].closed = 1; | 537 wev[i].closed = 1; |
537 #if (NGX_THREADS) | 538 #if (NGX_THREADS) |
538 wev[i].lock = &c[i].lock; | 539 wev[i].lock = &c[i].lock; |
539 wev[i].own_lock = &c[i].lock; | 540 wev[i].own_lock = &c[i].lock; |
545 | 546 |
546 do { | 547 do { |
547 i--; | 548 i--; |
548 | 549 |
549 c[i].data = next; | 550 c[i].data = next; |
550 c[i].read = &cycle->read_events0[i]; | 551 c[i].read = &cycle->read_events[i]; |
551 c[i].write = &cycle->write_events0[i]; | 552 c[i].write = &cycle->write_events[i]; |
552 c[i].fd = (ngx_socket_t) -1; | 553 c[i].fd = (ngx_socket_t) -1; |
553 | 554 |
554 next = &c[i]; | 555 next = &c[i]; |
555 | 556 |
556 #if (NGX_THREADS) | 557 #if (NGX_THREADS) |
570 | 571 |
571 if (c == NULL) { | 572 if (c == NULL) { |
572 return NGX_ERROR; | 573 return NGX_ERROR; |
573 } | 574 } |
574 | 575 |
575 rev = c->read; | |
576 wev = c->write; | |
577 | |
578 ngx_memzero(c, sizeof(ngx_connection_t)); | |
579 | |
580 c->read = rev; | |
581 c->write = wev; | |
582 c->fd = ls[i].fd; | |
583 c->log = &ls[i].log; | 576 c->log = &ls[i].log; |
584 | 577 |
585 c->listening = &ls[i]; | 578 c->listening = &ls[i]; |
586 ls[i].connection = c; | 579 ls[i].connection = c; |
587 | 580 |
588 c->ctx = ls[i].ctx; | 581 c->ctx = ls[i].ctx; |
589 c->servers = ls[i].servers; | 582 c->servers = ls[i].servers; |
590 | 583 |
591 ngx_memzero(rev, sizeof(ngx_event_t)); | 584 rev = c->read; |
592 ngx_memzero(wev, sizeof(ngx_event_t)); | |
593 | |
594 /* required by poll */ | |
595 wev->index = NGX_INVALID_INDEX; | |
596 | 585 |
597 rev->log = c->log; | 586 rev->log = c->log; |
598 rev->data = c; | |
599 rev->index = NGX_INVALID_INDEX; | |
600 | |
601 rev->available = 0; | |
602 | |
603 rev->accept = 1; | 587 rev->accept = 1; |
604 | 588 |
605 #if (NGX_HAVE_DEFERRED_ACCEPT) | 589 #if (NGX_HAVE_DEFERRED_ACCEPT) |
606 rev->deferred_accept = ls[i].deferred_accept; | 590 rev->deferred_accept = ls[i].deferred_accept; |
607 #endif | 591 #endif |