summaryrefslogtreecommitdiffhomepage
path: root/src/event
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
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')
-rw-r--r--src/event/modules/ngx_kqueue_module.c2
-rw-r--r--src/event/modules/ngx_poll_module.c4
-rw-r--r--src/event/modules/ngx_select_module.c9
-rw-r--r--src/event/ngx_event.c11
-rw-r--r--src/event/ngx_event.h8
-rw-r--r--src/event/ngx_event_accept.c49
6 files changed, 63 insertions, 20 deletions
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index e169c8c3e..28966feb2 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -375,6 +375,8 @@ static int ngx_kqueue_process_events(ngx_log_t *log)
ngx_gettimeofday(&tv);
ngx_time_update(tv.tv_sec);
+ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "kevent events: %d", events);
+
delta = ngx_elapsed_msec;
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
diff --git a/src/event/modules/ngx_poll_module.c b/src/event/modules/ngx_poll_module.c
index 37c10e361..8727c2120 100644
--- a/src/event/modules/ngx_poll_module.c
+++ b/src/event/modules/ngx_poll_module.c
@@ -320,12 +320,12 @@ static int ngx_poll_process_events(ngx_log_t *log)
found = 0;
- if (event_list[i].revents & (POLLIN|POLLERR|POLLHUP)) {
+ if (event_list[i].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL)) {
found = 1;
ready_index[nready++] = c->read;
}
- if (event_list[i].revents & (POLLOUT|POLLERR|POLLHUP)) {
+ if (event_list[i].revents & (POLLOUT|POLLERR|POLLHUP|POLLNVAL)) {
found = 1;
ready_index[nready++] = c->write;
}
diff --git a/src/event/modules/ngx_select_module.c b/src/event/modules/ngx_select_module.c
index 18d1bde7c..602960b0d 100644
--- a/src/event/modules/ngx_select_module.c
+++ b/src/event/modules/ngx_select_module.c
@@ -315,14 +315,15 @@ static int ngx_select_process_events(ngx_log_t *log)
deltas += delta;
if (deltas > 1000) {
ngx_gettimeofday(&tv);
- deltas = tv.tv_usec / 1000;
ngx_time_update(tv.tv_sec);
+ deltas = tv.tv_usec / 1000;
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
"select timer: %d, delta: %d", timer, (int) delta);
} else {
+ delta = 0;
ngx_gettimeofday(&tv);
ngx_time_update(tv.tv_sec);
@@ -438,8 +439,10 @@ static char *ngx_select_init_conf(ngx_cycle_t *cycle, void *conf)
/* disable warning: the default FD_SETSIZE is 1024U in FreeBSD 5.x */
if ((unsigned) ecf->connections > FD_SETSIZE) {
- return "maximum number of connections "
- "supported by select() is " ngx_value(FD_SETSIZE);
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
+ "the maximum number of files "
+ "supported by select() is " ngx_value(FD_SETSIZE));
+ return NGX_CONF_ERROR;
}
return NGX_CONF_OK;
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index bf6634661..482310b3d 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -84,6 +84,13 @@ static ngx_command_t ngx_event_core_commands[] = {
0,
NULL },
+ { ngx_string("multi_accept"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_flag_slot,
+ 0,
+ offsetof(ngx_event_conf_t, multi_accept),
+ NULL },
+
ngx_null_command
};
@@ -421,8 +428,8 @@ static void *ngx_event_create_conf(ngx_cycle_t *cycle)
NGX_CONF_ERROR);
ecf->connections = NGX_CONF_UNSET;
- ecf->timer_queues = NGX_CONF_UNSET;
ecf->use = NGX_CONF_UNSET;
+ ecf->multi_accept = NGX_CONF_UNSET;
ecf->name = (void *) NGX_CONF_UNSET;
return ecf;
@@ -457,7 +464,7 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
cycle->connection_n = ecf->connections;
- ngx_conf_init_value(ecf->timer_queues, 10);
+ ngx_conf_init_value(ecf->multi_accept, 1);
return NGX_CONF_OK;
}
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index 0e7939209..68d9f8199 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -345,10 +345,10 @@ extern ngx_event_actions_t ngx_event_actions;
typedef struct {
- int connections;
- int timer_queues;
- int use;
- char *name;
+ int connections;
+ int use;
+ ngx_flag_t multi_accept;
+ char *name;
} ngx_event_conf_t;
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;