mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 14:13:33 -06:00
nginx-0.0.3-2004-04-02-19:13:20 import
This commit is contained in:
parent
debb39eaed
commit
c972a3fe27
@ -14,7 +14,7 @@ static void ngx_aio_done(ngx_cycle_t *cycle);
|
||||
static int ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags);
|
||||
static int ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags);
|
||||
static int ngx_aio_del_connection(ngx_connection_t *c, u_int flags);
|
||||
static int ngx_aio_process_events(ngx_log_t *log);
|
||||
static int ngx_aio_process_events(ngx_cycle_t *cycle);
|
||||
|
||||
|
||||
ngx_os_io_t ngx_os_aio = {
|
||||
@ -53,7 +53,7 @@ ngx_module_t ngx_aio_module = {
|
||||
NULL, /* module directives */
|
||||
NGX_EVENT_MODULE, /* module type */
|
||||
NULL, /* init module */
|
||||
NULL /* init child */
|
||||
NULL /* init process */
|
||||
};
|
||||
|
||||
|
||||
@ -137,9 +137,9 @@ static int ngx_aio_del_connection(ngx_connection_t *c, u_int flags)
|
||||
}
|
||||
|
||||
|
||||
static int ngx_aio_process_events(ngx_log_t *log)
|
||||
static int ngx_aio_process_events(ngx_cycle_t *cycle)
|
||||
{
|
||||
return ngx_kqueue_module_ctx.actions.process(log);
|
||||
return ngx_kqueue_module_ctx.actions.process(cycle);
|
||||
}
|
||||
|
||||
#endif /* HAVE_KQUEUE */
|
||||
|
@ -36,7 +36,7 @@ static void ngx_devpoll_done(ngx_cycle_t *cycle);
|
||||
static int ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags);
|
||||
static int ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags);
|
||||
static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags);
|
||||
static int ngx_devpoll_process_events(ngx_log_t *log);
|
||||
static int ngx_devpoll_process_events(ngx_cycle_t *cycle);
|
||||
|
||||
static void *ngx_devpoll_create_conf(ngx_cycle_t *cycle);
|
||||
static char *ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf);
|
||||
@ -308,13 +308,15 @@ static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
|
||||
}
|
||||
|
||||
|
||||
int ngx_devpoll_process_events(ngx_log_t *log)
|
||||
int ngx_devpoll_process_events(ngx_cycle_t *cycle)
|
||||
{
|
||||
int events, i, j;
|
||||
int events;
|
||||
ngx_int_t i;
|
||||
ngx_uint_t j;
|
||||
size_t n;
|
||||
ngx_msec_t timer;
|
||||
ngx_err_t err;
|
||||
ngx_cycle_t **cycle;
|
||||
ngx_cycle_t **old_cycle;
|
||||
ngx_connection_t *c;
|
||||
ngx_epoch_msec_t delta;
|
||||
struct dvpoll dvp;
|
||||
@ -327,12 +329,13 @@ int ngx_devpoll_process_events(ngx_log_t *log)
|
||||
timer = (ngx_msec_t) INFTIM;
|
||||
}
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "devpoll timer: %d", timer);
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"devpoll timer: %d", timer);
|
||||
|
||||
if (nchanges) {
|
||||
n = nchanges * sizeof(struct pollfd);
|
||||
if (write(dp, change_list, n) != (ssize_t) n) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
"write(/dev/poll) failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -359,18 +362,18 @@ int ngx_devpoll_process_events(ngx_log_t *log)
|
||||
|
||||
if (err) {
|
||||
ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
|
||||
log, err, "ioctl(DP_POLL) failed");
|
||||
cycle->log, err, "ioctl(DP_POLL) failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (timer != (ngx_msec_t) INFTIM) {
|
||||
delta = ngx_elapsed_msec - delta;
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"devpoll timer: %d, delta: %d", timer, (int) delta);
|
||||
} else {
|
||||
if (events == 0) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
||||
"ioctl(DP_POLL) returned no events without timeout");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -380,12 +383,12 @@ int ngx_devpoll_process_events(ngx_log_t *log)
|
||||
c = &ngx_cycle->connections[event_list[i].fd];
|
||||
|
||||
if (c->fd == -1) {
|
||||
cycle = ngx_old_cycles.elts;
|
||||
old_cycle = ngx_old_cycles.elts;
|
||||
for (j = 0; j < ngx_old_cycles.nelts; j++) {
|
||||
if (cycle[i] == NULL) {
|
||||
if (old_cycle[j] == NULL) {
|
||||
continue;
|
||||
}
|
||||
c = &cycle[j]->connections[event_list[i].fd];
|
||||
c = &old_cycle[j]->connections[event_list[i].fd];
|
||||
if (c->fd != -1) {
|
||||
break;
|
||||
}
|
||||
@ -393,17 +396,17 @@ int ngx_devpoll_process_events(ngx_log_t *log)
|
||||
}
|
||||
|
||||
if (c->fd == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, 0, "unknown cycle");
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "unknown cycle");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"devpoll: 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,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
||||
"ioctl(DP_POLL) error fd:%d ev:%04X rev:%04X",
|
||||
event_list[i].fd,
|
||||
event_list[i].events, event_list[i].revents);
|
||||
@ -411,7 +414,7 @@ int ngx_devpoll_process_events(ngx_log_t *log)
|
||||
|
||||
if (event_list[i].revents & ~(POLLIN|POLLOUT|POLLERR|POLLHUP|POLLNVAL))
|
||||
{
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
||||
"strange ioctl(DP_POLL) events "
|
||||
"fd:%d ev:%04X rev:%04X",
|
||||
event_list[i].fd,
|
||||
|
@ -76,7 +76,7 @@ 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);
|
||||
static int ngx_epoll_add_connection(ngx_connection_t *c);
|
||||
static int ngx_epoll_del_connection(ngx_connection_t *c);
|
||||
static int ngx_epoll_process_events(ngx_log_t *log);
|
||||
static int ngx_epoll_process_events(ngx_cycle_t *cycle);
|
||||
|
||||
static void *ngx_epoll_create_conf(ngx_cycle_t *cycle);
|
||||
static char *ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf);
|
||||
@ -337,14 +337,13 @@ static int ngx_epoll_del_connection(ngx_connection_t *c)
|
||||
#endif
|
||||
|
||||
|
||||
int ngx_epoll_process_events(ngx_log_t *log)
|
||||
int ngx_epoll_process_events(ngx_cycle_t *cycle)
|
||||
{
|
||||
int events;
|
||||
ngx_int_t instance, i;
|
||||
size_t n;
|
||||
ngx_msec_t timer;
|
||||
ngx_err_t err;
|
||||
ngx_cycle_t **cycle;
|
||||
struct timeval tv;
|
||||
ngx_connection_t *c;
|
||||
ngx_epoch_msec_t delta;
|
||||
@ -357,7 +356,8 @@ int ngx_epoll_process_events(ngx_log_t *log)
|
||||
timer = (ngx_msec_t) -1;
|
||||
}
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "epoll timer: %d", timer);
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"epoll timer: %d", timer);
|
||||
|
||||
events = epoll_wait(ep, event_list, nevents, timer);
|
||||
|
||||
@ -376,11 +376,11 @@ int ngx_epoll_process_events(ngx_log_t *log)
|
||||
if (timer != (ngx_msec_t) -1) {
|
||||
delta = ngx_elapsed_msec - delta;
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"epoll timer: %d, delta: %d", timer, (int) delta);
|
||||
} else {
|
||||
if (events == 0) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
||||
"epoll_wait() returned no events without timeout");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -388,7 +388,7 @@ int ngx_epoll_process_events(ngx_log_t *log)
|
||||
|
||||
if (err) {
|
||||
ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
|
||||
log, err, "epoll_wait() failed");
|
||||
cycle->log, err, "epoll_wait() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
@ -398,7 +398,15 @@ int ngx_epoll_process_events(ngx_log_t *log)
|
||||
instance = (uintptr_t) c & 1;
|
||||
c = (ngx_connection_t *) ((uintptr_t) c & (uintptr_t) ~1);
|
||||
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
if (event_list[i].events & EPOLLIN) {
|
||||
c->read->returned_instance = instance;
|
||||
}
|
||||
|
||||
if (event_list[i].events & EPOLLOUT) {
|
||||
c->write->returned_instance = instance;
|
||||
}
|
||||
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"epoll: fd:%d ev:%04X d:" PTR_FMT,
|
||||
c->fd, event_list[i].events, event_list[i].data);
|
||||
|
||||
@ -409,19 +417,19 @@ int ngx_epoll_process_events(ngx_log_t *log)
|
||||
* that was just closed in this iteration
|
||||
*/
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"epoll: stale event " PTR_FMT, c);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event_list[i].events & (EPOLLERR|EPOLLHUP)) {
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"epoll_wait() error on fd:%d ev:%04X",
|
||||
c->fd, event_list[i].events);
|
||||
}
|
||||
|
||||
if (event_list[i].events & ~(EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP)) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
||||
"strange epoll_wait() events fd:%d ev:%04X",
|
||||
c->fd, event_list[i].events);
|
||||
}
|
||||
|
@ -346,7 +346,8 @@ static int ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
|
||||
static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
|
||||
{
|
||||
int events;
|
||||
ngx_int_t i, instance;
|
||||
ngx_int_t i;
|
||||
ngx_uint_t instance;
|
||||
ngx_err_t err;
|
||||
ngx_msec_t timer;
|
||||
ngx_event_t *ev;
|
||||
@ -517,10 +518,7 @@ static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
if (ngx_threaded || ngx_accept_token) {
|
||||
#endif
|
||||
if (ngx_accept_mutex_held) {
|
||||
if (ngx_threaded || ngx_accept_mutex_held) {
|
||||
|
||||
if (ev->accept) {
|
||||
ngx_mutex_unlock(ngx_posted_events_mutex);
|
||||
@ -533,7 +531,7 @@ static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
|
||||
}
|
||||
|
||||
} else {
|
||||
ev->next = ngx_posted_events;
|
||||
ev->next = (ngx_event_t *) ngx_posted_events;
|
||||
ngx_posted_events = ev;
|
||||
}
|
||||
|
||||
@ -551,11 +549,9 @@ static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
|
||||
ngx_event_expire_timers((ngx_msec_t) delta);
|
||||
}
|
||||
|
||||
#if (NGX_THREADS)
|
||||
if (ngx_threaded) {
|
||||
return NGX_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
for ( ;; ) {
|
||||
|
||||
@ -598,11 +594,6 @@ static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
|
||||
|
||||
static void ngx_kqueue_thread_handler(ngx_event_t *ev)
|
||||
{
|
||||
ngx_int_t instance;
|
||||
|
||||
instance = (uintptr_t) ev & 1;
|
||||
ev = (ngx_event_t *) ((uintptr_t) ev & (uintptr_t) ~1);
|
||||
|
||||
if ((!ev->posted && !ev->active)
|
||||
|| ev->instance != ev->returned_instance)
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ static int ngx_poll_init(ngx_cycle_t *cycle);
|
||||
static void ngx_poll_done(ngx_cycle_t *cycle);
|
||||
static int ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags);
|
||||
static int ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags);
|
||||
int ngx_poll_process_events(ngx_log_t *log);
|
||||
int ngx_poll_process_events(ngx_cycle_t *cycle);
|
||||
|
||||
|
||||
static struct pollfd *event_list;
|
||||
@ -49,7 +49,7 @@ ngx_module_t ngx_poll_module = {
|
||||
NULL, /* module directives */
|
||||
NGX_EVENT_MODULE, /* module type */
|
||||
NULL, /* init module */
|
||||
NULL /* init child */
|
||||
NULL /* init process */
|
||||
};
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ static int ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
|
||||
|
||||
static int ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
{
|
||||
ngx_int_t i;
|
||||
ngx_uint_t i;
|
||||
ngx_cycle_t **cycle;
|
||||
ngx_event_t *e;
|
||||
ngx_connection_t *c;
|
||||
@ -245,13 +245,14 @@ static int ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||
}
|
||||
|
||||
|
||||
int ngx_poll_process_events(ngx_log_t *log)
|
||||
int ngx_poll_process_events(ngx_cycle_t *cycle)
|
||||
{
|
||||
int ready;
|
||||
ngx_int_t i, j, nready, found;
|
||||
ngx_int_t i, nready;
|
||||
ngx_uint_t n, found;
|
||||
ngx_msec_t timer;
|
||||
ngx_err_t err;
|
||||
ngx_cycle_t **cycle;
|
||||
ngx_cycle_t **old_cycle;
|
||||
ngx_event_t *ev;
|
||||
ngx_epoch_msec_t delta;
|
||||
ngx_connection_t *c;
|
||||
@ -272,11 +273,12 @@ int ngx_poll_process_events(ngx_log_t *log)
|
||||
|
||||
#if (NGX_DEBUG0)
|
||||
for (i = 0; i < nevents; i++) {
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0, "poll: %d: fd:%d ev:%04X",
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"poll: %d: fd:%d ev:%04X",
|
||||
i, event_list[i].fd, event_list[i].events);
|
||||
}
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "poll timer: %d", timer);
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "poll timer: %d", timer);
|
||||
#endif
|
||||
|
||||
ready = poll(event_list, (u_int) nevents, (int) timer);
|
||||
@ -293,23 +295,23 @@ int ngx_poll_process_events(ngx_log_t *log)
|
||||
delta = ngx_elapsed_msec;
|
||||
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"poll ready %d of %d", ready, nevents);
|
||||
|
||||
if (err) {
|
||||
ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
|
||||
log, err, "poll() failed");
|
||||
cycle->log, err, "poll() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (timer != (ngx_msec_t) INFTIM) {
|
||||
delta = ngx_elapsed_msec - delta;
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"poll timer: %d, delta: %d", timer, (int) delta);
|
||||
} else {
|
||||
if (ready == 0) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
||||
"poll() returned no events without timeout");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -325,13 +327,13 @@ int ngx_poll_process_events(ngx_log_t *log)
|
||||
for (i = 0; i < nevents && ready; i++) {
|
||||
|
||||
#if 0
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"poll: %d: fd:%d ev:%04X rev:%04X",
|
||||
i, event_list[i].fd,
|
||||
event_list[i].events, event_list[i].revents);
|
||||
#else
|
||||
if (event_list[i].revents) {
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"poll: %d: fd:%d ev:%04X rev:%04X",
|
||||
i, event_list[i].fd,
|
||||
event_list[i].events, event_list[i].revents);
|
||||
@ -339,7 +341,7 @@ int ngx_poll_process_events(ngx_log_t *log)
|
||||
#endif
|
||||
|
||||
if (event_list[i].revents & (POLLERR|POLLHUP|POLLNVAL)) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
||||
"poll() error fd:%d ev:%04X rev:%04X",
|
||||
event_list[i].fd,
|
||||
event_list[i].events, event_list[i].revents);
|
||||
@ -347,7 +349,7 @@ int ngx_poll_process_events(ngx_log_t *log)
|
||||
|
||||
if (event_list[i].revents & ~(POLLIN|POLLOUT|POLLERR|POLLHUP|POLLNVAL))
|
||||
{
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
||||
"strange poll() events fd:%d ev:%04X rev:%04X",
|
||||
event_list[i].fd,
|
||||
event_list[i].events, event_list[i].revents);
|
||||
@ -363,12 +365,12 @@ int ngx_poll_process_events(ngx_log_t *log)
|
||||
c = &ngx_cycle->connections[event_list[i].fd];
|
||||
|
||||
if (c->fd == -1) {
|
||||
cycle = ngx_old_cycles.elts;
|
||||
for (j = 0; j < ngx_old_cycles.nelts; j++) {
|
||||
if (cycle[j] == NULL) {
|
||||
old_cycle = ngx_old_cycles.elts;
|
||||
for (n = 0; n < ngx_old_cycles.nelts; n++) {
|
||||
if (old_cycle[n] == NULL) {
|
||||
continue;
|
||||
}
|
||||
c = &cycle[j]->connections[event_list[i].fd];
|
||||
c = &old_cycle[n]->connections[event_list[i].fd];
|
||||
if (c->fd != -1) {
|
||||
break;
|
||||
}
|
||||
@ -376,7 +378,7 @@ int ngx_poll_process_events(ngx_log_t *log)
|
||||
}
|
||||
|
||||
if (c->fd == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0, "unexpected event");
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "unexpected event");
|
||||
|
||||
/*
|
||||
* it is certainly our fault and it should be investigated,
|
||||
@ -435,7 +437,7 @@ int ngx_poll_process_events(ngx_log_t *log)
|
||||
}
|
||||
|
||||
if (ready != 0) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0, "poll ready != events");
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "poll ready != events");
|
||||
}
|
||||
|
||||
if (timer != (ngx_msec_t) INFTIM && delta) {
|
||||
|
@ -39,8 +39,8 @@ static int ngx_rtsig_init(ngx_cycle_t *cycle);
|
||||
static void ngx_rtsig_done(ngx_cycle_t *cycle);
|
||||
static int ngx_rtsig_add_connection(ngx_connection_t *c);
|
||||
static int ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags);
|
||||
static int ngx_rtsig_process_events(ngx_log_t *log);
|
||||
static int ngx_rtsig_process_overflow(ngx_log_t *log);
|
||||
static int ngx_rtsig_process_events(ngx_cycle_t *cycle);
|
||||
static int ngx_rtsig_process_overflow(ngx_cycle_t *cycle);
|
||||
|
||||
static void *ngx_rtsig_create_conf(ngx_cycle_t *cycle);
|
||||
static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf);
|
||||
@ -188,14 +188,13 @@ static int ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags)
|
||||
}
|
||||
|
||||
|
||||
int ngx_rtsig_process_events(ngx_log_t *log)
|
||||
int ngx_rtsig_process_events(ngx_cycle_t *cycle)
|
||||
{
|
||||
int signo;
|
||||
ngx_int_t instance, i;
|
||||
size_t n;
|
||||
ngx_msec_t timer;
|
||||
ngx_err_t err;
|
||||
ngx_cycle_t **cycle;
|
||||
siginfo_t si;
|
||||
struct timeval tv;
|
||||
struct timespec ts, *tp;
|
||||
@ -216,7 +215,8 @@ int ngx_rtsig_process_events(ngx_log_t *log)
|
||||
tp = NULL;
|
||||
}
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "rtsig timer: %d", timer);
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"rtsig timer: %d", timer);
|
||||
|
||||
/* Linux sigwaitinfo() is sigtimedwait() with the NULL timeout pointer */
|
||||
|
||||
@ -236,18 +236,18 @@ int ngx_rtsig_process_events(ngx_log_t *log)
|
||||
|
||||
if (err) {
|
||||
ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
|
||||
log, err, "sigtimedwait() failed");
|
||||
cycle->log, err, "sigtimedwait() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (timer) {
|
||||
delta = ngx_elapsed_msec - delta;
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"rtsig timer: %d, delta: %d", timer, (int) delta);
|
||||
}
|
||||
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||
"signo:%d fd:%d band:%X", signo, si.si_fd, si.si_band);
|
||||
|
||||
rtscf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_rtsig_module);
|
||||
@ -255,6 +255,7 @@ int ngx_rtsig_process_events(ngx_log_t *log)
|
||||
if (signo == rtscf->signo) {
|
||||
|
||||
/* TODO: old_cycles */
|
||||
|
||||
c = &ngx_cycle->connections[si.si_fd];
|
||||
|
||||
/* TODO: stale signals */
|
||||
@ -274,7 +275,7 @@ int ngx_rtsig_process_events(ngx_log_t *log)
|
||||
}
|
||||
|
||||
} else if (signo == SIGIO) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
"signal queue overflowed: "
|
||||
"SIGIO, fd:%d, band:%X", si.si_fd, si.si_band);
|
||||
|
||||
@ -284,7 +285,7 @@ int ngx_rtsig_process_events(ngx_log_t *log)
|
||||
sa.sa_handler = SIG_DFL;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
if (sigaction(rtscf->signo, &sa, NULL) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
"sigaction(%d, SIG_DFL) failed", rtscf->signo);
|
||||
}
|
||||
|
||||
@ -297,7 +298,7 @@ int ngx_rtsig_process_events(ngx_log_t *log)
|
||||
|
||||
|
||||
} else {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
||||
"sigtimedwait() returned unexpected signal: %d", signo);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
@ -310,9 +311,9 @@ int ngx_rtsig_process_events(ngx_log_t *log)
|
||||
}
|
||||
|
||||
|
||||
static int ngx_rtsig_process_overflow(ngx_log_t *log)
|
||||
static int ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
|
||||
{
|
||||
if (ngx_poll_module_ctx.actions.process(log) == NGX_OK) {
|
||||
if (ngx_poll_module_ctx.actions.process(cycle) == NGX_OK) {
|
||||
ngx_event_actions = ngx_rtsig_module_ctx.actions;
|
||||
ngx_event_flags = NGX_USE_SIGIO_EVENT;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle)
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
ngx_accept_mutex_ptr = mmap(NULL, sizeof(ngx_atomic_t),
|
||||
ngx_accept_mutex_ptr = (ngx_atomic_t *) mmap(NULL, sizeof(ngx_atomic_t),
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_ANON|MAP_SHARED, -1, 0);
|
||||
|
||||
|
@ -381,6 +381,9 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *ev)
|
||||
p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
|
||||
|
||||
#if (HAVE_KQUEUE)
|
||||
|
||||
/* TODO: KEVENT_EVENT */
|
||||
|
||||
if (ev->kq_eof) {
|
||||
ev->eof = 1;
|
||||
|
||||
@ -405,6 +408,44 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *ev)
|
||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
n = recv(c->fd, buf, 1, MSG_PEEK);
|
||||
|
||||
if (n > 0) {
|
||||
/* TODO: delete level */
|
||||
return;
|
||||
}
|
||||
|
||||
if (n == -1) {
|
||||
err = ngx_socket_errno;
|
||||
if (err == NGX_EAGAIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
ev->error = 1;
|
||||
|
||||
} else if (n == 0) {
|
||||
err = 0;
|
||||
ev->eof = 1;
|
||||
}
|
||||
|
||||
if (!p->cachable && p->upstream->peer.connection) {
|
||||
ngx_log_error(NGX_LOG_INFO, ev->log, err,
|
||||
"client have closed prematurely connection, "
|
||||
"so upstream connection is closed too");
|
||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, ev->log, ev->err,
|
||||
"client have closed prematurely connection");
|
||||
|
||||
if (p->upstream == NULL || p->upstream->peer.connection == NULL) {
|
||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ void ngx_http_init_connection(ngx_connection_t *c)
|
||||
return;
|
||||
}
|
||||
|
||||
rev->next = ngx_posted_events;
|
||||
rev->next = (ngx_event_t *) ngx_posted_events;
|
||||
ngx_posted_events = rev;
|
||||
|
||||
ngx_mutex_unlock(ngx_posted_events_mutex);
|
||||
|
@ -43,7 +43,7 @@ ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
|
||||
str = strerror_r(err, errstr, size);
|
||||
|
||||
if (str != errstr) {
|
||||
return ngx_cpystrn(errstr, str, size) - errstr;
|
||||
return ngx_cpystrn(errstr, str, size) - (u_char *) errstr;
|
||||
}
|
||||
|
||||
for (len = 0; len < size; len++) {
|
||||
|
@ -26,7 +26,6 @@
|
||||
*/
|
||||
|
||||
|
||||
ngx_int_t ngx_threaded;
|
||||
char *ngx_freebsd_kern_usrstack;
|
||||
size_t ngx_thread_stack_size;
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <sys/resource.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h> /* TCP_CORK */
|
||||
|
@ -15,6 +15,7 @@ ngx_int_t ngx_process;
|
||||
ngx_pid_t ngx_pid;
|
||||
ngx_pid_t ngx_new_binary;
|
||||
ngx_int_t ngx_inherited;
|
||||
ngx_int_t ngx_threaded;
|
||||
|
||||
sig_atomic_t ngx_reap;
|
||||
sig_atomic_t ngx_timer;
|
||||
|
@ -26,6 +26,7 @@ extern ngx_int_t ngx_process;
|
||||
extern ngx_pid_t ngx_pid;
|
||||
extern ngx_pid_t ngx_new_binary;
|
||||
extern ngx_int_t ngx_inherited;
|
||||
extern ngx_int_t ngx_threaded;
|
||||
|
||||
extern sig_atomic_t ngx_reap;
|
||||
extern sig_atomic_t ngx_timer;
|
||||
|
@ -135,7 +135,7 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
||||
|
||||
ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
|
||||
{
|
||||
char *prev;
|
||||
u_char *prev;
|
||||
ssize_t n, size;
|
||||
struct iovec *iov;
|
||||
ngx_err_t err;
|
||||
|
@ -112,7 +112,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
|
||||
|
||||
#else /* ! NAVE_KQUEUE */
|
||||
|
||||
ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size)
|
||||
ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
|
||||
{
|
||||
ssize_t n;
|
||||
ngx_err_t err;
|
||||
|
@ -22,10 +22,11 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/filio.h> /* FIONBIO */
|
||||
#include <sys/stropts.h> /* INFTIM */
|
||||
#include <sys/mman.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sendfile.h>
|
||||
#include <sys/filio.h> /* FIONBIO */
|
||||
#include <sys/stropts.h> /* INFTIM */
|
||||
#include <sys/systeminfo.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
@ -102,9 +102,6 @@ ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try);
|
||||
ngx_int_t ngx_mutex_unlock(ngx_mutex_t *m);
|
||||
|
||||
|
||||
extern ngx_int_t ngx_threaded;
|
||||
|
||||
|
||||
#else /* !NGX_THREADS */
|
||||
|
||||
#define ngx_thread_volatile
|
||||
|
@ -20,72 +20,3 @@ void ngx_localtime(ngx_tm_t *tm)
|
||||
tm->ngx_tm_mon++;
|
||||
tm->ngx_tm_year += 1900;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
typedef struct {
|
||||
int busy;
|
||||
u_int_64 msec;
|
||||
time_t sec;
|
||||
tm;
|
||||
http_time_len;
|
||||
http_time[n];
|
||||
};
|
||||
|
||||
volatile *ngx_time_p;
|
||||
|
||||
ngx_time()
|
||||
{
|
||||
p = ngx_time_p;
|
||||
}
|
||||
|
||||
ngx_update_time()
|
||||
{
|
||||
u_int64 msec;
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
msec = (unsigned long) tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
p = ngx_time_p;
|
||||
|
||||
/* minimum can be for example 0, 10, 50 or 100 ms */
|
||||
if (tv_sec > p->sec || msec - p->msec >= minimum) {
|
||||
old_p = p;
|
||||
/* max_tries < max_slots - 10,
|
||||
max_slots should be more than max of threads */
|
||||
for (/* void */; i < max_tries; i++) {
|
||||
if (++p >= last_slot)
|
||||
p = first_slot;
|
||||
|
||||
if (!test_and_set(p->busy)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == max_tries) {
|
||||
ngx_log_error();
|
||||
return;
|
||||
}
|
||||
|
||||
if (tv_sec > p->sec) {
|
||||
p->sec = tv.tv.sec;
|
||||
p->msec = msec;
|
||||
localtime_r(&tv.tv_sec, tm);
|
||||
make http stirng;
|
||||
|
||||
} else {
|
||||
ngx_memcpy(p->sec, old_p->sec, sizeof() - offset_of(, sec));
|
||||
p->msec = msec;
|
||||
}
|
||||
|
||||
/* here can be too seldom and non-critical race condition */
|
||||
if (ngx_time_p == old_p)
|
||||
ngx_time_p = p;
|
||||
|
||||
unlock(p->busy);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -26,6 +26,7 @@ extern ngx_int_t ngx_process;
|
||||
extern ngx_pid_t ngx_pid;
|
||||
extern ngx_pid_t ngx_new_binary;
|
||||
extern ngx_int_t ngx_inherited;
|
||||
extern ngx_int_t ngx_threaded;
|
||||
|
||||
extern sig_atomic_t ngx_reap;
|
||||
extern sig_atomic_t ngx_timer;
|
||||
|
Loading…
Reference in New Issue
Block a user