summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornginx <nginx@nginx.org>2013-08-27 14:05:15 +0000
committerJon Kolb <jon@b0g.us>2013-08-27 14:05:15 +0000
commitb4f0587460c1cec132bbf547b658057a674aa94e (patch)
tree1a3cc61bb188774ed3c180f6d09e99b2428e0ed8
parentc1d6dbb45ec3f5494f8d94d51e44807e04eda5fc (diff)
downloadnginx-b4f0587460c1cec132bbf547b658057a674aa94e.tar.gz
Changes with nginx 1.5.4 27 Aug 2013v1.5.4
*) Change: the "js" extension MIME type has been changed to "application/javascript"; default value of the "charset_types" directive was changed accordingly. *) Change: now the "image_filter" directive with the "size" parameter returns responses with the "application/json" MIME type. *) Feature: the ngx_http_auth_request_module. *) Bugfix: a segmentation fault might occur on start or during reconfiguration if the "try_files" directive was used with an empty parameter. *) Bugfix: memory leak if relative paths were specified using variables in the "root" or "auth_basic_user_file" directives. *) Bugfix: the "valid_referers" directive incorrectly executed regular expressions if a "Referer" header started with "https://". Thanks to Liangbin Li. *) Bugfix: responses might hang if subrequests were used and an SSL handshake error happened during subrequest processing. Thanks to Aviram Cohen. *) Bugfix: in the ngx_http_autoindex_module. *) Bugfix: in the ngx_http_spdy_module.
-rw-r--r--CHANGES31
-rw-r--r--CHANGES.ru33
-rw-r--r--auto/cc/sunc2
-rw-r--r--auto/endianness4
-rw-r--r--auto/feature2
-rw-r--r--auto/include2
-rw-r--r--auto/lib/pcre/make3
-rw-r--r--auto/lib/pcre/makefile.bcc3
-rw-r--r--auto/lib/pcre/makefile.msvc3
-rw-r--r--auto/lib/pcre/makefile.owc3
-rw-r--r--auto/lib/test2
-rw-r--r--auto/modules5
-rw-r--r--auto/options3
-rw-r--r--auto/sources4
-rw-r--r--auto/types/sizeof2
-rw-r--r--auto/types/typedef2
-rw-r--r--auto/types/uintptr_t2
-rw-r--r--conf/mime.types9
-rw-r--r--conf/nginx.conf7
-rw-r--r--src/core/nginx.h4
-rw-r--r--src/core/ngx_conf_file.c91
-rw-r--r--src/core/ngx_file.c91
-rw-r--r--src/core/ngx_file.h3
-rw-r--r--src/core/ngx_inet.c5
-rw-r--r--src/core/ngx_open_file_cache.c2
-rw-r--r--src/event/modules/ngx_devpoll_module.c4
-rw-r--r--src/http/modules/ngx_http_auth_request_module.c444
-rw-r--r--src/http/modules/ngx_http_autoindex_module.c6
-rw-r--r--src/http/modules/ngx_http_charset_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_image_filter_module.c2
-rw-r--r--src/http/modules/ngx_http_referer_module.c4
-rw-r--r--src/http/ngx_http_core_module.c14
-rw-r--r--src/http/ngx_http_file_cache.c3
-rw-r--r--src/http/ngx_http_parse.c3
-rw-r--r--src/http/ngx_http_script.c9
-rw-r--r--src/http/ngx_http_spdy.c26
-rw-r--r--src/http/ngx_http_special_response.c2
-rw-r--r--src/http/ngx_http_upstream.c6
-rw-r--r--src/http/ngx_http_variables.c10
-rw-r--r--src/os/unix/ngx_channel.c2
-rw-r--r--src/os/unix/ngx_darwin_sendfile_chain.c30
-rw-r--r--src/os/unix/ngx_errno.h2
-rw-r--r--src/os/unix/ngx_freebsd_sendfile_chain.c34
-rw-r--r--src/os/unix/ngx_linux_sendfile_chain.c36
-rw-r--r--src/os/unix/ngx_solaris_sendfilev_chain.c30
45 files changed, 778 insertions, 209 deletions
diff --git a/CHANGES b/CHANGES
index 35a60613b..57c6146b7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,35 @@
+Changes with nginx 1.5.4 27 Aug 2013
+
+ *) Change: the "js" extension MIME type has been changed to
+ "application/javascript"; default value of the "charset_types"
+ directive was changed accordingly.
+
+ *) Change: now the "image_filter" directive with the "size" parameter
+ returns responses with the "application/json" MIME type.
+
+ *) Feature: the ngx_http_auth_request_module.
+
+ *) Bugfix: a segmentation fault might occur on start or during
+ reconfiguration if the "try_files" directive was used with an empty
+ parameter.
+
+ *) Bugfix: memory leak if relative paths were specified using variables
+ in the "root" or "auth_basic_user_file" directives.
+
+ *) Bugfix: the "valid_referers" directive incorrectly executed regular
+ expressions if a "Referer" header started with "https://".
+ Thanks to Liangbin Li.
+
+ *) Bugfix: responses might hang if subrequests were used and an SSL
+ handshake error happened during subrequest processing.
+ Thanks to Aviram Cohen.
+
+ *) Bugfix: in the ngx_http_autoindex_module.
+
+ *) Bugfix: in the ngx_http_spdy_module.
+
+
Changes with nginx 1.5.3 30 Jul 2013
*) Change in internal API: now u->length defaults to -1 if working with
diff --git a/CHANGES.ru b/CHANGES.ru
index cd732bd93..bbc8b908c 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,37 @@
+Изменения в nginx 1.5.4 27.08.2013
+
+ *) Изменение: MIME-тип для расширения js изменён на
+ "application/javascript"; значение по умолчанию директивы
+ charset_types изменено соответственно.
+
+ *) Изменение: теперь директива image_filter с параметром size возвращает
+ ответ с MIME-типом "application/json".
+
+ *) Добавление: модуль ngx_http_auth_request_module.
+
+ *) Исправление: на старте или во время переконфигурации мог произойти
+ segmentation fault, если использовалась директива try_files с пустым
+ параметром.
+
+ *) Исправление: утечки памяти при использовании в директивах root и
+ auth_basic_user_file относительных путей, заданных с помощью
+ переменных.
+
+ *) Исправление: директива valid_referers неправильно выполняла
+ регулярные выражения, если заголовок Referer начинался с "https://".
+ Спасибо Liangbin Li.
+
+ *) Исправление: ответы могли зависать, если использовались подзапросы и
+ при обработке подзапроса происходила ошибка во время SSL handshake с
+ бэкендом.
+ Спасибо Aviram Cohen.
+
+ *) Исправление: в модуле ngx_http_autoindex_module.
+
+ *) Исправление: в модуле ngx_http_spdy_module.
+
+
Изменения в nginx 1.5.3 30.07.2013
*) Изменение во внутреннем API: теперь при небуферизированной работе с
diff --git a/auto/cc/sunc b/auto/cc/sunc
index dd9ccedfb..8f12d7cd7 100644
--- a/auto/cc/sunc
+++ b/auto/cc/sunc
@@ -30,7 +30,7 @@ if [ -x $NGX_AUTOTEST ]; then
ngx_sunc_ver=`$NGX_AUTOTEST`
fi
-rm $NGX_AUTOTEST*
+rm -rf $NGX_AUTOTEST*
# 1424 == 0x590, Sun Studio 12
diff --git a/auto/endianness b/auto/endianness
index 87311a0f1..93da2f80d 100644
--- a/auto/endianness
+++ b/auto/endianness
@@ -34,10 +34,10 @@ if [ -x $NGX_AUTOTEST ]; then
echo " big endian"
fi
- rm $NGX_AUTOTEST*
+ rm -rf $NGX_AUTOTEST*
else
- rm $NGX_AUTOTEST*
+ rm -rf $NGX_AUTOTEST*
echo
echo "$0: error: cannot detect system byte ordering"
diff --git a/auto/feature b/auto/feature
index c13e51dfb..1145f2868 100644
--- a/auto/feature
+++ b/auto/feature
@@ -120,4 +120,4 @@ else
echo "----------" >> $NGX_AUTOCONF_ERR
fi
-rm $NGX_AUTOTEST*
+rm -rf $NGX_AUTOTEST*
diff --git a/auto/include b/auto/include
index 3466fda15..e34dabdae 100644
--- a/auto/include
+++ b/auto/include
@@ -58,4 +58,4 @@ else
echo "----------" >> $NGX_AUTOCONF_ERR
fi
-rm $NGX_AUTOTEST*
+rm -rf $NGX_AUTOTEST*
diff --git a/auto/lib/pcre/make b/auto/lib/pcre/make
index 834779b9c..c50d12f9f 100644
--- a/auto/lib/pcre/make
+++ b/auto/lib/pcre/make
@@ -32,7 +32,8 @@ case "$NGX_PLATFORM" in
cat << END >> $NGX_MAKEFILE
-`echo "$PCRE/pcre.lib: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
+`echo "$PCRE/pcre.lib: $PCRE/pcre.h $NGX_MAKEFILE" \
+ | sed -e "s/\//$ngx_regex_dirsep/g"`
\$(MAKE) -f auto/lib/pcre/$ngx_makefile $ngx_pcre $ngx_opt
`echo "$PCRE/pcre.h:" | sed -e "s/\//$ngx_regex_dirsep/g"`
diff --git a/auto/lib/pcre/makefile.bcc b/auto/lib/pcre/makefile.bcc
index 1c140d668..7230f3205 100644
--- a/auto/lib/pcre/makefile.bcc
+++ b/auto/lib/pcre/makefile.bcc
@@ -4,7 +4,8 @@
CFLAGS = -q -O2 -tWM -w-8004 $(CPU_OPT)
-PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10
+PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 \
+ -DSUPPORT_PCRE8 -DHAVE_MEMMOVE
pcre.lib:
diff --git a/auto/lib/pcre/makefile.msvc b/auto/lib/pcre/makefile.msvc
index 7a8da7158..07fd9a285 100644
--- a/auto/lib/pcre/makefile.msvc
+++ b/auto/lib/pcre/makefile.msvc
@@ -4,7 +4,8 @@
CFLAGS = -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT)
-PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10
+PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 \
+ -DSUPPORT_PCRE8 -DHAVE_MEMMOVE
pcre.lib:
diff --git a/auto/lib/pcre/makefile.owc b/auto/lib/pcre/makefile.owc
index bfb692068..78f5257b3 100644
--- a/auto/lib/pcre/makefile.owc
+++ b/auto/lib/pcre/makefile.owc
@@ -4,7 +4,8 @@
CFLAGS = -c -zq -bt=nt -ot -op -oi -oe -s -bm $(CPU_OPT)
-PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10
+PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 \
+ -DSUPPORT_PCRE8 -DHAVE_MEMMOVE
pcre.lib:
diff --git a/auto/lib/test b/auto/lib/test
index 907e2353b..ba943a29d 100644
--- a/auto/lib/test
+++ b/auto/lib/test
@@ -37,4 +37,4 @@ else
echo " not found"
fi
-rm $NGX_AUTOTEST*
+rm -rf $NGX_AUTOTEST*
diff --git a/auto/modules b/auto/modules
index a78e785e5..e710ae0ff 100644
--- a/auto/modules
+++ b/auto/modules
@@ -220,6 +220,11 @@ if [ $HTTP_RANDOM_INDEX = YES ]; then
HTTP_SRCS="$HTTP_SRCS $HTTP_RANDOM_INDEX_SRCS"
fi
+if [ $HTTP_AUTH_REQUEST = YES ]; then
+ HTTP_MODULES="$HTTP_MODULES $HTTP_AUTH_REQUEST_MODULE"
+ HTTP_SRCS="$HTTP_SRCS $HTTP_AUTH_REQUEST_SRCS"
+fi
+
if [ $HTTP_AUTH_BASIC = YES ]; then
USE_MD5=YES
USE_SHA1=YES
diff --git a/auto/options b/auto/options
index 6713379e3..6cea8c7c2 100644
--- a/auto/options
+++ b/auto/options
@@ -71,6 +71,7 @@ HTTP_ADDITION=NO
HTTP_DAV=NO
HTTP_ACCESS=YES
HTTP_AUTH_BASIC=YES
+HTTP_AUTH_REQUEST=NO
HTTP_USERID=YES
HTTP_AUTOINDEX=YES
HTTP_RANDOM_INDEX=NO
@@ -215,6 +216,7 @@ do
--with-http_mp4_module) HTTP_MP4=YES ;;
--with-http_gunzip_module) HTTP_GUNZIP=YES ;;
--with-http_gzip_static_module) HTTP_GZIP_STATIC=YES ;;
+ --with-http_auth_request_module) HTTP_AUTH_REQUEST=YES ;;
--with-http_random_index_module) HTTP_RANDOM_INDEX=YES ;;
--with-http_secure_link_module) HTTP_SECURE_LINK=YES ;;
--with-http_degradation_module) HTTP_DEGRADATION=YES ;;
@@ -363,6 +365,7 @@ cat << END
--with-http_mp4_module enable ngx_http_mp4_module
--with-http_gunzip_module enable ngx_http_gunzip_module
--with-http_gzip_static_module enable ngx_http_gzip_static_module
+ --with-http_auth_request_module enable ngx_http_auth_request_module
--with-http_random_index_module enable ngx_http_random_index_module
--with-http_secure_link_module enable ngx_http_secure_link_module
--with-http_degradation_module enable ngx_http_degradation_module
diff --git a/auto/sources b/auto/sources
index 90465c314..7ae41b95f 100644
--- a/auto/sources
+++ b/auto/sources
@@ -386,6 +386,10 @@ HTTP_AUTH_BASIC_MODULE=ngx_http_auth_basic_module
HTTP_AUTH_BASIC_SRCS=src/http/modules/ngx_http_auth_basic_module.c
+HTTP_AUTH_REQUEST_MODULE=ngx_http_auth_request_module
+HTTP_AUTH_REQUEST_SRCS=src/http/modules/ngx_http_auth_request_module.c
+
+
HTTP_AUTOINDEX_MODULE=ngx_http_autoindex_module
HTTP_AUTOINDEX_SRCS=src/http/modules/ngx_http_autoindex_module.c
diff --git a/auto/types/sizeof b/auto/types/sizeof
index e1d405c65..9215a545f 100644
--- a/auto/types/sizeof
+++ b/auto/types/sizeof
@@ -45,7 +45,7 @@ if [ -x $NGX_AUTOTEST ]; then
fi
-rm -f $NGX_AUTOTEST
+rm -rf $NGX_AUTOTEST*
case $ngx_size in
diff --git a/auto/types/typedef b/auto/types/typedef
index d81229331..8b5c3689c 100644
--- a/auto/types/typedef
+++ b/auto/types/typedef
@@ -49,7 +49,7 @@ END
fi
fi
- rm -f $NGX_AUTOTEST
+ rm -rf $NGX_AUTOTEST*
if [ $ngx_found = no ]; then
echo $ngx_n " $ngx_try not found$ngx_c"
diff --git a/auto/types/uintptr_t b/auto/types/uintptr_t
index 2f1908035..f3cdccb22 100644
--- a/auto/types/uintptr_t
+++ b/auto/types/uintptr_t
@@ -33,7 +33,7 @@ else
echo $ngx_n " uintptr_t not found" $ngx_c
fi
-rm $NGX_AUTOTEST*
+rm -rf $NGX_AUTOTEST*
if [ $found = no ]; then
diff --git a/conf/mime.types b/conf/mime.types
index 8a218b22a..6e3e8e00e 100644
--- a/conf/mime.types
+++ b/conf/mime.types
@@ -5,7 +5,7 @@ types {
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
- application/x-javascript js;
+ application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
@@ -24,6 +24,7 @@ types {
image/svg+xml svg svgz;
image/webp webp;
+ application/font-woff woff;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
@@ -31,6 +32,7 @@ types {
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
+ application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
@@ -56,10 +58,13 @@ types {
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
- application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
+ application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
+ application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
+ application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
+
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 3bb338936..29bc085f2 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -96,18 +96,17 @@ http {
# HTTPS server
#
#server {
- # listen 443;
+ # listen 443 ssl;
# server_name localhost;
- # ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
+ # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
- # ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
+ # ssl_prefer_server_ciphers on;
# location / {
# root html;
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 396abacc5..c2ecbfd86 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -9,8 +9,8 @@
#define _NGINX_H_INCLUDED_
-#define nginx_version 1005003
-#define NGINX_VERSION "1.5.3"
+#define nginx_version 1005004
+#define NGINX_VERSION "1.5.4"
#define NGINX_VER "nginx/" NGINX_VERSION
#define NGINX_VAR "NGINX"
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 0d12ec2cd..f61bfcabf 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -12,7 +12,6 @@
static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
-static ngx_int_t ngx_conf_test_full_name(ngx_str_t *name);
static void ngx_conf_flush_files(ngx_cycle_t *cycle);
@@ -801,95 +800,11 @@ ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_int_t
ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
{
- size_t len;
- u_char *p, *n, *prefix;
- ngx_int_t rc;
+ ngx_str_t *prefix;
- rc = ngx_conf_test_full_name(name);
+ prefix = conf_prefix ? &cycle->conf_prefix : &cycle->prefix;
- if (rc == NGX_OK) {
- return rc;
- }
-
- if (conf_prefix) {
- len = cycle->conf_prefix.len;
- prefix = cycle->conf_prefix.data;
-
- } else {
- len = cycle->prefix.len;
- prefix = cycle->prefix.data;
- }
-
-#if (NGX_WIN32)
-
- if (rc == 2) {
- len = rc;
- }
-
-#endif
-
- n = ngx_pnalloc(cycle->pool, len + name->len + 1);
- if (n == NULL) {
- return NGX_ERROR;
- }
-
- p = ngx_cpymem(n, prefix, len);
- ngx_cpystrn(p, name->data, name->len + 1);
-
- name->len += len;
- name->data = n;
-
- return NGX_OK;
-}
-
-
-static ngx_int_t
-ngx_conf_test_full_name(ngx_str_t *name)
-{
-#if (NGX_WIN32)
- u_char c0, c1;
-
- c0 = name->data[0];
-
- if (name->len < 2) {
- if (c0 == '/') {
- return 2;
- }
-
- return NGX_DECLINED;
- }
-
- c1 = name->data[1];
-
- if (c1 == ':') {
- c0 |= 0x20;
-
- if ((c0 >= 'a' && c0 <= 'z')) {
- return NGX_OK;
- }
-
- return NGX_DECLINED;
- }
-
- if (c1 == '/') {
- return NGX_OK;
- }
-
- if (c0 == '/') {
- return 2;
- }
-
- return NGX_DECLINED;
-
-#else
-
- if (name->data[0] == '/') {
- return NGX_OK;
- }
-
- return NGX_DECLINED;
-
-#endif
+ return ngx_get_full_name(cycle->pool, prefix, name);
}
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 35f5f8dc3..28e8871ec 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -9,11 +9,102 @@
#include <ngx_core.h>
+static ngx_int_t ngx_test_full_name(ngx_str_t *name);
+
+
static ngx_atomic_t temp_number = 0;
ngx_atomic_t *ngx_temp_number = &temp_number;
ngx_atomic_int_t ngx_random_number = 123456;
+ngx_int_t
+ngx_get_full_name(ngx_pool_t *pool, ngx_str_t *prefix, ngx_str_t *name)
+{
+ size_t len;
+ u_char *p, *n;
+ ngx_int_t rc;
+
+ rc = ngx_test_full_name(name);
+
+ if (rc == NGX_OK) {
+ return rc;
+ }
+
+ len = prefix->len;
+
+#if (NGX_WIN32)
+
+ if (rc == 2) {
+ len = rc;
+ }
+
+#endif
+
+ n = ngx_pnalloc(pool, len + name->len + 1);
+ if (n == NULL) {
+ return NGX_ERROR;
+ }
+
+ p = ngx_cpymem(n, prefix->data, len);
+ ngx_cpystrn(p, name->data, name->len + 1);
+
+ name->len += len;
+ name->data = n;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_test_full_name(ngx_str_t *name)
+{
+#if (NGX_WIN32)
+ u_char c0, c1;
+
+ c0 = name->data[0];
+
+ if (name->len < 2) {
+ if (c0 == '/') {
+ return 2;
+ }
+
+ return NGX_DECLINED;
+ }
+
+ c1 = name->data[1];
+
+ if (c1 == ':') {
+ c0 |= 0x20;
+
+ if ((c0 >= 'a' && c0 <= 'z')) {
+ return NGX_OK;
+ }
+
+ return NGX_DECLINED;
+ }
+
+ if (c1 == '/') {
+ return NGX_OK;
+ }
+
+ if (c0 == '/') {
+ return 2;
+ }
+
+ return NGX_DECLINED;
+
+#else
+
+ if (name->data[0] == '/') {
+ return NGX_OK;
+ }
+
+ return NGX_DECLINED;
+
+#endif
+}
+
+
ssize_t
ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
{
diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h
index 18abf1423..3ea6c28c8 100644
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -122,6 +122,9 @@ struct ngx_tree_ctx_s {
};
+ngx_int_t ngx_get_full_name(ngx_pool_t *pool, ngx_str_t *prefix,
+ ngx_str_t *name);
+
ssize_t ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain);
ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
ngx_pool_t *pool, ngx_uint_t persistent, ngx_uint_t clean,
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c
index 5dca72bc2..0792d6e8c 100644
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -233,7 +233,7 @@ ngx_sock_ntop(struct sockaddr *sa, socklen_t socklen, u_char *text, size_t len,
/* on Linux sockaddr might not include sun_path at all */
- if (socklen <= offsetof(struct sockaddr_un, sun_path)) {
+ if (socklen <= (socklen_t) offsetof(struct sockaddr_un, sun_path)) {
p = ngx_snprintf(text, len, "unix:%Z");
} else {
@@ -963,6 +963,9 @@ ngx_inet_resolve_host(ngx_pool_t *pool, ngx_url_t *u)
ngx_memzero(&hints, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
+#ifdef AI_ADDRCONFIG
+ hints.ai_flags = AI_ADDRCONFIG;
+#endif
if (getaddrinfo((char *) host, NULL, &hints, &res) != 0) {
u->err = "host not found";
diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c
index c44ac96b8..b72af5ea0 100644
--- a/src/core/ngx_open_file_cache.c
+++ b/src/core/ngx_open_file_cache.c
@@ -124,7 +124,7 @@ ngx_open_file_cache_cleanup(void *data)
if (cache->current) {
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
- "%d items still leave in open file cache",
+ "%ui items still leave in open file cache",
cache->current);
}
diff --git a/src/event/modules/ngx_devpoll_module.c b/src/event/modules/ngx_devpoll_module.c
index 6fdd00233..0506103e6 100644
--- a/src/event/modules/ngx_devpoll_module.c
+++ b/src/event/modules/ngx_devpoll_module.c
@@ -425,7 +425,7 @@ ngx_devpoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
case -1:
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
- "ioctl(DP_ISPOLLED) failed for socket %d, event",
+ "ioctl(DP_ISPOLLED) failed for socket %d, event %04Xd",
fd, revents);
break;
@@ -449,7 +449,7 @@ ngx_devpoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
!= (ssize_t) sizeof(struct pollfd))
{
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
- "write(/dev/poll) for %d failed, fd");
+ "write(/dev/poll) for %d failed", fd);
}
if (close(fd) == -1) {
diff --git a/src/http/modules/ngx_http_auth_request_module.c b/src/http/modules/ngx_http_auth_request_module.c
new file mode 100644
index 000000000..b4307be2e
--- /dev/null
+++ b/src/http/modules/ngx_http_auth_request_module.c
@@ -0,0 +1,444 @@
+
+/*
+ * Copyright (C) Maxim Dounin
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_http.h>
+
+
+typedef struct {
+ ngx_str_t uri;
+ ngx_array_t *vars;
+} ngx_http_auth_request_conf_t;
+
+
+typedef struct {
+ ngx_uint_t done;
+ ngx_uint_t status;
+ ngx_http_request_t *subrequest;
+} ngx_http_auth_request_ctx_t;
+
+
+typedef struct {
+ ngx_int_t index;
+ ngx_http_complex_value_t value;
+ ngx_http_set_variable_pt set_handler;
+} ngx_http_auth_request_variable_t;
+
+
+static ngx_int_t ngx_http_auth_request_handler(ngx_http_request_t *r);
+static ngx_int_t ngx_http_auth_request_done(ngx_http_request_t *r,
+ void *data, ngx_int_t rc);
+static ngx_int_t ngx_http_auth_request_set_variables(ngx_http_request_t *r,
+ ngx_http_auth_request_conf_t *arcf, ngx_http_auth_request_ctx_t *ctx);
+static ngx_int_t ngx_http_auth_request_variable(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
+static void *ngx_http_auth_request_create_conf(ngx_conf_t *cf);
+static char *ngx_http_auth_request_merge_conf(ngx_conf_t *cf,
+ void *parent, void *child);
+static ngx_int_t ngx_http_auth_request_init(ngx_conf_t *cf);
+static char *ngx_http_auth_request(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
+static char *ngx_http_auth_request_set(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
+
+
+static ngx_command_t ngx_http_auth_request_commands[] = {
+
+ { ngx_string("auth_request"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_http_auth_request,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
+ { ngx_string("auth_request_set"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
+ ngx_http_auth_request_set,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
+ ngx_null_command
+};
+
+
+static ngx_http_module_t ngx_http_auth_request_module_ctx = {
+ NULL, /* preconfiguration */
+ ngx_http_auth_request_init, /* postconfiguration */
+
+ NULL, /* create main configuration */
+ NULL, /* init main configuration */
+
+ NULL, /* create server configuration */
+ NULL, /* merge server configuration */
+
+ ngx_http_auth_request_create_conf, /* create location configuration */
+ ngx_http_auth_request_merge_conf /* merge location configuration */
+};
+
+
+ngx_module_t ngx_http_auth_request_module = {
+ NGX_MODULE_V1,
+ &ngx_http_auth_request_module_ctx, /* module context */
+ ngx_http_auth_request_commands, /* module directives */
+ NGX_HTTP_MODULE, /* module type */
+ NULL, /* init master */
+ NULL, /* init module */
+ NULL, /* init process */
+ NULL, /* init thread */
+ NULL, /* exit thread */
+ NULL, /* exit process */
+ NULL, /* exit master */
+ NGX_MODULE_V1_PADDING
+};
+
+
+static ngx_int_t
+ngx_http_auth_request_handler(ngx_http_request_t *r)
+{
+ ngx_table_elt_t *h, *ho;
+ ngx_http_request_t *sr;
+ ngx_http_post_subrequest_t *ps;
+ ngx_http_auth_request_ctx_t *ctx;
+ ngx_http_auth_request_conf_t *arcf;
+
+ arcf = ngx_http_get_module_loc_conf(r, ngx_http_auth_request_module);
+
+ if (arcf->uri.len == 0) {
+ return NGX_DECLINED;
+ }
+
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "auth request handler");
+
+ ctx = ngx_http_get_module_ctx(r, ngx_http_auth_request_module);
+
+ if (ctx != NULL) {
+ if (!ctx->done) {
+ return NGX_AGAIN;
+ }
+
+ /*
+ * as soon as we are done - explicitly set variables to make
+ * sure they will be available after internal redirects
+ */
+
+ if (ngx_http_auth_request_set_variables(r, arcf, ctx) != NGX_OK) {
+ return NGX_ERROR;
+ }
+
+ /* return appropriate status */
+
+ if (ctx->status == NGX_HTTP_FORBIDDEN) {
+ return ctx->status;
+ }
+
+ if (ctx->status == NGX_HTTP_UNAUTHORIZED) {
+ sr = ctx->subrequest;
+
+ h = sr->headers_out.www_authenticate;
+
+ if (!h && sr->upstream) {
+ h = sr->upstream->headers_in.www_authenticate;
+ }
+
+ if (h) {
+ ho = ngx_list_push(&r->headers_out.headers);
+ if (ho == NULL) {
+ return NGX_ERROR;
+ }
+
+ *ho = *h;
+
+ r->headers_out.www_authenticate = ho;
+ }
+
+ return ctx->status;
+ }
+
+ if (ctx->status >= NGX_HTTP_OK
+ && ctx->status < NGX_HTTP_SPECIAL_RESPONSE)
+ {
+ return NGX_OK;
+ }
+
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "auth request unexpected status: %d", ctx->status);
+
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_auth_request_ctx_t));
+ if (ctx == NULL) {
+ return NGX_ERROR;
+ }
+
+ ps = ngx_palloc(r->pool, sizeof(ngx_http_post_subrequest_t));
+ if (ps == NULL) {
+ return NGX_ERROR;
+ }
+
+ ps->handler = ngx_http_auth_request_done;
+ ps->data = ctx;
+
+ if (ngx_http_subrequest(r, &arcf->uri, NULL, &sr, ps,
+ NGX_HTTP_SUBREQUEST_WAITED)
+ != NGX_OK)
+ {
+ return NGX_ERROR;
+ }
+
+ /*
+ * allocate fake request body to avoid attempts to read it and to make
+ * sure real body file (if already read) won't be closed by upstream
+ */
+
+ sr->request_body = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
+ if (sr->request_body == NULL) {
+ return NGX_ERROR;
+ }
+
+ sr->header_only = 1;
+
+ ctx->subrequest = sr;
+
+ ngx_http_set_ctx(r, ctx, ngx_http_auth_request_module);
+
+ return NGX_AGAIN;
+}
+
+
+static ngx_int_t
+ngx_http_auth_request_done(ngx_http_request_t *r, void *data, ngx_int_t rc)
+{
+ ngx_http_auth_request_ctx_t *ctx = data;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "auth request done s:%d", r->headers_out.status);
+
+ ctx->done = 1;
+ ctx->status = r->headers_out.status;
+
+ return rc;
+}
+
+
+static ngx_int_t
+ngx_http_auth_request_set_variables(ngx_http_request_t *r,
+ ngx_http_auth_request_conf_t *arcf, ngx_http_auth_request_ctx_t *ctx)
+{
+ ngx_str_t val;
+ ngx_http_variable_t *v;
+ ngx_http_variable_value_t *vv;
+ ngx_http_auth_request_variable_t *av, *last;
+ ngx_http_core_main_conf_t *cmcf;
+
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "auth request set variables");
+
+ if (arcf->vars == NULL) {
+ return NGX_OK;
+ }
+
+ cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
+ v = cmcf->variables.elts;
+
+ av = arcf->vars->elts;
+ last = av + arcf->vars->nelts;
+
+ while (av < last) {
+ /*
+ * explicitly set new value to make sure it will be available after
+ * internal redirects
+ */
+
+ vv = &r->variables[av->index];
+
+ if (ngx_http_complex_value(ctx->subrequest, &av->value, &val)
+ != NGX_OK)
+ {
+ return NGX_ERROR;
+ }
+
+ vv->valid = 1;
+ vv->not_found = 0;
+ vv->data = val.data;
+ vv->len = val.len;
+
+ if (av->set_handler) {
+ /*
+ * set_handler only available in cmcf->variables_keys, so we store
+ * it explicitly
+ */
+
+ av->set_handler(r, vv, v[av->index].data);
+ }
+
+ av++;
+ }
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_http_auth_request_variable(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "auth request variable");
+
+ v->not_found = 1;
+
+ return NGX_OK;
+}
+
+
+static void *
+ngx_http_auth_request_create_conf(ngx_conf_t *cf)
+{
+ ngx_http_auth_request_conf_t *conf;
+
+ conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_auth_request_conf_t));
+ if (conf == NULL) {
+ return NULL;
+ }
+
+ /*
+ * set by ngx_pcalloc():
+ *
+ * conf->uri = { 0, NULL };
+ */
+
+ conf->vars = NGX_CONF_UNSET_PTR;
+
+ return conf;
+}
+
+
+static char *
+ngx_http_auth_request_merge_conf(ngx_conf_t *cf, void *parent, void *child)
+{
+ ngx_http_auth_request_conf_t *prev = parent;
+ ngx_http_auth_request_conf_t *conf = child;
+
+ ngx_conf_merge_str_value(conf->uri, prev->uri, "");
+ ngx_conf_merge_ptr_value(conf->vars, prev->vars, NULL);
+
+ return NGX_CONF_OK;
+}
+
+
+static ngx_int_t
+ngx_http_auth_request_init(ngx_conf_t *cf)
+{
+ ngx_http_handler_pt *h;
+ ngx_http_core_main_conf_t *cmcf;
+
+ cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
+
+ h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
+ if (h == NULL) {
+ return NGX_ERROR;
+ }
+
+ *h = ngx_http_auth_request_handler;
+
+ return NGX_OK;
+}
+
+
+static char *
+ngx_http_auth_request(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ ngx_http_auth_request_conf_t *arcf = conf;
+
+ ngx_str_t *value;
+
+ if (arcf->uri.data != NULL) {
+ return "is duplicate";
+ }
+
+ value = cf->args->elts;
+
+ if (ngx_strcmp(value[1].data, "off") == 0) {
+ arcf->uri.len = 0;
+ arcf->uri.data = (u_char *) "";
+
+ return NGX_CONF_OK;
+ }
+
+ arcf->uri = value[1];
+
+ return NGX_CONF_OK;
+}
+
+
+static char *
+ngx_http_auth_request_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ ngx_http_auth_request_conf_t *arcf = conf;
+
+ ngx_str_t *value;
+ ngx_http_variable_t *v;
+ ngx_http_auth_request_variable_t *av;
+ ngx_http_compile_complex_value_t ccv;
+
+ value = cf->args->elts;
+
+ if (value[1].data[0] != '$') {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid variable name \"%V\"", &value[1]);
+ return NGX_CONF_ERROR;
+ }
+
+ value[1].len--;
+ value[1].data++;
+
+ if (arcf->vars == NGX_CONF_UNSET_PTR) {
+ arcf->vars = ngx_array_create(cf->pool, 1,
+ sizeof(ngx_http_auth_request_variable_t));
+ if (arcf->vars == NULL) {
+ return NGX_CONF_ERROR;
+ }
+ }
+
+ av = ngx_array_push(arcf->vars);
+ if (av == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ v = ngx_http_add_variable(cf, &value[1], NGX_HTTP_VAR_CHANGEABLE);
+ if (v == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ av->index = ngx_http_get_variable_index(cf, &value[1]);
+ if (av->index == NGX_ERROR) {
+ return NGX_CONF_ERROR;
+ }
+
+ if (v->get_handler == NULL) {
+ v->get_handler = ngx_http_auth_request_variable;
+ v->data = (uintptr_t) av;
+ }
+
+ av->set_handler = v->set_handler;
+
+ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
+
+ ccv.cf = cf;
+ ccv.value = &value[2];
+ ccv.complex_value = &av->value;
+
+ if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
+
+ return NGX_CONF_OK;
+}
diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
index e3dcfd07e..221455120 100644
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -304,7 +304,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
if (ngx_de_info(filename, &dir) == NGX_FILE_ERROR) {
err = ngx_errno;
- if (err != NGX_ENOENT) {
+ if (err != NGX_ENOENT && err != NGX_ELOOP) {
ngx_log_error(NGX_LOG_CRIT, r->connection->log, err,
ngx_de_info_n " \"%s\" failed", filename);
@@ -388,7 +388,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
b = ngx_create_temp_buf(r->pool, len);
if (b == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ return NGX_ERROR;
}
if (entries.nelts > 1) {
@@ -649,7 +649,7 @@ ngx_http_autoindex_error(ngx_http_request_t *r, ngx_dir_t *dir, ngx_str_t *name)
ngx_close_dir_n " \"%V\" failed", name);
}
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ return r->header_sent ? NGX_ERROR : NGX_HTTP_INTERNAL_SERVER_ERROR;
}
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c
index 27a00d09a..c9b7e9e89 100644
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -128,7 +128,7 @@ ngx_str_t ngx_http_charset_default_types[] = {
ngx_string("text/xml"),
ngx_string("text/plain"),
ngx_string("text/vnd.wap.wml"),
- ngx_string("application/x-javascript"),
+ ngx_string("application/javascript"),
ngx_string("application/rss+xml"),
ngx_null_string
};
diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c
index c6c3b747a..6d3f47dcb 100644
--- a/src/http/modules/ngx_http_image_filter_module.c
+++ b/src/http/modules/ngx_http_image_filter_module.c
@@ -567,7 +567,7 @@ ngx_http_image_json(ngx_http_request_t *r, ngx_http_image_filter_ctx_t *ctx)
ngx_http_clean_header(r);
r->headers_out.status = NGX_HTTP_OK;
- ngx_str_set(&r->headers_out.content_type, "text/plain");
+ ngx_str_set(&r->headers_out.content_type, "application/json");
r->headers_out.content_type_lowcase = NULL;
if (ctx == NULL) {
diff --git a/src/http/modules/ngx_http_referer_module.c b/src/http/modules/ngx_http_referer_module.c
index d18b8b9d8..85b75ab3d 100644
--- a/src/http/modules/ngx_http_referer_module.c
+++ b/src/http/modules/ngx_http_referer_module.c
@@ -147,10 +147,12 @@ ngx_http_referer_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
if (ngx_strncasecmp(ref, (u_char *) "http://", 7) == 0) {
ref += 7;
+ len -= 7;
goto valid_scheme;
} else if (ngx_strncasecmp(ref, (u_char *) "https://", 8) == 0) {
ref += 8;
+ len -= 8;
goto valid_scheme;
}
}
@@ -191,7 +193,7 @@ valid_scheme:
ngx_int_t rc;
ngx_str_t referer;
- referer.len = len - 7;
+ referer.len = len;
referer.data = ref;
rc = ngx_regex_exec_array(rlcf->regex, &referer, r->connection->log);
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 12a82eb9c..85b4fe882 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1933,6 +1933,12 @@ ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
ngx_int_t
ngx_http_send_header(ngx_http_request_t *r)
{
+ if (r->header_sent) {
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
+ "header already sent");
+ return NGX_ERROR;
+ }
+
if (r->err_status) {
r->headers_out.status = r->err_status;
r->headers_out.status_line.len = 0;
@@ -2016,7 +2022,9 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
return NULL;
}
- if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, path, 0) != NGX_OK) {
+ if (ngx_get_full_name(r->pool, (ngx_str_t *) &ngx_cycle->prefix, path)
+ != NGX_OK)
+ {
return NULL;
}
@@ -4758,7 +4766,9 @@ ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
tf[i].name = value[i + 1];
- if (tf[i].name.data[tf[i].name.len - 1] == '/') {
+ if (tf[i].name.len > 0
+ && tf[i].name.data[tf[i].name.len - 1] == '/')
+ {
tf[i].test_dir = 1;
tf[i].name.len--;
tf[i].name.data[tf[i].name.len] = '\0';
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
index eacca595a..cf27683e6 100644
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -445,8 +445,7 @@ ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev)
timer = c->wait_time - ngx_current_msec;
if ((ngx_msec_int_t) timer <= 0) {
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
- "http file cache lock timeout");
+ ngx_log_error(NGX_LOG_INFO, ev->log, 0, "cache lock timeout");
c->lock = 0;
goto wakeup;
}
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index 697d856a0..973bc7430 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -212,14 +212,17 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
case 5:
if (ngx_str5cmp(m, 'M', 'K', 'C', 'O', 'L')) {
r->method = NGX_HTTP_MKCOL;
+ break;
}
if (ngx_str5cmp(m, 'P', 'A', 'T', 'C', 'H')) {
r->method = NGX_HTTP_PATCH;
+ break;
}
if (ngx_str5cmp(m, 'T', 'R', 'A', 'C', 'E')) {
r->method = NGX_HTTP_TRACE;
+ break;
}
break;
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
index 54d019589..5fc4cfca0 100644
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -1327,16 +1327,17 @@ ngx_http_script_full_name_code(ngx_http_script_engine_t *e)
{
ngx_http_script_full_name_code_t *code;
- ngx_str_t value;
+ ngx_str_t value, *prefix;
code = (ngx_http_script_full_name_code_t *) e->ip;
value.data = e->buf.data;
value.len = e->pos - e->buf.data;
- if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &value, code->conf_prefix)
- != NGX_OK)
- {
+ prefix = code->conf_prefix ? (ngx_str_t *) &ngx_cycle->conf_prefix:
+ (ngx_str_t *) &ngx_cycle->prefix;
+
+ if (ngx_get_full_name(e->request->pool, prefix, &value) != NGX_OK) {
e->ip = ngx_http_script_exit;
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
return;
diff --git a/src/http/ngx_http_spdy.c b/src/http/ngx_http_spdy.c
index f8136213a..e7bebccd5 100644
--- a/src/http/ngx_http_spdy.c
+++ b/src/http/ngx_http_spdy.c
@@ -809,6 +809,8 @@ ngx_http_spdy_state_headers(ngx_http_spdy_connection_t *sc, u_char *pos,
sc->zstream_in.next_in = pos;
sc->zstream_in.avail_in = size;
sc->zstream_in.next_out = buf->last;
+
+ /* one byte is reserved for null-termination of the last header value */
sc->zstream_in.avail_out = buf->end - buf->last - 1;
z = inflate(&sc->zstream_in, Z_NO_FLUSH);
@@ -912,9 +914,14 @@ ngx_http_spdy_state_headers(ngx_http_spdy_connection_t *sc, u_char *pos,
return ngx_http_spdy_state_headers_error(sc, pos, end);
}
+ /* null-terminate the last processed header name or value */
+ *buf->pos = '\0';
+
buf = r->header_in;
sc->zstream_in.next_out = buf->last;
+
+ /* one byte is reserved for null-termination */
sc->zstream_in.avail_out = buf->end - buf->last - 1;
z = inflate(&sc->zstream_in, Z_NO_FLUSH);
@@ -996,6 +1003,9 @@ ngx_http_spdy_state_headers(ngx_http_spdy_connection_t *sc, u_char *pos,
ngx_http_spdy_state_headers);
}
+ /* null-terminate the last header value */
+ *buf->pos = '\0';
+
ngx_http_spdy_run_request(r);
return ngx_http_spdy_state_complete(sc, pos, end);
@@ -1936,6 +1946,9 @@ ngx_http_spdy_parse_header(ngx_http_request_t *r)
return NGX_HTTP_PARSE_INVALID_HEADER;
}
+ /* null-terminate the previous header value */
+ *p = '\0';
+
p += NGX_SPDY_NV_NLEN_SIZE;
r->header_name_end = p + len;
@@ -2001,9 +2014,8 @@ ngx_http_spdy_parse_header(ngx_http_request_t *r)
len = ngx_spdy_frame_parse_uint16(p);
- if (!len) {
- return NGX_ERROR;
- }
+ /* null-terminate header name */
+ *p = '\0';
p += NGX_SPDY_NV_VLEN_SIZE;
@@ -2163,11 +2175,9 @@ ngx_http_spdy_handle_request_header(ngx_http_request_t *r)
h->key.len = r->lowcase_index;
h->key.data = r->header_name_start;
- h->key.data[h->key.len] = '\0';
h->value.len = r->header_size;
h->value.data = r->header_start;
- h->value.data[h->value.len] = '\0';
h->lowcase_key = h->key.data;
@@ -2653,7 +2663,8 @@ ngx_http_spdy_close_stream(ngx_http_spdy_stream_t *stream, ngx_int_t rc)
ev = fc->read;
if (ev->active || ev->disabled) {
- ngx_del_event(ev, NGX_READ_EVENT, 0);
+ ngx_log_error(NGX_LOG_ALERT, sc->connection->log, 0,
+ "spdy fake read event was activated");
}
if (ev->timer_set) {
@@ -2667,7 +2678,8 @@ ngx_http_spdy_close_stream(ngx_http_spdy_stream_t *stream, ngx_int_t rc)
ev = fc->write;
if (ev->active || ev->disabled) {
- ngx_del_event(ev, NGX_WRITE_EVENT, 0);
+ ngx_log_error(NGX_LOG_ALERT, sc->connection->log, 0,
+ "spdy fake write event was activated");
}
if (ev->timer_set) {
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index 875c24d9c..546400539 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -370,7 +370,7 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
ngx_http_core_loc_conf_t *clcf;
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http special response: %d, \"%V?%V\"",
+ "http special response: %i, \"%V?%V\"",
error, &r->uri, &r->args);
r->err_status = error;
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 9e2830d07..652222f8f 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1338,13 +1338,19 @@ ngx_http_upstream_ssl_handshake(ngx_connection_t *c)
c->write->handler = ngx_http_upstream_handler;
c->read->handler = ngx_http_upstream_handler;
+ c = r->connection;
+
ngx_http_upstream_send_request(r, u);
+ ngx_http_run_posted_requests(c);
return;
}
+ c = r->connection;
+
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
+ ngx_http_run_posted_requests(c);
}
#endif
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index 0b1a33430..4138bda42 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -487,7 +487,7 @@ ngx_http_get_indexed_variable(ngx_http_request_t *r, ngx_uint_t index)
if (cmcf->variables.nelts <= index) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
- "unknown variable index: %d", index);
+ "unknown variable index: %ui", index);
return NULL;
}
@@ -1374,7 +1374,9 @@ ngx_http_variable_document_root(ngx_http_request_t *r,
return NGX_ERROR;
}
- if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path, 0) != NGX_OK) {
+ if (ngx_get_full_name(r->pool, (ngx_str_t *) &ngx_cycle->prefix, &path)
+ != NGX_OK)
+ {
return NGX_ERROR;
}
@@ -1416,7 +1418,9 @@ ngx_http_variable_realpath_root(ngx_http_request_t *r,
path.data[path.len - 1] = '\0';
- if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path, 0) != NGX_OK) {
+ if (ngx_get_full_name(r->pool, (ngx_str_t *) &ngx_cycle->prefix, &path)
+ != NGX_OK)
+ {
return NGX_ERROR;
}
}
diff --git a/src/os/unix/ngx_channel.c b/src/os/unix/ngx_channel.c
index 536a9ed4b..8e9069660 100644
--- a/src/os/unix/ngx_channel.c
+++ b/src/os/unix/ngx_channel.c
@@ -144,7 +144,7 @@ ngx_read_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, ngx_log_t *log)
if ((size_t) n < sizeof(ngx_channel_t)) {
ngx_log_error(NGX_LOG_ALERT, log, 0,
- "recvmsg() returned not enough data: %uz", n);
+ "recvmsg() returned not enough data: %z", n);
return NGX_ERROR;
}
diff --git a/src/os/unix/ngx_darwin_sendfile_chain.c b/src/os/unix/ngx_darwin_sendfile_chain.c
index 078d10b24..76c4a3a4d 100644
--- a/src/os/unix/ngx_darwin_sendfile_chain.c
+++ b/src/os/unix/ngx_darwin_sendfile_chain.c
@@ -317,9 +317,9 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
c->sent += sent;
- for (cl = in; cl; cl = cl->next) {
+ for ( /* void */ ; in; in = in->next) {
- if (ngx_buf_special(cl->buf)) {
+ if (ngx_buf_special(in->buf)) {
continue;
}
@@ -327,28 +327,28 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
break;
}
- size = ngx_buf_size(cl->buf);
+ size = ngx_buf_size(in->buf);
if (sent >= size) {
sent -= size;
- if (ngx_buf_in_memory(cl->buf)) {
- cl->buf->pos = cl->buf->last;
+ if (ngx_buf_in_memory(in->buf)) {
+ in->buf->pos = in->buf->last;
}
- if (cl->buf->in_file) {
- cl->buf->file_pos = cl->buf->file_last;
+ if (in->buf->in_file) {
+ in->buf->file_pos = in->buf->file_last;
}
continue;
}
- if (ngx_buf_in_memory(cl->buf)) {
- cl->buf->pos += (size_t) sent;
+ if (ngx_buf_in_memory(in->buf)) {
+ in->buf->pos += (size_t) sent;
}
- if (cl->buf->in_file) {
- cl->buf->file_pos += sent;
+ if (in->buf->in_file) {
+ in->buf->file_pos += sent;
}
break;
@@ -360,13 +360,11 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
if (!complete) {
wev->ready = 0;
- return cl;
+ return in;
}
- if (send >= limit || cl == NULL) {
- return cl;
+ if (send >= limit || in == NULL) {
+ return in;
}
-
- in = cl;
}
}
diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h
index 125087e78..1497c5f2f 100644
--- a/src/os/unix/ngx_errno.h
+++ b/src/os/unix/ngx_errno.h
@@ -49,10 +49,10 @@ typedef int ngx_err_t;
#define NGX_ECANCELED ECANCELED
#define NGX_EILSEQ EILSEQ
#define NGX_ENOMOREFILES 0
+#define NGX_ELOOP ELOOP
#if (NGX_HAVE_OPENAT)
#define NGX_EMLINK EMLINK
-#define NGX_ELOOP ELOOP
#endif
#if (__hpux__)
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index f58b5c20f..b8665e042 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -368,9 +368,9 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
c->sent += sent;
- for (cl = in; cl; cl = cl->next) {
+ for ( /* void */ ; in; in = in->next) {
- if (ngx_buf_special(cl->buf)) {
+ if (ngx_buf_special(in->buf)) {
continue;
}
@@ -378,28 +378,28 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
break;
}
- size = ngx_buf_size(cl->buf);
+ size = ngx_buf_size(in->buf);
if (sent >= size) {
sent -= size;
- if (ngx_buf_in_memory(cl->buf)) {
- cl->buf->pos = cl->buf->last;
+ if (ngx_buf_in_memory(in->buf)) {
+ in->buf->pos = in->buf->last;
}
- if (cl->buf->in_file) {
- cl->buf->file_pos = cl->buf->file_last;
+ if (in->buf->in_file) {
+ in->buf->file_pos = in->buf->file_last;
}
continue;
}
- if (ngx_buf_in_memory(cl->buf)) {
- cl->buf->pos += (size_t) sent;
+ if (ngx_buf_in_memory(in->buf)) {
+ in->buf->pos += (size_t) sent;
}
- if (cl->buf->in_file) {
- cl->buf->file_pos += sent;
+ if (in->buf->in_file) {
+ in->buf->file_pos += sent;
}
break;
@@ -407,7 +407,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
#if (NGX_HAVE_AIO_SENDFILE)
if (c->busy_sendfile) {
- return cl;
+ return in;
}
#endif
@@ -421,7 +421,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
*/
wev->ready = 0;
- return cl;
+ return in;
}
if (eintr) {
@@ -430,13 +430,11 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
if (!complete) {
wev->ready = 0;
- return cl;
+ return in;
}
- if (send >= limit || cl == NULL) {
- return cl;
+ if (send >= limit || in == NULL) {
+ return in;
}
-
- in = cl;
}
}
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index 643855ed9..431542d42 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -24,7 +24,7 @@
* so we limit it to 2G-1 bytes.
*/
-#define NGX_SENDFILE_LIMIT 2147483647L
+#define NGX_SENDFILE_MAXSIZE 2147483647L
#if (IOV_MAX > 64)
@@ -63,8 +63,8 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
/* the maximum limit size is 2G-1 - the page size */
- if (limit == 0 || limit > (off_t) (NGX_SENDFILE_LIMIT - ngx_pagesize)) {
- limit = NGX_SENDFILE_LIMIT - ngx_pagesize;
+ if (limit == 0 || limit > (off_t) (NGX_SENDFILE_MAXSIZE - ngx_pagesize)) {
+ limit = NGX_SENDFILE_MAXSIZE - ngx_pagesize;
}
@@ -325,9 +325,9 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
c->sent += sent;
- for (cl = in; cl; cl = cl->next) {
+ for ( /* void */ ; in; in = in->next) {
- if (ngx_buf_special(cl->buf)) {
+ if (ngx_buf_special(in->buf)) {
continue;
}
@@ -335,28 +335,28 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
break;
}
- size = ngx_buf_size(cl->buf);
+ size = ngx_buf_size(in->buf);
if (sent >= size) {
sent -= size;
- if (ngx_buf_in_memory(cl->buf)) {
- cl->buf->pos = cl->buf->last;
+ if (ngx_buf_in_memory(in->buf)) {
+ in->buf->pos = in->buf->last;
}
- if (cl->buf->in_file) {
- cl->buf->file_pos = cl->buf->file_last;
+ if (in->buf->in_file) {
+ in->buf->file_pos = in->buf->file_last;
}
continue;
}
- if (ngx_buf_in_memory(cl->buf)) {
- cl->buf->pos += (size_t) sent;
+ if (ngx_buf_in_memory(in->buf)) {
+ in->buf->pos += (size_t) sent;
}
- if (cl->buf->in_file) {
- cl->buf->file_pos += sent;
+ if (in->buf->in_file) {
+ in->buf->file_pos += sent;
}
break;
@@ -368,13 +368,11 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
if (!complete) {
wev->ready = 0;
- return cl;
+ return in;
}
- if (send >= limit || cl == NULL) {
- return cl;
+ if (send >= limit || in == NULL) {
+ return in;
}
-
- in = cl;
}
}
diff --git a/src/os/unix/ngx_solaris_sendfilev_chain.c b/src/os/unix/ngx_solaris_sendfilev_chain.c
index 520eaaab4..37bb09d96 100644
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c
@@ -207,9 +207,9 @@ ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
c->sent += sent;
- for (cl = in; cl; cl = cl->next) {
+ for ( /* void */ ; in; in = in->next) {
- if (ngx_buf_special(cl->buf)) {
+ if (ngx_buf_special(in->buf)) {
continue;
}
@@ -217,28 +217,28 @@ ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
break;
}
- size = ngx_buf_size(cl->buf);
+ size = ngx_buf_size(in->buf);
if ((off_t) sent >= size) {
sent = (size_t) ((off_t) sent - size);
- if (ngx_buf_in_memory(cl->buf)) {
- cl->buf->pos = cl->buf->last;
+ if (ngx_buf_in_memory(in->buf)) {
+ in->buf->pos = in->buf->last;
}
- if (cl->buf->in_file) {
- cl->buf->file_pos = cl->buf->file_last;
+ if (in->buf->in_file) {
+ in->buf->file_pos = in->buf->file_last;
}
continue;
}
- if (ngx_buf_in_memory(cl->buf)) {
- cl->buf->pos += sent;
+ if (ngx_buf_in_memory(in->buf)) {
+ in->buf->pos += sent;
}
- if (cl->buf->in_file) {
- cl->buf->file_pos += sent;
+ if (in->buf->in_file) {
+ in->buf->file_pos += sent;
}
break;
@@ -250,13 +250,11 @@ ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
if (!complete) {
wev->ready = 0;
- return cl;
+ return in;
}
- if (send >= limit || cl == NULL) {
- return cl;
+ if (send >= limit || in == NULL) {
+ return in;
}
-
- in = cl;
}
}