mirror of
https://github.com/nginx/nginx.git
synced 2024-11-26 02:40:46 -06:00
nginx-0.0.2-2004-02-05-19:58:36 import
This commit is contained in:
parent
c537167285
commit
9260294400
@ -12,6 +12,7 @@ do
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
@ -28,6 +28,9 @@ NGX_AUTO_CONFIG="#include \"../$NGX_AUTO_CONFIG_H\""
|
|||||||
ngx_type="uint64_t"
|
ngx_type="uint64_t"
|
||||||
ngx_types="u_int64_t"; . auto/types/typedef
|
ngx_types="u_int64_t"; . auto/types/typedef
|
||||||
|
|
||||||
|
#ngx_type="sig_atomic_t"
|
||||||
|
#ngx_types="int"; . auto/types/typedef
|
||||||
|
|
||||||
ngx_type="socklen_t"
|
ngx_type="socklen_t"
|
||||||
ngx_types="uint32_t"; . auto/types/typedef
|
ngx_types="uint32_t"; . auto/types/typedef
|
||||||
|
|
||||||
|
@ -384,6 +384,8 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
|
|
||||||
if (ngx_processes[i].pid == ngx_new_binary) {
|
if (ngx_processes[i].pid == ngx_new_binary) {
|
||||||
ngx_new_binary = 0;
|
ngx_new_binary = 0;
|
||||||
|
|
||||||
|
/* TODO: if (ngx_noaccept) ngx_configure = 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != --ngx_last_process) {
|
if (i != --ngx_last_process) {
|
||||||
@ -444,6 +446,10 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
if (ccf->worker_reopen > 0) {
|
if (ccf->worker_reopen > 0) {
|
||||||
signo = ngx_signal_value(NGX_REOPEN_SIGNAL);
|
signo = ngx_signal_value(NGX_REOPEN_SIGNAL);
|
||||||
ngx_reopen = 0;
|
ngx_reopen = 0;
|
||||||
|
|
||||||
|
} else if (ngx_noaccept) {
|
||||||
|
ngx_reopen = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
|
signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ static int ngx_poll_process_events(ngx_log_t *log);
|
|||||||
static struct pollfd *event_list;
|
static struct pollfd *event_list;
|
||||||
static int nevents;
|
static int nevents;
|
||||||
|
|
||||||
static ngx_event_t **event_index;
|
|
||||||
static ngx_event_t **ready_index;
|
static ngx_event_t **ready_index;
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +57,6 @@ ngx_module_t ngx_poll_module = {
|
|||||||
static int ngx_poll_init(ngx_cycle_t *cycle)
|
static int ngx_poll_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
struct pollfd *list;
|
struct pollfd *list;
|
||||||
ngx_event_t **index;
|
|
||||||
|
|
||||||
if (event_list == NULL) {
|
if (event_list == NULL) {
|
||||||
nevents = 0;
|
nevents = 0;
|
||||||
@ -79,18 +77,6 @@ static int ngx_poll_init(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
event_list = list;
|
event_list = list;
|
||||||
|
|
||||||
ngx_test_null(index,
|
|
||||||
ngx_alloc(sizeof(ngx_event_t *) * cycle->connection_n,
|
|
||||||
cycle->log),
|
|
||||||
NGX_ERROR);
|
|
||||||
|
|
||||||
if (event_index) {
|
|
||||||
ngx_memcpy(index, event_index, sizeof(ngx_event_t *) * nevents);
|
|
||||||
ngx_free(event_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
event_index = index;
|
|
||||||
|
|
||||||
if (ready_index) {
|
if (ready_index) {
|
||||||
ngx_free(ready_index);
|
ngx_free(ready_index);
|
||||||
}
|
}
|
||||||
@ -114,11 +100,9 @@ static int ngx_poll_init(ngx_cycle_t *cycle)
|
|||||||
static void ngx_poll_done(ngx_cycle_t *cycle)
|
static void ngx_poll_done(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_free(event_list);
|
ngx_free(event_list);
|
||||||
ngx_free(event_index);
|
|
||||||
ngx_free(ready_index);
|
ngx_free(ready_index);
|
||||||
|
|
||||||
event_list = NULL;
|
event_list = NULL;
|
||||||
event_index = NULL;
|
|
||||||
ready_index = NULL;
|
ready_index = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,9 +120,6 @@ static int ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ev->active = 1;
|
|
||||||
ev->oneshot = (flags & NGX_ONESHOT_EVENT) ? 1 : 0;
|
|
||||||
|
|
||||||
if (event == NGX_READ_EVENT) {
|
if (event == NGX_READ_EVENT) {
|
||||||
e = c->write;
|
e = c->write;
|
||||||
#if (NGX_READ_EVENT != POLLIN)
|
#if (NGX_READ_EVENT != POLLIN)
|
||||||
@ -160,7 +141,6 @@ static int ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
event_list[nevents].events = event;
|
event_list[nevents].events = event;
|
||||||
event_list[nevents].revents = 0;
|
event_list[nevents].revents = 0;
|
||||||
|
|
||||||
event_index[nevents] = ev;
|
|
||||||
ev->index = nevents;
|
ev->index = nevents;
|
||||||
nevents++;
|
nevents++;
|
||||||
|
|
||||||
@ -172,18 +152,26 @@ static int ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
ev->index = e->index;
|
ev->index = e->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ev->active = 1;
|
||||||
|
ev->oneshot = (flags & NGX_ONESHOT_EVENT) ? 1 : 0;
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ngx_poll_del_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_event_t *e;
|
ngx_int_t i;
|
||||||
ngx_connection_t *c;
|
ngx_cycle_t **cycle;
|
||||||
|
ngx_event_t *e;
|
||||||
|
ngx_connection_t *c;
|
||||||
|
|
||||||
c = (ngx_connection_t *) ev->data;
|
c = ev->data;
|
||||||
|
|
||||||
if (ev->index == NGX_INVALID_INDEX) {
|
if (ev->index == NGX_INVALID_INDEX) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
|
||||||
|
"poll event fd:%d ev:%d is already deleted",
|
||||||
|
c->fd, event);
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +196,38 @@ static int ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
|
|
||||||
if (ev->index < (u_int) nevents) {
|
if (ev->index < (u_int) nevents) {
|
||||||
event_list[ev->index] = event_list[nevents];
|
event_list[ev->index] = event_list[nevents];
|
||||||
event_index[ev->index] = event_index[nevents];
|
|
||||||
event_index[ev->index]->index = ev->index;
|
c = &ngx_cycle->connections[event_list[nevents].fd];
|
||||||
|
|
||||||
|
if (c->fd == -1) {
|
||||||
|
cycle = ngx_old_cycles.elts;
|
||||||
|
for (i = 0; i < ngx_old_cycles.nelts; i++) {
|
||||||
|
if (cycle[i] == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
c = &cycle[i]->connections[event_list[nevents].fd];
|
||||||
|
if (c->fd != -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->fd == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
|
||||||
|
"unexpected last event");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (c->read->index == (u_int) nevents) {
|
||||||
|
c->read->index = ev->index;
|
||||||
|
|
||||||
|
} else if (c->write->index == (u_int) nevents) {
|
||||||
|
c->write->index = ev->index;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
|
||||||
|
"unexpected last event index");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -228,7 +246,8 @@ static int ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
|
|
||||||
static int ngx_poll_process_events(ngx_log_t *log)
|
static int ngx_poll_process_events(ngx_log_t *log)
|
||||||
{
|
{
|
||||||
int i, j, ready, nready, found;
|
int ready;
|
||||||
|
ngx_int_t i, j, nready, found;
|
||||||
ngx_msec_t timer;
|
ngx_msec_t timer;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
ngx_cycle_t **cycle;
|
ngx_cycle_t **cycle;
|
||||||
@ -244,7 +263,7 @@ static int ngx_poll_process_events(ngx_log_t *log)
|
|||||||
timer = (ngx_msec_t) INFTIM;
|
timer = (ngx_msec_t) INFTIM;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
#if (NGX_DEBUG0)
|
||||||
for (i = 0; i < nevents; i++) {
|
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, log, 0, "poll: %d: fd:%d ev:%04X",
|
||||||
i, event_list[i].fd, event_list[i].events);
|
i, event_list[i].fd, event_list[i].events);
|
||||||
@ -292,10 +311,19 @@ static int ngx_poll_process_events(ngx_log_t *log)
|
|||||||
|
|
||||||
for (i = 0; i < nevents && ready; i++) {
|
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, log, 0,
|
||||||
"poll: %d: fd:%d ev:%04X rev:%04X",
|
"poll: %d: fd:%d ev:%04X rev:%04X",
|
||||||
i, event_list[i].fd,
|
i, event_list[i].fd,
|
||||||
event_list[i].events, event_list[i].revents);
|
event_list[i].events, event_list[i].revents);
|
||||||
|
#else
|
||||||
|
if (event_list[i].revents) {
|
||||||
|
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, log, 0,
|
||||||
|
"poll: %d: fd:%d ev:%04X rev:%04X",
|
||||||
|
i, event_list[i].fd,
|
||||||
|
event_list[i].events, event_list[i].revents);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (event_list[i].revents & (POLLERR|POLLHUP|POLLNVAL)) {
|
if (event_list[i].revents & (POLLERR|POLLHUP|POLLNVAL)) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||||
@ -335,7 +363,7 @@ static int ngx_poll_process_events(ngx_log_t *log)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c->fd == -1) {
|
if (c->fd == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, log, 0, "unknown cycle");
|
ngx_log_error(NGX_LOG_ALERT, log, 0, "unexpected event");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* it is certainly our fault and it should be investigated,
|
* it is certainly our fault and it should be investigated,
|
||||||
|
@ -149,9 +149,8 @@ void ngx_signal_handler(int signo)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ngx_signal_value(NGX_CHANGEBIN_SIGNAL):
|
case ngx_signal_value(NGX_CHANGEBIN_SIGNAL):
|
||||||
if ((ngx_inherited && getppid() > 1)
|
if (getppid() > 1 || ngx_new_binary > 0) {
|
||||||
|| (!ngx_inherited && ngx_new_binary > 0))
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Ignore the signal in the new binary if its parent is
|
* Ignore the signal in the new binary if its parent is
|
||||||
* not the init process, i.e. the old binary's process
|
* not the init process, i.e. the old binary's process
|
||||||
|
Loading…
Reference in New Issue
Block a user