nginx-0.0.7-2004-07-13-21:59:12 import

This commit is contained in:
Igor Sysoev 2004-07-13 17:59:12 +00:00
parent 643c8ea353
commit a14f89c068
12 changed files with 96 additions and 42 deletions

View File

@ -163,6 +163,12 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...);
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \
arg1, arg2, arg3, arg4, arg5, arg6)
#define ngx_log_debug7(level, log, err, fmt, \
arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
if (log->log_level & level) \
ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \
arg1, arg2, arg3, arg4, arg5, arg6, arg7)
#else /* NO VARIADIC MACROS */
#define ngx_log_debug0(level, log, err, fmt) \
@ -194,6 +200,12 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...);
if (log->log_level & level) \
ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
#define ngx_log_debug7(level, log, err, fmt, \
arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
if (log->log_level & level) \
ngx_log_debug_core(log, err, fmt, \
arg1, arg2, arg3, arg4, arg5, arg6, arg7)
#endif
#else /* NO NGX_DEBUG */
@ -205,6 +217,8 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...);
#define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)
#define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
#define ngx_log_debug6(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
#define ngx_log_debug7(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6,
arg7)
#endif

View File

@ -405,7 +405,8 @@ int ngx_devpoll_process_events(ngx_cycle_t *cycle)
ngx_time_update(tv.tv_sec);
delta = ngx_elapsed_msec;
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
+ tv.tv_usec / 1000 - ngx_start_msec;
if (err) {
ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,

View File

@ -459,7 +459,8 @@ int ngx_epoll_process_events(ngx_cycle_t *cycle)
ngx_time_update(tv.tv_sec);
delta = ngx_elapsed_msec;
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
+ tv.tv_usec / 1000 - ngx_start_msec;
if (timer != NGX_TIMER_INFINITE) {
delta = ngx_elapsed_msec - delta;

View File

@ -198,7 +198,8 @@ static ngx_int_t ngx_iocp_process_events(ngx_cycle_t *cycle)
"iocp: %d b:%d k:%d ov:" PTR_FMT, rc, bytes, key, ovlp);
delta = ngx_elapsed_msec;
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
+ tv.tv_usec / 1000 - ngx_start_msec;
if (err) {
if (ovlp == NULL) {

View File

@ -527,9 +527,6 @@ static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
+ tv.tv_usec / 1000 - ngx_start_msec;
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"elapsed: %qd", ngx_elapsed_msec);
if (err) {
ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT,
cycle->log, err, "kevent() failed");

View File

@ -341,7 +341,8 @@ static ngx_int_t ngx_poll_process_events(ngx_cycle_t *cycle)
ngx_time_update(tv.tv_sec);
delta = ngx_elapsed_msec;
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
+ tv.tv_usec / 1000 - ngx_start_msec;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"poll ready %d of %d", ready, nevents);

View File

@ -389,7 +389,8 @@ ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle)
ngx_time_update(tv.tv_sec);
delta = ngx_elapsed_msec;
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
+ tv.tv_usec / 1000 - ngx_start_msec;
if (err) {
ngx_accept_mutex_unlock();

View File

@ -378,8 +378,8 @@ static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle)
ngx_time_update(tv.tv_sec);
deltas = tv.tv_usec / 1000;
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000
- ngx_start_msec;
ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
+ tv.tv_usec / 1000 - ngx_start_msec;
} else {
ngx_elapsed_msec += delta;
}
@ -392,8 +392,9 @@ static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle)
ngx_gettimeofday(&tv);
ngx_time_update(tv.tv_sec);
ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000
- ngx_start_msec;
ngx_elapsed_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000
+ tv.tv_usec / 1000 - ngx_start_msec;
if (ready == 0) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
"select() returned no events without timeout");

View File

