mirror of
https://github.com/nginx/nginx.git
synced 2024-11-27 15:39:01 +08:00
nginx-0.1.43-RELEASE import
*) Feature: the listen(2) backlog in the "listen" directive can be changed using the -HUP signal. *) Feature: the geo2nginx.pl script was added to contrib. *) Change: the FastCGI parameters with the empty values now are passed to a server. *) Bugfix: the segmentation fault occurred or the worker process may got caught in an endless loop if the proxied or FastCGI server sent the "Cache-Control" header line and the "expires" directive was used; in the proxied mode the the bug had appeared in 0.1.29.
This commit is contained in:
parent
e3c2cf87e5
commit
e5035397b0
23
conf/fastcgi_params
Normal file
23
conf/fastcgi_params
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
fastcgi_param QUERY_STRING $query_string;
|
||||||
|
fastcgi_param REQUEST_METHOD $request_method;
|
||||||
|
fastcgi_param CONTENT_TYPE $content_type;
|
||||||
|
fastcgi_param CONTENT_LENGTH $content_length;
|
||||||
|
|
||||||
|
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
|
||||||
|
fastcgi_param REQUEST_URI $request_uri;
|
||||||
|
fastcgi_param DOCUMENT_URI $document_uri;
|
||||||
|
fastcgi_param DOCUMENT_ROOT $document_root;
|
||||||
|
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
||||||
|
|
||||||
|
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
|
||||||
|
fastcgi_param SERVER_SOFTWARE nginx;
|
||||||
|
|
||||||
|
fastcgi_param REMOTE_ADDR $remote_addr;
|
||||||
|
fastcgi_param REMOTE_PORT $remote_port;
|
||||||
|
fastcgi_param SERVER_ADDR $server_addr;
|
||||||
|
fastcgi_param SERVER_PORT $server_port;
|
||||||
|
fastcgi_param SERVER_NAME $server_name;
|
||||||
|
|
||||||
|
# PHP only, required if PHP was built with --enable-force-cgi-redirect
|
||||||
|
fastcgi_param REDIRECT_STATUS 200;
|
6
contrib/README
Normal file
6
contrib/README
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
geo2nginx.pl by Andrei Nigmatulin
|
||||||
|
|
||||||
|
The perl script to convert CSV geoip database (free download
|
||||||
|
at http://www.maxmind.com/app/geoip_country) to format, suitable
|
||||||
|
for use with ngx_http_geo_module.
|
58
contrib/geo2nginx.pl
Normal file
58
contrib/geo2nginx.pl
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
# (c) Andrei Nigmatulin, 2005
|
||||||
|
#
|
||||||
|
# this script provided "as is", without any warranties. use it at your own risk.
|
||||||
|
#
|
||||||
|
# special thanx to Andrew Sitnikov for perl port
|
||||||
|
#
|
||||||
|
# this script converts CSV geoip database (free download at http://www.maxmind.com/app/geoip_country)
|
||||||
|
# to format, suitable for use with nginx_http_geo module (http://sysoev.ru/nginx)
|
||||||
|
#
|
||||||
|
# for example, line with ip range
|
||||||
|
#
|
||||||
|
# "62.16.68.0","62.16.127.255","1041253376","1041268735","RU","Russian Federation"
|
||||||
|
#
|
||||||
|
# will be converted to four subnetworks:
|
||||||
|
#
|
||||||
|
# 62.16.68.0/22 RU;
|
||||||
|
# 62.16.72.0/21 RU;
|
||||||
|
# 62.16.80.0/20 RU;
|
||||||
|
# 62.16.96.0/19 RU;
|
||||||
|
|
||||||
|
|
||||||
|
use warnings;
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
while( <STDIN> ){
|
||||||
|
if (/"[^"]+","[^"]+","([^"]+)","([^"]+)","([^"]+)"/){
|
||||||
|
print_subnets($1, $2, $3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub print_subnets {
|
||||||
|
my ($a1, $a2, $c) = @_;
|
||||||
|
my $l;
|
||||||
|
while ($a1 <= $a2) {
|
||||||
|
for ($l = 0; ($a1 & (1 << $l)) == 0 && ($a1 + ((1 << ($l + 1)) - 1)) <= $a2; $l++){};
|
||||||
|
print long2ip($a1) . "/" . (32 - $l) . " " . $c . ";\n";
|
||||||
|
$a1 += (1 << $l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub long2ip {
|
||||||
|
my $ip = shift;
|
||||||
|
|
||||||
|
my $str = 0;
|
||||||
|
|
||||||
|
$str = ($ip & 255);
|
||||||
|
|
||||||
|
$ip >>= 8;
|
||||||
|
$str = ($ip & 255).".$str";
|
||||||
|
|
||||||
|
$ip >>= 8;
|
||||||
|
$str = ($ip & 255).".$str";
|
||||||
|
|
||||||
|
$ip >>= 8;
|
||||||
|
$str = ($ip & 255).".$str";
|
||||||
|
}
|
@ -9,6 +9,71 @@
|
|||||||
<title lang="en">nginx changelog</title>
|
<title lang="en">nginx changelog</title>
|
||||||
|
|
||||||
|
|
||||||
|
<changes ver="0.1.43" date="30.08.2005">
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
listen(2) backlog × ÄÉÒÅËÔÉ×Å listen ÍÏÖÎÏ ÍÅÎÑÔØ ÐÏ ÓÉÇÎÁÌÕ -HUP.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the listen(2) backlog in the "listen" directive
|
||||||
|
can be changed using the -HUP signal.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
ÓËÒÉÐÔ geo2nginx.pl ÄÏÂÁ×ÌÅÎ × contrib.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the geo2nginx.pl script was added to contrib.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="change">
|
||||||
|
<para lang="ru">
|
||||||
|
ÐÁÒÁÍÅÔÒÙ FastCGI, Ó ÐÕÓÔÙÍ ÚÎÁÞÅÎÉÑÍÉ, ÔÅÐÅÒØ ÐÅÒÅÄÁÀÔÓÑ ÓÅÒ×ÅÒÕ.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the FastCGI parameters with the empty values now are passed to a server.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ÐÒÉ ÏÛÉÂËÁÈ × ÒÁÂÏÔÅ Ó ÐÒÏËÓÉÒÏ×ÁÎÎÙÍ ÓÅÒ×ÅÒÏÍ ÉÌÉ FastCGI ÓÅÒ×ÅÒÏÍ
|
||||||
|
ÍÏÇ ÐÒÏÉÚÏÊÔÉ segmentation fault;
|
||||||
|
× ÒÅÖÉÍÅ ÐÒÏËÓÉ ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.29.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the segmentation fault may occurred if there were errors while
|
||||||
|
working with proxied or FastCGI server;
|
||||||
|
in the proxied mode the bug appeared in 0.1.29.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ÅÓÌÉ × ÏÔ×ÅÔÅ ÐÒÏËÓÉÒÏ×ÁÎÎÏÇÏ ÓÅÒ×ÅÒÁ ÉÌÉ FastCGI ÓÅÒ×ÅÒÁ ÂÙÌÁ ÓÔÒÏËÁ
|
||||||
|
"Cache-Control", ÔÏ ÐÒÉ ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÄÉÒÅËÔÉ×Ù expires ÐÒÏÉÓÈÏÄÉÌ
|
||||||
|
segmentation fault ÉÌÉ ÒÁÂÏÞÉÊ ÐÒÏÃÅÓÓ ÍÏÇ ÚÁÃÉËÌÉÔÓÑ;
|
||||||
|
× ÒÅÖÉÍÅ ÐÒÏËÓÉ ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.29.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the segmentation fault occurred or the worker process may got caught
|
||||||
|
in an endless loop if the proxied or FastCGI server sent the "Cache-Control"
|
||||||
|
header line and the "expires" directive was used;
|
||||||
|
in the proxied mode the bug appeared in 0.1.29.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
</changes>
|
||||||
|
|
||||||
|
|
||||||
<changes ver="0.1.42" date="23.08.2005">
|
<changes ver="0.1.42" date="23.08.2005">
|
||||||
|
|
||||||
<change type="bugfix">
|
<change type="bugfix">
|
||||||
|
@ -288,9 +288,9 @@ ngx_add_inherited_sockets(ngx_cycle_t *cycle)
|
|||||||
s = ngx_atoi(v, p - v);
|
s = ngx_atoi(v, p - v);
|
||||||
if (s == NGX_ERROR) {
|
if (s == NGX_ERROR) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
||||||
"invalid socket number \"%s\" in "
|
"invalid socket number \"%s\" in " NGINX_VAR
|
||||||
NGINX_VAR " environment variable, "
|
" environment variable, ignoring the rest"
|
||||||
"ignoring the rest of the variable", v);
|
" of the variable", v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define _NGINX_H_INCLUDED_
|
#define _NGINX_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
#define NGINX_VER "nginx/0.1.42"
|
#define NGINX_VER "nginx/0.1.43"
|
||||||
|
|
||||||
#define NGINX_VAR "NGINX"
|
#define NGINX_VAR "NGINX"
|
||||||
#define NGX_NEWPID_EXT ".newbin"
|
#define NGX_NEWPID_EXT ".newbin"
|
||||||
|
@ -123,6 +123,8 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
|
|||||||
ntohs(sin->sin_port))
|
ntohs(sin->sin_port))
|
||||||
- ls[i].addr_text.data;
|
- ls[i].addr_text.data;
|
||||||
|
|
||||||
|
ls[i].backlog = -1;
|
||||||
|
|
||||||
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
||||||
|
|
||||||
ngx_memzero(&af, sizeof(struct accept_filter_arg));
|
ngx_memzero(&af, sizeof(struct accept_filter_arg));
|
||||||
@ -467,7 +469,8 @@ ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err == NGX_ECONNRESET
|
if (err == 0
|
||||||
|
|| err == NGX_ECONNRESET
|
||||||
#if !(NGX_WIN32)
|
#if !(NGX_WIN32)
|
||||||
|| err == NGX_EPIPE
|
|| err == NGX_EPIPE
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,6 +45,7 @@ typedef struct {
|
|||||||
unsigned bound:1; /* already bound */
|
unsigned bound:1; /* already bound */
|
||||||
unsigned inherited:1; /* inherited from previous process */
|
unsigned inherited:1; /* inherited from previous process */
|
||||||
unsigned nonblocking_accept:1;
|
unsigned nonblocking_accept:1;
|
||||||
|
unsigned change_backlog:1;
|
||||||
unsigned nonblocking:1;
|
unsigned nonblocking:1;
|
||||||
unsigned shared:1; /* shared between threads or processes */
|
unsigned shared:1; /* shared between threads or processes */
|
||||||
unsigned addr_ntop:1;
|
unsigned addr_ntop:1;
|
||||||
|
@ -339,6 +339,10 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
nls[n].remain = 1;
|
nls[n].remain = 1;
|
||||||
ls[i].remain = 1;
|
ls[i].remain = 1;
|
||||||
|
|
||||||
|
if (ls[n].backlog != nls[i].backlog) {
|
||||||
|
nls[n].change_backlog = 1;
|
||||||
|
}
|
||||||
|
|
||||||
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -405,12 +409,21 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_HAVE_DEFERRED_ACCEPT)
|
|
||||||
|
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
ls = cycle->listening.elts;
|
ls = cycle->listening.elts;
|
||||||
for (i = 0; i < cycle->listening.nelts; i++) {
|
for (i = 0; i < cycle->listening.nelts; i++) {
|
||||||
|
|
||||||
|
if (ls[i].change_backlog) {
|
||||||
|
if (listen(ls[i].fd, ls[i].backlog) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno,
|
||||||
|
"changing the listen() backlog to %d "
|
||||||
|
"for %V failed, ignored",
|
||||||
|
&ls[i].addr_text, ls[i].backlog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (NGX_HAVE_DEFERRED_ACCEPT)
|
||||||
|
|
||||||
#ifdef SO_ACCEPTFILTER
|
#ifdef SO_ACCEPTFILTER
|
||||||
if (ls[i].delete_deferred) {
|
if (ls[i].delete_deferred) {
|
||||||
if (setsockopt(ls[i].fd, SOL_SOCKET, SO_ACCEPTFILTER,
|
if (setsockopt(ls[i].fd, SOL_SOCKET, SO_ACCEPTFILTER,
|
||||||
@ -475,10 +488,10 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
if (ls[i].add_deferred) {
|
if (ls[i].add_deferred) {
|
||||||
ls[i].deferred_accept = 1;
|
ls[i].deferred_accept = 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,15 +144,6 @@ static ngx_http_fastcgi_request_start_t ngx_http_fastcgi_request_start = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static ngx_str_t ngx_http_fastcgi_methods[] = {
|
|
||||||
ngx_string("GET"),
|
|
||||||
ngx_string("HEAD"),
|
|
||||||
ngx_string("POST")
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static ngx_str_t ngx_http_fastcgi_script_name =
|
static ngx_str_t ngx_http_fastcgi_script_name =
|
||||||
ngx_string("fastcgi_script_name");
|
ngx_string("fastcgi_script_name");
|
||||||
|
|
||||||
@ -428,9 +419,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
le.ip += sizeof(uintptr_t);
|
le.ip += sizeof(uintptr_t);
|
||||||
|
|
||||||
if (val_len) {
|
len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len;
|
||||||
len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,22 +516,18 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
le.ip += sizeof(uintptr_t);
|
le.ip += sizeof(uintptr_t);
|
||||||
|
|
||||||
if (val_len) {
|
*e.pos++ = (u_char) key_len;
|
||||||
*e.pos++ = (u_char) key_len;
|
|
||||||
|
|
||||||
if (val_len > 127) {
|
if (val_len > 127) {
|
||||||
*e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80);
|
*e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80);
|
||||||
*e.pos++ = (u_char) ((val_len >> 16) & 0xff);
|
*e.pos++ = (u_char) ((val_len >> 16) & 0xff);
|
||||||
*e.pos++ = (u_char) ((val_len >> 8) & 0xff);
|
*e.pos++ = (u_char) ((val_len >> 8) & 0xff);
|
||||||
*e.pos++ = (u_char) (val_len & 0xff);
|
*e.pos++ = (u_char) (val_len & 0xff);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
*e.pos++ = (u_char) val_len;
|
*e.pos++ = (u_char) val_len;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e.skip = val_len ? 0 : 1;
|
|
||||||
|
|
||||||
while (*(uintptr_t *) e.ip) {
|
while (*(uintptr_t *) e.ip) {
|
||||||
code = *(ngx_http_script_code_pt *) e.ip;
|
code = *(ngx_http_script_code_pt *) e.ip;
|
||||||
code((ngx_http_script_engine_t *) &e);
|
code((ngx_http_script_engine_t *) &e);
|
||||||
|
@ -73,7 +73,7 @@ ngx_http_headers_filter(ngx_http_request_t *r)
|
|||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_table_elt_t *expires, *cc;
|
ngx_table_elt_t *expires, *cc, **ccp;
|
||||||
ngx_http_headers_conf_t *conf;
|
ngx_http_headers_conf_t *conf;
|
||||||
|
|
||||||
if (r->headers_out.status != NGX_HTTP_OK || r->main) {
|
if (r->headers_out.status != NGX_HTTP_OK || r->main) {
|
||||||
@ -103,9 +103,20 @@ ngx_http_headers_filter(ngx_http_request_t *r)
|
|||||||
len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT");
|
len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT");
|
||||||
expires->value.len = len - 1;
|
expires->value.len = len - 1;
|
||||||
|
|
||||||
cc = r->headers_out.cache_control.elts;
|
ccp = r->headers_out.cache_control.elts;
|
||||||
|
|
||||||
if (cc == NULL) {
|
if (ccp == NULL) {
|
||||||
|
|
||||||
|
if (ngx_array_init(&r->headers_out.cache_control, r->pool,
|
||||||
|
1, sizeof(ngx_table_elt_t *)) != NGX_OK)
|
||||||
|
{
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ccp = ngx_array_push(&r->headers_out.cache_control);
|
||||||
|
if (ccp == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
cc = ngx_list_push(&r->headers_out.headers);
|
cc = ngx_list_push(&r->headers_out.headers);
|
||||||
if (cc == NULL) {
|
if (cc == NULL) {
|
||||||
@ -116,10 +127,14 @@ ngx_http_headers_filter(ngx_http_request_t *r)
|
|||||||
cc->key.len = sizeof("Cache-Control") - 1;
|
cc->key.len = sizeof("Cache-Control") - 1;
|
||||||
cc->key.data = (u_char *) "Cache-Control";
|
cc->key.data = (u_char *) "Cache-Control";
|
||||||
|
|
||||||
|
*ccp = cc;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (i = 1; i < r->headers_out.cache_control.nelts; i++) {
|
for (i = 1; i < r->headers_out.cache_control.nelts; i++) {
|
||||||
cc[i].hash = 0;
|
ccp[i]->hash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc = ccp[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf->expires == NGX_HTTP_EXPIRES_EPOCH) {
|
if (conf->expires == NGX_HTTP_EXPIRES_EPOCH) {
|
||||||
|
@ -637,8 +637,24 @@ ngx_http_process_request_line(ngx_event_t *rev)
|
|||||||
"http exten: \"%V\"", &r->exten);
|
"http exten: \"%V\"", &r->exten);
|
||||||
|
|
||||||
if (r->http_version < NGX_HTTP_VERSION_10) {
|
if (r->http_version < NGX_HTTP_VERSION_10) {
|
||||||
|
|
||||||
|
if (rev->timer_set) {
|
||||||
|
ngx_del_timer(rev);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (NGX_STAT_STUB)
|
||||||
|
ngx_atomic_dec(ngx_stat_reading);
|
||||||
|
r->stat_reading = 0;
|
||||||
|
ngx_atomic_inc(ngx_stat_writing);
|
||||||
|
r->stat_writing = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rev->handler = ngx_http_request_handler;
|
||||||
|
c->write->handler = ngx_http_request_handler;
|
||||||
r->read_event_handler = ngx_http_block_read;
|
r->read_event_handler = ngx_http_block_read;
|
||||||
|
|
||||||
ngx_http_handler(r);
|
ngx_http_handler(r);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,6 +884,7 @@ ngx_http_process_request_headers(ngx_event_t *rev)
|
|||||||
r->read_event_handler = ngx_http_block_read;
|
r->read_event_handler = ngx_http_block_read;
|
||||||
|
|
||||||
ngx_http_handler(r);
|
ngx_http_handler(r);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1783,6 +1800,8 @@ ngx_http_discard_body(ngx_http_request_t *r)
|
|||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r->discard_body = 1;
|
||||||
|
|
||||||
size = r->header_in->last - r->header_in->pos;
|
size = r->header_in->last - r->header_in->pos;
|
||||||
|
|
||||||
if (size) {
|
if (size) {
|
||||||
|
@ -362,6 +362,7 @@ struct ngx_http_request_s {
|
|||||||
unsigned header_only:1;
|
unsigned header_only:1;
|
||||||
unsigned keepalive:1;
|
unsigned keepalive:1;
|
||||||
unsigned lingering_close:1;
|
unsigned lingering_close:1;
|
||||||
|
unsigned discard_body:1;
|
||||||
unsigned internal:1;
|
unsigned internal:1;
|
||||||
unsigned done:1;
|
unsigned done:1;
|
||||||
unsigned utf8:1;
|
unsigned utf8:1;
|
||||||
|
@ -31,7 +31,7 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
|
|||||||
ngx_http_request_body_t *rb;
|
ngx_http_request_body_t *rb;
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
|
|
||||||
if (r->request_body) {
|
if (r->request_body || r->discard_body) {
|
||||||
post_handler(r);
|
post_handler(r);
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,9 @@ ngx_http_upstream_init(ngx_http_request_t *r)
|
|||||||
|
|
||||||
u = r->upstream;
|
u = r->upstream;
|
||||||
|
|
||||||
u->request_bufs = r->request_body->bufs;
|
if (r->request_body) {
|
||||||
|
u->request_bufs = r->request_body->bufs;
|
||||||
|
}
|
||||||
|
|
||||||
if (u->conf->method == NGX_CONF_UNSET_UINT) {
|
if (u->conf->method == NGX_CONF_UNSET_UINT) {
|
||||||
u->method = r->method;
|
u->method = r->method;
|
||||||
@ -250,7 +252,7 @@ ngx_http_upstream_init(ngx_http_request_t *r)
|
|||||||
u->method = u->conf->method;
|
u->method = u->conf->method;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u->create_request(r) == NGX_ERROR) {
|
if (u->create_request(r) != NGX_OK) {
|
||||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -615,9 +617,8 @@ ngx_http_upstream_send_request(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
&& !u->request_sent
|
&& !u->request_sent
|
||||||
&& c->write->pending_eof)
|
&& c->write->pending_eof)
|
||||||
{
|
{
|
||||||
ngx_log_error(NGX_LOG_ERR, c->log, c->write->kq_errno,
|
(void) ngx_connection_error(c, c->write->kq_errno,
|
||||||
"connect() failed");
|
"kevent() reported that connect() failed");
|
||||||
|
|
||||||
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
|
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -716,12 +717,6 @@ ngx_http_upstream_send_request_handler(ngx_event_t *wev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r->connection->write->eof && (!u->cachable || !u->request_sent)) {
|
|
||||||
ngx_http_upstream_finalize_request(r, u,
|
|
||||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ngx_http_upstream_send_request(r, u);
|
ngx_http_upstream_send_request(r, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1788,6 +1783,7 @@ static u_char *
|
|||||||
ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, size_t len)
|
ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, size_t len)
|
||||||
{
|
{
|
||||||
u_char *p;
|
u_char *p;
|
||||||
|
ngx_str_t line;
|
||||||
uintptr_t escape;
|
uintptr_t escape;
|
||||||
ngx_http_upstream_t *u;
|
ngx_http_upstream_t *u;
|
||||||
ngx_peer_connection_t *peer;
|
ngx_peer_connection_t *peer;
|
||||||
@ -1824,32 +1820,34 @@ ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, size_t len)
|
|||||||
buf += r->uri.len - u->conf->location->len + escape;
|
buf += r->uri.len - u->conf->location->len + escape;
|
||||||
len -= r->uri.len - u->conf->location->len + escape;
|
len -= r->uri.len - u->conf->location->len + escape;
|
||||||
|
|
||||||
if (r->args.len) {
|
} else {
|
||||||
p = ngx_snprintf(buf, len, "?%V", &r->args);
|
p = ngx_palloc(r->pool,
|
||||||
len -= p - buf;
|
r->uri.len - u->conf->location->len + escape);
|
||||||
buf = p;
|
if (p == NULL) {
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ngx_http_log_error_info(r, buf, len);
|
ngx_escape_uri(p, r->uri.data + u->conf->location->len,
|
||||||
|
r->uri.len - u->conf->location->len, NGX_ESCAPE_URI);
|
||||||
|
|
||||||
|
line.len = len;
|
||||||
|
line.data = p;
|
||||||
|
|
||||||
|
return ngx_snprintf(buf, len, "%V", &line);
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ngx_palloc(r->pool, r->uri.len - u->conf->location->len + escape);
|
|
||||||
if (p == NULL) {
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
ngx_escape_uri(p, r->uri.data + u->conf->location->len,
|
|
||||||
r->uri.len - u->conf->location->len, NGX_ESCAPE_URI);
|
|
||||||
|
|
||||||
p = ngx_cpymem(buf, p, r->uri.len - u->conf->location->len + escape);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
p = ngx_cpymem(buf, r->uri.data + u->conf->location->len,
|
line.len = r->uri.len - u->conf->location->len;
|
||||||
r->uri.len - u->conf->location->len);
|
if (line.len > len) {
|
||||||
}
|
line.len = len;
|
||||||
|
}
|
||||||
|
|
||||||
len -= p - buf;
|
line.data = r->uri.data + u->conf->location->len;
|
||||||
buf = p;
|
p = ngx_snprintf(buf, len, "%V", &line);
|
||||||
|
|
||||||
|
len -= p - buf;
|
||||||
|
buf = p;
|
||||||
|
}
|
||||||
|
|
||||||
if (r->args.len) {
|
if (r->args.len) {
|
||||||
p = ngx_snprintf(buf, len, "?%V", &r->args);
|
p = ngx_snprintf(buf, len, "?%V", &r->args);
|
||||||
|
@ -57,9 +57,8 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|||||||
#if (NGX_HAVE_KQUEUE)
|
#if (NGX_HAVE_KQUEUE)
|
||||||
|
|
||||||
if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
|
if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
|
||||||
ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
|
(void) ngx_connection_error(c, wev->kq_errno,
|
||||||
"kevent() reported about an closed connection");
|
"kevent() reported about an closed connection");
|
||||||
|
|
||||||
wev->error = 1;
|
wev->error = 1;
|
||||||
return NGX_CHAIN_ERROR;
|
return NGX_CHAIN_ERROR;
|
||||||
}
|
}
|
||||||
@ -228,8 +227,8 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|||||||
|
|
||||||
if (err != NGX_EINTR) {
|
if (err != NGX_EINTR) {
|
||||||
wev->error = 1;
|
wev->error = 1;
|
||||||
ngx_connection_error(c, err,
|
(void) ngx_connection_error(c, err,
|
||||||
ngx_tcp_nopush_n " failed");
|
ngx_tcp_nopush_n " failed");
|
||||||
return NGX_CHAIN_ERROR;
|
return NGX_CHAIN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +275,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
wev->error = 1;
|
wev->error = 1;
|
||||||
ngx_connection_error(c, err, "sendfile() failed");
|
(void) ngx_connection_error(c, err, "sendfile() failed");
|
||||||
return NGX_CHAIN_ERROR;
|
return NGX_CHAIN_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,20 +29,12 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
|
|||||||
rev->ready = 0;
|
rev->ready = 0;
|
||||||
rev->eof = 1;
|
rev->eof = 1;
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
|
|
||||||
"kevent() reported about an closed connection");
|
|
||||||
|
|
||||||
if (rev->kq_errno) {
|
if (rev->kq_errno) {
|
||||||
rev->error = 1;
|
rev->error = 1;
|
||||||
ngx_set_socket_errno(rev->kq_errno);
|
ngx_set_socket_errno(rev->kq_errno);
|
||||||
|
|
||||||
if (rev->kq_errno == NGX_ECONNRESET
|
return ngx_connection_error(c, rev->kq_errno,
|
||||||
&& c->log_error == NGX_ERROR_IGNORE_ECONNRESET)
|
"kevent() reported about an closed connection");
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -20,9 +20,8 @@ ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size)
|
|||||||
#if (NGX_HAVE_KQUEUE)
|
#if (NGX_HAVE_KQUEUE)
|
||||||
|
|
||||||
if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
|
if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
|
||||||
ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
|
(void) ngx_connection_error(c, wev->kq_errno,
|
||||||
"kevent() reported about an closed connection");
|
"kevent() reported about an closed connection");
|
||||||
|
|
||||||
wev->error = 1;
|
wev->error = 1;
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -63,7 +62,7 @@ ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
wev->error = 1;
|
wev->error = 1;
|
||||||
ngx_connection_error(c, err, "send() failed");
|
(void) ngx_connection_error(c, err, "send() failed");
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,8 @@ ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|||||||
#if (NGX_HAVE_KQUEUE)
|
#if (NGX_HAVE_KQUEUE)
|
||||||
|
|
||||||
if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
|
if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
|
||||||
ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
|
(void) ngx_connection_error(c, wev->kq_errno,
|
||||||
"kevent() reported about an closed connection");
|
"kevent() reported about an closed connection");
|
||||||
|
|
||||||
wev->error = 1;
|
wev->error = 1;
|
||||||
return NGX_CHAIN_ERROR;
|
return NGX_CHAIN_ERROR;
|
||||||
}
|
}
|
||||||
@ -117,7 +116,7 @@ ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
wev->error = 1;
|
wev->error = 1;
|
||||||
ngx_connection_error(c, err, "writev() failed");
|
(void) ngx_connection_error(c, err, "writev() failed");
|
||||||
return NGX_CHAIN_ERROR;
|
return NGX_CHAIN_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user