nginx-0.1.15-RELEASE import

*) Bugfix: the error while the connecting to the FastCGI server caused
       segmentation fault.

    *) Bugfix: the correct handling of the regular expression, that has
       different number of the captures and substitutions.

    *) Feature: the location, that is passed to the FastCGI server, can be
       regular expression.

    *) Bugfix: the FastCGI's parameter REQUEST_URI is now passed with the
       arguments and in the original state.

    *) Bugfix: the ngx_http_rewrite_module module was required to be built
       to use the regular expressions in locations.

    *) Bugfix: the directive "proxy_preserve_host  on" adds port 80 to the
       "Host" headers, if upstream listen on port 80; the bug had appeared
       in 0.1.14.

    *) Bugfix: the same paths in autoconfiguration parameters
       --http-client-body-temp-path=PATH and --http-proxy-temp-path=PATH,
       or --http-client-body-temp-path=PATH and
       --http-fastcgi-temp-path=PATH caused segmentation fault.
This commit is contained in:
Igor Sysoev 2005-01-19 13:10:56 +00:00
parent fbf4fc0da9
commit 3259e85b7a
15 changed files with 181 additions and 40 deletions

View File

@ -2,7 +2,7 @@
# Copyright (C) Igor Sysoev
if [ $USE_PCRE = YES ]; then
if [ $USE_PCRE = YES -o $PCRE != NONE ]; then
. auto/lib/pcre/conf
fi

View File

@ -32,6 +32,10 @@ http {
index index.html index.htm;
}
# deny access to .htaccess files
#
#location ~ \.ht {
# deny all;
#}
}
}

View File

@ -6,6 +6,94 @@
title="nginx">
<changes ver="0.1.15" date="19.01.2005">
<change type="bugfix">
<para lang="ru">
ÏÛÉÂËÁ ÓÏÅÄÉÎÅÎÉÑ Ó FastCGI-ÓÅÒ×ÅÒÏÍ ×ÙÚÙ×ÁÌÁ segmentation fault.
</para>
<para lang="en">
the error while the connecting to the FastCGI server caused
segmentation fault.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ËÏÒÒÅËÔÎÁÑ ÏÂÒÁÂÏÔËÁ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ, × ËÏÔÏÒÏÍ ÞÉÓÌÏ
×ÙÄÅÌÅÎÎÙÈ ÞÁÓÔÅÊ ÎÅ ÓÏ×ÐÁÄÁÅÔ Ó ÞÉÓÌÏÍ ÐÏÄÓÔÁÎÏ×ÏË.
</para>
<para lang="en">
the correct handling of the regular exporession, that
has different number of the captures and substitutions.
</para>
</change>
<change type="feature">
<para lang="ru">
location, ËÏÔÏÒÙÊ ÐÅÒÅÄÁ£ÔÓÑ FastCGI-ÓÅÒ×ÅÒÕ, ÍÏÖÅÔ ÂÙÔØ ÚÁÄÁÎ
Ó ÐÏÍÏÝØÀ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ.
</para>
<para lang="en">
the location, that is passed to the FastCGI server, can be
regualar expression.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÐÁÒÁÍÅÔÒ FastCGI REQUEST_URI ÔÅÐÅÒØ ÐÅÒÅÄÁ£ÔÓÑ ×ÍÅÓÔÅ Ó ÁÒÇÕÍÅÎÔÁÍÉ
É × ÔÏÍ ×ÉÄÅ, × ËÏÔÏÒÏÍ ÂÙÌ ÐÏÌÕÞÅÎ ÏÔ ËÌÉÅÎÔÁ.
</para>
<para lang="en">
the FastCGI's parameter REQUEST_URI is now passed with the arguments
and in the original state.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÄÌÑ ÉÓÐÏÌØÚÏ×ÁÎÉÑ ÒÅÇÕÌÑÒÎÙÈ ×ÙÒÁÖÅÎÉÊ × location ÎÕÖÎÏ ÂÙÌÏ
ÓÏÂÉÒÁÔØ nginx ×ÍÅÓÔÅ Ó ngx_http_rewrite_module.
</para>
<para lang="en">
the ngx_http_rewrite_module module was required to be built to use
the regular expressions in locations.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÅÓÌÉ ÂÜËÅÎÄ ÓÌÕÛÁÌ ÎÁ 80-ÏÍ ÐÏÒÔÕ, ÔÏ ÐÒÉ ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÄÉÒÅËÔÉ×Ù
<nobr>"proxy_preserve_host on"</nobr> × ÚÁÇÏÌÏ×ËÅ "Host" ÕËÁÚÙ×ÁÌÓÑ
ÔÁËÖÅ ÐÏÒÔ 80;
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.14.
</para>
<para lang="en">
the directive <nobr>"proxy_preserve_host on"</nobr> adds port 80
to the "Host" headers, if upstream listen on port 80;
bug appeared in 0.1.14.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÅÓÌÉ ÚÁÄÁÔØ ÏÄÉÎÁËÏ×ÙÅ ÐÕÔÉ × ÐÁÒÁÍÅÔÒÁÈ Á×ÔÏËÏÎÆÉÇÕÒÁÃÉÉ
--http-client-body-temp-path=PATH É --http-proxy-temp-path=PATH
ÉÌÉ --http-client-body-temp-path=PATH É --http-fastcgi-temp-path=PATH,
ÔÏ ÐÒÏÉÓÈÏÄÉÌ segmentation fault.
</para>
<para lang="en">
the same pathes in autoconfiguration paramters
--http-client-body-temp-path=PATH and --http-proxy-temp-path=PATH,
or --http-client-body-temp-path=PATH nad --http-fastcgi-temp-path=PATH
caused segmentation fault.
</para>
</change>
</changes>
<changes ver="0.1.14" date="18.01.2005">
<change type="feature">

