Mercurial > hg > nginx
comparison src/event/ngx_event_accept.c @ 346:55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 06 Jun 2004 19:49:18 +0000 |
parents | ba876b26b76d |
children | 7b96b7f8a6af |
comparison
equal
deleted
inserted
replaced
345:fade4edd61f8 | 346:55e496a8ece3 |
---|---|
28 ngx_event_conf_t *ecf; | 28 ngx_event_conf_t *ecf; |
29 ngx_accept_log_ctx_t *ctx; | 29 ngx_accept_log_ctx_t *ctx; |
30 | 30 |
31 ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module); | 31 ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module); |
32 | 32 |
33 if (ngx_event_flags & (NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT)) { | 33 if (ngx_event_flags & (NGX_USE_EDGE_EVENT|NGX_USE_RTSIG_EVENT)) { |
34 ev->available = 1; | 34 ev->available = 1; |
35 | 35 |
36 } else if (!(ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)) { | 36 } else if (!(ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)) { |
37 ev->available = ecf->multi_accept; | 37 ev->available = ecf->multi_accept; |
38 } | 38 } |
50 do { | 50 do { |
51 | 51 |
52 if (pool == NULL) { | 52 if (pool == NULL) { |
53 | 53 |
54 /* | 54 /* |
55 * Create the pool before accept() to avoid copy the sockaddr. | 55 * Create the pool before accept() to avoid the copying of |
56 * Although accept() can fail it's an uncommon case | 56 * the sockaddr. Although accept() can fail it is uncommon |
57 * and besides the pool can be got from the free pool list | 57 * case and besides the pool can be got from the free pool list |
58 */ | 58 */ |
59 | 59 |
60 if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) { | 60 if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) { |
61 return; | 61 return; |
62 } | 62 } |
78 if (!(ctx = ngx_palloc(pool, sizeof(ngx_accept_log_ctx_t)))) { | 78 if (!(ctx = ngx_palloc(pool, sizeof(ngx_accept_log_ctx_t)))) { |
79 ngx_destroy_pool(pool); | 79 ngx_destroy_pool(pool); |
80 return; | 80 return; |
81 } | 81 } |
82 | 82 |
83 /* -1 disable logging the connection number */ | 83 /* -1 disables the connection number logging */ |
84 ctx->flag = -1; | 84 ctx->flag = -1; |
85 ctx->name = ls->listening->addr_text.data; | 85 ctx->name = ls->listening->addr_text.data; |
86 | 86 |
87 log->data = ctx; | 87 log->data = ctx; |
88 log->handler = ngx_accept_log_error; | 88 log->handler = ngx_accept_log_error; |
93 if (s == -1) { | 93 if (s == -1) { |
94 err = ngx_socket_errno; | 94 err = ngx_socket_errno; |
95 | 95 |
96 if (err == NGX_EAGAIN) { | 96 if (err == NGX_EAGAIN) { |
97 if (!(ngx_event_flags | 97 if (!(ngx_event_flags |
98 & (NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT))) | 98 & (NGX_USE_EDGE_EVENT|NGX_USE_RTSIG_EVENT))) |
99 { | 99 { |
100 ngx_log_error(NGX_LOG_NOTICE, log, err, | 100 ngx_log_error(NGX_LOG_NOTICE, log, err, |
101 "EAGAIN after %d accepted connection(s)", | 101 "EAGAIN after %d accepted connection(s)", |
102 accepted); | 102 accepted); |
103 } | 103 } |
165 return; | 165 return; |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 } else { | 169 } else { |
170 if (!(ngx_event_flags & NGX_USE_AIO_EVENT)) { | 170 if (!(ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT))) { |
171 if (ngx_nonblocking(s) == -1) { | 171 if (ngx_nonblocking(s) == -1) { |
172 ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno, | 172 ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno, |
173 ngx_nonblocking_n " failed"); | 173 ngx_nonblocking_n " failed"); |
174 | 174 |
175 if (ngx_close_socket(s) == -1) { | 175 if (ngx_close_socket(s) == -1) { |
244 | 244 |
245 wev->write = 1; | 245 wev->write = 1; |
246 wev->ready = 1; | 246 wev->ready = 1; |
247 | 247 |
248 if (ngx_event_flags | 248 if (ngx_event_flags |
249 & (NGX_USE_AIO_EVENT|NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT)) | 249 & (NGX_USE_AIO_EVENT|NGX_USE_EDGE_EVENT|NGX_USE_RTSIG_EVENT)) |
250 { | 250 { |
251 /* aio, iocp, sigio, epoll */ | 251 /* epoll, rtsig, aio, iocp */ |
252 rev->ready = 1; | 252 rev->ready = 1; |
253 } | 253 } |
254 | 254 |
255 if (ev->deferred_accept) { | 255 if (ev->deferred_accept) { |
256 rev->ready = 1; | 256 rev->ready = 1; |
364 | 364 |
365 s = cycle->listening.elts; | 365 s = cycle->listening.elts; |
366 for (i = 0; i < cycle->listening.nelts; i++) { | 366 for (i = 0; i < cycle->listening.nelts; i++) { |
367 | 367 |
368 /* | 368 /* |
369 * we do not need to handle the Winsock sockets here (divde a socket | 369 * we do not need to handle the Winsock sockets here (divide a socket |
370 * number by 4) because this function would never called | 370 * number by 4) because this function would never called |
371 * in the Winsock environment | 371 * in the Winsock environment |
372 */ | 372 */ |
373 | 373 |
374 if (ngx_event_flags & NGX_USE_SIGIO_EVENT) { | 374 if (ngx_event_flags & NGX_USE_RTSIG_EVENT) { |
375 if (ngx_add_conn(&cycle->connections[s[i].fd]) == NGX_ERROR) { | 375 if (ngx_add_conn(&cycle->connections[s[i].fd]) == NGX_ERROR) { |
376 return NGX_ERROR; | 376 return NGX_ERROR; |
377 } | 377 } |
378 | 378 |
379 } else { | 379 } else { |
396 | 396 |
397 s = cycle->listening.elts; | 397 s = cycle->listening.elts; |
398 for (i = 0; i < cycle->listening.nelts; i++) { | 398 for (i = 0; i < cycle->listening.nelts; i++) { |
399 | 399 |
400 /* | 400 /* |
401 * we do not need to handle the Winsock sockets here (divde a socket | 401 * we do not need to handle the Winsock sockets here (divide a socket |
402 * number by 4) because this function would never called | 402 * number by 4) because this function would never called |
403 * in the Winsock environment | 403 * in the Winsock environment |
404 */ | 404 */ |
405 | 405 |
406 if (ngx_event_flags & NGX_USE_SIGIO_EVENT) { | 406 if (ngx_event_flags & NGX_USE_RTSIG_EVENT) { |
407 if (!cycle->connections[s[i].fd].read->active) { | 407 if (!cycle->connections[s[i].fd].read->active) { |
408 continue; | 408 continue; |
409 } | 409 } |
410 | 410 |
411 if (ngx_del_conn(&cycle->connections[s[i].fd], NGX_DISABLE_EVENT) | 411 if (ngx_del_conn(&cycle->connections[s[i].fd], NGX_DISABLE_EVENT) |