mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 14:13:33 -06:00
nginx-0.0.1-2004-01-16-21:29:15 import
This commit is contained in:
parent
c599198d83
commit
f20c05fd26
@ -22,6 +22,7 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx);
|
static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx);
|
||||||
|
static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx);
|
||||||
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
|
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
|
||||||
static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp);
|
static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp);
|
||||||
static ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv);
|
static ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv);
|
||||||
@ -266,6 +267,7 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
ngx_new_binary = 0;
|
ngx_new_binary = 0;
|
||||||
signo = 0;
|
signo = 0;
|
||||||
sent = 0;
|
sent = 0;
|
||||||
|
live = 0;
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "new cycle");
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "new cycle");
|
||||||
@ -273,6 +275,7 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
if (ngx_process == NGX_PROCESS_MASTER) {
|
if (ngx_process == NGX_PROCESS_MASTER) {
|
||||||
ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
|
ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
|
||||||
"worker process", NGX_PROCESS_RESPAWN);
|
"worker process", NGX_PROCESS_RESPAWN);
|
||||||
|
live = 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ngx_init_temp_number();
|
ngx_init_temp_number();
|
||||||
@ -414,31 +417,14 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!live) {
|
if (!live) {
|
||||||
if (ngx_terminate || ngx_quit) {
|
sent = 0;
|
||||||
|
|
||||||
if (ngx_inherited && getppid() > 1) {
|
|
||||||
name = ctx->pid.name.data;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
name = ctx->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ngx_delete_file(name) == NGX_FILE_ERROR) {
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log,
|
|
||||||
ngx_errno,
|
|
||||||
ngx_delete_file_n
|
|
||||||
" \"%s\" failed", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exit");
|
|
||||||
exit(0);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
sent = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!live && (ngx_terminate || ngx_quit)) {
|
||||||
|
ngx_master_exit(cycle, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
if (ngx_terminate) {
|
if (ngx_terminate) {
|
||||||
if (delay > 10000) {
|
if (delay > 10000) {
|
||||||
signo = SIGKILL;
|
signo = SIGKILL;
|
||||||
@ -530,7 +516,6 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
|
|
||||||
/* STUB */
|
/* STUB */
|
||||||
if (ngx_reopen) {
|
if (ngx_reopen) {
|
||||||
ngx_reopen = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +524,10 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_noaccept) {
|
if (ngx_reopen) {
|
||||||
|
ngx_reopen = 0;
|
||||||
|
|
||||||
|
} else if (ngx_noaccept) {
|
||||||
ngx_noaccept = 0;
|
ngx_noaccept = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -559,6 +547,27 @@ static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
if (ngx_inherited && getppid() > 1) {
|
||||||
|
name = ctx->pid.name.data;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
name = ctx->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_delete_file(name) == NGX_FILE_ERROR) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
|
ngx_delete_file_n " \"%s\" failed", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exit");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
|
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
|
||||||
{
|
{
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
|
@ -77,7 +77,7 @@ static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
|||||||
|
|
||||||
static int ngx_http_range_header_filter(ngx_http_request_t *r)
|
static int ngx_http_range_header_filter(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
int rc, boundary, len, i;
|
ngx_int_t rc, boundary, suffix, len, i;
|
||||||
char *p;
|
char *p;
|
||||||
off_t start, end;
|
off_t start, end;
|
||||||
ngx_http_range_t *range;
|
ngx_http_range_t *range;
|
||||||
@ -121,44 +121,52 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r)
|
|||||||
p = r->headers_in.range->value.data + 6;
|
p = r->headers_in.range->value.data + 6;
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
start = end = 0;
|
start = 0;
|
||||||
|
end = 0;
|
||||||
|
suffix = 0;
|
||||||
|
|
||||||
while (*p == ' ') { p++; }
|
while (*p == ' ') { p++; }
|
||||||
|
|
||||||
if (*p < '0' || *p > '9') {
|
if (*p != '-') {
|
||||||
rc = NGX_HTTP_RANGE_NOT_SATISFIABLE;
|
if (*p < '0' || *p > '9') {
|
||||||
break;
|
rc = NGX_HTTP_RANGE_NOT_SATISFIABLE;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
while (*p >= '0' && *p <= '9') {
|
while (*p >= '0' && *p <= '9') {
|
||||||
start = start * 10 + *p++ - '0';
|
start = start * 10 + *p++ - '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*p == ' ') { p++; }
|
while (*p == ' ') { p++; }
|
||||||
|
|
||||||
if (*p++ != '-') {
|
if (*p++ != '-') {
|
||||||
rc = NGX_HTTP_RANGE_NOT_SATISFIABLE;
|
rc = NGX_HTTP_RANGE_NOT_SATISFIABLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start >= r->headers_out.content_length_n) {
|
if (start >= r->headers_out.content_length_n) {
|
||||||
rc = NGX_HTTP_RANGE_NOT_SATISFIABLE;
|
rc = NGX_HTTP_RANGE_NOT_SATISFIABLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*p == ' ') { p++; }
|
while (*p == ' ') { p++; }
|
||||||
|
|
||||||
if (*p == ',' || *p == '\0') {
|
if (*p == ',' || *p == '\0') {
|
||||||
ngx_test_null(range, ngx_push_array(&r->headers_out.ranges),
|
ngx_test_null(range, ngx_push_array(&r->headers_out.ranges),
|
||||||
NGX_ERROR);
|
NGX_ERROR);
|
||||||
range->start = start;
|
range->start = start;
|
||||||
range->end = r->headers_out.content_length_n;
|
range->end = r->headers_out.content_length_n;
|
||||||
|
|
||||||
|
if (*p++ != ',') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (*p++ == ',') {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
} else {
|
||||||
|
suffix = 1;
|
||||||
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p < '0' || *p > '9') {
|
if (*p < '0' || *p > '9') {
|
||||||
@ -177,20 +185,33 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end >= r->headers_out.content_length_n || start >= end) {
|
if (suffix) {
|
||||||
|
start = r->headers_out.content_length_n - end;
|
||||||
|
end = r->headers_out.content_length_n - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start > end) {
|
||||||
rc = NGX_HTTP_RANGE_NOT_SATISFIABLE;
|
rc = NGX_HTTP_RANGE_NOT_SATISFIABLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_test_null(range, ngx_push_array(&r->headers_out.ranges), NGX_ERROR);
|
ngx_test_null(range, ngx_push_array(&r->headers_out.ranges), NGX_ERROR);
|
||||||
range->start = start;
|
range->start = start;
|
||||||
range->end = end + 1;
|
|
||||||
|
|
||||||
if (*p++ == ',') {
|
if (end >= r->headers_out.content_length_n) {
|
||||||
continue;
|
/*
|
||||||
|
* Download Accelerator sends the last byte position
|
||||||
|
* that equals to the file length
|
||||||
|
*/
|
||||||
|
range->end = r->headers_out.content_length_n;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
range->end = end + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
if (*p++ != ',') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user