View File

@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_
#define NGINX_VER "nginx/0.1.14"
#define NGINX_VER "nginx/0.1.15"
#define NGINX_VAR "NGINX"
#define NGX_NEWPID_EXT ".newbin"

View File

@ -252,9 +252,19 @@ ngx_int_t ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot)
for (n = 0; n < 3; n++) {
if (p[i]->level[n] != path->level[n]) {
if (path->conf_file == NULL) {
if (p[i]->conf_file == NULL) {
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
"the default path name \"%V\" has "
"the same name as another default path, "
"but the different levels, you need to "
"redefine one of them in http section",
&p[i]->name);
return NGX_ERROR;
}
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
"the path name \"%V\" in %s:%ui has "
"the same name as default path but "
"the same name as default path, but "
"the different levels, you need to "
"define default path in http section",
&p[i]->name, p[i]->conf_file, p[i]->line);

View File

@ -79,16 +79,28 @@ ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
}
ngx_uint_t ngx_regex_capture_count(ngx_regex_t *re)
{
int rc, n;
n = 0;
rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n);
return (ngx_uint_t) n;
}
ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
int *matches, ngx_int_t size)
int *captures, ngx_int_t size)
{
int rc;
rc = pcre_exec(re, NULL, (const char *) s->data, s->len, 0, 0,
matches, size);
captures, size);
if (rc == -1) {
return NGX_DECLINED;
return NGX_REGEX_NO_MATCHED;
}
return rc;

View File

@ -14,15 +14,18 @@
#include <pcre.h>
#define NGX_REGEX_CASELESS PCRE_CASELESS
#define NGX_REGEX_NO_MATCHED -1000
#define NGX_REGEX_CASELESS PCRE_CASELESS
typedef pcre ngx_regex_t;
void ngx_regex_init();
ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
ngx_pool_t *pool, ngx_str_t *err);
ngx_uint_t ngx_regex_capture_count(ngx_regex_t *re);
ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
int *matches, ngx_int_t size);
int *captures, ngx_int_t size);
#define ngx_regex_exec_n "pcre_exec()"

View File

