mirror of
https://github.com/nginx/nginx.git
synced 2025-01-22 14:23:18 -06:00
nginx-0.0.1-2003-07-03-20:30:22 import
This commit is contained in:
parent
9d9f58f24d
commit
7349befe26
@ -22,7 +22,9 @@ int ngx_max_module;
|
||||
int ngx_connection_counter;
|
||||
|
||||
|
||||
#if 1
|
||||
int restart;
|
||||
int rotate;
|
||||
|
||||
|
||||
int main(int argc, char *const *argv)
|
||||
{
|
||||
@ -53,6 +55,8 @@ int main(int argc, char *const *argv)
|
||||
/* life cycle */
|
||||
|
||||
for ( ;; ) {
|
||||
/* STUB */ cycle->log->file->fd = log->file->fd;
|
||||
/* STUB */ cycle->log->log_level = NGX_LOG_DEBUG;
|
||||
|
||||
/* STUB */
|
||||
ngx_io = ngx_os_io;
|
||||
@ -66,9 +70,26 @@ int main(int argc, char *const *argv)
|
||||
|
||||
/* threads */
|
||||
|
||||
restart = 0;
|
||||
rotate = 0;
|
||||
|
||||
for ( ;; ) {
|
||||
|
||||
ngx_worker(cycle);
|
||||
for ( ;; ) {
|
||||
ngx_log_debug(cycle->log, "worker cycle");
|
||||
|
||||
ngx_process_events(cycle->log);
|
||||
|
||||
if (rotate) {
|
||||
ngx_log_debug(cycle->log, "rotate");
|
||||
}
|
||||
|
||||
if (restart) {
|
||||
ngx_log_debug(cycle->log, "restart");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new_cycle = ngx_init_cycle(cycle, cycle->log);
|
||||
if (new_cycle == NULL) {
|
||||
@ -316,7 +337,7 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
|
||||
|
||||
|
||||
|
||||
#else
|
||||
#if 0
|
||||
|
||||
|
||||
int main(int argc, char *const *argv)
|
||||
|
@ -40,4 +40,8 @@ extern int ngx_max_sockets;
|
||||
extern int ngx_inherited_nonblocking;
|
||||
|
||||
|
||||
extern int restart;
|
||||
extern int rotate;
|
||||
|
||||
|
||||
#endif /* _NGX_OS_INIT_H_INCLUDED_ */
|
||||
|
@ -11,8 +11,11 @@
|
||||
|
||||
|
||||
typedef struct {
|
||||
u_int changes;
|
||||
u_int events;
|
||||
int kqueue;
|
||||
struct kevent *change_list;
|
||||
u_int changes;
|
||||
struct kevent *event_list;
|
||||
u_int events;
|
||||
} ngx_kqueue_conf_t;
|
||||
|
||||
|
||||
@ -83,6 +86,138 @@ ngx_module_t ngx_kqueue_module = {
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
static int ngx_kqueue_init(ngx_cycle_t *cycle, ngx_log_t *log)
|
||||
{
|
||||
struct timespec ts;
|
||||
ngx_kqueue_conf_t *kcf;
|
||||
|
||||
kcf = ngx_event_get_conf(cycle->conf_ctx, ngx_kqueue_module);
|
||||
|
||||
ngx_log_debug(log, "CH: %d" _ kcf->changes);
|
||||
ngx_log_debug(log, "EV: %d" _ kcf->events);
|
||||
|
||||
if (ngx_kqueue == -1) {
|
||||
kcf->kqueue = kqueue();
|
||||
|
||||
if (kcf->kqueue == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "kqueue() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
kcf->kqueue = ngx_kqueue;
|
||||
}
|
||||
|
||||
if (max_changes < kcf->changes) {
|
||||
if (nchanges) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 0;
|
||||
|
||||
if (kevent(ngx_kqueue, change_list, nchanges, NULL, 0, &ts) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "kevent() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
nchanges = 0;
|
||||
}
|
||||
|
||||
ngx_test_null(kcf->change_list,
|
||||
ngx_alloc(kcf->changes * sizeof(struct kevent), log),
|
||||
NGX_ERROR);
|
||||
|
||||
} else {
|
||||
kcf->change_list = change_list;
|
||||
}
|
||||
|
||||
if (nevents < kcf->events) {
|
||||
ngx_test_null(kcf->event_list,
|
||||
ngx_alloc(kcf->events * sizeof(struct kevent), log),
|
||||
NGX_ERROR);
|
||||
} else {
|
||||
kcf->event_list = event_list;
|
||||
}
|
||||
|
||||
if (ngx_event_timer_init(cycle, log) == NGX_ERROR) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static void ngx_kqueue_commit(ngx_cycle_t *cycle, ngx_log_t *log)
|
||||
{
|
||||
ngx_kqueue_conf_t *kcf;
|
||||
|
||||
kcf = ngx_event_get_conf(cycle->conf_ctx, ngx_kqueue_module);
|
||||
|
||||
ngx_kqueue = kcf->kqueue;
|
||||
|
||||
if (change_list != kcf->change_list) {
|
||||
ngx_free(change_list);
|
||||
change_list = kcf->change_list;
|
||||
}
|
||||
|
||||
max_changes = kcf->changes;
|
||||
|
||||
if (event_list != kcf->event_list) {
|
||||
ngx_free(event_list);
|
||||
event_list = kcf->event_list;
|
||||
}
|
||||
|
||||
nevents = kcf->events;
|
||||
|
||||
ngx_event_timer_commit(cycle, log);
|
||||
|
||||
/* TODO: re-add active events with new udata
|
||||
if ecf->connections was increased */
|
||||
|
||||
ngx_event_actions = ngx_kqueue_module_ctx.actions;
|
||||
ngx_io = ngx_os_io;
|
||||
|
||||
ngx_event_flags = NGX_HAVE_LEVEL_EVENT
|
||||
|NGX_HAVE_ONESHOT_EVENT
|
||||
#if (HAVE_CLEAR_EVENT)
|
||||
|NGX_HAVE_CLEAR_EVENT
|
||||
#else
|
||||
|NGX_USE_LEVEL_EVENT
|
||||
#endif
|
||||
#if (HAVE_LOWAT_EVENT)
|
||||
|NGX_HAVE_LOWAT_EVENT
|
||||
#endif
|
||||
|NGX_HAVE_KQUEUE_EVENT;
|
||||
}
|
||||
|
||||
|
||||
static void ngx_kqueue_rollback(ngx_cycle_t *cycle, ngx_log_t *log)
|
||||
{
|
||||
ngx_kqueue_conf_t *kcf;
|
||||
|
||||
kcf = ngx_event_get_conf(cycle->conf_ctx, ngx_kqueue_module);
|
||||
|
||||
if (ngx_kqueue == -1) {
|
||||
if (close(kcf->kqueue) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
||||
"kqueue close() failed");
|
||||
}
|
||||
}
|
||||
|
||||
if (change_list != kcf->change_list) {
|
||||
ngx_free(kcf->change_list);
|
||||
}
|
||||
|
||||
if (event_list != kcf->event_list) {
|
||||
ngx_free(kcf->event_list);
|
||||
}
|
||||
|
||||
ngx_event_timer_rollback(cycle, log);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static int ngx_kqueue_init(ngx_log_t *log)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
@ -7,6 +7,10 @@ int ngx_max_sockets;
|
||||
int ngx_inherited_nonblocking;
|
||||
|
||||
|
||||
void ngx_restart_signal_handler(int signo);
|
||||
void ngx_rotate_signal_handler(int signo);
|
||||
|
||||
|
||||
int ngx_posix_init(ngx_log_t *log)
|
||||
{
|
||||
struct sigaction sa;
|
||||
@ -15,13 +19,26 @@ int ngx_posix_init(ngx_log_t *log)
|
||||
ngx_memzero(&sa, sizeof(struct sigaction));
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
if (sigaction(SIGPIPE, &sa, NULL) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
||||
"sigaction(SIGPIPE, SIG_IGN) failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
sa.sa_handler = ngx_restart_signal_handler;
|
||||
if (sigaction(SIGHUP, &sa, NULL) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
||||
"sigaction(SIGHUP) failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
sa.sa_handler = ngx_rotate_signal_handler;
|
||||
if (sigaction(SIGUSR1, &sa, NULL) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
||||
"sigaction(SIGUSR1) failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, errno,
|
||||
@ -45,6 +62,18 @@ int ngx_posix_init(ngx_log_t *log)
|
||||
}
|
||||
|
||||
|
||||
void ngx_restart_signal_handler(int signo)
|
||||
{
|
||||
restart = 1;
|
||||
}
|
||||
|
||||
|
||||
void ngx_rotate_signal_handler(int signo)
|
||||
{
|
||||
rotate = 1;
|
||||
}
|
||||
|
||||
|
||||
int ngx_posix_post_conf_init(ngx_log_t *log)
|
||||
{
|
||||
ngx_fd_t pp[2];
|
||||
|
Loading…
Reference in New Issue
Block a user