aboutsummaryrefslogtreecommitdiff
path: root/src/event/modules/ngx_epoll_module.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-01-25 12:27:35 +0000
committerIgor Sysoev <igor@sysoev.ru>2005-01-25 12:27:35 +0000
commite5a222c6fef26b51d956c35530178837c60bf8c4 (patch)
tree65dafe2f85fe2b09b82d3efd2abe2b43720a1f4e /src/event/modules/ngx_epoll_module.c
parent4f06a9709164123e7d8ccbd6fa723da387a9a86c (diff)
downloadnginx-e5a222c6fef26b51d956c35530178837c60bf8c4.tar.gz
nginx-e5a222c6fef26b51d956c35530178837c60bf8c4.zip
nginx-0.1.16-RELEASE importrelease-0.1.16
*) Bugfix: if the response were transferred by chunks, then on the HEAD request the final chunk was issued. *) Bugfix: the "Connection: keep-alive" header were issued, even if the keepalive_timeout directive forbade the keep-alive use. *) Bugfix: the errors in the ngx_http_fastcgi_module caused the segmentation faults. *) Bugfix: the compressed response encrypted by SSL may not transferred complete. *) Bugfix: the TCP-specific TCP_NODELAY, TCP_NOPSUH, and TCP_CORK options, are not used for the unix domain sockets. *) Feature: the rewrite directive supports the arguments rewriting. *) Bugfix: the response code 400 was returned for the POST request with the "Content-Length: 0" header; the bug had appeared in 0.1.14.
Diffstat (limited to 'src/event/modules/ngx_epoll_module.c')
-rw-r--r--src/event/modules/ngx_epoll_module.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c
index 907d6aeb5..af2781851 100644
--- a/src/event/modules/ngx_epoll_module.c
+++ b/src/event/modules/ngx_epoll_module.c
@@ -198,37 +198,40 @@ static void ngx_epoll_done(ngx_cycle_t *cycle)
static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
{
- int op, prev;
+ int op;
+ uint32_t events, prev;
ngx_event_t *e;
ngx_connection_t *c;
struct epoll_event ee;
c = ev->data;
+ events = (uint32_t) event;
+
if (event == NGX_READ_EVENT) {
e = c->write;
prev = EPOLLOUT;
#if (NGX_READ_EVENT != EPOLLIN)
- event = EPOLLIN;
+ events = EPOLLIN;
#endif
} else {
e = c->read;
prev = EPOLLIN;
#if (NGX_WRITE_EVENT != EPOLLOUT)
- event = EPOLLOUT;
+ events = EPOLLOUT;
#endif
}
if (e->active) {
op = EPOLL_CTL_MOD;
- event |= prev;
+ events |= prev;
} else {
op = EPOLL_CTL_ADD;
}
- ee.events = event | flags;
+ ee.events = events | flags;
ee.data.u64 = (uintptr_t) c | ev->instance;
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
@@ -252,14 +255,15 @@ static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
{
- int op, prev;
+ int op;
+ uint32_t prev;
ngx_event_t *e;
ngx_connection_t *c;
struct epoll_event ee;
/*
- * when the file descriptor is closed the epoll automatically deletes
- * it from its queue so we do not need to delete explicity the event
+ * when the file descriptor is closed, the epoll automatically deletes
+ * it from its queue, so we do not need to delete explicity the event
* before the closing the file descriptor
*/
@@ -370,6 +374,7 @@ int ngx_epoll_process_events(ngx_cycle_t *cycle)
{
int events;
size_t n;
+ uint32_t revents;
ngx_int_t instance, i;
ngx_uint_t lock, accept_lock, expire;
ngx_err_t err;
@@ -521,27 +526,40 @@ int ngx_epoll_process_events(ngx_cycle_t *cycle)
log = c->log ? c->log : cycle->log;
#endif
+ revents = event_list[i].events;
+
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
"epoll: fd:%d ev:%04XD d:%p",
- c->fd, event_list[i].events, event_list[i].data);
+ c->fd, revents, event_list[i].data);
- if (event_list[i].events & (EPOLLERR|EPOLLHUP)) {
+ if (revents & (EPOLLERR|EPOLLHUP)) {
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
"epoll_wait() error on fd:%d ev:%04XD",
- c->fd, event_list[i].events);
+ c->fd, revents);
}
- if (event_list[i].events & ~(EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP)) {
+ if (revents & ~(EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP)) {
ngx_log_error(NGX_LOG_ALERT, log, 0,
"strange epoll_wait() events fd:%d ev:%04XD",
- c->fd, event_list[i].events);
+ c->fd, revents);
+ }
+
+ if ((revents & (EPOLLERR|EPOLLHUP))
+ && (revents & (EPOLLIN|EPOLLOUT)) == 0)
+ {
+ /*
+ * if the error events were returned without EPOLLIN or EPOLLOUT,
+ * then add these flags to handle the events at least in one
+ * active handler
+ */
+
+ revents |= EPOLLIN|EPOLLOUT;
}
wev = c->write;
- if ((event_list[i].events & (EPOLLOUT|EPOLLERR|EPOLLHUP))
- && wev->active)
- {
+ if ((revents & EPOLLOUT) && wev->active) {
+
if (ngx_threaded) {
wev->posted_ready = 1;
ngx_post_event(wev);
@@ -564,9 +582,8 @@ int ngx_epoll_process_events(ngx_cycle_t *cycle)
* if the accept event is the last one.
*/
- if ((event_list[i].events & (EPOLLIN|EPOLLERR|EPOLLHUP))
- && rev->active)
- {
+ if ((revents & EPOLLIN) && rev->active) {
+
if (ngx_threaded && !rev->accept) {
rev->posted_ready = 1;