@ -229,7 +229,7 @@ static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
}
ee.events = event | flags;
ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
ee.data.u64 = (uintptr_t) c | ev->instance;
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"epoll add event: fd:%d op:%d ev:%08XD",
@ -282,7 +282,7 @@ static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
if (e->active) {
op = EPOLL_CTL_MOD;
ee.events = prev | flags;
ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);
ee.data.u64 = (uintptr_t) c | ev->instance;
} else {
op = EPOLL_CTL_DEL;
@ -311,7 +311,7 @@ static int ngx_epoll_add_connection(ngx_connection_t *c)
struct epoll_event ee;
ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
ee.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
ee.data.u64 = (uintptr_t) c | c->read->instance;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
"epoll add connection: fd:%d ev:%08XD", c->fd, ee.events);
@ -351,7 +351,7 @@ static int ngx_epoll_del_connection(ngx_connection_t *c, u_int flags)
op = EPOLL_CTL_DEL;
ee.events = 0;
ee.data.ptr = NULL;
ee.data.u64 = 0;
if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,

View File

@ -318,6 +318,7 @@ static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle)
rev = cycle->read_events;
for (i = 0; i < cycle->connection_n; i++) {
rev[i].closed = 1;
rev[i].instance = 1;
#if (NGX_THREADS)
rev[i].lock = &c[i].lock;
rev[i].own_lock = &c[i].lock;
@ -325,7 +326,7 @@ static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle)
}
cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * ecf->connections,
cycle->log);
cycle->log);
if (cycle->write_events == NULL) {
return NGX_ERROR;
}
@ -361,6 +362,7 @@ static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle)
ngx_memzero(c, sizeof(ngx_connection_t));
ngx_memzero(rev, sizeof(ngx_event_t));
ngx_memzero(wev, sizeof(ngx_event_t));
c->fd = s[i].fd;
c->listening = &s[i];

View File

@ -144,6 +144,9 @@ static ngx_str_t ngx_http_fastcgi_methods[] = {
};
static ngx_str_t ngx_http_fastcgi_uri = ngx_string("/");
static ngx_http_header_t ngx_http_fastcgi_headers_in[] = {
{ ngx_string("Status"), offsetof(ngx_http_fastcgi_headers_in_t, status) },
@ -474,8 +477,8 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r)
}
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
len += 1 + ((r->uri.len > 127) ? 4 : 1)
+ sizeof("REQUEST_URI") - 1 + r->uri.len;
len += 1 + ((r->unparsed_uri.len > 127) ? 4 : 1)
+ sizeof("REQUEST_URI") - 1 + r->unparsed_uri.len;
}
if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) {
@ -734,7 +737,7 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r)
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
*b->last++ = sizeof("REQUEST_URI") - 1;
len = r->uri.len;
len = r->unparsed_uri.len;
if (len > 127) {
*b->last++ = (u_char) (((len >> 24) & 0x7f) | 0x80);
*b->last++ = (u_char) ((len >> 16) & 0xff);
@ -746,7 +749,7 @@ static ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r)
}
b->last = ngx_cpymem(b->last, "REQUEST_URI", sizeof("REQUEST_URI") - 1);
b->last = ngx_cpymem(b->last, r->uri.data, len);
b->last = ngx_cpymem(b->last, r->unparsed_uri.data, len);
}
@ -1718,7 +1721,6 @@ static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
unix_upstream.name = value[1];
unix_upstream.url = value[1];
if (!(lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream))) {
return NGX_CONF_ERROR;
}
@ -1744,9 +1746,10 @@ static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
lcf->location = &clcf->name;
clcf->handler = ngx_http_fastcgi_handler;
lcf->location = clcf->regex ? &ngx_http_fastcgi_uri: &clcf->name;
if (clcf->name.data[clcf->name.len - 1] == '/') {
clcf->auto_redirect = 1;
}

View File

