aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/event/modules/ngx_devpoll_module.c43
-rw-r--r--src/event/modules/ngx_epoll_module.c107
-rw-r--r--src/event/modules/ngx_kqueue_module.c2
-rw-r--r--src/event/modules/ngx_poll_module.c55
-rw-r--r--src/event/modules/ngx_sigio_module.c41
-rw-r--r--src/event/ngx_event_accept.c2
-rw-r--r--src/http/modules/ngx_http_ssi_filter.c9
-rw-r--r--src/http/ngx_http_request.c2
-rw-r--r--src/os/unix/ngx_linux_config.h8
-rw-r--r--src/os/unix/ngx_linux_sendfile_chain.c2
10 files changed, 148 insertions, 123 deletions
diff --git a/src/event/modules/ngx_devpoll_module.c b/src/event/modules/ngx_devpoll_module.c
index 1aa042ab2..e8204cd63 100644
--- a/src/event/modules/ngx_devpoll_module.c
+++ b/src/event/modules/ngx_devpoll_module.c
@@ -363,7 +363,7 @@ int ngx_devpoll_process_events(ngx_log_t *log)
return NGX_ERROR;
}
- if ((int) timer != INFTIM) {
+ if (timer != (ngx_msec_t) INFTIM) {
delta = ngx_elapsed_msec - delta;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
@@ -402,34 +402,35 @@ int ngx_devpoll_process_events(ngx_log_t *log)
event_list[i].fd,
event_list[i].events, event_list[i].revents);
- if (event_list[i].revents & POLLIN) {
- if (!c->read->active) {
- continue;
- }
+ if (event_list[i].revents & (POLLERR|POLLHUP|POLLNVAL)) {
+ ngx_log_error(NGX_LOG_ALERT, log, 0,
+ "ioctl(DP_POLL) error fd:%d ev:%04X rev:%04X",
+ event_list[i].fd,
+ event_list[i].events, event_list[i].revents);
+ }
+
+ if (event_list[i].revents & ~(POLLIN|POLLOUT|POLLERR|POLLHUP|POLLNVAL))
+ {
+ ngx_log_error(NGX_LOG_ALERT, log, 0,
+ "strange ioctl(DP_POLL) events "
+ "fd:%d ev:%04X rev:%04X",
+ event_list[i].fd,
+ event_list[i].events, event_list[i].revents);
+ }
+ if ((event_list[i].events & (POLLIN|POLLERR|POLLHUP))
+ && c->read->active)
+ {
c->read->ready = 1;
c->read->event_handler(c->read);
}
- if (event_list[i].revents & POLLOUT) {
- if (!c->write->active) {
- continue;
- }
-
+ if ((event_list[i].events & (POLLOUT|POLLERR|POLLHUP))
+ && c->write->active)
+ {
c->write->ready = 1;
c->write->event_handler(c->write);
}
-
- if (event_list[i].revents & (POLLERR|POLLHUP|POLLNVAL)) {
- err = 0;
- if (event_list[i].revents & POLLNVAL) {
- err = EBADF;
- }
-
- ngx_log_error(NGX_LOG_ERR, log, err,
- "ioctl(DP_POLL) error on %d:%d",
- event_list[i].fd, event_list[i].revents);
- }
}
if (timer != (ngx_msec_t) INFTIM && delta) {
diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c
index a4eff7e24..bf3320439 100644
--- a/src/event/modules/ngx_epoll_module.c
+++ b/src/event/modules/ngx_epoll_module.c
@@ -13,16 +13,19 @@
/* epoll declarations */
-#define EPOLLIN 0x001
-#define EPOLLPRI 0x002
-#define EPOLLOUT 0x004
-#define EPOLLRDNORM 0x040
-#define EPOLLRDBAND 0x080
-#define EPOLLWRNORM 0x100
-#define EPOLLWRBAND 0x200
-#define EPOLLMSG 0x400
-#define EPOLLERR 0x008
-#define EPOLLHUP 0x010
+#define EPOLLIN 0x001
+#define EPOLLPRI 0x002
+#define EPOLLOUT 0x004
+#define EPOLLRDNORM 0x040
+#define EPOLLRDBAND 0x080
+#define EPOLLWRNORM 0x100
+#define EPOLLWRBAND 0x200
+#define EPOLLMSG 0x400
+#define EPOLLERR 0x008
+#define EPOLLHUP 0x010
+
+#define EPOLLET 0x80000000
+#define EPOLLONESHOT 0x40000000
#define EPOLL_CTL_ADD 1
#define EPOLL_CTL_DEL 2
@@ -114,7 +117,6 @@ ngx_event_module_t ngx_epoll_module_ctx = {
ngx_epoll_init, /* init the events */
ngx_epoll_done, /* done the events */
}
-
};
ngx_module_t ngx_epoll_module = {
@@ -186,7 +188,7 @@ static void ngx_epoll_done(ngx_cycle_t *cycle)
static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
{
- struct epoll_event e;
+ struct epoll_event ee;
ngx_connection_t *c;
c = ev->data;
@@ -200,65 +202,60 @@ static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
}
#endif
- e.events = event;
- e.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
+ ee.events = event;
+ ee.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "epoll add event: fd:%d ev:%04X", c->fd, e.events);
+ "epoll add event: fd:%d ev:%04X", c->fd, ee.events);
- if (epoll_ctl(ep, EPOLL_CTL_MOD, c->fd, &e) == -1) {
+ if (epoll_ctl(ep, EPOLL_CTL_ADD, c->fd, &ee) == -1) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
"epoll_ctl(EPOLL_CTL_MOD, %d) failed", c->fd);
return NGX_ERROR;
}
+ ev->active = 1;
+
return NGX_OK;
}
static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
{
- struct epoll_event e;
+ struct epoll_event ee;
ngx_connection_t *c;
c = ev->data;
-#if (NGX_READ_EVENT != EPOLLIN) || (NGX_WRITE_EVENT != EPOLLOUT)
- if (event == NGX_READ_EVENT) {
- event = EPOLLIN;
-
- } else {
- event = EPOLLOUT;
- }
-#endif
-
- e.events = event;
- e.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
+ ee.events = 0;
+ ee.data.ptr = NULL;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "epoll del event: fd:%d ev:%04X", c->fd, e.events);
+ "epoll del event: fd:%d ev:%04X", c->fd, ee.events);
- if (epoll_ctl(ep, EPOLL_CTL_MOD, c->fd, &e) == -1) {
+ if (epoll_ctl(ep, EPOLL_CTL_DEL, c->fd, &ee) == -1) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
"epoll_ctl(EPOLL_CTL_MOD, %d) failed", c->fd);
return NGX_ERROR;
}
+ ev->active = 0;
+
return NGX_OK;
}
static int ngx_epoll_add_connection(ngx_connection_t *c)
{
- struct epoll_event ev;
+ struct epoll_event ee;
- ev.events = EPOLLIN|EPOLLOUT;
- ev.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
+ ee.events = EPOLLIN|EPOLLOUT;
+ ee.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "epoll add connection: fd:%d ev:%04X", c->fd, ev.events);
+ "epoll add connection: fd:%d ev:%04X", c->fd, ee.events);
- if (epoll_ctl(ep, EPOLL_CTL_ADD, c->fd, &ev) == -1) {
+ if (epoll_ctl(ep, EPOLL_CTL_ADD, c->fd, &ee) == -1) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
"epoll_ctl(EPOLL_CTL_ADD, %d) failed", c->fd);
return NGX_ERROR;
@@ -316,7 +313,7 @@ int ngx_epoll_process_events(ngx_log_t *log)
delta = ngx_elapsed_msec;
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
- if ((int) timer != INFTIM) {
+ if (timer != (ngx_msec_t) -1) {
delta = ngx_elapsed_msec - delta;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
@@ -348,7 +345,7 @@ int ngx_epoll_process_events(ngx_log_t *log)
if (c->read->instance != instance) {
/*
- * it's a stale event from a file descriptor
+ * the stale event from a file descriptor
* that was just closed in this iteration
*/
@@ -357,37 +354,31 @@ int ngx_epoll_process_events(ngx_log_t *log)
continue;
}
- if (event_list[i].events & EPOLLIN) {
- if (!c->read->active) {
- continue;
- }
-
- c->read->ready = 1;
- c->read->event_handler(c->read);
- }
-
- if (event_list[i].events & EPOLLOUT) {
- if (!c->write->active) {
- continue;
- }
-
- c->write->ready = 1;
- c->write->event_handler(c->write);
- }
-
if (event_list[i].events & (EPOLLERR|EPOLLHUP)) {
ngx_log_error(NGX_LOG_ALERT, log, 0,
"epoll_wait() error on fd:%d ev:%d",
c->fd, event_list[i].events);
- continue;
}
- if (event_list[i].events & ~(EPOLLIN|EPOLLOUT)) {
+ if (event_list[i].events & ~(EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP)) {
ngx_log_error(NGX_LOG_ALERT, log, 0,
- "epoll_wait() returned strange events on fd:%d ev:%d",
+ "strange epoll_wait() events fd:%d ev:%04X",
c->fd, event_list[i].events);
}
+ if ((event_list[i].events & (EPOLLIN|EPOLLERR|EPOLLHUP))
+ && c->read->active)
+ {
+ c->read->ready = 1;
+ c->read->event_handler(c->read);
+ }
+
+ if ((event_list[i].events & (EPOLLOUT|EPOLLERR|EPOLLHUP))
+ && c->write->active)
+ {
+ c->write->ready = 1;
+ c->write->event_handler(c->write);
+ }
}
if (timer != (ngx_msec_t) -1 && delta) {
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index da86726ff..e169c8c3e 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -431,7 +431,7 @@ static int ngx_kqueue_process_events(ngx_log_t *log)
if (ev->active == 0 || ev->instance != instance) {
/*
- * it's a stale event from a file descriptor
+ * the stale event from a file descriptor
* that was just closed in this iteration
*/
diff --git a/src/event/modules/ngx_poll_module.c b/src/event/modules/ngx_poll_module.c
index 708dbd67a..37c10e361 100644
--- a/src/event/modules/ngx_poll_module.c
+++ b/src/event/modules/ngx_poll_module.c
@@ -261,7 +261,7 @@ static int ngx_poll_process_events(ngx_log_t *log)
return NGX_ERROR;
}
- if ((int) timer != INFTIM) {
+ if (timer != (ngx_msec_t) INFTIM) {
delta = ngx_elapsed_msec - delta;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
@@ -277,6 +277,27 @@ static int ngx_poll_process_events(ngx_log_t *log)
nready = 0;
for (i = 0; i < nevents && ready; i++) {
+
+ ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
+ "poll: fd:%d ev:%04X rev:%04X",
+ event_list[i].fd,
+ event_list[i].events, event_list[i].revents);
+
+ if (event_list[i].revents & (POLLERR|POLLHUP|POLLNVAL)) {
+ ngx_log_error(NGX_LOG_ALERT, log, 0,
+ "poll() error fd:%d ev:%04X rev:%04X",
+ event_list[i].fd,
+ event_list[i].events, event_list[i].revents);
+ }
+
+ if (event_list[i].revents & ~(POLLIN|POLLOUT|POLLERR|POLLHUP|POLLNVAL))
+ {
+ ngx_log_error(NGX_LOG_ALERT, log, 0,
+ "strange poll() events fd:%d ev:%04X rev:%04X",
+ event_list[i].fd,
+ event_list[i].events, event_list[i].revents);
+ }
+
c = &ngx_cycle->connections[event_list[i].fd];
if (c->fd == -1) {
@@ -293,35 +314,18 @@ static int ngx_poll_process_events(ngx_log_t *log)
}
if (c->fd == -1) {
- ngx_log_error(NGX_LOG_ALERT, log, 0, "unkonwn cycle");
- exit(1);
+ ngx_log_error(NGX_LOG_ALERT, log, 0, "unknown cycle");
+ continue;
}
- ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
- "poll: fd:%d ev:%04X rev:%04X",
- event_list[i].fd,
- event_list[i].events, event_list[i].revents);
-
found = 0;
- if (event_list[i].revents & POLLNVAL) {
- ngx_log_error(NGX_LOG_ALERT, log, EBADF,
- "poll() error on %d", event_list[i].fd);
- continue;
- }
-
- if (event_list[i].revents & POLLIN
- || (event_list[i].revents & (POLLERR|POLLHUP)
- && c->read->active))
- {
+ if (event_list[i].revents & (POLLIN|POLLERR|POLLHUP)) {
found = 1;
ready_index[nready++] = c->read;
}
- if (event_list[i].revents & POLLOUT
- || (event_list[i].revents & (POLLERR|POLLHUP)
- && c->write->active))
- {
+ if (event_list[i].revents & (POLLOUT|POLLERR|POLLHUP)) {
found = 1;
ready_index[nready++] = c->write;
}
@@ -330,13 +334,6 @@ static int ngx_poll_process_events(ngx_log_t *log)
ready--;
continue;
}
-
- if (event_list[i].revents & (POLLERR|POLLHUP)) {
- ngx_log_error(NGX_LOG_ALERT, log, 0,
- "strange poll() error on fd:%d ev:%04X rev:%04X",
- event_list[i].fd,
- event_list[i].events, event_list[i].revents);
- }
}
for (i = 0; i < nready; i++) {
diff --git a/src/event/modules/ngx_sigio_module.c b/src/event/modules/ngx_sigio_module.c
index fb6730a06..7e4bee33f 100644
--- a/src/event/modules/ngx_sigio_module.c
+++ b/src/event/modules/ngx_sigio_module.c
@@ -13,11 +13,14 @@
#define F_SETSIG 10
+#define POLL_IN POLLIN
+#define POLL_OUT POLLOUT
+
#endif
typedef struct {
- int signal;
+ int signo;
} ngx_sigio_conf_t;
@@ -44,7 +47,7 @@ static ngx_command_t ngx_sigio_commands[] = {
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
0,
- offsetof(ngx_sigio_conf_t, signal),
+ offsetof(ngx_sigio_conf_t, signo),
NULL},
ngx_null_command
@@ -87,7 +90,7 @@ static int ngx_sigio_init(ngx_cycle_t *cycle)
sgcf = ngx_event_get_conf(cycle->conf_ctx, ngx_sigio_module);
sigemptyset(&set);
- sigaddset(&set, sgcf->signal);
+ sigaddset(&set, sgcf->signo);
sigaddset(&set, SIGIO);
if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
@@ -144,7 +147,7 @@ static int ngx_sigio_add_connection(ngx_connection_t *c)
sgcf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_sigio_module);
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "sigio add connection: fd:%d signo:%d", c->fd, sgcf->signal);
+ "sigio add connection: fd:%d signo:%d", c->fd, sgcf->signo);
if (fcntl(c->fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC) == -1) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
@@ -152,7 +155,7 @@ static int ngx_sigio_add_connection(ngx_connection_t *c)
return NGX_ERROR;
}
- if (fcntl(c->fd, F_SETSIG, sgcf->signal) == -1) {
+ if (fcntl(c->fd, F_SETSIG, sgcf->signo) == -1) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
"fcntl(F_SETSIG) failed");
return NGX_ERROR;
@@ -199,6 +202,7 @@ int ngx_sigio_process_events(ngx_log_t *log)
siginfo_t si;
struct timeval tv;
struct timespec ts;
+ struct sigaction sa;
ngx_connection_t *c;
ngx_epoch_msec_t delta;
ngx_sigio_conf_t *sgcf;
@@ -246,12 +250,21 @@ int ngx_sigio_process_events(ngx_log_t *log)
sgcf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_sigio_module);
- if (signo == sgcf->signal) {
+ if (signo == sgcf->signo) {
/* STUB: old_cycles */
- c = &ngx_connections[si.si_fd];
+ c = &ngx_cycle->connections[si.si_fd];
- if (si.si_band & EPOLLIN) {
+ if (si.si_band & POLL_IN) {
+ if (!c->read->active) {
+ continue;
+ }
+
+ c->read->ready = 1;
+ c->read->event_handler(c->read);
+ }
+
+ if (si.si_band & POLL_OUT) {
if (!c->read->active) {
continue;
}
@@ -265,6 +278,15 @@ int ngx_sigio_process_events(ngx_log_t *log)
"signal queue overflowed: "
"SIGIO, fd:%d, band:%d", si.si_fd, si.si_band);
+ ngx_memzero(&sa, sizeof(struct sigaction));
+ sa.sa_sigaction = SIG_DFL;
+ sigemptyset(&sa.sa_mask);
+ if (sigaction(sgcf->signo, &sa, NULL) == -1) {
+ ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
+ "sigaction queue overflowed: "
+ "SIGIO, fd:%d, band:%d", si.si_fd, si.si_band);
+ }
+
} else {
ngx_log_error(NGX_LOG_ALERT, log, 0,
timer ? "sigtimedwait() returned unexpected signal: %d":
@@ -350,7 +372,8 @@ static char *ngx_sigio_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_sigio_conf_t *sgcf = conf;
- ngx_conf_init_unsigned_value(sgcf->signal, SIGRTMIN);
+ /* LinuxThreads uses the first 3 RT signals */
+ ngx_conf_init_unsigned_value(sgcf->signo, SIGRTMIN + 10);
return NGX_CONF_OK;
}
diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c
index 75701cb83..be282eba2 100644
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -214,8 +214,6 @@ void ngx_event_accept(ngx_event_t *ev)
c->number = ngx_connection_counter++;
- ngx_log_debug(ev->log, "LOG: %x" _ ev->log->log_level);
-
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"accept: %d, %d", s, c->number);
diff --git a/src/http/modules/ngx_http_ssi_filter.c b/src/http/modules/ngx_http_ssi_filter.c
index 56070d11f..4aed6ae20 100644
--- a/src/http/modules/ngx_http_ssi_filter.c
+++ b/src/http/modules/ngx_http_ssi_filter.c
@@ -158,6 +158,15 @@ static int ngx_http_ssi_header_filter(ngx_http_request_t *r)
return ngx_http_next_header_filter(r);
}
+ /* TODO: "text/html" -> custom types */
+
+ if (r->headers_out.content_type
+ && ngx_strncasecmp(r->headers_out.content_type->value.data,
+ "text/html", 5) != 0)
+ {
+ return ngx_http_next_header_filter(r);
+ }
+
ngx_http_create_ctx(r, ctx, ngx_http_ssi_filter_module,
sizeof(ngx_http_ssi_ctx_t), NGX_ERROR);
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index c5e87fed0..5d411a84f 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1037,8 +1037,6 @@ static void ngx_http_block_read(ngx_event_t *rev)
ngx_http_close_connection(c);
}
}
-
- return;
}
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index d3be6d247..de3f2871e 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -76,6 +76,14 @@ extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);
#endif
+/*
+ * SuSE 8.2 supports epoll's EPOLLET but misses it in <sys/epoll.h>
+ */
+#ifndef EPOLLET
+#define EPOLLET 0x80000000
+#endif
+
+
#define ngx_setproctitle(title)
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index 5fc61f062..73e2aec3b 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -20,7 +20,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in)
char *prev;
off_t fprev;
size_t size, fsize, sent;
- ngx_int_t use_cork, eintr;
+ ngx_int_t eintr;
struct iovec *iov;
ngx_err_t err;
ngx_hunk_t *file;