summaryrefslogtreecommitdiffhomepage
path: root/src/event/ngx_event_accept.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-02-02 21:19:52 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-02-02 21:19:52 +0000
commita4b16df728abe1e989a8311e901ba5d9ae30328e (patch)
tree35d3d0ba37e1c285421688846c2954aa297a642c /src/event/ngx_event_accept.c
parent328af6e8cd26f274bf385cfff3c888725746ea4f (diff)
downloadnginx-a4b16df728abe1e989a8311e901ba5d9ae30328e.tar.gz
nginx-a4b16df728abe1e989a8311e901ba5d9ae30328e.tar.bz2
nginx-0.0.2-2004-02-03-00:19:52 import
Diffstat (limited to 'src/event/ngx_event_accept.c')
-rw-r--r--src/event/ngx_event_accept.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c
index be282eba2..8ecd29bfb 100644
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -23,6 +23,13 @@ void ngx_event_accept(ngx_event_t *ev)
ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module);
+ if (ngx_event_flags & (NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT)) {
+ ev->available = 1;
+
+ } else if (!(ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)) {
+ ev->available = ecf->multi_accept;
+ }
+
ls = ev->data;
ngx_log_debug(ev->log, "accept on %s ready: %d" _
@@ -31,26 +38,33 @@ void ngx_event_accept(ngx_event_t *ev)
ev->ready = 0;
accepted = 0;
+ pool = NULL;
do {
- /*
- * Create the pool before accept() to avoid copy the sockaddr.
- * Although accept() can fail it's an uncommon case
- * and besides the pool can be got from the free pool list
- */
+ if (pool == NULL) {
- if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) {
- return;
+ /*
+ * Create the pool before accept() to avoid copy the sockaddr.
+ * Although accept() can fail it's an uncommon case
+ * and besides the pool can be got from the free pool list
+ */
+
+ if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) {
+ return;
+ }
}
if (!(sa = ngx_palloc(pool, ls->listening->socklen))) {
+ ngx_destroy_pool(pool);
return;
}
if (!(log = ngx_palloc(pool, sizeof(ngx_log_t)))) {
+ ngx_destroy_pool(pool);
return;
}
+
ngx_memcpy(log, ls->log, sizeof(ngx_log_t));
pool->log = log;
@@ -67,6 +81,8 @@ void ngx_event_accept(ngx_event_t *ev)
ngx_log_error(NGX_LOG_NOTICE, log, err,
"EAGAIN after %d accepted connection(s)",
accepted);
+
+ ngx_destroy_pool(pool);
return;
}
@@ -74,6 +90,17 @@ void ngx_event_accept(ngx_event_t *ev)
"accept() on %s failed",
ls->listening->addr_text.data);
+ if (err == NGX_ECONNABORTED) {
+ if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ ev->available--;
+ }
+
+ if (ev->available) {
+ /* reuse the previously allocated pool */
+ continue;
+ }
+ }
+
ngx_destroy_pool(pool);
return;
}
@@ -187,8 +214,10 @@ void ngx_event_accept(ngx_event_t *ev)
wev->write = 1;
wev->ready = 1;
- if (ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_EDGE_EVENT)) {
- /* aio, iocp, epoll */
+ if (ngx_event_flags
+ & (NGX_USE_AIO_EVENT|NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT))
+ {
+ /* aio, iocp, sigio, epoll */
rev->ready = 1;
}
@@ -229,6 +258,8 @@ void ngx_event_accept(ngx_event_t *ev)
}
}
+ pool = NULL;
+
log->data = NULL;
log->handler = NULL;