@ -148,12 +148,19 @@ static ngx_int_t ngx_http_charset_header_filter(ngx_http_request_t *r)
}
#endif
if (r->headers_out.content_type == NULL
|| ngx_strncasecmp(r->headers_out.content_type->value.data,
if (r->headers_out.content_type == NULL) {
return ngx_http_next_header_filter(r);
}
if (ngx_strncasecmp(r->headers_out.content_type->value.data,
"text/", 5) != 0
|| ngx_strstr(r->headers_out.content_type->value.data, "charset")
!= NULL
)
&& ngx_strncasecmp(r->headers_out.content_type->value.data,
"application/x-javascript", 24) != 0)
{
return ngx_http_next_header_filter(r);
}
if (ngx_strstr(r->headers_out.content_type->value.data, "charset") != NULL)
{
return ngx_http_next_header_filter(r);
}

View File

@ -125,7 +125,8 @@ static ngx_int_t ngx_http_headers_filter(ngx_http_request_t *r)
cc->value.data = (u_char *) "no-cache";
} else {
cc->value.data = ngx_palloc(r->pool, TIME_T_LEN + 1);
cc->value.data = ngx_palloc(r->pool,
sizeof("max-age=") + TIME_T_LEN + 1);
if (cc->value.data == NULL) {
return NGX_ERROR;
}

View File

@ -20,7 +20,23 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t pid;
ngx_int_t s;
s = respawn >= 0 ? respawn : ngx_last_process;
if (respawn >= 0) {
s = respawn;
} else {
for (s = 0; s < ngx_last_process; s++) {
if (ngx_processes[s].pid == -1) {
break;
}
}
if (s == NGX_MAX_PROCESSES) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
"no more than %d processes can be spawned",
NGX_MAX_PROCESSES);
return NGX_ERROR;
}
}
if (respawn != NGX_PROCESS_DETACHED) {
@ -146,7 +162,9 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
break;
}
ngx_last_process++;
if (s == ngx_last_process) {
ngx_last_process++;
}
return pid;
}
@ -220,7 +238,7 @@ void ngx_process_get_status()
one = 1;
process = "";
process = "unknown process";
for (i = 0; i < ngx_last_process; i++) {
if (ngx_processes[i].pid == pid) {
@ -231,10 +249,6 @@ void ngx_process_get_status()
}
}
if (i == ngx_last_process) {
process = "unknown process";
}
if (WTERMSIG(status)) {
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
"%s " PID_T_FMT " exited on signal %d%s",

View File

@ -306,11 +306,17 @@ static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
ch.slot = ngx_process_slot;
ch.fd = ngx_processes[ngx_process_slot].channel[0];
for (i = 0; i < ngx_last_process - 1; i++) {
for (i = 0; i < ngx_last_process; i++) {
ngx_log_debug4(NGX_LOG_DEBUG_CORE, cycle->log, 0,
"pass channel s: %d pid:" PID_T_FMT " fd:%d to:"
PID_T_FMT, ch.slot, ch.pid, ch.fd, ngx_processes[i].pid);
if (i == ngx_process_slot || ngx_processes[i].pid == -1) {
continue;
}
ngx_log_debug5(NGX_LOG_DEBUG_CORE, cycle->log, 0,
"pass channel s:%d pid:" PID_T_FMT
" fd:%d to s:%d pid:" PID_T_FMT,
ch.slot, ch.pid, ch.fd,
i, ngx_processes[i].pid);
/* TODO: NGX_AGAIN */
@ -367,7 +373,7 @@ static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
for (i = 0; i < ngx_last_process; i++) {
if (ngx_processes[i].detached) {
if (ngx_processes[i].detached || ngx_processes[i].pid == -1) {
continue;
}
@ -432,8 +438,9 @@ static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle)
live = 0;
for (i = 0; i < ngx_last_process; i++) {
ngx_log_debug6(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"child: " PID_T_FMT " e:%d t:%d d:%d r:%d j:%d",
ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"child: %d " PID_T_FMT " e:%d t:%d d:%d r:%d j:%d",
i,
ngx_processes[i].pid,
ngx_processes[i].exiting,
ngx_processes[i].exited,
@ -441,6 +448,10 @@ static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle)
ngx_processes[i].respawn,
ngx_processes[i].just_respawn);
if (ngx_processes[i].pid == -1) {
continue;
}
if (ngx_processes[i].exited) {
if (!ngx_processes[i].detached) {
@ -454,13 +465,14 @@ static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle)
for (n = 0; n < ngx_last_process; n++) {
if (ngx_processes[n].exited
|| ngx_processes[n].pid == -1
|| ngx_processes[n].channel[0] == -1)
{
continue;
}
ngx_log_debug3(NGX_LOG_DEBUG_CORE, cycle->log, 0,
"pass close channel s: %d pid:" PID_T_FMT
"pass close channel s:%d pid:" PID_T_FMT
" to:" PID_T_FMT, ch.slot, ch.pid, ngx_processes[n].pid);
/* TODO: NGX_AGAIN */
@ -498,8 +510,11 @@ static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle)
}
}
if (i != --ngx_last_process) {
ngx_processes[i--] = ngx_processes[ngx_last_process];
if (i == ngx_last_process - 1) {
ngx_last_process--;
} else {
ngx_processes[i].pid = -1;
}
} else if (ngx_processes[i].exiting || !ngx_processes[i].detached) {
@ -593,14 +608,9 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
}
}
for (n = 0; n <= ngx_last_process; n++) {
if (n == ngx_process_slot) {
if (close(ngx_processes[n].channel[0]) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"close() failed");
}
for (n = 0; n < ngx_last_process; n++) {
if (ngx_processes[n].pid == -1) {
continue;
}
@ -610,6 +620,11 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
}
}
if (close(ngx_processes[ngx_process_slot].channel[0]) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"close() failed");
}
#if 0
ngx_last_process = 0;
#endif