@ -23,7 +23,7 @@ typedef struct {
typedef struct {
ngx_regex_t *regex;
ngx_uint_t msize;
ngx_uint_t ncaptures;
ngx_array_t ops;
ngx_uint_t size;
@ -113,7 +113,7 @@ ngx_module_t ngx_http_rewrite_module = {
static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
{
int *matches;
int *captures;
u_char *p;
size_t len;
uintptr_t data;
@ -132,18 +132,20 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
rule = scf->rules.elts;
for (i = 0; i < scf->rules.nelts; i++) {
if (rule[i].msize) {
if (!(matches = ngx_palloc(r->pool, rule[i].msize * sizeof(int)))) {
if (rule[i].ncaptures) {
captures = ngx_palloc(r->pool, rule[i].ncaptures * sizeof(int));
if (captures == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
} else {
matches = NULL;
captures = NULL;
}
rc = ngx_regex_exec(rule[i].regex, &r->uri, matches, rule[i].msize);
rc = ngx_regex_exec(rule[i].regex, &r->uri,
captures, rule[i].ncaptures);
if (rc == NGX_DECLINED) {
if (rc == NGX_REGEX_NO_MATCHED) {
if (scf->log) {
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
"\"%V\" does not match \"%V\"",
@ -174,7 +176,7 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
uri.len = rule[i].size;
for (n = 1; n < (ngx_uint_t) rc; n++) {
uri.len += matches[2 * n + 1] - matches[2 * n];
uri.len += captures[2 * n + 1] - captures[2 * n];
}
if (!(uri.data = ngx_palloc(r->pool, uri.len))) {
@ -198,11 +200,13 @@ static ngx_int_t ngx_http_rewrite_handler(ngx_http_request_t *r)
} else { /* NGX_HTTP_REWRITE_COPY_MATCH */
m = 2 * op[n].data;
p = ngx_cpymem(p, &r->uri.data[matches[m]],
matches[m + 1] - matches[m]);
p = ngx_cpymem(p, &r->uri.data[captures[m]],
captures[m + 1] - captures[m]);
}
}
uri.len = p - uri.data;
if (scf->log) {
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
"rewritten uri: \"%V\"", &uri);
@ -309,7 +313,7 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
u_char *data, *p;
size_t len;
ngx_str_t *value, err;
ngx_uint_t i;
ngx_uint_t i, n;
ngx_http_rewrite_op_t *op;
ngx_http_rewrite_rule_t *rule;
u_char errstr[NGX_MAX_CONF_ERRSTR];
@ -321,7 +325,7 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
ngx_init_array(rule->ops, cf->pool, 5, sizeof(ngx_http_rewrite_op_t),
NGX_CONF_ERROR);
rule->msize = 0;
rule->ncaptures = 0;
rule->size = 0;
rule->status = 0;
rule->last = 0;
@ -371,8 +375,8 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
op->op = NGX_HTTP_REWRITE_COPY_MATCH;
op->data = value[2].data[++i] - '0';
if (rule->msize < op->data) {
rule->msize = op->data;
if (rule->ncaptures < op->data) {
rule->ncaptures = op->data;
}
i++;
@ -414,9 +418,22 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
}
}
if (rule->msize) {
rule->msize++;
rule->msize *= 3;
n = ngx_regex_capture_count(rule->regex);
if (rule->ncaptures > n) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"pattern \"%V\" has less captures "
"than referrenced in substitution \"%V\"",
&value[1], &value[2]);
return NGX_CONF_ERROR;
}
if (rule->ncaptures < n) {
rule->ncaptures = n;
}
if (rule->ncaptures) {
rule->ncaptures = (rule->ncaptures + 1) * 3;
}
if (cf->args->nelts > 3) {

View File

@ -1351,6 +1351,7 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
lcf->upstream->port_text = inet_upstream.port_text;
lcf->upstream->uri = inet_upstream.uri;
lcf->upstream->uri_separator = "";
lcf->upstream->default_port = inet_upstream.default_port;
}
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);

View File

@ -678,7 +678,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
n = ngx_regex_exec(clcfp[i]->regex, &r->uri, NULL, 0);
if (n == NGX_DECLINED) {
if (n == NGX_REGEX_NO_MATCHED) {
continue;
}

View File

@ -1034,7 +1034,7 @@ static void ngx_http_upstream_finalize_request(ngx_http_request_t *r,
r->connection->log->handler = u->saved_handler;
}
if (u->pipe.temp_file->file.fd) {
if (u->pipe.temp_file) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http upstream temp fd: %d",
u->pipe.temp_file->file.fd);
@ -1048,7 +1048,7 @@ static void ngx_http_upstream_finalize_request(ngx_http_request_t *r,
}
#endif
if (u->pipe.temp_file->file.fd) {
if (u->pipe.temp_file) {
r->file.fd = u->pipe.temp_file->file.fd;
#if 0

View File

@ -58,6 +58,7 @@ ngx_int_t ngx_write_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size,
msg.msg_namelen = 0;
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_flags = 0;
n = sendmsg(s, &msg, 0);