mirror of
https://github.com/nginx/nginx.git
synced 2024-11-24 13:29:17 +08:00
nginx-0.0.10-2004-09-15-20:00:43 import
This commit is contained in:
parent
dc3b2a7875
commit
85cccfba8d
@ -41,7 +41,8 @@ ngx_inline static ngx_int_t ngx_array_init(ngx_array_t *array, ngx_pool_t *pool,
|
||||
ngx_test_null(a.elts, ngx_palloc(p, n * s), rc); \
|
||||
a.nelts = 0; a.size = s; a.nalloc = n; a.pool = p;
|
||||
|
||||
#define ngx_array_push ngx_push_array
|
||||
#define ngx_array_create ngx_create_array
|
||||
#define ngx_array_push ngx_push_array
|
||||
|
||||
|
||||
#endif /* _NGX_ARRAY_H_INCLUDED_ */
|
||||
|
@ -84,11 +84,20 @@ typedef long ngx_flag_t;
|
||||
#define NGX_OFF_T_LEN sizeof("-9223372036854775808") - 1
|
||||
|
||||
|
||||
#if (SOLARIS)
|
||||
|
||||
/* TODO: auto_conf */
|
||||
#define NGX_ALIGN (_MAX_ALIGNMENT - 1) /* platform word */
|
||||
#define NGX_ALIGN_CAST (unsigned long) /* size of the pointer */
|
||||
|
||||
#else
|
||||
|
||||
/* TODO: auto_conf */
|
||||
#define NGX_ALIGN (sizeof(unsigned long) - 1) /* platform word */
|
||||
#define NGX_ALIGN_CAST (unsigned long) /* size of the pointer */
|
||||
|
||||
#endif
|
||||
|
||||
#define ngx_align(p) (char *) ((NGX_ALIGN_CAST p + NGX_ALIGN) & ~NGX_ALIGN)
|
||||
|
||||
|
||||
|
@ -137,6 +137,10 @@ ngx_int_t ngx_http_log_handler(ngx_http_request_t *r)
|
||||
|
||||
lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
|
||||
|
||||
if (lcf->off) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
log = lcf->logs->elts;
|
||||
for (l = 0; l < lcf->logs->nelts; l++) {
|
||||
|
||||
@ -662,8 +666,9 @@ static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf)
|
||||
{
|
||||
ngx_http_log_loc_conf_t *conf;
|
||||
|
||||
ngx_test_null(conf, ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)),
|
||||
NGX_CONF_ERROR);
|
||||
if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)))) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
return conf;
|
||||
}
|
||||
@ -680,17 +685,27 @@ static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent,
|
||||
ngx_http_log_main_conf_t *lmcf;
|
||||
|
||||
if (conf->logs == NULL) {
|
||||
|
||||
if (conf->off) {
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
if (prev->logs) {
|
||||
conf->logs = prev->logs;
|
||||
|
||||
} else {
|
||||
|
||||
conf->logs = ngx_create_array(cf->pool, 2, sizeof(ngx_http_log_t));
|
||||
if (prev->off) {
|
||||
conf->off = prev->off;
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
conf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
|
||||
if (conf->logs == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (!(log = ngx_push_array(conf->logs))) {
|
||||
if (!(log = ngx_array_push(conf->logs))) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
@ -701,6 +716,7 @@ static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent,
|
||||
|
||||
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
|
||||
fmt = lmcf->formats.elts;
|
||||
|
||||
/* the default "combined" format */
|
||||
log->ops = fmt[0].ops;
|
||||
}
|
||||
@ -721,17 +737,23 @@ static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
ngx_http_log_fmt_t *fmt;
|
||||
ngx_http_log_main_conf_t *lmcf;
|
||||
|
||||
value = cf->args->elts;
|
||||
|
||||
if (ngx_strcmp(value[1].data, "off") == 0) {
|
||||
llcf->off = 1;
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
if (llcf->logs == NULL) {
|
||||
if (!(llcf->logs = ngx_create_array(cf->pool, 2,
|
||||
sizeof(ngx_http_log_t)))) {
|
||||
llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
|
||||
if (llcf->logs == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
value = cf->args->elts;
|
||||
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
|
||||
|
||||
if (!(log = ngx_push_array(llcf->logs))) {
|
||||
if (!(log = ngx_array_push(llcf->logs))) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
ngx_array_t *logs; /* array of ngx_http_log_t */
|
||||
ngx_uint_t off; /* unsigned off:1 */
|
||||
} ngx_http_log_loc_conf_t;
|
||||
|
||||
|
||||
|
@ -97,10 +97,6 @@ void ngx_http_init_connection(ngx_connection_t *c)
|
||||
ngx_event_t *rev;
|
||||
ngx_http_log_ctx_t *ctx;
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_reading)++;
|
||||
#endif
|
||||
|
||||
if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
@ -133,6 +129,10 @@ void ngx_http_init_connection(ngx_connection_t *c)
|
||||
return;
|
||||
}
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_reading)++;
|
||||
#endif
|
||||
|
||||
ngx_http_init_request(rev);
|
||||
return;
|
||||
}
|
||||
@ -155,6 +155,11 @@ void ngx_http_init_connection(ngx_connection_t *c)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_reading)++;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -178,6 +183,11 @@ static void ngx_http_init_request(ngx_event_t *rev)
|
||||
|
||||
if (rev->timedout) {
|
||||
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_reading)--;
|
||||
#endif
|
||||
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
}
|
||||
@ -186,8 +196,17 @@ static void ngx_http_init_request(ngx_event_t *rev)
|
||||
r = c->data;
|
||||
ngx_memzero(r, sizeof(ngx_http_request_t));
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_reading)++;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) {
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_reading)--;
|
||||
#endif
|
||||
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
}
|
||||
@ -195,6 +214,10 @@ static void ngx_http_init_request(ngx_event_t *rev)
|
||||
c->data = r;
|
||||
}
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
r->stat_reading = 1;
|
||||
#endif
|
||||
|
||||
c->sent = 0;
|
||||
r->signature = NGX_HTTP_MODULE;
|
||||
|
||||
@ -869,7 +892,9 @@ static void ngx_http_process_request_headers(ngx_event_t *rev)
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_reading)--;
|
||||
r->stat_reading = 0;
|
||||
(*ngx_stat_writing)++;
|
||||
r->stat_writing = 1;
|
||||
#endif
|
||||
|
||||
rev->event_handler = ngx_http_block_read;
|
||||
@ -1118,6 +1143,12 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
|
||||
ngx_ssl_set_nosendshut(r->connection->ssl);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ngx_strstr(r->headers_in.user_agent->value.data, "Opera")) {
|
||||
r->headers_in.opera = 1;
|
||||
r->headers_in.msie = 0;
|
||||
r->headers_in.msie4 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
@ -1148,11 +1179,6 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int rc)
|
||||
}
|
||||
|
||||
if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) {
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_writing)--;
|
||||
#endif
|
||||
|
||||
ngx_http_close_request(r, 0);
|
||||
ngx_http_close_connection(r->connection);
|
||||
return;
|
||||
@ -1163,11 +1189,6 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int rc)
|
||||
return;
|
||||
|
||||
} else if (rc == NGX_ERROR) {
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_writing)--;
|
||||
#endif
|
||||
|
||||
ngx_http_close_request(r, 0);
|
||||
ngx_http_close_connection(r->connection);
|
||||
return;
|
||||
@ -1177,10 +1198,6 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int rc)
|
||||
return;
|
||||
}
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
(*ngx_stat_writing)--;
|
||||
#endif
|
||||
|
||||
if (r->connection->read->timer_set) {
|
||||
ngx_del_timer(r->connection->read);
|
||||
}
|
||||
@ -1800,6 +1817,16 @@ void ngx_http_close_request(ngx_http_request_t *r, int error)
|
||||
return;
|
||||
}
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
if (r->stat_reading) {
|
||||
(*ngx_stat_reading)--;
|
||||
}
|
||||
|
||||
if (r->stat_writing) {
|
||||
(*ngx_stat_writing)--;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (error && r->headers_out.status == 0) {
|
||||
r->headers_out.status = error;
|
||||
}
|
||||
|
@ -148,6 +148,7 @@ typedef struct {
|
||||
|
||||
unsigned msie:1;
|
||||
unsigned msie4:1;
|
||||
unsigned opera:1;
|
||||
} ngx_http_headers_in_t;
|
||||
|
||||
|
||||
@ -308,6 +309,11 @@ struct ngx_http_request_s {
|
||||
unsigned filter_need_temporary:1;
|
||||
unsigned filter_allow_ranges:1;
|
||||
|
||||
#if (NGX_STAT_STUB)
|
||||
unsigned stat_reading:1;
|
||||
unsigned stat_writing:1;
|
||||
#endif
|
||||
|
||||
ngx_uint_t headers_n;
|
||||
|
||||
/* used to parse HTTP headers */
|
||||
|
Loading…
Reference in New Issue
Block a user