mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 14:13:33 -06:00
nginx-0.0.1-2004-01-22-20:10:46 import
This commit is contained in:
parent
d8e1f07a93
commit
54c80845ea
@ -233,12 +233,10 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
char *name;
|
char *name;
|
||||||
sigset_t set, wset;
|
sigset_t set, wset;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
ngx_uint_t i, live, sent;
|
ngx_uint_t i, live;
|
||||||
ngx_msec_t delay;
|
ngx_msec_t delay;
|
||||||
ngx_core_conf_t *ccf;
|
ngx_core_conf_t *ccf;
|
||||||
|
|
||||||
delay = 125;
|
|
||||||
|
|
||||||
sigemptyset(&set);
|
sigemptyset(&set);
|
||||||
sigaddset(&set, SIGCHLD);
|
sigaddset(&set, SIGCHLD);
|
||||||
sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL));
|
sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL));
|
||||||
@ -255,10 +253,12 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
"sigprocmask() failed");
|
"sigprocmask() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngx_setproctitle("master process");
|
||||||
|
|
||||||
ngx_signal = 0;
|
ngx_signal = 0;
|
||||||
ngx_new_binary = 0;
|
ngx_new_binary = 0;
|
||||||
|
delay = 0;
|
||||||
signo = 0;
|
signo = 0;
|
||||||
sent = 0;
|
|
||||||
live = 0;
|
live = 0;
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
@ -294,9 +294,9 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
|
|
||||||
if (ngx_process == NGX_PROCESS_MASTER) {
|
if (ngx_process == NGX_PROCESS_MASTER) {
|
||||||
if (sent) {
|
if (delay) {
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||||
"sent signal cycle");
|
"temination cycle");
|
||||||
|
|
||||||
if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1) {
|
if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
@ -311,9 +311,7 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
|
|
||||||
if (!ngx_signal) {
|
if (!ngx_signal) {
|
||||||
|
|
||||||
if (delay < 15000) {
|
delay *= 2;
|
||||||
delay *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||||
"msleep %d", delay);
|
"msleep %d", delay);
|
||||||
@ -358,7 +356,6 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
if (ngx_reap) {
|
if (ngx_reap) {
|
||||||
ngx_reap = 0;
|
ngx_reap = 0;
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||||
|
|
||||||
"reap childs");
|
"reap childs");
|
||||||
|
|
||||||
live = 0;
|
live = 0;
|
||||||
@ -413,10 +410,6 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
live = 1;
|
live = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!live) {
|
|
||||||
sent = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!live && (ngx_terminate || ngx_quit)) {
|
if (!live && (ngx_terminate || ngx_quit)) {
|
||||||
@ -424,7 +417,11 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_terminate) {
|
if (ngx_terminate) {
|
||||||
if (delay > 10000) {
|
if (delay == 0) {
|
||||||
|
delay = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delay > 1000) {
|
||||||
signo = SIGKILL;
|
signo = SIGKILL;
|
||||||
} else {
|
} else {
|
||||||
signo = ngx_signal_value(NGX_TERMINATE_SIGNAL);
|
signo = ngx_signal_value(NGX_TERMINATE_SIGNAL);
|
||||||
@ -467,7 +464,8 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
|
|
||||||
ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
|
ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
|
||||||
"reopening logs");
|
"reopening logs");
|
||||||
ngx_reopen_files(cycle);
|
ngx_reopen_files(cycle,
|
||||||
|
ccf->worker_reopen > 0 ? ccf->user : -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +481,6 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
ngx_processes[i].pid, signo);
|
ngx_processes[i].pid, signo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay = 125;
|
|
||||||
signo = 0;
|
signo = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,7 +508,6 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
if (ngx_processes[i].signal
|
if (ngx_processes[i].signal
|
||||||
!= ngx_signal_value(NGX_REOPEN_SIGNAL))
|
!= ngx_signal_value(NGX_REOPEN_SIGNAL))
|
||||||
{
|
{
|
||||||
sent = 1;
|
|
||||||
ngx_processes[i].exiting = 1;
|
ngx_processes[i].exiting = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -623,6 +619,8 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngx_setproctitle("worker process");
|
||||||
|
|
||||||
/* TODO: threads: start ngx_worker_thread_cycle() */
|
/* TODO: threads: start ngx_worker_thread_cycle() */
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
@ -638,12 +636,13 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
|
|||||||
if (ngx_quit) {
|
if (ngx_quit) {
|
||||||
ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
|
ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
|
||||||
"gracefully shutdowning");
|
"gracefully shutdowning");
|
||||||
|
ngx_setproctitle("worker process is shutdowning");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_reopen) {
|
if (ngx_reopen) {
|
||||||
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs");
|
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs");
|
||||||
ngx_reopen_files(cycle);
|
ngx_reopen_files(cycle, -1);
|
||||||
ngx_reopen = 0;
|
ngx_reopen = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,9 @@ typedef int ngx_flag_t;
|
|||||||
/* STUB: autoconf */
|
/* STUB: autoconf */
|
||||||
#define PTR_FMT "%08X"
|
#define PTR_FMT "%08X"
|
||||||
|
|
||||||
|
/* STUB: autoconf */
|
||||||
|
#define ngx_setproctitle setproctitle
|
||||||
|
|
||||||
#include <ngx_auto_config.h>
|
#include <ngx_auto_config.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_reopen_files(ngx_cycle_t *cycle)
|
void ngx_reopen_files(ngx_cycle_t *cycle, uid_t user)
|
||||||
{
|
{
|
||||||
ngx_fd_t fd;
|
ngx_fd_t fd;
|
||||||
ngx_int_t i;
|
ngx_int_t i;
|
||||||
@ -387,6 +387,19 @@ void ngx_reopen_files(ngx_cycle_t *cycle)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user != (uid_t) -1) {
|
||||||
|
if (chown(file[i].name.data, user, -1) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||||
|
"chown \"%s\" failed", file[i].name.data);
|
||||||
|
|
||||||
|
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||||
|
ngx_close_file_n " \"%s\" failed",
|
||||||
|
file[i].name.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if (WIN32)
|
#if (WIN32)
|
||||||
if (ngx_file_append_mode(fd) == NGX_ERROR) {
|
if (ngx_file_append_mode(fd) == NGX_ERROR) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||||
|
@ -26,7 +26,7 @@ struct ngx_cycle_s {
|
|||||||
|
|
||||||
|
|
||||||
ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle);
|
ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle);
|
||||||
void ngx_reopen_files(ngx_cycle_t *cycle);
|
void ngx_reopen_files(ngx_cycle_t *cycle, uid_t user);
|
||||||
|
|
||||||
|
|
||||||
extern volatile ngx_cycle_t *ngx_cycle;
|
extern volatile ngx_cycle_t *ngx_cycle;
|
||||||
|
Loading…
Reference in New Issue
Block a user