mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
nginx-0.1.25-RELEASE import
*) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
This commit is contained in:
parent
e12fbfe82a
commit
c15717285d
35
auto/cc/gcc
35
auto/cc/gcc
@ -2,8 +2,15 @@
|
|||||||
# Copyright (C) Igor Sysoev
|
# Copyright (C) Igor Sysoev
|
||||||
|
|
||||||
|
|
||||||
# gcc 2.7.2.3, 2.8.1, 2.95.4,
|
# gcc 2.7.2.3, 2.8.1, 2.95.4, egcs-1.1.2
|
||||||
# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4.0, 3.4.2
|
# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4.0, 3.4.2
|
||||||
|
# 4.0.0
|
||||||
|
|
||||||
|
|
||||||
|
NGX_GCC_VER=`$CC -v 2>&1 | grep 'gcc version' 2>&1 \
|
||||||
|
| sed -e 's/^.* version \(.*\)/\1/'`
|
||||||
|
|
||||||
|
echo " + gcc version: $NGX_GCC_VER"
|
||||||
|
|
||||||
|
|
||||||
# Solaris 7's /usr/ccs/bin/as does not support "-pipe"
|
# Solaris 7's /usr/ccs/bin/as does not support "-pipe"
|
||||||
@ -24,7 +31,6 @@ if [ $ngx_found = yes ]; then
|
|||||||
PIPE="-pipe"
|
PIPE="-pipe"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# optimizations
|
# optimizations
|
||||||
|
|
||||||
#NGX_GCC_OPT="-O2"
|
#NGX_GCC_OPT="-O2"
|
||||||
@ -61,8 +67,12 @@ case $CPU in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
# STUB for batch builds
|
case "$NGX_GCC_VER" in
|
||||||
if [ $CC = gcc27 ]; then CPU_OPT=; fi
|
2.7*)
|
||||||
|
# batch build
|
||||||
|
CPU_OPT=
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
CFLAGS="$CFLAGS $PIPE $CPU_OPT"
|
CFLAGS="$CFLAGS $PIPE $CPU_OPT"
|
||||||
@ -95,8 +105,21 @@ CFLAGS="$CFLAGS -Wall -Wpointer-arith"
|
|||||||
#CFLAGS="$CFLAGS -Wconversion"
|
#CFLAGS="$CFLAGS -Wconversion"
|
||||||
#CFLAGS="$CFLAGS -Winline"
|
#CFLAGS="$CFLAGS -Winline"
|
||||||
|
|
||||||
# we have a lot of the unused function arguments
|
|
||||||
CFLAGS="$CFLAGS -Wno-unused"
|
case "$NGX_GCC_VER" in
|
||||||
|
3.* | 4.* )
|
||||||
|
# we have a lot of the unused function arguments
|
||||||
|
CFLAGS="$CFLAGS -Wno-unused-parameter"
|
||||||
|
CFLAGS="$CFLAGS -Wno-unused-function"
|
||||||
|
#CFLAGS="$CFLAGS -Wunreachable-code"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# we have a lot of the unused function arguments
|
||||||
|
CFLAGS="$CFLAGS -Wno-unused"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
# stop on warning
|
# stop on warning
|
||||||
CFLAGS="$CFLAGS -Werror"
|
CFLAGS="$CFLAGS -Werror"
|
||||||
|
36
auto/cc/icc
36
auto/cc/icc
@ -7,7 +7,7 @@
|
|||||||
# optimizations
|
# optimizations
|
||||||
|
|
||||||
CFLAGS="$CFLAGS -O"
|
CFLAGS="$CFLAGS -O"
|
||||||
# inline functions declared with __inline
|
# inline the functions declared with __inline
|
||||||
#CFLAGS="$CFLAGS -Ob1"
|
#CFLAGS="$CFLAGS -Ob1"
|
||||||
# inline any function, at the compiler's discretion
|
# inline any function, at the compiler's discretion
|
||||||
CFLAGS="$CFLAGS -Ob2"
|
CFLAGS="$CFLAGS -Ob2"
|
||||||
@ -54,14 +54,34 @@ fi
|
|||||||
|
|
||||||
# warnings
|
# warnings
|
||||||
|
|
||||||
CFLAGS="$CFLAGS -w1"
|
CFLAGS="$CFLAGS -w2"
|
||||||
#CFLAGS="$CFLAGS -w2"
|
|
||||||
|
|
||||||
# disable the ICC 8.1 errors:
|
# disable some warnings
|
||||||
# error #181: argument is incompatible with corresponding format
|
|
||||||
# string conversion
|
# invalid type conversion: "int" to "char *"
|
||||||
# error #269: invalid format string conversion
|
CFLAGS="$CFLAGS -wd171"
|
||||||
CFLAGS="$CFLAGS -wd181 -wd269"
|
# argument is incompatible with corresponding format string conversion
|
||||||
|
CFLAGS="$CFLAGS -wd181"
|
||||||
|
# zero used for undefined preprocessing identifier
|
||||||
|
CFLAGS="$CFLAGS -wd193"
|
||||||
|
# invalid format string conversion
|
||||||
|
CFLAGS="$CFLAGS -wd269"
|
||||||
|
# conversion from "long long" to "size_t" may lose significant bits
|
||||||
|
CFLAGS="$CFLAGS -wd810"
|
||||||
|
# parameter was never referenced
|
||||||
|
CFLAGS="$CFLAGS -wd869"
|
||||||
|
|
||||||
|
# STUB
|
||||||
|
# enumerated type mixed with another type
|
||||||
|
CFLAGS="$CFLAGS -wd188"
|
||||||
|
# controlling expression is constant
|
||||||
|
CFLAGS="$CFLAGS -wd279"
|
||||||
|
# operands are evaluated in unspecified order
|
||||||
|
CFLAGS="$CFLAGS -wd981"
|
||||||
|
# external definition with no prior declaration
|
||||||
|
CFLAGS="$CFLAGS -wd1418"
|
||||||
|
# external declaration in primary source file
|
||||||
|
CFLAGS="$CFLAGS -wd1419"
|
||||||
|
|
||||||
# stop on warning
|
# stop on warning
|
||||||
CFLAGS="$CFLAGS -Werror"
|
CFLAGS="$CFLAGS -Werror"
|
||||||
|
@ -1,17 +1,28 @@
|
|||||||
|
|
||||||
# Copyright (C) Igor Sysoev
|
# Copyright (C) Igor Sysoev
|
||||||
|
|
||||||
|
if test -n "$OPENSSL_OPT"; then
|
||||||
|
NGX_OPENSSL_CONFIG="./Configure \"$OPENSSL_OPT\""
|
||||||
|
else
|
||||||
|
NGX_OPENSSL_CONFIG="./config"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "$USE_THREADS"; then
|
||||||
|
NGX_OPENSSL_CONFIG="$NGX_OPENSSL_CONFIG threads"
|
||||||
|
fi
|
||||||
|
|
||||||
case "$NGX_PLATFORM" in
|
case "$NGX_PLATFORM" in
|
||||||
*)
|
*)
|
||||||
echo "$OPENSSL/libssl.a:" >> $MAKEFILE
|
cat << END >> $NGX_MAKEFILE
|
||||||
echo " cd $OPENSSL \\" >> $MAKEFILE
|
|
||||||
echo " && \$(MAKE) clean \\" >> $MAKEFILE
|
$OPENSSL/libssl.a:
|
||||||
echo " && CC=\"\$(CC)\" \\" >> $MAKEFILE
|
cd $OPENSSL \\
|
||||||
echo " ./config threads no-shared \\" >> $MAKEFILE
|
&& \$(MAKE) clean \\
|
||||||
echo " && \$(MAKE)" >> $MAKEFILE
|
&& $NGX_OPENSSL_CONFIG no-shared \\
|
||||||
|
&& \$(MAKE)
|
||||||
|
|
||||||
|
END
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo >> $MAKEFILE
|
|
||||||
|
@ -153,6 +153,7 @@ do
|
|||||||
--with-pcre-opt=*) PCRE_OPT="$value" ;;
|
--with-pcre-opt=*) PCRE_OPT="$value" ;;
|
||||||
|
|
||||||
--with-openssl=*) OPENSSL="$value" ;;
|
--with-openssl=*) OPENSSL="$value" ;;
|
||||||
|
--with-openssl-opt=*) OPENSSL_OPT="$value" ;;
|
||||||
|
|
||||||
--with-md5=*) MD5="$value" ;;
|
--with-md5=*) MD5="$value" ;;
|
||||||
--with-md5-opt=*) MD5_OPT="$value" ;;
|
--with-md5-opt=*) MD5_OPT="$value" ;;
|
||||||
@ -203,6 +204,7 @@ cat << END
|
|||||||
--with-http_ssl_module enable ngx_http_ssl_module
|
--with-http_ssl_module enable ngx_http_ssl_module
|
||||||
--without-http_charset_module disable ngx_http_charset_module
|
--without-http_charset_module disable ngx_http_charset_module
|
||||||
--without-http_gzip_module disable ngx_http_gzip_module
|
--without-http_gzip_module disable ngx_http_gzip_module
|
||||||
|
--without-http_ssi_module disable ngx_http_ssi_module
|
||||||
--without-http_userid_module disable ngx_http_userid_module
|
--without-http_userid_module disable ngx_http_userid_module
|
||||||
--without-http_access_module disable ngx_http_access_module
|
--without-http_access_module disable ngx_http_access_module
|
||||||
--without-http_autoindex_module disable ngx_http_autoindex_module
|
--without-http_autoindex_module disable ngx_http_autoindex_module
|
||||||
@ -241,6 +243,7 @@ cat << END
|
|||||||
pentium, pentiumpro
|
pentium, pentiumpro
|
||||||
|
|
||||||
--with-openssl=DIR set path to OpenSSL library sources
|
--with-openssl=DIR set path to OpenSSL library sources
|
||||||
|
--with-openssl-opt=OPTIONS set additional options for OpenSSL building
|
||||||
|
|
||||||
--with-debug enable the debugging logging
|
--with-debug enable the debugging logging
|
||||||
|
|
||||||
|
40
auto/sources
40
auto/sources
@ -241,27 +241,27 @@ HTTP_DEPS="src/http/ngx_http.h \
|
|||||||
src/http/ngx_http_variables.h \
|
src/http/ngx_http_variables.h \
|
||||||
src/http/ngx_http_upstream.h \
|
src/http/ngx_http_upstream.h \
|
||||||
src/http/ngx_http_busy_lock.h \
|
src/http/ngx_http_busy_lock.h \
|
||||||
src/http/ngx_http_log_handler.h"
|
src/http/ngx_http_log_module.h"
|
||||||
|
|
||||||
HTTP_SRCS="src/http/ngx_http.c \
|
HTTP_SRCS="src/http/ngx_http.c \
|
||||||
src/http/ngx_http_core_module.c \
|
src/http/ngx_http_core_module.c \
|
||||||
src/http/ngx_http_special_response.c \
|
src/http/ngx_http_special_response.c \
|
||||||
src/http/ngx_http_request.c \
|
src/http/ngx_http_request.c \
|
||||||
src/http/ngx_http_parse.c \
|
src/http/ngx_http_parse.c \
|
||||||
src/http/ngx_http_header_filter.c \
|
src/http/ngx_http_header_filter_module.c \
|
||||||
src/http/ngx_http_write_filter.c \
|
src/http/ngx_http_write_filter_module.c \
|
||||||
src/http/ngx_http_copy_filter.c \
|
src/http/ngx_http_copy_filter_module.c \
|
||||||
src/http/ngx_http_log_handler.c \
|
src/http/ngx_http_log_module.c \
|
||||||
src/http/ngx_http_request_body.c \
|
src/http/ngx_http_request_body.c \
|
||||||
src/http/ngx_http_variables.c \
|
src/http/ngx_http_variables.c \
|
||||||
src/http/ngx_http_upstream.c \
|
src/http/ngx_http_upstream.c \
|
||||||
src/http/ngx_http_parse_time.c \
|
src/http/ngx_http_parse_time.c \
|
||||||
src/http/modules/ngx_http_static_handler.c \
|
src/http/modules/ngx_http_static_module.c \
|
||||||
src/http/modules/ngx_http_index_handler.c \
|
src/http/modules/ngx_http_index_module.c \
|
||||||
src/http/modules/ngx_http_chunked_filter.c \
|
src/http/modules/ngx_http_chunked_filter_module.c \
|
||||||
src/http/modules/ngx_http_range_filter.c \
|
src/http/modules/ngx_http_range_filter_module.c \
|
||||||
src/http/modules/ngx_http_headers_filter.c \
|
src/http/modules/ngx_http_headers_filter_module.c \
|
||||||
src/http/modules/ngx_http_not_modified_filter.c"
|
src/http/modules/ngx_http_not_modified_filter_module.c"
|
||||||
|
|
||||||
# STUB
|
# STUB
|
||||||
HTTP_SRCS="$HTTP_SRCS src/http/ngx_http_busy_lock.c"
|
HTTP_SRCS="$HTTP_SRCS src/http/ngx_http_busy_lock.c"
|
||||||
@ -271,31 +271,31 @@ HTPP_FILE_CACHE_SRCS=src/http/ngx_http_file_cache.c
|
|||||||
|
|
||||||
|
|
||||||
HTTP_CHARSET_FILTER_MODULE=ngx_http_charset_filter_module
|
HTTP_CHARSET_FILTER_MODULE=ngx_http_charset_filter_module
|
||||||
HTTP_CHARSET_SRCS=src/http/modules/ngx_http_charset_filter.c
|
HTTP_CHARSET_SRCS=src/http/modules/ngx_http_charset_filter_module.c
|
||||||
|
|
||||||
|
|
||||||
HTTP_GZIP_FILTER_MODULE=ngx_http_gzip_filter_module
|
HTTP_GZIP_FILTER_MODULE=ngx_http_gzip_filter_module
|
||||||
HTTP_GZIP_SRCS=src/http/modules/ngx_http_gzip_filter.c
|
HTTP_GZIP_SRCS=src/http/modules/ngx_http_gzip_filter_module.c
|
||||||
|
|
||||||
|
|
||||||
HTTP_SSI_FILTER_MODULE=ngx_http_ssi_filter_module
|
HTTP_SSI_FILTER_MODULE=ngx_http_ssi_filter_module
|
||||||
HTTP_SSI_SRCS=src/http/modules/ngx_http_ssi_filter.c
|
HTTP_SSI_SRCS=src/http/modules/ngx_http_ssi_filter_module.c
|
||||||
|
|
||||||
|
|
||||||
HTTP_USERID_FILTER_MODULE=ngx_http_userid_filter_module
|
HTTP_USERID_FILTER_MODULE=ngx_http_userid_filter_module
|
||||||
HTTP_USERID_SRCS=src/http/modules/ngx_http_userid_filter.c
|
HTTP_USERID_SRCS=src/http/modules/ngx_http_userid_filter_module.c
|
||||||
|
|
||||||
|
|
||||||
HTTP_ACCESS_MODULE=ngx_http_access_module
|
HTTP_ACCESS_MODULE=ngx_http_access_module
|
||||||
HTTP_ACCESS_SRCS=src/http/modules/ngx_http_access_handler.c
|
HTTP_ACCESS_SRCS=src/http/modules/ngx_http_access_module.c
|
||||||
|
|
||||||
|
|
||||||
HTTP_AUTOINDEX_MODULE=ngx_http_autoindex_module
|
HTTP_AUTOINDEX_MODULE=ngx_http_autoindex_module
|
||||||
HTTP_AUTOINDEX_SRCS=src/http/modules/ngx_http_autoindex_handler.c
|
HTTP_AUTOINDEX_SRCS=src/http/modules/ngx_http_autoindex_module.c
|
||||||
|
|
||||||
|
|
||||||
HTTP_STATUS_MODULE=ngx_http_status_module
|
HTTP_STATUS_MODULE=ngx_http_status_module
|
||||||
HTTP_STATUS_SRCS=src/http/modules/ngx_http_status_handler.c
|
HTTP_STATUS_SRCS=src/http/modules/ngx_http_status_module.c
|
||||||
|
|
||||||
|
|
||||||
HTTP_GEO_MODULE=ngx_http_geo_module
|
HTTP_GEO_MODULE=ngx_http_geo_module
|
||||||
@ -303,7 +303,7 @@ HTTP_GEO_SRCS=src/http/modules/ngx_http_geo_module.c
|
|||||||
|
|
||||||
|
|
||||||
HTTP_REWRITE_MODULE=ngx_http_rewrite_module
|
HTTP_REWRITE_MODULE=ngx_http_rewrite_module
|
||||||
HTTP_REWRITE_SRCS=src/http/modules/ngx_http_rewrite_handler.c
|
HTTP_REWRITE_SRCS=src/http/modules/ngx_http_rewrite_module.c
|
||||||
|
|
||||||
|
|
||||||
HTTP_SSL_MODULE=ngx_http_ssl_module
|
HTTP_SSL_MODULE=ngx_http_ssl_module
|
||||||
@ -324,7 +324,7 @@ HTTP_PROXY_SRCS="src/http/modules/proxy/ngx_http_proxy_handler.c \
|
|||||||
|
|
||||||
|
|
||||||
HTTP_FASTCGI_MODULE=ngx_http_fastcgi_module
|
HTTP_FASTCGI_MODULE=ngx_http_fastcgi_module
|
||||||
HTTP_FASTCGI_SRCS=src/http/modules/ngx_http_fastcgi_handler.c
|
HTTP_FASTCGI_SRCS=src/http/modules/ngx_http_fastcgi_module.c
|
||||||
|
|
||||||
|
|
||||||
IMAP_INCS="src/imap"
|
IMAP_INCS="src/imap"
|
||||||
|
@ -17,7 +17,7 @@ case $USE_THREADS in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $USE_PCRE = DISABLED ]; then
|
if [ $USE_PCRE = DISABLED ]; then
|
||||||
echo " + PCRE library is disabled"
|
echo " + PCRE library is disabled"
|
||||||
|
|
||||||
else
|
else
|
||||||
case $PCRE in
|
case $PCRE in
|
||||||
|
@ -9,6 +9,123 @@
|
|||||||
<title lang="en">nginx changelog</title>
|
<title lang="en">nginx changelog</title>
|
||||||
|
|
||||||
|
|
||||||
|
<changes ver="0.1.25" date="19.03.2005">
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
nginx ÎÅ ÒÁÂÏÔÁÌ ÎÁ Linux parisc.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
nginx did run on Linux parisc.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
nginx ÔÅÐÅÒØ ÎÅ ÚÁÐÕÓËÁÅÔÓÑ ÐÏÄ FreeBSD, ÅÓÌÉ ÚÎÁÞÅÎÉÅ
|
||||||
|
sysctl kern.ipc.somaxconn ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn
|
||||||
|
value is too big.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ÅÓÌÉ ÍÏÄÕÌØ ngx_http_index_module ÄÅÌÁÌ ×ÎÕÔÒÅÎÎÅÅ ÐÅÒÅÎÁÐÒÁ×ÌÅÎÉÅ ÚÁÐÒÏÓÁ
|
||||||
|
× ÍÏÄÕÌÉ ngx_http_proxy_module ÉÌÉ ngx_http_fastcgi_module, ÔÏ ÆÁÊÌ ÉÎÄÅËÓÁ
|
||||||
|
ÎÅ ÚÁËÒÙ×ÁÌÓÑ ÐÏÓÌÅ ÏÂÓÌÕÖÉ×ÁÎÉÑ ÚÁÐÒÏÓÁ.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
if a request was internally redirected by the ngx_http_index_module
|
||||||
|
module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules,
|
||||||
|
then the index file was not closed after request completion.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
ÄÉÒÅËÔÉ×Á proxy_pass ÍÏÖÅÔ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ × location, ÚÁÄÁÎÎÙÈ ÒÅÇÕÌÑÒÎÙÍ
|
||||||
|
×ÙÒÁÖÅÎÉÅÍ.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the "proxy_pass" can be used in location with regular expression.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
ÍÏÄÕÌØ ngx_http_rewrite_filter_module ÐÏÄÄÅÒÖÉ×ÁÅÔ ÕÓÌÏ×ÉÑ ×ÉÄÁ
|
||||||
|
"if ($HTTP_USER_AGENT ~ MSIE)".
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the ngx_http_rewrite_filter_module module supports the condition like
|
||||||
|
"if ($HTTP_USER_AGENT ~ MSIE)".
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
nginx ÏÞÅÎØ ÍÅÄÌÅÎÎÏ ÚÁÐÕÓËÁÌÓÑ ÐÒÉ ÂÏÌØÛÏÍ ËÏÌÉÞÅÓÔ×Å ÁÄÒÅÓÏ× É
|
||||||
|
ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÔÅËÓÔÏ×ÙÈ ÚÎÁÞÅÎÉÊ × ÄÉÒÅËÔÉ×Å geo.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
nginx started too slow if the large number of addresses and text values
|
||||||
|
were used in the "geo" directive.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="change">
|
||||||
|
<para lang="ru">
|
||||||
|
ÉÍÑ ÐÅÒÅÍÅÎÎÏÊ × ÄÉÒÅËÔÉ×Å geo ÎÕÖÎÏ ÕËÁÚÙ×ÁÔØ, ËÁË $name.
|
||||||
|
ðÒÅÖÎÉÊ ×ÁÒÉÁÎÔ ÂÅÚ "$" ÐÏËÁ ÒÁÂÏÔÁÅÔ, ÎÏ ×ÓËÏÒÅ ÂÕÄÅÔ ÕÂÒÁÎ.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
a variable name must be declared as "$name" in the "geo" directive.
|
||||||
|
The previous variant without "$" is still supported, but will be removed soon.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
ÐÁÒÁÍÅÔÒ ÌÏÇÁ "%{VARIABLE}v".
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the "%{VARIABLE}v" logging parameter.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
ÄÉÒÅËÔÉ×Á "set $name value".
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the "set $name value" directive.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
ÓÏ×ÍÅÓÔÉÍÏÓÔØ Ó gcc 4.0.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
gcc 4.0 compatibility.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
ÐÁÒÁÍÅÔÒ Á×ÔÏËÏÎÆÉÇÕÒÁÃÉÉ --with-openssl-opt=OPTIONS.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
the --with-openssl-opt=OPTIONS autoconfiguration directive.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
</changes>
|
||||||
|
|
||||||
|
|
||||||
<changes ver="0.1.24" date="04.03.2005">
|
<changes ver="0.1.24" date="04.03.2005">
|
||||||
|
|
||||||
<change type="feature">
|
<change type="feature">
|
||||||
|
@ -141,7 +141,8 @@ main(int argc, char *const *argv)
|
|||||||
|
|
||||||
ngx_pid = ngx_getpid();
|
ngx_pid = ngx_getpid();
|
||||||
|
|
||||||
if (!(log = ngx_log_init())) {
|
log = ngx_log_init();
|
||||||
|
if (log == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +156,8 @@ main(int argc, char *const *argv)
|
|||||||
init_cycle.log = log;
|
init_cycle.log = log;
|
||||||
ngx_cycle = &init_cycle;
|
ngx_cycle = &init_cycle;
|
||||||
|
|
||||||
if (!(init_cycle.pool = ngx_create_pool(1024, log))) {
|
init_cycle.pool = ngx_create_pool(1024, log);
|
||||||
|
if (init_cycle.pool == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,9 +257,9 @@ main(int argc, char *const *argv)
|
|||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_add_inherited_sockets(ngx_cycle_t *cycle)
|
ngx_add_inherited_sockets(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
u_char *p, *v, *inherited;
|
u_char *p, *v, *inherited;
|
||||||
ngx_socket_t s;
|
ngx_int_t s;
|
||||||
ngx_listening_t *ls;
|
ngx_listening_t *ls;
|
||||||
|
|
||||||
inherited = (u_char *) getenv(NGINX_VAR);
|
inherited = (u_char *) getenv(NGINX_VAR);
|
||||||
|
|
||||||
@ -287,11 +289,12 @@ ngx_add_inherited_sockets(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
v = p + 1;
|
v = p + 1;
|
||||||
|
|
||||||
if (!(ls = ngx_array_push(&cycle->listening))) {
|
ls = ngx_array_push(&cycle->listening);
|
||||||
|
if (ls == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ls->fd = s;
|
ls->fd = (ngx_socket_t) s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +318,7 @@ ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv)
|
|||||||
ctx.argv = argv;
|
ctx.argv = argv;
|
||||||
|
|
||||||
var = ngx_alloc(sizeof(NGINX_VAR)
|
var = ngx_alloc(sizeof(NGINX_VAR)
|
||||||
+ cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2,
|
+ cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2,
|
||||||
cycle->log);
|
cycle->log);
|
||||||
|
|
||||||
p = ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR));
|
p = ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR));
|
||||||
@ -411,27 +414,29 @@ static ngx_int_t ngx_getopt(ngx_cycle_t *cycle, int argc, char *const *argv)
|
|||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv)
|
ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv)
|
||||||
{
|
{
|
||||||
|
#if (NGX_FREEBSD)
|
||||||
|
|
||||||
|
ngx_os_argv = (char **) argv;
|
||||||
|
ngx_argc = argc;
|
||||||
|
ngx_argv = (char **) argv;
|
||||||
|
|
||||||
|
#else
|
||||||
size_t len;
|
size_t len;
|
||||||
ngx_int_t i;
|
ngx_int_t i;
|
||||||
|
|
||||||
ngx_os_argv = (char **) argv;
|
ngx_os_argv = (char **) argv;
|
||||||
|
|
||||||
ngx_argc = argc;
|
ngx_argc = argc;
|
||||||
|
|
||||||
#if (NGX_FREEBSD)
|
ngx_argv = ngx_alloc((argc + 1) * sizeof(char *), cycle->log);
|
||||||
|
if (ngx_argv == NULL) {
|
||||||
ngx_argv = (char **) argv;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
if (!(ngx_argv = ngx_alloc((argc + 1) * sizeof(char *), cycle->log))) {
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
len = ngx_strlen(argv[i]) + 1;
|
len = ngx_strlen(argv[i]) + 1;
|
||||||
|
|
||||||
if (!(ngx_argv[i] = ngx_alloc(len, cycle->log))) {
|
ngx_argv[i] = ngx_alloc(len, cycle->log);
|
||||||
|
if (ngx_argv[i] == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +456,8 @@ ngx_core_module_create_conf(ngx_cycle_t *cycle)
|
|||||||
{
|
{
|
||||||
ngx_core_conf_t *ccf;
|
ngx_core_conf_t *ccf;
|
||||||
|
|
||||||
if (!(ccf = ngx_pcalloc(cycle->pool, sizeof(ngx_core_conf_t)))) {
|
ccf = ngx_pcalloc(cycle->pool, sizeof(ngx_core_conf_t));
|
||||||
|
if (ccf == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,7 +540,8 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||||||
|
|
||||||
ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT);
|
ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT);
|
||||||
|
|
||||||
if (!(ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len))) {
|
ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len);
|
||||||
|
if (ccf->newpid.data == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define _NGINX_H_INCLUDED_
|
#define _NGINX_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
#define NGINX_VER "nginx/0.1.24"
|
#define NGINX_VER "nginx/0.1.25"
|
||||||
|
|
||||||
#define NGINX_VAR "NGINX"
|
#define NGINX_VAR "NGINX"
|
||||||
#define NGX_NEWPID_EXT ".newbin"
|
#define NGX_NEWPID_EXT ".newbin"
|
||||||
|
@ -12,11 +12,13 @@ ngx_array_t *ngx_array_create(ngx_pool_t *p, ngx_uint_t n, size_t size)
|
|||||||
{
|
{
|
||||||
ngx_array_t *a;
|
ngx_array_t *a;
|
||||||
|
|
||||||
if (!(a = ngx_palloc(p, sizeof(ngx_array_t)))) {
|
a = ngx_palloc(p, sizeof(ngx_array_t));
|
||||||
|
if (a == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(a->elts = ngx_palloc(p, n * size))) {
|
a->elts = ngx_palloc(p, n * size);
|
||||||
|
if (a->elts == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +74,8 @@ void *ngx_array_push(ngx_array_t *a)
|
|||||||
} else {
|
} else {
|
||||||
/* allocate a new array */
|
/* allocate a new array */
|
||||||
|
|
||||||
if (!(new = ngx_palloc(p, 2 * size))) {
|
new = ngx_palloc(p, 2 * size);
|
||||||
|
if (new == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +123,8 @@ void *ngx_array_push_n(ngx_array_t *a, ngx_uint_t n)
|
|||||||
|
|
||||||
nalloc = 2 * ((n >= a->nalloc) ? n : a->nalloc);
|
nalloc = 2 * ((n >= a->nalloc) ? n : a->nalloc);
|
||||||
|
|
||||||
if (!(new = ngx_palloc(p, nalloc * a->size))) {
|
new = ngx_palloc(p, nalloc * a->size);
|
||||||
|
if (new == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,11 @@ void *ngx_array_push(ngx_array_t *a);
|
|||||||
void *ngx_array_push_n(ngx_array_t *a, ngx_uint_t n);
|
void *ngx_array_push_n(ngx_array_t *a, ngx_uint_t n);
|
||||||
|
|
||||||
|
|
||||||
static ngx_inline ngx_int_t ngx_array_init(ngx_array_t *array, ngx_pool_t *pool,
|
static ngx_inline ngx_int_t
|
||||||
ngx_uint_t n, size_t size)
|
ngx_array_init(ngx_array_t *array, ngx_pool_t *pool, ngx_uint_t n, size_t size)
|
||||||
{
|
{
|
||||||
if (!(array->elts = ngx_palloc(pool, n * size))) {
|
array->elts = ngx_palloc(pool, n * size);
|
||||||
|
if (array->elts == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,14 +44,4 @@ static ngx_inline ngx_int_t ngx_array_init(ngx_array_t *array, ngx_pool_t *pool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* STUB */
|
|
||||||
#define ngx_init_array(a, p, n, s, rc) \
|
|
||||||
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_create_array ngx_array_create
|
|
||||||
#define ngx_push_array ngx_array_push
|
|
||||||
/**/
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_ARRAY_H_INCLUDED_ */
|
#endif /* _NGX_ARRAY_H_INCLUDED_ */
|
||||||
|
@ -13,11 +13,13 @@ ngx_create_temp_buf(ngx_pool_t *pool, size_t size)
|
|||||||
{
|
{
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(pool))) {
|
b = ngx_calloc_buf(pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(b->start = ngx_palloc(pool, size))) {
|
b->start = ngx_palloc(pool, size);
|
||||||
|
if (b->start == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,14 +51,17 @@ ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs)
|
|||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_chain_t *chain, *cl, **ll;
|
ngx_chain_t *chain, *cl, **ll;
|
||||||
|
|
||||||
if (!(p = ngx_palloc(pool, bufs->num * bufs->size))) {
|
p = ngx_palloc(pool, bufs->num * bufs->size);
|
||||||
|
if (p == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ll = &chain;
|
ll = &chain;
|
||||||
|
|
||||||
for (i = 0; i < bufs->num; i++) {
|
for (i = 0; i < bufs->num; i++) {
|
||||||
if (!(b = ngx_calloc_buf(pool))) {
|
|
||||||
|
b = ngx_calloc_buf(pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +84,8 @@ ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs)
|
|||||||
p += bufs->size;
|
p += bufs->size;
|
||||||
b->end = p;
|
b->end = p;
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(pool))) {
|
cl = ngx_alloc_chain_link(pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +112,10 @@ ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (in) {
|
while (in) {
|
||||||
ngx_test_null(cl, ngx_alloc_chain_link(pool), NGX_ERROR);
|
cl = ngx_alloc_chain_link(pool);
|
||||||
|
if (cl == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
cl->buf = in->buf;
|
cl->buf = in->buf;
|
||||||
*ll = cl;
|
*ll = cl;
|
||||||
|
@ -119,27 +119,9 @@ ngx_chain_t *ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs);
|
|||||||
#define ngx_alloc_buf(pool) ngx_palloc(pool, sizeof(ngx_buf_t))
|
#define ngx_alloc_buf(pool) ngx_palloc(pool, sizeof(ngx_buf_t))
|
||||||
#define ngx_calloc_buf(pool) ngx_pcalloc(pool, sizeof(ngx_buf_t))
|
#define ngx_calloc_buf(pool) ngx_pcalloc(pool, sizeof(ngx_buf_t))
|
||||||
|
|
||||||
|
|
||||||
#define ngx_alloc_chain_link(pool) ngx_palloc(pool, sizeof(ngx_chain_t))
|
#define ngx_alloc_chain_link(pool) ngx_palloc(pool, sizeof(ngx_chain_t))
|
||||||
|
|
||||||
|
|
||||||
#define ngx_alloc_link_and_set_buf(chain, b, pool, error) \
|
|
||||||
do { \
|
|
||||||
ngx_test_null(chain, ngx_alloc_chain_link(pool), error); \
|
|
||||||
chain->buf = b; \
|
|
||||||
chain->next = NULL; \
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
|
|
||||||
#define ngx_chain_add_link(chain, last, cl) \
|
|
||||||
if (chain) { \
|
|
||||||
*last = cl; \
|
|
||||||
} else { \
|
|
||||||
chain = cl; \
|
|
||||||
} \
|
|
||||||
last = &cl->next
|
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in);
|
ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in);
|
||||||
ngx_int_t ngx_chain_writer(void *ctx, ngx_chain_t *in);
|
ngx_int_t ngx_chain_writer(void *ctx, ngx_chain_t *in);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <ngx_core.h>
|
#include <ngx_core.h>
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
|
||||||
static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||||
|
|
||||||
|
|
||||||
@ -53,13 +54,10 @@ static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
|
|||||||
|
|
||||||
char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
||||||
{
|
{
|
||||||
int m, rc, found, valid;
|
|
||||||
char *rv;
|
char *rv;
|
||||||
void *conf, **confp;
|
|
||||||
ngx_fd_t fd;
|
ngx_fd_t fd;
|
||||||
ngx_str_t *name;
|
ngx_int_t rc;
|
||||||
ngx_conf_file_t *prev;
|
ngx_conf_file_t *prev;
|
||||||
ngx_command_t *cmd;
|
|
||||||
|
|
||||||
#if (NGX_SUPPRESS_WARN)
|
#if (NGX_SUPPRESS_WARN)
|
||||||
fd = NGX_INVALID_FILE;
|
fd = NGX_INVALID_FILE;
|
||||||
@ -78,7 +76,9 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
prev = cf->conf_file;
|
prev = cf->conf_file;
|
||||||
if (!(cf->conf_file = ngx_palloc(cf->pool, sizeof(ngx_conf_file_t)))) {
|
|
||||||
|
cf->conf_file = ngx_palloc(cf->pool, sizeof(ngx_conf_file_t));
|
||||||
|
if (cf->conf_file == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,194 +130,30 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
|||||||
rv = (*cf->handler)(cf, NULL, cf->handler_conf);
|
rv = (*cf->handler)(cf, NULL, cf->handler_conf);
|
||||||
if (rv == NGX_CONF_OK) {
|
if (rv == NGX_CONF_OK) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (rv == NGX_CONF_ERROR) {
|
if (rv == NGX_CONF_ERROR) {
|
||||||
rc = NGX_ERROR;
|
|
||||||
break;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
|
||||||
"%s in %s:%d",
|
|
||||||
rv,
|
|
||||||
cf->conf_file->file.name.data,
|
|
||||||
cf->conf_file->line);
|
|
||||||
rc = NGX_ERROR;
|
rc = NGX_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
name = (ngx_str_t *) cf->args->elts;
|
|
||||||
found = 0;
|
|
||||||
|
|
||||||
for (m = 0; rc != NGX_ERROR && !found && ngx_modules[m]; m++) {
|
|
||||||
|
|
||||||
/* look up the directive in the appropriate modules */
|
|
||||||
|
|
||||||
if (ngx_modules[m]->type != NGX_CONF_MODULE
|
|
||||||
&& ngx_modules[m]->type != cf->module_type)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd = ngx_modules[m]->commands;
|
|
||||||
if (cmd == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (cmd->name.len) {
|
|
||||||
if (name->len == cmd->name.len
|
|
||||||
&& ngx_strcmp(name->data, cmd->name.data) == 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
found = 1;
|
|
||||||
|
|
||||||
/* is the directive's location right ? */
|
|
||||||
|
|
||||||
if ((cmd->type & cf->cmd_type) == 0) {
|
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
|
||||||
"directive \"%s\" in %s:%d "
|
|
||||||
"is not allowed here",
|
|
||||||
name->data,
|
|
||||||
cf->conf_file->file.name.data,
|
|
||||||
cf->conf_file->line);
|
|
||||||
rc = NGX_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(cmd->type & NGX_CONF_BLOCK) && rc != NGX_OK)
|
|
||||||
{
|
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
|
||||||
"directive \"%s\" in %s:%d "
|
|
||||||
"is not terminated by \";\"",
|
|
||||||
name->data,
|
|
||||||
cf->conf_file->file.name.data,
|
|
||||||
cf->conf_file->line);
|
|
||||||
rc = NGX_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((cmd->type & NGX_CONF_BLOCK)
|
|
||||||
&& rc != NGX_CONF_BLOCK_START)
|
|
||||||
{
|
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
|
||||||
"directive \"%s\" in %s:%d "
|
|
||||||
"has not the opening \"{\"",
|
|
||||||
name->data,
|
|
||||||
cf->conf_file->file.name.data,
|
|
||||||
cf->conf_file->line);
|
|
||||||
rc = NGX_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* is the directive's argument count right ? */
|
|
||||||
|
|
||||||
if (cmd->type & NGX_CONF_ANY) {
|
|
||||||
valid = 1;
|
|
||||||
|
|
||||||
} else if (cmd->type & NGX_CONF_FLAG) {
|
|
||||||
|
|
||||||
if (cf->args->nelts == 2) {
|
|
||||||
valid = 1;
|
|
||||||
} else {
|
|
||||||
valid = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (cmd->type & NGX_CONF_1MORE) {
|
|
||||||
|
|
||||||
if (cf->args->nelts > 1) {
|
|
||||||
valid = 1;
|
|
||||||
} else {
|
|
||||||
valid = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (cmd->type & NGX_CONF_2MORE) {
|
|
||||||
|
|
||||||
if (cf->args->nelts > 2) {
|
|
||||||
valid = 1;
|
|
||||||
} else {
|
|
||||||
valid = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (cf->args->nelts <= 10
|
|
||||||
&& (cmd->type
|
|
||||||
& argument_number[cf->args->nelts - 1]))
|
|
||||||
{
|
|
||||||
valid = 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
valid = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!valid) {
|
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
|
||||||
"invalid number arguments in "
|
|
||||||
"directive \"%s\" in %s:%d",
|
|
||||||
name->data,
|
|
||||||
cf->conf_file->file.name.data,
|
|
||||||
cf->conf_file->line);
|
|
||||||
rc = NGX_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set up the directive's configuration context */
|
|
||||||
|
|
||||||
conf = NULL;
|
|
||||||
|
|
||||||
if (cmd->type & NGX_DIRECT_CONF) {
|
|
||||||
conf = ((void **) cf->ctx)[ngx_modules[m]->index];
|
|
||||||
|
|
||||||
} else if (cmd->type & NGX_MAIN_CONF) {
|
|
||||||
conf = &(((void **) cf->ctx)[ngx_modules[m]->index]);
|
|
||||||
|
|
||||||
} else if (cf->ctx) {
|
|
||||||
confp = *(void **) ((char *) cf->ctx + cmd->conf);
|
|
||||||
|
|
||||||
if (confp) {
|
|
||||||
conf = confp[ngx_modules[m]->ctx_index];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = cmd->set(cf, cmd, conf);
|
|
||||||
|
|
||||||
if (rv == NGX_CONF_OK) {
|
|
||||||
break;
|
|
||||||
|
|
||||||
} else if (rv == NGX_CONF_ERROR) {
|
|
||||||
rc = NGX_ERROR;
|
|
||||||
break;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
|
||||||
"the \"%s\" directive %s in %s:%d",
|
|
||||||
name->data, rv,
|
|
||||||
cf->conf_file->file.name.data,
|
|
||||||
cf->conf_file->line);
|
|
||||||
|
|
||||||
rc = NGX_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
"unknown directive \"%s\" in %s:%d",
|
"%s in %s:%d",
|
||||||
name->data,
|
rv, cf->conf_file->file.name.data,
|
||||||
cf->conf_file->file.name.data,
|
cf->conf_file->line);
|
||||||
cf->conf_file->line);
|
|
||||||
|
|
||||||
rc = NGX_ERROR;
|
rc = NGX_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rc = ngx_conf_handler(cf, rc);
|
||||||
|
|
||||||
if (rc == NGX_ERROR) {
|
if (rc == NGX_ERROR) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (filename) {
|
if (filename) {
|
||||||
cf->conf_file = prev;
|
cf->conf_file = prev;
|
||||||
|
|
||||||
@ -337,6 +173,164 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last)
|
||||||
|
{
|
||||||
|
char *rv;
|
||||||
|
void *conf, **confp;
|
||||||
|
ngx_uint_t i, valid;
|
||||||
|
ngx_str_t *name;
|
||||||
|
ngx_command_t *cmd;
|
||||||
|
|
||||||
|
name = cf->args->elts;
|
||||||
|
|
||||||
|
for (i = 0; ngx_modules[i]; i++) {
|
||||||
|
|
||||||
|
/* look up the directive in the appropriate modules */
|
||||||
|
|
||||||
|
if (ngx_modules[i]->type != NGX_CONF_MODULE
|
||||||
|
&& ngx_modules[i]->type != cf->module_type)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = ngx_modules[i]->commands;
|
||||||
|
if (cmd == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cmd->name.len) {
|
||||||
|
|
||||||
|
if (name->len == cmd->name.len
|
||||||
|
&& ngx_strcmp(name->data, cmd->name.data) == 0)
|
||||||
|
{
|
||||||
|
/* is the directive's location right ? */
|
||||||
|
|
||||||
|
if (!(cmd->type & cf->cmd_type)) {
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
|
"directive \"%s\" in %s:%d "
|
||||||
|
"is not allowed here",
|
||||||
|
name->data, cf->conf_file->file.name.data,
|
||||||
|
cf->conf_file->line);
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(cmd->type & NGX_CONF_BLOCK) && last != NGX_OK) {
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
|
"directive \"%s\" in %s:%d "
|
||||||
|
"is not terminated by \";\"",
|
||||||
|
name->data, cf->conf_file->file.name.data,
|
||||||
|
cf->conf_file->line);
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((cmd->type & NGX_CONF_BLOCK)
|
||||||
|
&& last != NGX_CONF_BLOCK_START)
|
||||||
|
{
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
|
"directive \"%s\" in %s:%d "
|
||||||
|
"has not the opening \"{\"",
|
||||||
|
name->data, cf->conf_file->file.name.data,
|
||||||
|
cf->conf_file->line);
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* is the directive's argument count right ? */
|
||||||
|
|
||||||
|
if (cmd->type & NGX_CONF_ANY) {
|
||||||
|
valid = 1;
|
||||||
|
|
||||||
|
} else if (cmd->type & NGX_CONF_FLAG) {
|
||||||
|
|
||||||
|
if (cf->args->nelts == 2) {
|
||||||
|
valid = 1;
|
||||||
|
} else {
|
||||||
|
valid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (cmd->type & NGX_CONF_1MORE) {
|
||||||
|
|
||||||
|
if (cf->args->nelts > 1) {
|
||||||
|
valid = 1;
|
||||||
|
} else {
|
||||||
|
valid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (cmd->type & NGX_CONF_2MORE) {
|
||||||
|
|
||||||
|
if (cf->args->nelts > 2) {
|
||||||
|
valid = 1;
|
||||||
|
} else {
|
||||||
|
valid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (cf->args->nelts <= 10
|
||||||
|
&& (cmd->type
|
||||||
|
& argument_number[cf->args->nelts - 1]))
|
||||||
|
{
|
||||||
|
valid = 1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
valid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!valid) {
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
|
"invalid number arguments in "
|
||||||
|
"directive \"%s\" in %s:%d",
|
||||||
|
name->data, cf->conf_file->file.name.data,
|
||||||
|
cf->conf_file->line);
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set up the directive's configuration context */
|
||||||
|
|
||||||
|
conf = NULL;
|
||||||
|
|
||||||
|
if (cmd->type & NGX_DIRECT_CONF) {
|
||||||
|
conf = ((void **) cf->ctx)[ngx_modules[i]->index];
|
||||||
|
|
||||||
|
} else if (cmd->type & NGX_MAIN_CONF) {
|
||||||
|
conf = &(((void **) cf->ctx)[ngx_modules[i]->index]);
|
||||||
|
|
||||||
|
} else if (cf->ctx) {
|
||||||
|
confp = *(void **) ((char *) cf->ctx + cmd->conf);
|
||||||
|
|
||||||
|
if (confp) {
|
||||||
|
conf = confp[ngx_modules[i]->ctx_index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = cmd->set(cf, cmd, conf);
|
||||||
|
|
||||||
|
if (rv == NGX_CONF_OK) {
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rv == NGX_CONF_ERROR) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
|
"the \"%s\" directive %s in %s:%d",
|
||||||
|
name->data, rv, cf->conf_file->file.name.data,
|
||||||
|
cf->conf_file->line);
|
||||||
|
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
|
"unknown directive \"%s\" in %s:%d",
|
||||||
|
name->data, cf->conf_file->file.name.data,
|
||||||
|
cf->conf_file->line);
|
||||||
|
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf)
|
static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
u_char *start, ch, *src, *dst;
|
u_char *start, ch, *src, *dst;
|
||||||
@ -523,11 +517,13 @@ static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
if (!(word = ngx_push_array(cf->args))) {
|
word = ngx_array_push(cf->args);
|
||||||
|
if (word == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(word->data = ngx_palloc(cf->pool, b->pos - start + 1))) {
|
word->data = ngx_palloc(cf->pool, b->pos - start + 1);
|
||||||
|
if (word->data == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,7 +619,8 @@ ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name)
|
|||||||
name->len = cycle->root.len + old.len;
|
name->len = cycle->root.len + old.len;
|
||||||
|
|
||||||
if (cycle->connections) {
|
if (cycle->connections) {
|
||||||
if (!(name->data = ngx_palloc(cycle->pool, name->len + 1))) {
|
name->data = ngx_palloc(cycle->pool, name->len + 1);
|
||||||
|
if (name->data == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +628,8 @@ ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name)
|
|||||||
|
|
||||||
/* the init_cycle */
|
/* the init_cycle */
|
||||||
|
|
||||||
if (!(name->data = ngx_alloc(name->len + 1, cycle->log))) {
|
name->data = ngx_alloc(name->len + 1, cycle->log);
|
||||||
|
if (name->data == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -686,7 +684,8 @@ ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(file = ngx_list_push(&cycle->open_files))) {
|
file = ngx_list_push(&cycle->open_files);
|
||||||
|
if (file == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,15 @@ ngx_listening_t *ngx_listening_inet_stream_socket(ngx_conf_t *cf,
|
|||||||
ngx_listening_t *ls;
|
ngx_listening_t *ls;
|
||||||
struct sockaddr_in *sin;
|
struct sockaddr_in *sin;
|
||||||
|
|
||||||
if (!(ls = ngx_array_push(&cf->cycle->listening))) {
|
ls = ngx_array_push(&cf->cycle->listening);
|
||||||
|
if (ls == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_memzero(ls, sizeof(ngx_listening_t));
|
ngx_memzero(ls, sizeof(ngx_listening_t));
|
||||||
|
|
||||||
if (!(sin = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in)))) {
|
sin = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in));
|
||||||
|
if (sin == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +48,6 @@ ngx_listening_t *ngx_listening_inet_stream_socket(ngx_conf_t *cf,
|
|||||||
ls->addr_text.len = ngx_sprintf(ls->addr_text.data + len, ":%d", port)
|
ls->addr_text.len = ngx_sprintf(ls->addr_text.data + len, ":%d", port)
|
||||||
- ls->addr_text.data;
|
- ls->addr_text.data;
|
||||||
|
|
||||||
|
|
||||||
ls->fd = (ngx_socket_t) -1;
|
ls->fd = (ngx_socket_t) -1;
|
||||||
ls->family = AF_INET;
|
ls->family = AF_INET;
|
||||||
ls->type = SOCK_STREAM;
|
ls->type = SOCK_STREAM;
|
||||||
|
@ -54,15 +54,18 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
|
|
||||||
log = old_cycle->log;
|
log = old_cycle->log;
|
||||||
|
|
||||||
if (!(pool = ngx_create_pool(16 * 1024, log))) {
|
pool = ngx_create_pool(16 * 1024, log);
|
||||||
|
if (pool == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pool->log = log;
|
pool->log = log;
|
||||||
|
|
||||||
if (!(cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t)))) {
|
cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t));
|
||||||
|
if (cycle == NULL) {
|
||||||
ngx_destroy_pool(pool);
|
ngx_destroy_pool(pool);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cycle->pool = pool;
|
cycle->pool = pool;
|
||||||
cycle->log = log;
|
cycle->log = log;
|
||||||
cycle->old_cycle = old_cycle;
|
cycle->old_cycle = old_cycle;
|
||||||
@ -72,10 +75,13 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
|
|
||||||
|
|
||||||
n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
|
n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
|
||||||
if (!(cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)))) {
|
|
||||||
|
cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *));
|
||||||
|
if (cycle->pathes.elts == NULL) {
|
||||||
ngx_destroy_pool(pool);
|
ngx_destroy_pool(pool);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cycle->pathes.nelts = 0;
|
cycle->pathes.nelts = 0;
|
||||||
cycle->pathes.size = sizeof(ngx_path_t *);
|
cycle->pathes.size = sizeof(ngx_path_t *);
|
||||||
cycle->pathes.nalloc = n;
|
cycle->pathes.nalloc = n;
|
||||||
@ -100,7 +106,8 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!(cycle->new_log = ngx_log_create_errlog(cycle, NULL))) {
|
cycle->new_log = ngx_log_create_errlog(cycle, NULL);
|
||||||
|
if (cycle->new_log == NULL) {
|
||||||
ngx_destroy_pool(pool);
|
ngx_destroy_pool(pool);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -109,11 +116,13 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
|
|
||||||
|
|
||||||
n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10;
|
n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10;
|
||||||
|
|
||||||
cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t));
|
cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t));
|
||||||
if (cycle->listening.elts == NULL) {
|
if (cycle->listening.elts == NULL) {
|
||||||
ngx_destroy_pool(pool);
|
ngx_destroy_pool(pool);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cycle->listening.nelts = 0;
|
cycle->listening.nelts = 0;
|
||||||
cycle->listening.size = sizeof(ngx_listening_t);
|
cycle->listening.size = sizeof(ngx_listening_t);
|
||||||
cycle->listening.nalloc = n;
|
cycle->listening.nalloc = n;
|
||||||
@ -147,7 +156,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
|
|
||||||
ngx_memzero(&conf, sizeof(ngx_conf_t));
|
ngx_memzero(&conf, sizeof(ngx_conf_t));
|
||||||
/* STUB: init array ? */
|
/* STUB: init array ? */
|
||||||
conf.args = ngx_create_array(pool, 10, sizeof(ngx_str_t));
|
conf.args = ngx_array_create(pool, 10, sizeof(ngx_str_t));
|
||||||
if (conf.args == NULL) {
|
if (conf.args == NULL) {
|
||||||
ngx_destroy_pool(pool);
|
ngx_destroy_pool(pool);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -516,7 +525,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
|
|||||||
|
|
||||||
ngx_temp_pool->log = cycle->log;
|
ngx_temp_pool->log = cycle->log;
|
||||||
|
|
||||||
old = ngx_push_array(&ngx_old_cycles);
|
old = ngx_array_push(&ngx_old_cycles);
|
||||||
if (old == NULL) {
|
if (old == NULL) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -562,7 +571,7 @@ ngx_int_t ngx_create_pidfile(ngx_cycle_t *cycle, ngx_cycle_t *old_cycle)
|
|||||||
{
|
{
|
||||||
ngx_uint_t trunc;
|
ngx_uint_t trunc;
|
||||||
size_t len;
|
size_t len;
|
||||||
u_char *name, pid[NGX_INT64_LEN];
|
u_char pid[NGX_INT64_LEN];
|
||||||
ngx_file_t file;
|
ngx_file_t file;
|
||||||
ngx_core_conf_t *ccf, *old_ccf;
|
ngx_core_conf_t *ccf, *old_ccf;
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool,
|
|||||||
|
|
||||||
file->name.len = path->name.len + 1 + path->len + NGX_ATOMIC_T_LEN;
|
file->name.len = path->name.len + 1 + path->len + NGX_ATOMIC_T_LEN;
|
||||||
|
|
||||||
if (!(file->name.data = ngx_palloc(pool, file->name.len + 1))) {
|
file->name.data = ngx_palloc(pool, file->name.len + 1);
|
||||||
|
if (file->name.data == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +204,8 @@ ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
return "is duplicate";
|
return "is duplicate";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(path = ngx_pcalloc(cf->pool, sizeof(ngx_path_t)))) {
|
path = ngx_pcalloc(cf->pool, sizeof(ngx_path_t));
|
||||||
|
if (path == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +294,8 @@ ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(p = ngx_array_push(&cf->cycle->pathes))) {
|
p = ngx_array_push(&cf->cycle->pathes);
|
||||||
|
if (p == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,8 @@ char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
|||||||
#define ngx_conf_merge_path_value(curr, prev, path, l1, l2, l3, clean, cf) \
|
#define ngx_conf_merge_path_value(curr, prev, path, l1, l2, l3, clean, cf) \
|
||||||
if (curr == NULL) { \
|
if (curr == NULL) { \
|
||||||
if (prev == NULL) { \
|
if (prev == NULL) { \
|
||||||
if (!(curr = ngx_palloc(cf->pool, sizeof(ngx_path_t)))) { \
|
curr = ngx_palloc(cf->pool, sizeof(ngx_path_t)); \
|
||||||
|
if (curr == NULL) { \
|
||||||
return NGX_CONF_ERROR; \
|
return NGX_CONF_ERROR; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
@ -77,7 +77,8 @@ ngx_int_t ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, ngx_int_t level)
|
|||||||
|
|
||||||
buf.len = dname->len + 1 + len + NGX_DIR_MASK_LEN;
|
buf.len = dname->len + 1 + len + NGX_DIR_MASK_LEN;
|
||||||
|
|
||||||
if (!(buf.data = ngx_alloc(buf.len + 1, ctx->log))) {
|
buf.data = ngx_alloc(buf.len + 1, ctx->log);
|
||||||
|
if (buf.data == NULL) {
|
||||||
return NGX_ABORT;
|
return NGX_ABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,8 @@ ngx_peers_t *ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u)
|
|||||||
|
|
||||||
u->port = u->default_port_value;
|
u->port = u->default_port_value;
|
||||||
|
|
||||||
if (!(u->port_text.data = ngx_palloc(cf->pool, sizeof("65536") - 1))) {
|
u->port_text.data = ngx_palloc(cf->pool, sizeof("65536") - 1);
|
||||||
|
if (u->port_text.data == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +272,8 @@ ngx_peers_t *ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u)
|
|||||||
|
|
||||||
u->port = htons(u->port);
|
u->port = htons(u->port);
|
||||||
|
|
||||||
if (!(host = ngx_palloc(cf->pool, u->host.len + 1))) {
|
host = ngx_palloc(cf->pool, u->host.len + 1);
|
||||||
|
if (host == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +299,6 @@ ngx_peers_t *ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u)
|
|||||||
|
|
||||||
peers = ngx_pcalloc(cf->pool,
|
peers = ngx_pcalloc(cf->pool,
|
||||||
sizeof(ngx_peers_t) + sizeof(ngx_peer_t) * (i - 1));
|
sizeof(ngx_peers_t) + sizeof(ngx_peer_t) * (i - 1));
|
||||||
|
|
||||||
if (peers == NULL) {
|
if (peers == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -307,7 +308,8 @@ ngx_peers_t *ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u)
|
|||||||
|
|
||||||
for (i = 0; h->h_addr_list[i] != NULL; i++) {
|
for (i = 0; h->h_addr_list[i] != NULL; i++) {
|
||||||
|
|
||||||
if (!(sin = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in)))) {
|
sin = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in));
|
||||||
|
if (sin == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +322,8 @@ ngx_peers_t *ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u)
|
|||||||
|
|
||||||
len = INET_ADDRSTRLEN - 1 + 1 + u->port_text.len;
|
len = INET_ADDRSTRLEN - 1 + 1 + u->port_text.len;
|
||||||
|
|
||||||
if (!(peers->peer[i].name.data = ngx_palloc(cf->pool, len))) {
|
peers->peer[i].name.data = ngx_palloc(cf->pool, len);
|
||||||
|
if (peers->peer[i].name.data == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,11 +348,13 @@ ngx_peers_t *ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u)
|
|||||||
|
|
||||||
/* MP: ngx_shared_palloc() */
|
/* MP: ngx_shared_palloc() */
|
||||||
|
|
||||||
if (!(peers = ngx_pcalloc(cf->pool, sizeof(ngx_peers_t)))) {
|
peers = ngx_pcalloc(cf->pool, sizeof(ngx_peers_t));
|
||||||
|
if (peers == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sin = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in)))) {
|
sin = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in));
|
||||||
|
if (sin == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +371,8 @@ ngx_peers_t *ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u)
|
|||||||
|
|
||||||
peers->peer[0].name.len = len;
|
peers->peer[0].name.len = len;
|
||||||
|
|
||||||
if (!(peers->peer[0].name.data = ngx_palloc(cf->pool, len))) {
|
peers->peer[0].name.data = ngx_palloc(cf->pool, len);
|
||||||
|
if (peers->peer[0].name.data == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,13 @@ void *ngx_list_push(ngx_list_t *l)
|
|||||||
|
|
||||||
/* the last part is full, allocate a new list part */
|
/* the last part is full, allocate a new list part */
|
||||||
|
|
||||||
if (!(last = ngx_palloc(l->pool, sizeof(ngx_list_part_t)))) {
|
last = ngx_palloc(l->pool, sizeof(ngx_list_part_t));
|
||||||
|
if (last == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(last->elts = ngx_palloc(l->pool, l->nalloc * l->size))) {
|
last->elts = ngx_palloc(l->pool, l->nalloc * l->size);
|
||||||
|
if (last->elts == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,12 @@ typedef struct {
|
|||||||
} ngx_list_t;
|
} ngx_list_t;
|
||||||
|
|
||||||
|
|
||||||
static ngx_inline ngx_int_t ngx_list_init(ngx_list_t *list, ngx_pool_t *pool,
|
static ngx_inline
|
||||||
ngx_uint_t n, size_t size)
|
ngx_int_t ngx_list_init(ngx_list_t *list, ngx_pool_t *pool, ngx_uint_t n,
|
||||||
|
size_t size)
|
||||||
{
|
{
|
||||||
if (!(list->part.elts = ngx_palloc(pool, n * size))) {
|
list->part.elts = ngx_palloc(pool, n * size);
|
||||||
|
if (list->part.elts == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,11 +253,13 @@ ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args)
|
|||||||
name = NULL;
|
name = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)))) {
|
log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t));
|
||||||
|
if (log == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(log->file = ngx_conf_open_file(cycle, name))) {
|
log->file = ngx_conf_open_file(cycle, name);
|
||||||
|
if (log->file == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,8 @@ ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ctx->buf = ngx_create_temp_buf(ctx->pool, size))) {
|
ctx->buf = ngx_create_temp_buf(ctx->pool, size);
|
||||||
|
if (ctx->buf == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,9 +187,11 @@ ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
|
|||||||
ctx->in = ctx->in->next;
|
ctx->in = ctx->in->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(ctx->pool))) {
|
cl = ngx_alloc_chain_link(ctx->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->buf = ctx->buf;
|
cl->buf = ctx->buf;
|
||||||
cl->next = NULL;
|
cl->next = NULL;
|
||||||
*last_out = cl;
|
*last_out = cl;
|
||||||
@ -269,7 +272,8 @@ ngx_output_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
|
|||||||
|
|
||||||
while (in) {
|
while (in) {
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(pool))) {
|
cl = ngx_alloc_chain_link(pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +285,8 @@ ngx_output_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
|
|||||||
&& buf->file_pos < NGX_SENDFILE_LIMIT
|
&& buf->file_pos < NGX_SENDFILE_LIMIT
|
||||||
&& buf->file_last > NGX_SENDFILE_LIMIT)
|
&& buf->file_last > NGX_SENDFILE_LIMIT)
|
||||||
{
|
{
|
||||||
if (!(b = ngx_calloc_buf(pool))) {
|
b = ngx_calloc_buf(pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,9 +436,11 @@ ngx_chain_writer(void *data, ngx_chain_t *in)
|
|||||||
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->connection->log, 0,
|
||||||
"chain writer buf size: %uz", ngx_buf_size(in->buf));
|
"chain writer buf size: %uz", ngx_buf_size(in->buf));
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(ctx->pool))) {
|
cl = ngx_alloc_chain_link(ctx->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->buf = in->buf;
|
cl->buf = in->buf;
|
||||||
cl->next = NULL;
|
cl->next = NULL;
|
||||||
*ctx->last = cl;
|
*ctx->last = cl;
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
#include <ngx_core.h>
|
#include <ngx_core.h>
|
||||||
|
|
||||||
|
|
||||||
ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log)
|
ngx_pool_t *
|
||||||
|
ngx_create_pool(size_t size, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
ngx_pool_t *p;
|
ngx_pool_t *p;
|
||||||
|
|
||||||
if (!(p = ngx_alloc(size, log))) {
|
p = ngx_alloc(size, log);
|
||||||
|
if (p == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +28,8 @@ ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_destroy_pool(ngx_pool_t *pool)
|
void
|
||||||
|
ngx_destroy_pool(ngx_pool_t *pool)
|
||||||
{
|
{
|
||||||
ngx_pool_t *p, *n;
|
ngx_pool_t *p, *n;
|
||||||
ngx_pool_large_t *l;
|
ngx_pool_large_t *l;
|
||||||
@ -68,7 +71,8 @@ void ngx_destroy_pool(ngx_pool_t *pool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *ngx_palloc(ngx_pool_t *pool, size_t size)
|
void *
|
||||||
|
ngx_palloc(ngx_pool_t *pool, size_t size)
|
||||||
{
|
{
|
||||||
u_char *m;
|
u_char *m;
|
||||||
ngx_pool_t *p, *n;
|
ngx_pool_t *p, *n;
|
||||||
@ -94,7 +98,8 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
|
|||||||
|
|
||||||
/* allocate a new pool block */
|
/* allocate a new pool block */
|
||||||
|
|
||||||
if (!(n = ngx_create_pool((size_t) (p->end - (u_char *) p), p->log))) {
|
n = ngx_create_pool((size_t) (p->end - (u_char *) p), p->log);
|
||||||
|
if (n == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +130,8 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (large == NULL) {
|
if (large == NULL) {
|
||||||
if (!(large = ngx_palloc(pool, sizeof(ngx_pool_large_t)))) {
|
large = ngx_palloc(pool, sizeof(ngx_pool_large_t));
|
||||||
|
if (large == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,11 +139,13 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (!(p = ngx_memalign(ngx_pagesize, size, pool->log))) {
|
p = ngx_memalign(ngx_pagesize, size, pool->log);
|
||||||
|
if (p == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (!(p = ngx_alloc(size, pool->log))) {
|
p = ngx_alloc(size, pool->log);
|
||||||
|
if (p == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -155,7 +163,8 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_pfree(ngx_pool_t *pool, void *p)
|
ngx_int_t
|
||||||
|
ngx_pfree(ngx_pool_t *pool, void *p)
|
||||||
{
|
{
|
||||||
ngx_pool_large_t *l;
|
ngx_pool_large_t *l;
|
||||||
|
|
||||||
@ -174,7 +183,8 @@ ngx_int_t ngx_pfree(ngx_pool_t *pool, void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *ngx_pcalloc(ngx_pool_t *pool, size_t size)
|
void *
|
||||||
|
ngx_pcalloc(ngx_pool_t *pool, size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
@ -188,7 +198,8 @@ void *ngx_pcalloc(ngx_pool_t *pool, size_t size)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
static void *ngx_get_cached_block(size_t size)
|
static void *
|
||||||
|
ngx_get_cached_block(size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
ngx_cached_block_slot_t *slot;
|
ngx_cached_block_slot_t *slot;
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
#define NGX_DEFAULT_POOL_SIZE (16 * 1024)
|
#define NGX_DEFAULT_POOL_SIZE (16 * 1024)
|
||||||
|
|
||||||
#define ngx_test_null(p, alloc, rc) if ((p = alloc) == NULL) { return rc; }
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct ngx_pool_large_s ngx_pool_large_t;
|
typedef struct ngx_pool_large_s ngx_pool_large_t;
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ ngx_radix_tree_create(ngx_pool_t *pool, ngx_int_t preallocate)
|
|||||||
uint32_t key, mask, inc;
|
uint32_t key, mask, inc;
|
||||||
ngx_radix_tree_t *tree;
|
ngx_radix_tree_t *tree;
|
||||||
|
|
||||||
if (!(tree = ngx_palloc(pool, sizeof(ngx_radix_tree_t)))) {
|
tree = ngx_palloc(pool, sizeof(ngx_radix_tree_t));
|
||||||
|
if (tree == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +27,8 @@ ngx_radix_tree_create(ngx_pool_t *pool, ngx_int_t preallocate)
|
|||||||
tree->start = NULL;
|
tree->start = NULL;
|
||||||
tree->size = 0;
|
tree->size = 0;
|
||||||
|
|
||||||
if (!(tree->root = ngx_radix_alloc(tree))) {
|
tree->root = ngx_radix_alloc(tree);
|
||||||
|
if (tree->root == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +142,8 @@ ngx_radix32tree_insert(ngx_radix_tree_t *tree, uint32_t key, uint32_t mask,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (bit & mask) {
|
while (bit & mask) {
|
||||||
if (!(next = ngx_radix_alloc(tree))) {
|
next = ngx_radix_alloc(tree);
|
||||||
|
if (next == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +269,8 @@ ngx_radix_alloc(ngx_radix_tree_t *tree)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tree->size < sizeof(ngx_radix_node_t)) {
|
if (tree->size < sizeof(ngx_radix_node_t)) {
|
||||||
if (!(tree->start = ngx_palloc(tree->pool, ngx_pagesize))) {
|
tree->start = ngx_palloc(tree->pool, ngx_pagesize);
|
||||||
|
if (tree->start == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ 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)
|
ngx_int_t ngx_regex_capture_count(ngx_regex_t *re)
|
||||||
{
|
{
|
||||||
int rc, n;
|
int rc, n;
|
||||||
|
|
||||||
@ -87,7 +87,11 @@ ngx_uint_t ngx_regex_capture_count(ngx_regex_t *re)
|
|||||||
|
|
||||||
rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n);
|
rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n);
|
||||||
|
|
||||||
return (ngx_uint_t) n;
|
if (rc < 0) {
|
||||||
|
return (ngx_int_t) rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ngx_int_t) n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,11 +23,12 @@ typedef pcre ngx_regex_t;
|
|||||||
void ngx_regex_init(void);
|
void ngx_regex_init(void);
|
||||||
ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
|
ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
|
||||||
ngx_pool_t *pool, ngx_str_t *err);
|
ngx_pool_t *pool, ngx_str_t *err);
|
||||||
ngx_uint_t ngx_regex_capture_count(ngx_regex_t *re);
|
ngx_int_t ngx_regex_capture_count(ngx_regex_t *re);
|
||||||
ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
|
ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
|
||||||
int *captures, ngx_int_t size);
|
int *captures, ngx_int_t size);
|
||||||
|
|
||||||
#define ngx_regex_exec_n "pcre_exec()"
|
#define ngx_regex_exec_n "pcre_exec()"
|
||||||
|
#define ngx_regex_capture_count_n "pcre_fullinfo()"
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_REGEX_H_INCLUDED_ */
|
#endif /* _NGX_REGEX_H_INCLUDED_ */
|
||||||
|
@ -34,7 +34,8 @@ ngx_pstrdup(ngx_pool_t *pool, ngx_str_t *src)
|
|||||||
{
|
{
|
||||||
u_char *dst;
|
u_char *dst;
|
||||||
|
|
||||||
if (!(dst = ngx_palloc(pool, src->len))) {
|
dst = ngx_palloc(pool, src->len);
|
||||||
|
if (dst == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,6 +490,84 @@ ngx_atoi(u_char *line, size_t n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
ngx_atosz(u_char *line, size_t n)
|
||||||
|
{
|
||||||
|
ssize_t value;
|
||||||
|
|
||||||
|
if (n == 0) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (value = 0; n--; line++) {
|
||||||
|
if (*line < '0' || *line > '9') {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = value * 10 + (*line - '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value < 0) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
off_t
|
||||||
|
ngx_atoof(u_char *line, size_t n)
|
||||||
|
{
|
||||||
|
off_t value;
|
||||||
|
|
||||||
|
if (n == 0) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (value = 0; n--; line++) {
|
||||||
|
if (*line < '0' || *line > '9') {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = value * 10 + (*line - '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value < 0) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
time_t
|
||||||
|
ngx_atotm(u_char *line, size_t n)
|
||||||
|
{
|
||||||
|
time_t value;
|
||||||
|
|
||||||
|
if (n == 0) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (value = 0; n--; line++) {
|
||||||
|
if (*line < '0' || *line > '9') {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = value * 10 + (*line - '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value < 0) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_hextoi(u_char *line, size_t n)
|
ngx_hextoi(u_char *line, size_t n)
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,7 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
#define ngx_tolower(c) (u_char) ((c >= 'A' && c <= 'Z') ? (c | 0x20) : c)
|
#define ngx_tolower(c) (u_char) ((c >= 'A' && c <= 'Z') ? (c | 0x20) : c)
|
||||||
|
#define ngx_toupper(c) (u_char) ((c >= 'a' && c <= 'z') ? (c & ~0x20) : c)
|
||||||
|
|
||||||
|
|
||||||
#if (NGX_WIN32)
|
#if (NGX_WIN32)
|
||||||
@ -81,6 +82,9 @@ ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
|
|||||||
ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n);
|
ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n);
|
||||||
|
|
||||||
ngx_int_t ngx_atoi(u_char *line, size_t n);
|
ngx_int_t ngx_atoi(u_char *line, size_t n);
|
||||||
|
ssize_t ngx_atosz(u_char *line, size_t n);
|
||||||
|
off_t ngx_atoof(u_char *line, size_t n);
|
||||||
|
time_t ngx_atotm(u_char *line, size_t n);
|
||||||
ngx_int_t ngx_hextoi(u_char *line, size_t n);
|
ngx_int_t ngx_hextoi(u_char *line, size_t n);
|
||||||
|
|
||||||
void ngx_md5_text(u_char *text, u_char *md5);
|
void ngx_md5_text(u_char *text, u_char *md5);
|
||||||
|
@ -70,8 +70,8 @@ static char *week[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
|||||||
static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||||
|
|
||||||
|
void
|
||||||
void ngx_time_init(void)
|
ngx_time_init(void)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
@ -104,9 +104,12 @@ void ngx_time_init(void)
|
|||||||
|
|
||||||
#if (NGX_THREADS)
|
#if (NGX_THREADS)
|
||||||
|
|
||||||
ngx_int_t ngx_time_mutex_init(ngx_log_t *log)
|
ngx_int_t
|
||||||
|
ngx_time_mutex_init(ngx_log_t *log)
|
||||||
{
|
{
|
||||||
if (!(ngx_time_mutex = ngx_mutex_init(log, NGX_MUTEX_LIGHT))) {
|
ngx_time_mutex = ngx_mutex_init(log, NGX_MUTEX_LIGHT);
|
||||||
|
|
||||||
|
if (ngx_time_mutex == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +119,8 @@ ngx_int_t ngx_time_mutex_init(ngx_log_t *log)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void ngx_time_update(time_t s)
|
void
|
||||||
|
ngx_time_update(time_t s)
|
||||||
{
|
{
|
||||||
u_char *p;
|
u_char *p;
|
||||||
ngx_tm_t tm;
|
ngx_tm_t tm;
|
||||||
@ -209,7 +213,8 @@ void ngx_time_update(time_t s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u_char *ngx_http_time(u_char *buf, time_t t)
|
u_char *
|
||||||
|
ngx_http_time(u_char *buf, time_t t)
|
||||||
{
|
{
|
||||||
ngx_tm_t tm;
|
ngx_tm_t tm;
|
||||||
|
|
||||||
@ -226,7 +231,8 @@ u_char *ngx_http_time(u_char *buf, time_t t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u_char *ngx_http_cookie_time(u_char *buf, time_t t)
|
u_char *
|
||||||
|
ngx_http_cookie_time(u_char *buf, time_t t)
|
||||||
{
|
{
|
||||||
ngx_tm_t tm;
|
ngx_tm_t tm;
|
||||||
|
|
||||||
@ -252,7 +258,8 @@ u_char *ngx_http_cookie_time(u_char *buf, time_t t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_gmtime(time_t t, ngx_tm_t *tp)
|
void
|
||||||
|
ngx_gmtime(time_t t, ngx_tm_t *tp)
|
||||||
{
|
{
|
||||||
ngx_int_t sec, min, hour, mday, mon, year, wday, yday, days;
|
ngx_int_t sec, min, hour, mday, mon, year, wday, yday, days;
|
||||||
|
|
||||||
|
@ -59,11 +59,13 @@ ngx_peers_t *ngx_unix_upstream_parse(ngx_conf_t *cf,
|
|||||||
|
|
||||||
/* MP: ngx_shared_palloc() */
|
/* MP: ngx_shared_palloc() */
|
||||||
|
|
||||||
if (!(peers = ngx_pcalloc(cf->pool, sizeof(ngx_peers_t)))) {
|
peers = ngx_pcalloc(cf->pool, sizeof(ngx_peers_t));
|
||||||
|
if (peers == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sun = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_un)))) {
|
sun = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_un));
|
||||||
|
if (sun == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,19 +134,21 @@ ngx_devpoll_init(ngx_cycle_t *cycle)
|
|||||||
ngx_free(change_list);
|
ngx_free(change_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_test_null(change_list,
|
change_list = ngx_alloc(sizeof(struct pollfd) * dpcf->changes,
|
||||||
ngx_alloc(sizeof(struct pollfd) * dpcf->changes,
|
cycle->log);
|
||||||
cycle->log),
|
if (change_list == NULL) {
|
||||||
NGX_ERROR);
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (change_index) {
|
if (change_index) {
|
||||||
ngx_free(change_index);
|
ngx_free(change_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_test_null(change_index,
|
change_index = ngx_alloc(sizeof(ngx_event_t *) * dpcf->changes,
|
||||||
ngx_alloc(sizeof(ngx_event_t *) * dpcf->changes,
|
cycle->log);
|
||||||
cycle->log),
|
if (change_index == NULL) {
|
||||||
NGX_ERROR);
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
max_changes = dpcf->changes;
|
max_changes = dpcf->changes;
|
||||||
@ -156,10 +158,11 @@ ngx_devpoll_init(ngx_cycle_t *cycle)
|
|||||||
ngx_free(event_list);
|
ngx_free(event_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_test_null(event_list,
|
event_list = ngx_alloc(sizeof(struct pollfd) * dpcf->events,
|
||||||
ngx_alloc(sizeof(struct pollfd) * dpcf->events,
|
cycle->log);
|
||||||
cycle->log),
|
if (event_list == NULL) {
|
||||||
NGX_ERROR);
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nevents = dpcf->events;
|
nevents = dpcf->events;
|
||||||
@ -318,11 +321,13 @@ ngx_devpoll_process_events(ngx_cycle_t *cycle)
|
|||||||
{
|
{
|
||||||
int events, revents;
|
int events, revents;
|
||||||
ngx_int_t i;
|
ngx_int_t i;
|
||||||
ngx_uint_t j, lock, accept_lock, expire;
|
ngx_uint_t lock, accept_lock, expire;
|
||||||
size_t n;
|
size_t n;
|
||||||
ngx_msec_t timer;
|
ngx_msec_t timer;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
|
#if 0
|
||||||
ngx_cycle_t **old_cycle;
|
ngx_cycle_t **old_cycle;
|
||||||
|
#endif
|
||||||
ngx_event_t *rev, *wev;
|
ngx_event_t *rev, *wev;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
ngx_epoch_msec_t delta;
|
ngx_epoch_msec_t delta;
|
||||||
@ -580,8 +585,10 @@ ngx_devpoll_create_conf(ngx_cycle_t *cycle)
|
|||||||
{
|
{
|
||||||
ngx_devpoll_conf_t *dpcf;
|
ngx_devpoll_conf_t *dpcf;
|
||||||
|
|
||||||
ngx_test_null(dpcf, ngx_palloc(cycle->pool, sizeof(ngx_devpoll_conf_t)),
|
dpcf = ngx_palloc(cycle->pool, sizeof(ngx_devpoll_conf_t));
|
||||||
NGX_CONF_ERROR);
|
if (dpcf == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
dpcf->changes = NGX_CONF_UNSET;
|
dpcf->changes = NGX_CONF_UNSET;
|
||||||
dpcf->events = NGX_CONF_UNSET;
|
dpcf->events = NGX_CONF_UNSET;
|
||||||
|
@ -133,7 +133,6 @@ ngx_module_t ngx_epoll_module = {
|
|||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_epoll_init(ngx_cycle_t *cycle)
|
ngx_epoll_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
size_t n;
|
|
||||||
ngx_event_conf_t *ecf;
|
ngx_event_conf_t *ecf;
|
||||||
ngx_epoll_conf_t *epcf;
|
ngx_epoll_conf_t *epcf;
|
||||||
|
|
||||||
@ -380,7 +379,6 @@ static ngx_int_t
|
|||||||
ngx_epoll_process_events(ngx_cycle_t *cycle)
|
ngx_epoll_process_events(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
int events;
|
int events;
|
||||||
size_t n;
|
|
||||||
uint32_t revents;
|
uint32_t revents;
|
||||||
ngx_int_t instance, i;
|
ngx_int_t instance, i;
|
||||||
ngx_uint_t lock, accept_lock, expire;
|
ngx_uint_t lock, accept_lock, expire;
|
||||||
@ -663,8 +661,10 @@ ngx_epoll_create_conf(ngx_cycle_t *cycle)
|
|||||||
{
|
{
|
||||||
ngx_epoll_conf_t *epcf;
|
ngx_epoll_conf_t *epcf;
|
||||||
|
|
||||||
ngx_test_null(epcf, ngx_palloc(cycle->pool, sizeof(ngx_epoll_conf_t)),
|
epcf = ngx_palloc(cycle->pool, sizeof(ngx_epoll_conf_t));
|
||||||
NGX_CONF_ERROR);
|
if (epcf == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
epcf->events = NGX_CONF_UNSET;
|
epcf->events = NGX_CONF_UNSET;
|
||||||
|
|
||||||
|
@ -90,7 +90,8 @@ ngx_os_io_t ngx_iocp_io = {
|
|||||||
static HANDLE iocp;
|
static HANDLE iocp;
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_iocp_init(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_iocp_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_iocp_conf_t *cf;
|
ngx_iocp_conf_t *cf;
|
||||||
|
|
||||||
@ -117,7 +118,8 @@ static ngx_int_t ngx_iocp_init(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_iocp_done(ngx_cycle_t *cycle)
|
static void
|
||||||
|
ngx_iocp_done(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
if (CloseHandle(iocp) == -1) {
|
if (CloseHandle(iocp) == -1) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||||
@ -128,7 +130,8 @@ static void ngx_iocp_done(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key)
|
static ngx_int_t
|
||||||
|
ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key)
|
||||||
{
|
{
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
|
|
||||||
@ -150,7 +153,8 @@ static ngx_int_t ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_iocp_del_connection(ngx_connection_t *c, u_int flags)
|
static ngx_int_t
|
||||||
|
ngx_iocp_del_connection(ngx_connection_t *c, u_int flags)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
if (flags & NGX_CLOSE_EVENT) {
|
if (flags & NGX_CLOSE_EVENT) {
|
||||||
@ -167,7 +171,8 @@ static ngx_int_t ngx_iocp_del_connection(ngx_connection_t *c, u_int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_iocp_process_events(ngx_cycle_t *cycle)
|
static
|
||||||
|
ngx_int_t ngx_iocp_process_events(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
u_int key;
|
u_int key;
|
||||||
@ -301,12 +306,15 @@ static ngx_int_t ngx_iocp_process_events(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_iocp_create_conf(ngx_cycle_t *cycle)
|
static void *
|
||||||
|
ngx_iocp_create_conf(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_iocp_conf_t *cf;
|
ngx_iocp_conf_t *cf;
|
||||||
|
|
||||||
ngx_test_null(cf, ngx_palloc(cycle->pool, sizeof(ngx_iocp_conf_t)),
|
cf = ngx_palloc(cycle->pool, sizeof(ngx_iocp_conf_t));
|
||||||
NGX_CONF_ERROR);
|
if (cf == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
cf->threads = NGX_CONF_UNSET;
|
cf->threads = NGX_CONF_UNSET;
|
||||||
cf->post_acceptex = NGX_CONF_UNSET;
|
cf->post_acceptex = NGX_CONF_UNSET;
|
||||||
@ -316,7 +324,8 @@ static void *ngx_iocp_create_conf(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_iocp_init_conf(ngx_cycle_t *cycle, void *conf)
|
static char *
|
||||||
|
ngx_iocp_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||||
{
|
{
|
||||||
ngx_iocp_conf_t *cf = conf;
|
ngx_iocp_conf_t *cf = conf;
|
||||||
|
|
||||||
|
@ -123,11 +123,13 @@ ngx_kqueue_init(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
#if (NGX_THREADS)
|
#if (NGX_THREADS)
|
||||||
|
|
||||||
if (!(list_mutex = ngx_mutex_init(cycle->log, 0))) {
|
list_mutex = ngx_mutex_init(cycle->log, 0);
|
||||||
|
if (list_mutex == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(kevent_mutex = ngx_mutex_init(cycle->log, 0))) {
|
kevent_mutex = ngx_mutex_init(cycle->log, 0);
|
||||||
|
if (kevent_mutex == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,8 +799,10 @@ ngx_kqueue_create_conf(ngx_cycle_t *cycle)
|
|||||||
{
|
{
|
||||||
ngx_kqueue_conf_t *kcf;
|
ngx_kqueue_conf_t *kcf;
|
||||||
|
|
||||||
ngx_test_null(kcf, ngx_palloc(cycle->pool, sizeof(ngx_kqueue_conf_t)),
|
kcf = ngx_palloc(cycle->pool, sizeof(ngx_kqueue_conf_t));
|
||||||
NGX_CONF_ERROR);
|
if (kcf == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
kcf->changes = NGX_CONF_UNSET;
|
kcf->changes = NGX_CONF_UNSET;
|
||||||
kcf->events = NGX_CONF_UNSET;
|
kcf->events = NGX_CONF_UNSET;
|
||||||
|
@ -73,10 +73,11 @@ ngx_poll_init(ngx_cycle_t *cycle)
|
|||||||
|| cycle->old_cycle == NULL
|
|| cycle->old_cycle == NULL
|
||||||
|| cycle->old_cycle->connection_n < cycle->connection_n)
|
|| cycle->old_cycle->connection_n < cycle->connection_n)
|
||||||
{
|
{
|
||||||
ngx_test_null(list,
|
list = ngx_alloc(sizeof(struct pollfd) * cycle->connection_n,
|
||||||
ngx_alloc(sizeof(struct pollfd) * cycle->connection_n,
|
cycle->log);
|
||||||
cycle->log),
|
if (list == NULL) {
|
||||||
NGX_ERROR);
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (event_list) {
|
if (event_list) {
|
||||||
ngx_memcpy(list, event_list, sizeof(ngx_event_t *) * nevents);
|
ngx_memcpy(list, event_list, sizeof(ngx_event_t *) * nevents);
|
||||||
@ -90,10 +91,11 @@ ngx_poll_init(ngx_cycle_t *cycle)
|
|||||||
ngx_free(ready_index);
|
ngx_free(ready_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_test_null(ready_index,
|
ready_index = ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n,
|
||||||
ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n,
|
cycle->log);
|
||||||
cycle->log),
|
if (ready_index == NULL) {
|
||||||
NGX_ERROR);
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,9 +274,8 @@ static ngx_int_t
|
|||||||
ngx_rtsig_process_events(ngx_cycle_t *cycle)
|
ngx_rtsig_process_events(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
int signo;
|
int signo;
|
||||||
ngx_int_t instance, i;
|
ngx_int_t instance;
|
||||||
ngx_uint_t expire;
|
ngx_uint_t expire;
|
||||||
size_t n;
|
|
||||||
ngx_msec_t timer;
|
ngx_msec_t timer;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
siginfo_t si;
|
siginfo_t si;
|
||||||
@ -777,8 +776,10 @@ ngx_rtsig_create_conf(ngx_cycle_t *cycle)
|
|||||||
{
|
{
|
||||||
ngx_rtsig_conf_t *rtscf;
|
ngx_rtsig_conf_t *rtscf;
|
||||||
|
|
||||||
ngx_test_null(rtscf, ngx_palloc(cycle->pool, sizeof(ngx_rtsig_conf_t)),
|
rtscf = ngx_palloc(cycle->pool, sizeof(ngx_rtsig_conf_t));
|
||||||
NGX_CONF_ERROR);
|
if (rtscf == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
rtscf->signo = NGX_CONF_UNSET;
|
rtscf->signo = NGX_CONF_UNSET;
|
||||||
rtscf->overflow_events = NGX_CONF_UNSET;
|
rtscf->overflow_events = NGX_CONF_UNSET;
|
||||||
|
@ -72,7 +72,8 @@ ngx_module_t ngx_select_module = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_select_init(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_select_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_event_t **index;
|
ngx_event_t **index;
|
||||||
|
|
||||||
@ -86,10 +87,11 @@ static ngx_int_t ngx_select_init(ngx_cycle_t *cycle)
|
|||||||
|| cycle->old_cycle == NULL
|
|| cycle->old_cycle == NULL
|
||||||
|| cycle->old_cycle->connection_n < cycle->connection_n)
|
|| cycle->old_cycle->connection_n < cycle->connection_n)
|
||||||
{
|
{
|
||||||
ngx_test_null(index,
|
index = ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n,
|
||||||
ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n,
|
cycle->log);
|
||||||
cycle->log),
|
if (index == NULL) {
|
||||||
NGX_ERROR);
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (event_index) {
|
if (event_index) {
|
||||||
ngx_memcpy(index, event_index, sizeof(ngx_event_t *) * nevents);
|
ngx_memcpy(index, event_index, sizeof(ngx_event_t *) * nevents);
|
||||||
@ -101,10 +103,12 @@ static ngx_int_t ngx_select_init(ngx_cycle_t *cycle)
|
|||||||
if (ready_index) {
|
if (ready_index) {
|
||||||
ngx_free(ready_index);
|
ngx_free(ready_index);
|
||||||
}
|
}
|
||||||
ngx_test_null(ready_index,
|
|
||||||
ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n,
|
ready_index = ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n,
|
||||||
cycle->log),
|
cycle->log);
|
||||||
NGX_ERROR);
|
if (ready_index == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +128,8 @@ static ngx_int_t ngx_select_init(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_select_done(ngx_cycle_t *cycle)
|
static void
|
||||||
|
ngx_select_done(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_free(event_index);
|
ngx_free(event_index);
|
||||||
#if 0
|
#if 0
|
||||||
@ -135,7 +140,8 @@ static void ngx_select_done(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_select_add_event(ngx_event_t *ev, int event, u_int flags)
|
static ngx_int_t
|
||||||
|
ngx_select_add_event(ngx_event_t *ev, int event, u_int flags)
|
||||||
{
|
{
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
|
|
||||||
@ -196,7 +202,8 @@ static ngx_int_t ngx_select_add_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_select_del_event(ngx_event_t *ev, int event, u_int flags)
|
static ngx_int_t
|
||||||
|
ngx_select_del_event(ngx_event_t *ev, int event, u_int flags)
|
||||||
{
|
{
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
|
|
||||||
@ -248,7 +255,8 @@ static ngx_int_t ngx_select_del_event(ngx_event_t *ev, int event, u_int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_select_process_events(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
int ready, nready;
|
int ready, nready;
|
||||||
ngx_uint_t i, found, lock, expire;
|
ngx_uint_t i, found, lock, expire;
|
||||||
@ -592,7 +600,8 @@ static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_select_init_conf(ngx_cycle_t *cycle, void *conf)
|
static char *
|
||||||
|
ngx_select_init_conf(ngx_cycle_t *cycle, void *conf)
|
||||||
{
|
{
|
||||||
ngx_event_conf_t *ecf;
|
ngx_event_conf_t *ecf;
|
||||||
|
|
||||||
|
@ -219,7 +219,8 @@ static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(shared = ngx_create_shared_memory(size, cycle->log))) {
|
shared = ngx_create_shared_memory(size, cycle->log);
|
||||||
|
if (shared == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +273,8 @@ static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
#if (NGX_THREADS)
|
||||||
if (!(ngx_posted_events_mutex = ngx_mutex_init(cycle->log, 0))) {
|
ngx_posted_events_mutex = ngx_mutex_init(cycle->log, 0);
|
||||||
|
if (ngx_posted_events_mutex == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -497,42 +499,47 @@ ngx_int_t ngx_send_lowat(ngx_connection_t *c, size_t lowat)
|
|||||||
|
|
||||||
static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
int m;
|
char *rv;
|
||||||
char *rv;
|
|
||||||
void ***ctx;
|
void ***ctx;
|
||||||
|
ngx_uint_t i;
|
||||||
ngx_conf_t pcf;
|
ngx_conf_t pcf;
|
||||||
ngx_event_module_t *module;
|
ngx_event_module_t *m;
|
||||||
|
|
||||||
/* count the number of the event modules and set up their indices */
|
/* count the number of the event modules and set up their indices */
|
||||||
|
|
||||||
ngx_event_max_module = 0;
|
ngx_event_max_module = 0;
|
||||||
for (m = 0; ngx_modules[m]; m++) {
|
for (i = 0; ngx_modules[i]; i++) {
|
||||||
if (ngx_modules[m]->type != NGX_EVENT_MODULE) {
|
if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_modules[m]->ctx_index = ngx_event_max_module++;
|
ngx_modules[i]->ctx_index = ngx_event_max_module++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_test_null(ctx, ngx_pcalloc(cf->pool, sizeof(void *)), NGX_CONF_ERROR);
|
ctx = ngx_pcalloc(cf->pool, sizeof(void *));
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ngx_test_null(*ctx,
|
*ctx = ngx_pcalloc(cf->pool, ngx_event_max_module * sizeof(void *));
|
||||||
ngx_pcalloc(cf->pool, ngx_event_max_module * sizeof(void *)),
|
if (*ctx == NULL) {
|
||||||
NGX_CONF_ERROR);
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
*(void **) conf = ctx;
|
*(void **) conf = ctx;
|
||||||
|
|
||||||
for (m = 0; ngx_modules[m]; m++) {
|
for (i = 0; ngx_modules[i]; i++) {
|
||||||
if (ngx_modules[m]->type != NGX_EVENT_MODULE) {
|
if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
module = ngx_modules[m]->ctx;
|
m = ngx_modules[i]->ctx;
|
||||||
|
|
||||||
if (module->create_conf) {
|
if (m->create_conf) {
|
||||||
ngx_test_null((*ctx)[ngx_modules[m]->ctx_index],
|
(*ctx)[ngx_modules[i]->ctx_index] = m->create_conf(cf->cycle);
|
||||||
module->create_conf(cf->cycle),
|
if ((*ctx)[ngx_modules[i]->ctx_index] == NULL) {
|
||||||
NGX_CONF_ERROR);
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,22 +547,23 @@ static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
cf->ctx = ctx;
|
cf->ctx = ctx;
|
||||||
cf->module_type = NGX_EVENT_MODULE;
|
cf->module_type = NGX_EVENT_MODULE;
|
||||||
cf->cmd_type = NGX_EVENT_CONF;
|
cf->cmd_type = NGX_EVENT_CONF;
|
||||||
|
|
||||||
rv = ngx_conf_parse(cf, NULL);
|
rv = ngx_conf_parse(cf, NULL);
|
||||||
|
|
||||||
*cf = pcf;
|
*cf = pcf;
|
||||||
|
|
||||||
if (rv != NGX_CONF_OK)
|
if (rv != NGX_CONF_OK)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
for (m = 0; ngx_modules[m]; m++) {
|
for (i = 0; ngx_modules[i]; i++) {
|
||||||
if (ngx_modules[m]->type != NGX_EVENT_MODULE) {
|
if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
module = ngx_modules[m]->ctx;
|
m = ngx_modules[i]->ctx;
|
||||||
|
|
||||||
if (module->init_conf) {
|
if (m->init_conf) {
|
||||||
rv = module->init_conf(cf->cycle,
|
rv = m->init_conf(cf->cycle, (*ctx)[ngx_modules[i]->ctx_index]);
|
||||||
(*ctx)[ngx_modules[m]->ctx_index]);
|
|
||||||
if (rv != NGX_CONF_OK) {
|
if (rv != NGX_CONF_OK) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -668,7 +676,8 @@ static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
|
|
||||||
/* AF_INET only */
|
/* AF_INET only */
|
||||||
|
|
||||||
if (!(addr = ngx_push_array(&ecf->debug_connection))) {
|
addr = ngx_array_push(&ecf->debug_connection);
|
||||||
|
if (addr == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,8 +713,10 @@ static void *ngx_event_create_conf(ngx_cycle_t *cycle)
|
|||||||
{
|
{
|
||||||
ngx_event_conf_t *ecf;
|
ngx_event_conf_t *ecf;
|
||||||
|
|
||||||
ngx_test_null(ecf, ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t)),
|
ecf = ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t));
|
||||||
NGX_CONF_ERROR);
|
if (ecf == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ecf->connections = NGX_CONF_UNSET_UINT;
|
ecf->connections = NGX_CONF_UNSET_UINT;
|
||||||
ecf->use = NGX_CONF_UNSET_UINT;
|
ecf->use = NGX_CONF_UNSET_UINT;
|
||||||
@ -715,8 +726,13 @@ static void *ngx_event_create_conf(ngx_cycle_t *cycle)
|
|||||||
ecf->name = (void *) NGX_CONF_UNSET;
|
ecf->name = (void *) NGX_CONF_UNSET;
|
||||||
|
|
||||||
#if (NGX_DEBUG)
|
#if (NGX_DEBUG)
|
||||||
ngx_init_array(ecf->debug_connection, cycle->pool, 4, sizeof(in_addr_t),
|
|
||||||
NGX_CONF_ERROR);
|
if (ngx_array_init(&ecf->debug_connection, cycle->pool, 4,
|
||||||
|
sizeof(in_addr_t)) == NGX_ERROR)
|
||||||
|
{
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ecf;
|
return ecf;
|
||||||
@ -727,7 +743,12 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||||||
{
|
{
|
||||||
ngx_event_conf_t *ecf = conf;
|
ngx_event_conf_t *ecf = conf;
|
||||||
|
|
||||||
int fd, rtsig;
|
#if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
|
||||||
|
int fd;
|
||||||
|
#endif
|
||||||
|
#if (NGX_HAVE_RTSIG)
|
||||||
|
ngx_uint_t rtsig;
|
||||||
|
#endif
|
||||||
ngx_int_t i, connections;
|
ngx_int_t i, connections;
|
||||||
ngx_module_t *module;
|
ngx_module_t *module;
|
||||||
ngx_core_conf_t *ccf;
|
ngx_core_conf_t *ccf;
|
||||||
@ -735,8 +756,6 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||||||
|
|
||||||
connections = NGX_CONF_UNSET_UINT;
|
connections = NGX_CONF_UNSET_UINT;
|
||||||
module = NULL;
|
module = NULL;
|
||||||
rtsig = 0;
|
|
||||||
fd = 0;
|
|
||||||
|
|
||||||
#if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
|
#if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
|
||||||
|
|
||||||
@ -760,6 +779,9 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||||||
connections = DEFAULT_CONNECTIONS;
|
connections = DEFAULT_CONNECTIONS;
|
||||||
module = &ngx_rtsig_module;
|
module = &ngx_rtsig_module;
|
||||||
rtsig = 1;
|
rtsig = 1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
rtsig = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -782,11 +804,10 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||||||
|
|
||||||
if (module == NULL) {
|
if (module == NULL) {
|
||||||
|
|
||||||
#if (NGX_WIN32)
|
#if (NGX_WIN32 || FD_SETSIZE >= DEFAULT_CONNECTIONS)
|
||||||
connections = DEFAULT_CONNECTIONS;
|
connections = DEFAULT_CONNECTIONS;
|
||||||
#else
|
#else
|
||||||
connections = FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE:
|
connections = FD_SETSIZE;
|
||||||
DEFAULT_CONNECTIONS;
|
|
||||||
#endif
|
#endif
|
||||||
module = &ngx_select_module;
|
module = &ngx_select_module;
|
||||||
}
|
}
|
||||||
@ -828,7 +849,15 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||||||
ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500);
|
ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500);
|
||||||
|
|
||||||
|
|
||||||
if (!rtsig || ecf->accept_mutex) {
|
#if (NGX_HAVE_RTSIG)
|
||||||
|
|
||||||
|
if (!rtsig) {
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (ecf->accept_mutex) {
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,10 @@ static u_char *ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len);
|
|||||||
void
|
void
|
||||||
ngx_event_accept(ngx_event_t *ev)
|
ngx_event_accept(ngx_event_t *ev)
|
||||||
{
|
{
|
||||||
ngx_uint_t instance, accepted;
|
ngx_uint_t instance;
|
||||||
|
#if 0
|
||||||
|
ngx_uint_t accepted;
|
||||||
|
#endif
|
||||||
socklen_t len;
|
socklen_t len;
|
||||||
struct sockaddr *sa;
|
struct sockaddr *sa;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
@ -43,8 +46,10 @@ ngx_event_accept(ngx_event_t *ev)
|
|||||||
&ls->listening->addr_text, ev->available);
|
&ls->listening->addr_text, ev->available);
|
||||||
|
|
||||||
ev->ready = 0;
|
ev->ready = 0;
|
||||||
accepted = 0;
|
|
||||||
pool = NULL;
|
pool = NULL;
|
||||||
|
#if 0
|
||||||
|
accepted = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
@ -56,17 +61,20 @@ ngx_event_accept(ngx_event_t *ev)
|
|||||||
* case and besides the pool can be got from the free pool list.
|
* case and besides the pool can be got from the free pool list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) {
|
pool = ngx_create_pool(ls->listening->pool_size, ev->log);
|
||||||
|
if (pool == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sa = ngx_palloc(pool, ls->listening->socklen))) {
|
sa = ngx_palloc(pool, ls->listening->socklen);
|
||||||
|
if (sa == NULL) {
|
||||||
ngx_destroy_pool(pool);
|
ngx_destroy_pool(pool);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(log = ngx_palloc(pool, sizeof(ngx_log_t)))) {
|
log = ngx_palloc(pool, sizeof(ngx_log_t));
|
||||||
|
if (log == NULL) {
|
||||||
ngx_destroy_pool(pool);
|
ngx_destroy_pool(pool);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -331,7 +339,9 @@ ngx_event_accept(ngx_event_t *ev)
|
|||||||
ev->available--;
|
ev->available--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
accepted++;
|
accepted++;
|
||||||
|
#endif
|
||||||
|
|
||||||
} while (ev->available);
|
} while (ev->available);
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,8 @@ int ngx_event_post_acceptex(ngx_listening_t *ls, int n)
|
|||||||
c->recv = ngx_recv;
|
c->recv = ngx_recv;
|
||||||
c->send_chain = ngx_send_chain;
|
c->send_chain = ngx_send_chain;
|
||||||
|
|
||||||
if (!(c->pool = ngx_create_pool(ls->pool_size, ls->log))) {
|
c->pool = ngx_create_pool(ls->pool_size, ls->log);
|
||||||
|
if (c->pool == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,15 +165,18 @@ int ngx_event_post_acceptex(ngx_listening_t *ls, int n)
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(c->local_sockaddr = ngx_palloc(c->pool, ls->socklen))) {
|
c->local_sockaddr = ngx_palloc(c->pool, ls->socklen);
|
||||||
|
if (c->local_sockaddr == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(c->sockaddr = ngx_palloc(c->pool, ls->socklen))) {
|
c->sockaddr = ngx_palloc(c->pool, ls->socklen);
|
||||||
|
if (c->sockaddr == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(c->log = ngx_palloc(c->pool, sizeof(ngx_log_t)))) {
|
c->log = ngx_palloc(c->pool, sizeof(ngx_log_t));
|
||||||
|
if (c->log == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,6 @@ static void ngx_ssl_read_handler(ngx_event_t *rev);
|
|||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_ssl_init(ngx_log_t *log)
|
ngx_ssl_init(ngx_log_t *log)
|
||||||
{
|
{
|
||||||
ENGINE *engine;
|
|
||||||
|
|
||||||
SSL_library_init();
|
SSL_library_init();
|
||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
ENGINE_load_builtin_engines();
|
ENGINE_load_builtin_engines();
|
||||||
@ -36,11 +34,13 @@ ngx_ssl_create_session(ngx_ssl_ctx_t *ssl_ctx, ngx_connection_t *c,
|
|||||||
{
|
{
|
||||||
ngx_ssl_t *ssl;
|
ngx_ssl_t *ssl;
|
||||||
|
|
||||||
if (!(ssl = ngx_pcalloc(c->pool, sizeof(ngx_ssl_t)))) {
|
ssl = ngx_pcalloc(c->pool, sizeof(ngx_ssl_t));
|
||||||
|
if (ssl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ssl->buf = ngx_create_temp_buf(c->pool, NGX_SSL_BUFSIZE))) {
|
ssl->buf = ngx_create_temp_buf(c->pool, NGX_SSL_BUFSIZE);
|
||||||
|
if (ssl->buf == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,7 +586,7 @@ ngx_ssl_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, char *fmt, ...)
|
|||||||
p = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args);
|
p = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
p = ngx_cpystrn(p, " (SSL: ", last - p);
|
p = ngx_cpystrn(p, (u_char *) " (SSL: ", last - p);
|
||||||
|
|
||||||
ERR_error_string_n(ERR_get_error(), (char *) p, last - p);
|
ERR_error_string_n(ERR_get_error(), (char *) p, last - p);
|
||||||
|
|
||||||
|
@ -165,13 +165,15 @@ static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
|||||||
|
|
||||||
/* allocate a new buf if it's still allowed */
|
/* allocate a new buf if it's still allowed */
|
||||||
|
|
||||||
if (!(b = ngx_create_temp_buf(p->pool, p->bufs.size))) {
|
b = ngx_create_temp_buf(p->pool, p->bufs.size);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ABORT;
|
return NGX_ABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->allocated++;
|
p->allocated++;
|
||||||
|
|
||||||
if (!(chain = ngx_alloc_chain_link(p->pool))) {
|
chain = ngx_alloc_chain_link(p->pool);
|
||||||
|
if (chain == NULL) {
|
||||||
return NGX_ABORT;
|
return NGX_ABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +497,13 @@ static ngx_int_t ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cl->next = NULL;
|
cl->next = NULL;
|
||||||
ngx_chain_add_link(out, ll, cl);
|
|
||||||
|
if (out) {
|
||||||
|
*ll = cl;
|
||||||
|
} else {
|
||||||
|
out = cl;
|
||||||
|
}
|
||||||
|
ll = &cl->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
||||||
@ -635,11 +643,17 @@ static ngx_int_t ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p)
|
|||||||
b->in_file = 1;
|
b->in_file = 1;
|
||||||
b->temp_file = 1;
|
b->temp_file = 1;
|
||||||
|
|
||||||
ngx_chain_add_link(p->out, p->last_out, cl);
|
if (p->out) {
|
||||||
|
*p->last_out = cl;
|
||||||
|
} else {
|
||||||
|
p->out = cl;
|
||||||
|
}
|
||||||
|
p->last_out = &cl->next;
|
||||||
|
|
||||||
if (b->last_shadow) {
|
if (b->last_shadow) {
|
||||||
|
|
||||||
if (!(tl = ngx_alloc_chain_link(p->pool))) {
|
tl = ngx_alloc_chain_link(p->pool);
|
||||||
|
if (tl == NULL) {
|
||||||
return NGX_ABORT;
|
return NGX_ABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,7 +690,8 @@ ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
p->free = p->free->next;
|
p->free = p->free->next;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!(b = ngx_alloc_buf(p->pool))) {
|
b = ngx_alloc_buf(p->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -688,7 +703,8 @@ ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
b->recycled = 1;
|
b->recycled = 1;
|
||||||
buf->shadow = b;
|
buf->shadow = b;
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(p->pool))) {
|
cl = ngx_alloc_chain_link(p->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,7 +713,12 @@ ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
|
||||||
|
|
||||||
ngx_chain_add_link(p->in, p->last_in, cl);
|
if (p->in) {
|
||||||
|
*p->last_in = cl;
|
||||||
|
} else {
|
||||||
|
p->in = cl;
|
||||||
|
}
|
||||||
|
p->last_in = &cl->next;
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
@ -766,7 +787,8 @@ ngx_int_t ngx_event_pipe_add_free_buf(ngx_event_pipe_t *p, ngx_buf_t *b)
|
|||||||
{
|
{
|
||||||
ngx_chain_t *cl;
|
ngx_chain_t *cl;
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(p->pool))) {
|
cl = ngx_alloc_chain_link(p->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,10 +43,10 @@ void ngx_event_process_posted(ngx_cycle_t *cycle)
|
|||||||
void ngx_wakeup_worker_thread(ngx_cycle_t *cycle)
|
void ngx_wakeup_worker_thread(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_int_t i;
|
ngx_int_t i;
|
||||||
|
#if 0
|
||||||
ngx_uint_t busy;
|
ngx_uint_t busy;
|
||||||
ngx_event_t *ev;
|
ngx_event_t *ev;
|
||||||
|
|
||||||
#if 0
|
|
||||||
busy = 1;
|
busy = 1;
|
||||||
|
|
||||||
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
|
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
|
||||||
|
@ -31,7 +31,8 @@ ngx_event_timer_init(ngx_log_t *log)
|
|||||||
ngx_event_timer_rbtree = &ngx_event_timer_sentinel;
|
ngx_event_timer_rbtree = &ngx_event_timer_sentinel;
|
||||||
|
|
||||||
#if (NGX_THREADS)
|
#if (NGX_THREADS)
|
||||||
if (!(ngx_event_timer_mutex = ngx_mutex_init(log, 0))) {
|
ngx_event_timer_mutex = ngx_mutex_init(log, 0);
|
||||||
|
if (ngx_event_timer_mutex == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
#include <ngx_event.h>
|
#include <ngx_event.h>
|
||||||
|
|
||||||
|
|
||||||
#define NGX_TIMER_INFINITE -1
|
#define NGX_TIMER_INFINITE (ngx_msec_t) -1
|
||||||
#define NGX_TIMER_ERROR -2
|
#define NGX_TIMER_ERROR (ngx_msec_t) -2
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -25,10 +25,10 @@ typedef struct {
|
|||||||
|
|
||||||
static ngx_int_t ngx_http_access_handler(ngx_http_request_t *r);
|
static ngx_int_t ngx_http_access_handler(ngx_http_request_t *r);
|
||||||
static char *ngx_http_access_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *ngx_http_access_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
void *conf);
|
void *conf);
|
||||||
static void *ngx_http_access_create_loc_conf(ngx_conf_t *cf);
|
static void *ngx_http_access_create_loc_conf(ngx_conf_t *cf);
|
||||||
static char *ngx_http_access_merge_loc_conf(ngx_conf_t *cf,
|
static char *ngx_http_access_merge_loc_conf(ngx_conf_t *cf,
|
||||||
void *parent, void *child);
|
void *parent, void *child);
|
||||||
static ngx_int_t ngx_http_access_init(ngx_cycle_t *cycle);
|
static ngx_int_t ngx_http_access_init(ngx_cycle_t *cycle);
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +77,8 @@ ngx_module_t ngx_http_access_module = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_access_handler(ngx_http_request_t *r)
|
static ngx_int_t
|
||||||
|
ngx_http_access_handler(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
struct sockaddr_in *sin;
|
struct sockaddr_in *sin;
|
||||||
@ -117,8 +118,8 @@ static ngx_int_t ngx_http_access_handler(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_access_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *
|
||||||
void *conf)
|
ngx_http_access_rule(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
ngx_http_access_loc_conf_t *alcf = conf;
|
ngx_http_access_loc_conf_t *alcf = conf;
|
||||||
|
|
||||||
@ -127,14 +128,15 @@ static char *ngx_http_access_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
ngx_http_access_rule_t *rule;
|
ngx_http_access_rule_t *rule;
|
||||||
|
|
||||||
if (alcf->rules == NULL) {
|
if (alcf->rules == NULL) {
|
||||||
alcf->rules = ngx_create_array(cf->pool, 4,
|
alcf->rules = ngx_array_create(cf->pool, 4,
|
||||||
sizeof(ngx_http_access_rule_t));
|
sizeof(ngx_http_access_rule_t));
|
||||||
if (alcf->rules == NULL) {
|
if (alcf->rules == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(rule = ngx_push_array(alcf->rules))) {
|
rule = ngx_array_push(alcf->rules);
|
||||||
|
if (rule == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,11 +172,13 @@ static char *ngx_http_access_rule(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_access_create_loc_conf(ngx_conf_t *cf)
|
static void *
|
||||||
|
ngx_http_access_create_loc_conf(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
ngx_http_access_loc_conf_t *conf;
|
ngx_http_access_loc_conf_t *conf;
|
||||||
|
|
||||||
if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_access_loc_conf_t)))) {
|
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_access_loc_conf_t));
|
||||||
|
if (conf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,8 +186,8 @@ static void *ngx_http_access_create_loc_conf(ngx_conf_t *cf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_access_merge_loc_conf(ngx_conf_t *cf,
|
static char *
|
||||||
void *parent, void *child)
|
ngx_http_access_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||||
{
|
{
|
||||||
ngx_http_access_loc_conf_t *prev = parent;
|
ngx_http_access_loc_conf_t *prev = parent;
|
||||||
ngx_http_access_loc_conf_t *conf = child;
|
ngx_http_access_loc_conf_t *conf = child;
|
||||||
@ -196,14 +200,15 @@ static char *ngx_http_access_merge_loc_conf(ngx_conf_t *cf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_access_init(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_http_access_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_http_handler_pt *h;
|
ngx_http_handler_pt *h;
|
||||||
ngx_http_core_main_conf_t *cmcf;
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
|
|
||||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||||
|
|
||||||
h = ngx_push_array(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
|
h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
@ -218,10 +218,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
|
|||||||
if (ngx_read_dir(&dir) == NGX_ERROR) {
|
if (ngx_read_dir(&dir) == NGX_ERROR) {
|
||||||
err = ngx_errno;
|
err = ngx_errno;
|
||||||
|
|
||||||
if (err == NGX_ENOMOREFILES) {
|
if (err != NGX_ENOMOREFILES) {
|
||||||
rc = NGX_OK;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ngx_log_error(NGX_LOG_CRIT, r->connection->log, err,
|
ngx_log_error(NGX_LOG_CRIT, r->connection->log, err,
|
||||||
ngx_read_dir_n " \"%s\" failed", dname.data);
|
ngx_read_dir_n " \"%s\" failed", dname.data);
|
||||||
return ngx_http_autoindex_error(r, &dir, dname.data);
|
return ngx_http_autoindex_error(r, &dir, dname.data);
|
||||||
@ -251,7 +248,8 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
|
|||||||
if (dname.len + 1 + len > fname.len) {
|
if (dname.len + 1 + len > fname.len) {
|
||||||
fname.len = dname.len + 1 + len + 32;
|
fname.len = dname.len + 1 + len + 32;
|
||||||
|
|
||||||
if (!(fname.data = ngx_palloc(pool, fname.len))) {
|
fname.data = ngx_palloc(pool, fname.len);
|
||||||
|
if (fname.data == NULL) {
|
||||||
return ngx_http_autoindex_error(r, &dir, dname.data);
|
return ngx_http_autoindex_error(r, &dir, dname.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +278,8 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(entry = ngx_array_push(&entries))) {
|
entry = ngx_array_push(&entries);
|
||||||
|
if (entry == NULL) {
|
||||||
return ngx_http_autoindex_error(r, &dir, dname.data);
|
return ngx_http_autoindex_error(r, &dir, dname.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +287,8 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
|
|||||||
entry->escape = 2 * ngx_escape_uri(NULL, ngx_de_name(&dir), len,
|
entry->escape = 2 * ngx_escape_uri(NULL, ngx_de_name(&dir), len,
|
||||||
NGX_ESCAPE_HTML);
|
NGX_ESCAPE_HTML);
|
||||||
|
|
||||||
if (!(entry->name.data = ngx_palloc(pool, len + entry->escape + 1))) {
|
entry->name.data = ngx_palloc(pool, len + entry->escape + 1);
|
||||||
|
if (entry->name.data == NULL) {
|
||||||
return ngx_http_autoindex_error(r, &dir, dname.data);
|
return ngx_http_autoindex_error(r, &dir, dname.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +326,8 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
|
|||||||
+ 2;
|
+ 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(b = ngx_create_temp_buf(r->pool, len))) {
|
b = ngx_create_temp_buf(r->pool, len);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,11 +482,13 @@ ngx_http_autoindex_alloc(ngx_http_autoindex_ctx_t *ctx, size_t size)
|
|||||||
ctx->size += ctx->buf->last - ctx->buf->pos;
|
ctx->size += ctx->buf->last - ctx->buf->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ctx->buf = ngx_create_temp_buf(ctx->pool, ctx->alloc_size))) {
|
ctx->buf = ngx_create_temp_buf(ctx->pool, ctx->alloc_size);
|
||||||
|
if (ctx->buf == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(ctx->pool))) {
|
cl = ngx_alloc_chain_link(ctx->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -48,11 +48,11 @@ typedef struct {
|
|||||||
static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table);
|
static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table);
|
||||||
|
|
||||||
static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
void *conf);
|
void *conf);
|
||||||
static char *ngx_charset_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
|
static char *ngx_charset_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
|
||||||
|
|
||||||
static char *ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
void *conf);
|
void *conf);
|
||||||
static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name);
|
static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name);
|
||||||
|
|
||||||
static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle);
|
static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle);
|
||||||
@ -61,7 +61,7 @@ static void *ngx_http_charset_create_main_conf(ngx_conf_t *cf);
|
|||||||
static char *ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf);
|
static char *ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf);
|
||||||
static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf);
|
static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf);
|
||||||
static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf,
|
static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf,
|
||||||
void *parent, void *child);
|
void *parent, void *child);
|
||||||
|
|
||||||
|
|
||||||
static ngx_command_t ngx_http_charset_filter_commands[] = {
|
static ngx_command_t ngx_http_charset_filter_commands[] = {
|
||||||
@ -133,7 +133,8 @@ static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
|
|||||||
static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_charset_header_filter(ngx_http_request_t *r)
|
static ngx_int_t
|
||||||
|
ngx_http_charset_header_filter(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ngx_http_charset_t *charsets;
|
ngx_http_charset_t *charsets;
|
||||||
ngx_http_charset_ctx_t *ctx;
|
ngx_http_charset_ctx_t *ctx;
|
||||||
@ -165,7 +166,7 @@ static ngx_int_t ngx_http_charset_header_filter(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (r->headers_out.status == NGX_HTTP_MOVED_PERMANENTLY
|
if (r->headers_out.status == NGX_HTTP_MOVED_PERMANENTLY
|
||||||
&& r->headers_out.status == NGX_HTTP_MOVED_TEMPORARILY)
|
|| r->headers_out.status == NGX_HTTP_MOVED_TEMPORARILY)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* do not set charset for the redirect because NN 4.x uses this
|
* do not set charset for the redirect because NN 4.x uses this
|
||||||
@ -187,8 +188,14 @@ static ngx_int_t ngx_http_charset_header_filter(ngx_http_request_t *r)
|
|||||||
return ngx_http_next_header_filter(r);
|
return ngx_http_next_header_filter(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_http_create_ctx(r, ctx, ngx_http_charset_filter_module,
|
|
||||||
sizeof(ngx_http_charset_ctx_t), NGX_ERROR);
|
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_charset_ctx_t));
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_http_set_ctx(r, ctx, ngx_http_charset_filter_module);
|
||||||
|
|
||||||
|
|
||||||
r->filter_need_in_memory = 1;
|
r->filter_need_in_memory = 1;
|
||||||
|
|
||||||
@ -196,8 +203,8 @@ static ngx_int_t ngx_http_charset_header_filter(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_charset_body_filter(ngx_http_request_t *r,
|
static ngx_int_t
|
||||||
ngx_chain_t *in)
|
ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
||||||
{
|
{
|
||||||
char *table;
|
char *table;
|
||||||
ngx_chain_t *cl;
|
ngx_chain_t *cl;
|
||||||
@ -226,7 +233,8 @@ static ngx_int_t ngx_http_charset_body_filter(ngx_http_request_t *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table)
|
static ngx_uint_t
|
||||||
|
ngx_charset_recode(ngx_buf_t *b, char *table)
|
||||||
{
|
{
|
||||||
u_char *p;
|
u_char *p;
|
||||||
ngx_uint_t change;
|
ngx_uint_t change;
|
||||||
@ -254,8 +262,8 @@ static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *
|
||||||
void *conf)
|
ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
ngx_http_charset_main_conf_t *mcf = conf;
|
ngx_http_charset_main_conf_t *mcf = conf;
|
||||||
|
|
||||||
@ -297,18 +305,21 @@ static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(table = ngx_push_array(&mcf->tables))) {
|
table = ngx_array_push(&mcf->tables);
|
||||||
|
if (table == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
table->src = src;
|
table->src = src;
|
||||||
table->dst = dst;
|
table->dst = dst;
|
||||||
|
|
||||||
if (!(table->src2dst = ngx_palloc(cf->pool, 256))) {
|
table->src2dst = ngx_palloc(cf->pool, 256);
|
||||||
|
if (table->src2dst == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(table->dst2src = ngx_palloc(cf->pool, 256))) {
|
table->dst2src = ngx_palloc(cf->pool, 256);
|
||||||
|
if (table->dst2src == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,14 +337,17 @@ static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
cf->ctx = table;
|
cf->ctx = table;
|
||||||
cf->handler = ngx_charset_map;
|
cf->handler = ngx_charset_map;
|
||||||
cf->handler_conf = conf;
|
cf->handler_conf = conf;
|
||||||
|
|
||||||
rv = ngx_conf_parse(cf, NULL);
|
rv = ngx_conf_parse(cf, NULL);
|
||||||
|
|
||||||
*cf = pvcf;
|
*cf = pvcf;
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_charset_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
static char *
|
||||||
|
ngx_charset_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
||||||
{
|
{
|
||||||
ngx_int_t src, dst;
|
ngx_int_t src, dst;
|
||||||
ngx_str_t *value;
|
ngx_str_t *value;
|
||||||
@ -369,8 +383,8 @@ static char *ngx_charset_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *
|
||||||
void *conf)
|
ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
char *p = conf;
|
char *p = conf;
|
||||||
|
|
||||||
@ -404,7 +418,8 @@ static char *ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
|
static ngx_int_t
|
||||||
|
ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
|
||||||
{
|
{
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_http_charset_t *c;
|
ngx_http_charset_t *c;
|
||||||
@ -424,7 +439,8 @@ static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(c = ngx_push_array(charsets))) {
|
c = ngx_array_push(charsets);
|
||||||
|
if (c == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +452,8 @@ static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_http_charset_filter_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||||
ngx_http_top_header_filter = ngx_http_charset_header_filter;
|
ngx_http_top_header_filter = ngx_http_charset_header_filter;
|
||||||
@ -448,25 +465,34 @@ static ngx_int_t ngx_http_charset_filter_init(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_charset_create_main_conf(ngx_conf_t *cf)
|
static void *
|
||||||
|
ngx_http_charset_create_main_conf(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
ngx_http_charset_main_conf_t *mcf;
|
ngx_http_charset_main_conf_t *mcf;
|
||||||
|
|
||||||
if (!(mcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_main_conf_t)))) {
|
mcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_main_conf_t));
|
||||||
|
if (mcf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_init_array(mcf->charsets, cf->pool, 2, sizeof(ngx_http_charset_t),
|
if (ngx_array_init(&mcf->charsets, cf->pool, 2, sizeof(ngx_http_charset_t))
|
||||||
NGX_CONF_ERROR);
|
== NGX_ERROR)
|
||||||
|
{
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ngx_init_array(mcf->tables, cf->pool, 4, sizeof(ngx_http_charset_tables_t),
|
if (ngx_array_init(&mcf->tables, cf->pool, 4,
|
||||||
NGX_CONF_ERROR);
|
sizeof(ngx_http_charset_tables_t)) == NGX_ERROR)
|
||||||
|
{
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return mcf;
|
return mcf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf)
|
static char *
|
||||||
|
ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf)
|
||||||
{
|
{
|
||||||
ngx_http_charset_main_conf_t *mcf = conf;
|
ngx_http_charset_main_conf_t *mcf = conf;
|
||||||
|
|
||||||
@ -484,7 +510,6 @@ static char *ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf)
|
|||||||
|
|
||||||
charset[i].tables = ngx_pcalloc(cf->pool,
|
charset[i].tables = ngx_pcalloc(cf->pool,
|
||||||
sizeof(char *) * mcf->charsets.nelts);
|
sizeof(char *) * mcf->charsets.nelts);
|
||||||
|
|
||||||
if (charset[i].tables == NULL) {
|
if (charset[i].tables == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -527,11 +552,13 @@ static char *ngx_http_charset_init_main_conf(ngx_conf_t *cf, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf)
|
static void *
|
||||||
|
ngx_http_charset_create_loc_conf(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
ngx_http_charset_loc_conf_t *lcf;
|
ngx_http_charset_loc_conf_t *lcf;
|
||||||
|
|
||||||
if (!(lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_loc_conf_t)))) {
|
lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_loc_conf_t));
|
||||||
|
if (lcf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,8 +571,8 @@ static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf,
|
static char *
|
||||||
void *parent, void *child)
|
ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||||
{
|
{
|
||||||
ngx_http_charset_loc_conf_t *prev = parent;
|
ngx_http_charset_loc_conf_t *prev = parent;
|
||||||
ngx_http_charset_loc_conf_t *conf = child;
|
ngx_http_charset_loc_conf_t *conf = child;
|
@ -40,7 +40,8 @@ static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
|
|||||||
static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_chunked_header_filter(ngx_http_request_t *r)
|
static ngx_int_t
|
||||||
|
ngx_http_chunked_header_filter(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED) {
|
if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED) {
|
||||||
return ngx_http_next_header_filter(r);
|
return ngx_http_next_header_filter(r);
|
||||||
@ -59,8 +60,8 @@ static ngx_int_t ngx_http_chunked_header_filter(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
|
static ngx_int_t
|
||||||
ngx_chain_t *in)
|
ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
||||||
{
|
{
|
||||||
u_char *chunk;
|
u_char *chunk;
|
||||||
off_t size;
|
off_t size;
|
||||||
@ -85,7 +86,8 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
|
|||||||
|
|
||||||
if (cl->buf->flush || ngx_buf_in_memory(cl->buf) || cl->buf->in_file) {
|
if (cl->buf->flush || ngx_buf_in_memory(cl->buf) || cl->buf->in_file) {
|
||||||
|
|
||||||
if (!(tl = ngx_alloc_chain_link(r->pool))) {
|
tl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (tl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,10 +104,13 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (size) {
|
if (size) {
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* the "0000000000000000" is 64-bit hexadimal string */
|
||||||
|
|
||||||
chunk = ngx_palloc(r->pool, sizeof("0000000000000000" CRLF) - 1);
|
chunk = ngx_palloc(r->pool, sizeof("0000000000000000" CRLF) - 1);
|
||||||
if (chunk == NULL) {
|
if (chunk == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
@ -119,7 +124,8 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cl->buf->last_buf) {
|
if (cl->buf->last_buf) {
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +150,8 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
|
|||||||
return ngx_http_next_body_filter(r, out.next);
|
return ngx_http_next_body_filter(r, out.next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +168,8 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_chunked_filter_init(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_http_chunked_filter_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||||
ngx_http_top_header_filter = ngx_http_chunked_header_filter;
|
ngx_http_top_header_filter = ngx_http_chunked_header_filter;
|
@ -377,7 +377,8 @@ ngx_http_fastcgi_handler(ngx_http_request_t *r)
|
|||||||
|
|
||||||
flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
|
flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
|
||||||
|
|
||||||
if (!(u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t)))) {
|
u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t));
|
||||||
|
if (u == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -492,25 +493,24 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
index = (r->uri.data[r->uri.len - 1] == '/') ? flcf->index.len : 0;
|
index = (r->uri.data[r->uri.len - 1] == '/') ? flcf->index.len : 0;
|
||||||
|
|
||||||
len += 1 + ((flcf->root.len + r->uri.len + index > 127) ? 4 : 1)
|
len += 1 + ((flcf->root.len + r->uri.len + index > 127) ? 4 : 1)
|
||||||
+ sizeof("PATH_TRANSLATED") - 1
|
+ sizeof("PATH_TRANSLATED") - 1 + flcf->root.len + r->uri.len + index;
|
||||||
+ flcf->root.len + r->uri.len + index;
|
|
||||||
|
|
||||||
if (r->args.len) {
|
if (r->args.len) {
|
||||||
len += 1 + ((r->args.len > 127) ? 4 : 1) + sizeof("QUERY_STRING") - 1
|
len += 1 + ((r->args.len > 127) ? 4 : 1) + sizeof("QUERY_STRING") - 1
|
||||||
+ r->args.len;
|
+ r->args.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r->headers_in.content_length_n > 0) {
|
if (r->headers_in.content_length_n > 0) {
|
||||||
len += 1 + ((r->headers_in.content_length->value.len > 127) ? 4 : 1)
|
len += 1 + ((r->headers_in.content_length->value.len > 127) ? 4 : 1)
|
||||||
+ sizeof("CONTENT_LENGTH") - 1
|
+ sizeof("CONTENT_LENGTH") - 1
|
||||||
+ r->headers_in.content_length->value.len;
|
+ r->headers_in.content_length->value.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (r->headers_in.content_type) {
|
if (r->headers_in.content_type) {
|
||||||
len += 1 + ((r->headers_in.content_type->value.len > 127) ? 4 : 1)
|
len += 1 + ((r->headers_in.content_type->value.len > 127) ? 4 : 1)
|
||||||
+ sizeof("CONTENT_TYPE") - 1
|
+ sizeof("CONTENT_TYPE") - 1
|
||||||
+ r->headers_in.content_type->value.len;
|
+ r->headers_in.content_type->value.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -520,24 +520,24 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
|
|
||||||
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
|
if (flcf->params & NGX_HTTP_FASTCGI_REQUEST_URI) {
|
||||||
len += 1 + ((r->unparsed_uri.len > 127) ? 4 : 1)
|
len += 1 + ((r->unparsed_uri.len > 127) ? 4 : 1)
|
||||||
+ sizeof("REQUEST_URI") - 1 + r->unparsed_uri.len;
|
+ sizeof("REQUEST_URI") - 1 + r->unparsed_uri.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flcf->params & NGX_HTTP_FASTCGI_DOCUMENT_ROOT) {
|
if (flcf->params & NGX_HTTP_FASTCGI_DOCUMENT_ROOT) {
|
||||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||||
len += 1 + ((clcf->root.len > 127) ? 4 : 1)
|
len += 1 + ((clcf->root.len > 127) ? 4 : 1)
|
||||||
+ sizeof("DOCUMENT_ROOT") - 1 + clcf->root.len;
|
+ sizeof("DOCUMENT_ROOT") - 1 + clcf->root.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_FILENAME) {
|
if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_FILENAME) {
|
||||||
len += 1 + ((flcf->root.len + r->uri.len + index > 127) ? 4 : 1)
|
len += 1 + ((flcf->root.len + r->uri.len + index > 127) ? 4 : 1)
|
||||||
+ sizeof("SCRIPT_FILENAME") - 1
|
+ sizeof("SCRIPT_FILENAME") - 1
|
||||||
+ flcf->root.len + r->uri.len + index;
|
+ flcf->root.len + r->uri.len + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) {
|
if (flcf->params & NGX_HTTP_FASTCGI_SCRIPT_NAME) {
|
||||||
len += 1 + ((r->uri.len + index > 127) ? 4 : 1)
|
len += 1 + ((r->uri.len + index > 127) ? 4 : 1)
|
||||||
+ sizeof("SCRIPT_NAME") - 1 + r->uri.len + index ;
|
+ sizeof("SCRIPT_NAME") - 1 + r->uri.len + index ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flcf->params & NGX_HTTP_FASTCGI_REMOTE_ADDR) {
|
if (flcf->params & NGX_HTTP_FASTCGI_REMOTE_ADDR) {
|
||||||
@ -579,7 +579,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
&& r->http_protocol.len)
|
&& r->http_protocol.len)
|
||||||
{
|
{
|
||||||
len += 1 + ((r->http_protocol.len > 127) ? 4 : 1)
|
len += 1 + ((r->http_protocol.len > 127) ? 4 : 1)
|
||||||
+ sizeof("SERVER_PROTOCOL") - 1 + r->http_protocol.len;
|
+ sizeof("SERVER_PROTOCOL") - 1 + r->http_protocol.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flcf->params & NGX_HTTP_FASTCGI_SERVER_SOFTWARE) {
|
if (flcf->params & NGX_HTTP_FASTCGI_SERVER_SOFTWARE) {
|
||||||
@ -599,7 +599,8 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
|
|
||||||
for (i = 0; i < flcf->vars->nelts; i++) {
|
for (i = 0; i < flcf->vars->nelts; i++) {
|
||||||
|
|
||||||
if (!(value = ngx_http_get_indexed_variable(r, vindex[i]))) {
|
value = ngx_http_get_indexed_variable(r, vindex[i]);
|
||||||
|
if (value == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,8 +627,8 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
len += ((header[i].key.len > 127) ? 4 : 1)
|
len += ((header[i].key.len > 127) ? 4 : 1)
|
||||||
+ ((header[i].value.len > 127) ? 4 : 1)
|
+ ((header[i].value.len > 127) ? 4 : 1)
|
||||||
+ 5 + header[i].key.len + header[i].value.len;
|
+ 5 + header[i].key.len + header[i].value.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -652,11 +653,13 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
+ sizeof(ngx_http_fastcgi_header_t); /* NGX_HTTP_FASTCGI_STDIN */
|
+ sizeof(ngx_http_fastcgi_header_t); /* NGX_HTTP_FASTCGI_STDIN */
|
||||||
|
|
||||||
|
|
||||||
if (!(b = ngx_create_temp_buf(r->pool, size))) {
|
b = ngx_create_temp_buf(r->pool, size);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(r->pool))) {
|
cl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,7 +1001,8 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
if (flcf->vars) {
|
if (flcf->vars) {
|
||||||
for (i = 0; i < flcf->vars->nelts; i++) {
|
for (i = 0; i < flcf->vars->nelts; i++) {
|
||||||
|
|
||||||
if (!(value = ngx_http_get_indexed_variable(r, vindex[i]))) {
|
value = ngx_http_get_indexed_variable(r, vindex[i]);
|
||||||
|
if (value == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1115,7 +1119,8 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
next = 0;
|
next = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!(b = ngx_alloc_buf(r->pool))) {
|
b = ngx_alloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1158,7 +1163,8 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
h->padding_length = (u_char) padding;
|
h->padding_length = (u_char) padding;
|
||||||
h->reserved = 0;
|
h->reserved = 0;
|
||||||
|
|
||||||
if (!(cl->next = ngx_alloc_chain_link(r->pool))) {
|
cl->next = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl->next == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1179,7 +1185,8 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
|
|||||||
h = (ngx_http_fastcgi_header_t *) b->last;
|
h = (ngx_http_fastcgi_header_t *) b->last;
|
||||||
b->last += sizeof(ngx_http_fastcgi_header_t);
|
b->last += sizeof(ngx_http_fastcgi_header_t);
|
||||||
|
|
||||||
if (!(cl->next = ngx_alloc_chain_link(r->pool))) {
|
cl->next = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl->next == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1248,7 +1255,8 @@ static ngx_int_t ngx_http_fastcgi_process_header(ngx_http_request_t *r)
|
|||||||
f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
|
f = ngx_http_get_module_ctx(r, ngx_http_fastcgi_module);
|
||||||
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
if (!(f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)))) {
|
f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t));
|
||||||
|
if (f == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1413,7 +1421,8 @@ static ngx_int_t ngx_http_fastcgi_process_header(ngx_http_request_t *r)
|
|||||||
|
|
||||||
/* a header line has been parsed successfully */
|
/* a header line has been parsed successfully */
|
||||||
|
|
||||||
if (!(h = ngx_list_push(&f->upstream->headers_in.headers))) {
|
h = ngx_list_push(&f->upstream->headers_in.headers);
|
||||||
|
if (h == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1580,7 +1589,8 @@ ngx_http_fastcgi_send_header(ngx_http_request_t *r)
|
|||||||
|
|
||||||
/* copy some header pointers and set up r->headers_out */
|
/* copy some header pointers and set up r->headers_out */
|
||||||
|
|
||||||
if (!(ho = ngx_list_push(&r->headers_out.headers))) {
|
ho = ngx_list_push(&r->headers_out.headers);
|
||||||
|
if (ho == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1733,7 +1743,8 @@ ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
p->free = p->free->next;
|
p->free = p->free->next;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!(b = ngx_alloc_buf(p->pool))) {
|
b = ngx_alloc_buf(p->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1750,18 +1761,26 @@ ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
*prev = b;
|
*prev = b;
|
||||||
prev = &b->shadow;
|
prev = &b->shadow;
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(p->pool))) {
|
cl = ngx_alloc_chain_link(p->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->buf = b;
|
cl->buf = b;
|
||||||
cl->next = NULL;
|
cl->next = NULL;
|
||||||
|
|
||||||
|
if (p->in) {
|
||||||
|
*p->last_in = cl;
|
||||||
|
} else {
|
||||||
|
p->in = cl;
|
||||||
|
}
|
||||||
|
p->last_in = &cl->next;
|
||||||
|
|
||||||
|
|
||||||
/* STUB */ b->num = buf->num;
|
/* STUB */ b->num = buf->num;
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
|
||||||
|
|
||||||
ngx_chain_add_link(p->in, p->last_in, cl);
|
|
||||||
|
|
||||||
if (f->pos + f->length < f->last) {
|
if (f->pos + f->length < f->last) {
|
||||||
|
|
||||||
@ -1820,11 +1839,8 @@ ngx_http_fastcgi_process_record(ngx_http_request_t *r,
|
|||||||
ngx_http_fastcgi_ctx_t *f)
|
ngx_http_fastcgi_ctx_t *f)
|
||||||
{
|
{
|
||||||
u_char ch, *p;
|
u_char ch, *p;
|
||||||
ngx_http_upstream_t *u;
|
|
||||||
ngx_http_fastcgi_state_e state;
|
ngx_http_fastcgi_state_e state;
|
||||||
|
|
||||||
u = r->upstream;
|
|
||||||
|
|
||||||
state = f->state;
|
state = f->state;
|
||||||
|
|
||||||
for (p = f->pos; p < f->last; p++) {
|
for (p = f->pos; p < f->last; p++) {
|
||||||
@ -1968,7 +1984,8 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
unix_upstream.name = value[1];
|
unix_upstream.name = value[1];
|
||||||
unix_upstream.url = value[1];
|
unix_upstream.url = value[1];
|
||||||
|
|
||||||
if (!(lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream))) {
|
lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream);
|
||||||
|
if (lcf->peers == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1986,7 +2003,8 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
inet_upstream.name = value[1];
|
inet_upstream.name = value[1];
|
||||||
inet_upstream.url = value[1];
|
inet_upstream.url = value[1];
|
||||||
|
|
||||||
if (!(lcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream))) {
|
lcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream);
|
||||||
|
if (lcf->peers == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1996,7 +2014,7 @@ ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
clcf->handler = ngx_http_fastcgi_handler;
|
clcf->handler = ngx_http_fastcgi_handler;
|
||||||
|
|
||||||
#if (NGX_PCRE)
|
#if (NGX_PCRE)
|
||||||
lcf->location = clcf->regex ? &ngx_http_fastcgi_uri: &clcf->name;
|
lcf->location = clcf->regex ? &ngx_http_fastcgi_uri : &clcf->name;
|
||||||
#else
|
#else
|
||||||
lcf->location = &clcf->name;
|
lcf->location = &clcf->name;
|
||||||
#endif
|
#endif
|
||||||
@ -2035,7 +2053,8 @@ ngx_http_fastcgi_set_var(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
for (i = 0; i < cmcf->variables.nelts; i++) {
|
for (i = 0; i < cmcf->variables.nelts; i++) {
|
||||||
if (ngx_strcasecmp(var[i].name.data, value[1].data) == 0) {
|
if (ngx_strcasecmp(var[i].name.data, value[1].data) == 0) {
|
||||||
|
|
||||||
if (!(index = ngx_array_push(lcf->vars))) {
|
index = ngx_array_push(lcf->vars);
|
||||||
|
if (index == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2084,7 +2103,8 @@ ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_fastcgi_loc_conf_t *conf;
|
ngx_http_fastcgi_loc_conf_t *conf;
|
||||||
|
|
||||||
if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t)))) {
|
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_fastcgi_loc_conf_t));
|
||||||
|
if (conf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
@ -64,9 +64,9 @@ static ngx_http_variable_value_t ngx_http_geo_null_value =
|
|||||||
/* AF_INET only */
|
/* AF_INET only */
|
||||||
|
|
||||||
static ngx_http_variable_value_t *
|
static ngx_http_variable_value_t *
|
||||||
ngx_http_geo_variable(ngx_http_request_t *r, void *data)
|
ngx_http_geo_variable(ngx_http_request_t *r, uintptr_t data)
|
||||||
{
|
{
|
||||||
ngx_radix_tree_t *tree = data;
|
ngx_radix_tree_t *tree = (ngx_radix_tree_t *) data;
|
||||||
|
|
||||||
struct sockaddr_in *sin;
|
struct sockaddr_in *sin;
|
||||||
ngx_http_variable_value_t *var;
|
ngx_http_variable_value_t *var;
|
||||||
@ -90,33 +90,46 @@ static char *
|
|||||||
ngx_http_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
ngx_http_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
char *rv;
|
char *rv;
|
||||||
ngx_str_t *value;
|
ngx_str_t *value, name;
|
||||||
ngx_conf_t save;
|
ngx_conf_t save;
|
||||||
ngx_pool_t *pool;
|
ngx_pool_t *pool;
|
||||||
ngx_radix_tree_t *tree;
|
ngx_radix_tree_t *tree;
|
||||||
ngx_http_geo_conf_t geo;
|
ngx_http_geo_conf_t geo;
|
||||||
ngx_http_variable_t *var;
|
ngx_http_variable_t *var;
|
||||||
|
|
||||||
if (!(var = ngx_http_add_variable(cf))) {
|
|
||||||
return NGX_CONF_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(tree = ngx_radix_tree_create(cf->pool, -1))) {
|
|
||||||
return NGX_CONF_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = cf->args->elts;
|
value = cf->args->elts;
|
||||||
|
|
||||||
var->name = value[1];
|
name = value[1];
|
||||||
|
|
||||||
|
if (name.data[0] != '$') {
|
||||||
|
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
||||||
|
"\"%V\" variable name should start with '$'",
|
||||||
|
&value[1]);
|
||||||
|
} else {
|
||||||
|
name.len--;
|
||||||
|
name.data++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var = ngx_http_add_variable(cf, &name, 1);
|
||||||
|
if (var == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
tree = ngx_radix_tree_create(cf->pool, -1);
|
||||||
|
if (tree == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
var->handler = ngx_http_geo_variable;
|
var->handler = ngx_http_geo_variable;
|
||||||
var->data = tree;
|
var->data = (uintptr_t) tree;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create the temporary pool of a huge initial size
|
* create the temporary pool of a huge initial size
|
||||||
* to process quickly a large number of geo lines
|
* to process quickly a large number of geo lines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!(pool = ngx_create_pool(512 * 1024, cf->log))) {
|
pool = ngx_create_pool(512 * 1024, cf->log);
|
||||||
|
if (pool == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +225,12 @@ ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
|||||||
|
|
||||||
if (n == NGX_ERROR) {
|
if (n == NGX_ERROR) {
|
||||||
for (i = 0; i < geo->values.nelts; i++) {
|
for (i = 0; i < geo->values.nelts; i++) {
|
||||||
if (ngx_strcmp(value[1].data, v[i]->text.data) == 0) {
|
if (v[i]->text.len != value[1].len) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_strncmp(value[1].data, v[i]->text.data, value[1].len) == 0)
|
||||||
|
{
|
||||||
var = v[i];
|
var = v[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -227,20 +245,22 @@ ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == geo->values.nelts) {
|
if (var == NULL) {
|
||||||
var = ngx_palloc(geo->pool, sizeof(ngx_http_variable_value_t));
|
var = ngx_palloc(geo->pool, sizeof(ngx_http_variable_value_t));
|
||||||
if (var == NULL) {
|
if (var == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
var->text.len = value[1].len;
|
var->text.len = value[1].len;
|
||||||
if (!(var->text.data = ngx_pstrdup(geo->pool, &value[1]))) {
|
var->text.data = ngx_pstrdup(geo->pool, &value[1]);
|
||||||
|
if (var->text.data == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
var->value = (n == NGX_ERROR) ? 0 : n;
|
var->value = (n == NGX_ERROR) ? 0 : n;
|
||||||
|
|
||||||
if (!(v = ngx_array_push(&geo->values))) {
|
v = ngx_array_push(&geo->values);
|
||||||
|
if (v == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,9 +331,14 @@ ngx_http_gzip_header_filter(ngx_http_request_t *r)
|
|||||||
return ngx_http_next_header_filter(r);
|
return ngx_http_next_header_filter(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_gzip_ctx_t));
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_http_set_ctx(r, ctx, ngx_http_gzip_filter_module);
|
||||||
|
|
||||||
|
|
||||||
ngx_http_create_ctx(r, ctx, ngx_http_gzip_filter_module,
|
|
||||||
sizeof(ngx_http_gzip_ctx_t), NGX_ERROR);
|
|
||||||
ctx->request = r;
|
ctx->request = r;
|
||||||
|
|
||||||
r->headers_out.content_encoding = ngx_list_push(&r->headers_out.headers);
|
r->headers_out.content_encoding = ngx_list_push(&r->headers_out.headers);
|
||||||
@ -445,7 +450,7 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
ngx_int_t last;
|
ngx_int_t last;
|
||||||
struct gztrailer *trailer;
|
struct gztrailer *trailer;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_chain_t *cl;
|
ngx_chain_t *cl, out;
|
||||||
ngx_http_gzip_ctx_t *ctx;
|
ngx_http_gzip_ctx_t *ctx;
|
||||||
ngx_http_gzip_conf_t *conf;
|
ngx_http_gzip_conf_t *conf;
|
||||||
|
|
||||||
@ -485,7 +490,8 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
ctx->allocated = 8192 + (1 << (wbits + 2)) + (1 << (memlevel + 9));
|
ctx->allocated = 8192 + (1 << (wbits + 2)) + (1 << (memlevel + 9));
|
||||||
|
|
||||||
if (!(ctx->preallocated = ngx_palloc(r->pool, ctx->allocated))) {
|
ctx->preallocated = ngx_palloc(r->pool, ctx->allocated);
|
||||||
|
if (ctx->preallocated == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +511,8 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)))) {
|
b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
|
||||||
|
if (b == NULL) {
|
||||||
ngx_http_gzip_error(ctx);
|
ngx_http_gzip_error(ctx);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -514,12 +521,8 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
b->pos = gzheader;
|
b->pos = gzheader;
|
||||||
b->last = b->pos + 10;
|
b->last = b->pos + 10;
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(r->pool))) {
|
out.buf = b;
|
||||||
ngx_http_gzip_error(ctx);
|
out.next = NULL;
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
cl->buf = b;
|
|
||||||
cl->next = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We pass the gzheader to the next filter now to avoid its linking
|
* We pass the gzheader to the next filter now to avoid its linking
|
||||||
@ -528,7 +531,7 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
* to the ctx->busy chain would be flushed by ngx_http_write_filter().
|
* to the ctx->busy chain would be flushed by ngx_http_write_filter().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (ngx_http_next_body_filter(r, cl) == NGX_ERROR) {
|
if (ngx_http_next_body_filter(r, &out) == NGX_ERROR) {
|
||||||
ngx_http_gzip_error(ctx);
|
ngx_http_gzip_error(ctx);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -673,10 +676,12 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
/* zlib wants to output some more gzipped data */
|
/* zlib wants to output some more gzipped data */
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(r->pool))) {
|
cl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
ngx_http_gzip_error(ctx);
|
ngx_http_gzip_error(ctx);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->buf = ctx->out_buf;
|
cl->buf = ctx->out_buf;
|
||||||
cl->next = NULL;
|
cl->next = NULL;
|
||||||
*ctx->last_out = cl;
|
*ctx->last_out = cl;
|
||||||
@ -694,10 +699,12 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
ctx->out_buf->flush = 0;
|
ctx->out_buf->flush = 0;
|
||||||
ctx->flush = Z_NO_FLUSH;
|
ctx->flush = Z_NO_FLUSH;
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(r->pool))) {
|
cl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
ngx_http_gzip_error(ctx);
|
ngx_http_gzip_error(ctx);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->buf = ctx->out_buf;
|
cl->buf = ctx->out_buf;
|
||||||
cl->next = NULL;
|
cl->next = NULL;
|
||||||
*ctx->last_out = cl;
|
*ctx->last_out = cl;
|
||||||
@ -722,10 +729,12 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
ngx_pfree(r->pool, ctx->preallocated);
|
ngx_pfree(r->pool, ctx->preallocated);
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(r->pool))) {
|
cl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
ngx_http_gzip_error(ctx);
|
ngx_http_gzip_error(ctx);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->buf = ctx->out_buf;
|
cl->buf = ctx->out_buf;
|
||||||
cl->next = NULL;
|
cl->next = NULL;
|
||||||
*ctx->last_out = cl;
|
*ctx->last_out = cl;
|
||||||
@ -737,17 +746,20 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
ctx->out_buf->last_buf = 1;
|
ctx->out_buf->last_buf = 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!(b = ngx_create_temp_buf(r->pool, 8))) {
|
b = ngx_create_temp_buf(r->pool, 8);
|
||||||
|
if (b == NULL) {
|
||||||
ngx_http_gzip_error(ctx);
|
ngx_http_gzip_error(ctx);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
b->last_buf = 1;
|
b->last_buf = 1;
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(r->pool))) {
|
cl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
ngx_http_gzip_error(ctx);
|
ngx_http_gzip_error(ctx);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->buf = b;
|
cl->buf = b;
|
||||||
cl->next = NULL;
|
cl->next = NULL;
|
||||||
*ctx->last_out = cl;
|
*ctx->last_out = cl;
|
||||||
@ -782,10 +794,13 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (conf->no_buffer && ctx->in == NULL) {
|
if (conf->no_buffer && ctx->in == NULL) {
|
||||||
if (!(cl = ngx_alloc_chain_link(r->pool))) {
|
|
||||||
|
cl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
ngx_http_gzip_error(ctx);
|
ngx_http_gzip_error(ctx);
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->buf = ctx->out_buf;
|
cl->buf = ctx->out_buf;
|
||||||
cl->next = NULL;
|
cl->next = NULL;
|
||||||
*ctx->last_out = cl;
|
*ctx->last_out = cl;
|
||||||
@ -816,7 +831,7 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngx_chain_update_chains(&ctx->free, &ctx->busy, &ctx->out,
|
ngx_chain_update_chains(&ctx->free, &ctx->busy, &ctx->out,
|
||||||
(ngx_buf_tag_t) &ngx_http_gzip_filter_module);
|
(ngx_buf_tag_t) &ngx_http_gzip_filter_module);
|
||||||
ctx->last_out = &ctx->out;
|
ctx->last_out = &ctx->out;
|
||||||
|
|
||||||
if (ctx->done) {
|
if (ctx->done) {
|
||||||
@ -969,7 +984,8 @@ ngx_http_gzip_create_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_gzip_conf_t *conf;
|
ngx_http_gzip_conf_t *conf;
|
||||||
|
|
||||||
if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_gzip_conf_t)))) {
|
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_gzip_conf_t));
|
||||||
|
if (conf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1027,7 +1043,8 @@ ngx_http_gzip_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(type = ngx_array_push(conf->types))) {
|
type = ngx_array_push(conf->types);
|
||||||
|
if (type == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1055,12 +1072,13 @@ ngx_http_gzip_set_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
if (gcf->types == NULL) {
|
if (gcf->types == NULL) {
|
||||||
gcf->types = ngx_array_create(cf->pool, 4,
|
gcf->types = ngx_array_create(cf->pool, 4,
|
||||||
sizeof(ngx_http_gzip_type_t));
|
sizeof(ngx_http_gzip_type_t));
|
||||||
if (gcf->types == NULL) {
|
if (gcf->types == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(type = ngx_array_push(gcf->types))) {
|
type = ngx_array_push(gcf->types);
|
||||||
|
if (type == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1077,13 +1095,15 @@ ngx_http_gzip_set_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(type = ngx_array_push(gcf->types))) {
|
type = ngx_array_push(gcf->types);
|
||||||
|
if (type == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
type->name.len = value[i].len;
|
type->name.len = value[i].len;
|
||||||
|
|
||||||
if (!(type->name.data = ngx_palloc(cf->pool, type->name.len + 1))) {
|
type->name.data = ngx_palloc(cf->pool, type->name.len + 1);
|
||||||
|
if (type->name.data == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,8 @@ static ngx_int_t ngx_http_headers_filter_init(ngx_cycle_t *cycle);
|
|||||||
static void *ngx_http_headers_create_conf(ngx_conf_t *cf);
|
static void *ngx_http_headers_create_conf(ngx_conf_t *cf);
|
||||||
static char *ngx_http_headers_merge_conf(ngx_conf_t *cf,
|
static char *ngx_http_headers_merge_conf(ngx_conf_t *cf,
|
||||||
void *parent, void *child);
|
void *parent, void *child);
|
||||||
char *ngx_http_headers_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
static char *ngx_http_headers_expires(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
|
void *conf);
|
||||||
|
|
||||||
|
|
||||||
static ngx_command_t ngx_http_headers_filter_commands[] = {
|
static ngx_command_t ngx_http_headers_filter_commands[] = {
|
||||||
@ -66,7 +67,8 @@ ngx_module_t ngx_http_headers_filter_module = {
|
|||||||
static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
|
static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_headers_filter(ngx_http_request_t *r)
|
static ngx_int_t
|
||||||
|
ngx_http_headers_filter(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
ngx_table_elt_t *expires, *cc;
|
ngx_table_elt_t *expires, *cc;
|
||||||
@ -80,13 +82,15 @@ static ngx_int_t ngx_http_headers_filter(ngx_http_request_t *r)
|
|||||||
|
|
||||||
if (conf->expires != NGX_HTTP_EXPIRES_OFF) {
|
if (conf->expires != NGX_HTTP_EXPIRES_OFF) {
|
||||||
|
|
||||||
if (!(expires = ngx_list_push(&r->headers_out.headers))) {
|
expires = ngx_list_push(&r->headers_out.headers);
|
||||||
|
if (expires == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->headers_out.expires = expires;
|
r->headers_out.expires = expires;
|
||||||
|
|
||||||
if (!(cc = ngx_list_push(&r->headers_out.headers))) {
|
cc = ngx_list_push(&r->headers_out.headers);
|
||||||
|
if (cc == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +151,8 @@ static ngx_int_t ngx_http_headers_filter(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_headers_filter_init(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_http_headers_filter_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
||||||
ngx_http_top_header_filter = ngx_http_headers_filter;
|
ngx_http_top_header_filter = ngx_http_headers_filter;
|
||||||
@ -156,11 +161,13 @@ static ngx_int_t ngx_http_headers_filter_init(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_headers_create_conf(ngx_conf_t *cf)
|
static void *
|
||||||
|
ngx_http_headers_create_conf(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
ngx_http_headers_conf_t *conf;
|
ngx_http_headers_conf_t *conf;
|
||||||
|
|
||||||
if (!(conf = ngx_palloc(cf->pool, sizeof(ngx_http_headers_conf_t)))) {
|
conf = ngx_palloc(cf->pool, sizeof(ngx_http_headers_conf_t));
|
||||||
|
if (conf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,8 +177,8 @@ static void *ngx_http_headers_create_conf(ngx_conf_t *cf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_headers_merge_conf(ngx_conf_t *cf,
|
static char *
|
||||||
void *parent, void *child)
|
ngx_http_headers_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||||
{
|
{
|
||||||
ngx_http_headers_conf_t *prev = parent;
|
ngx_http_headers_conf_t *prev = parent;
|
||||||
ngx_http_headers_conf_t *conf = child;
|
ngx_http_headers_conf_t *conf = child;
|
||||||
@ -185,7 +192,8 @@ static char *ngx_http_headers_merge_conf(ngx_conf_t *cf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *ngx_http_headers_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
static char *
|
||||||
|
ngx_http_headers_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
ngx_http_headers_conf_t *hcf = conf;
|
ngx_http_headers_conf_t *hcf = conf;
|
||||||
|
|
||||||
@ -223,6 +231,7 @@ char *ngx_http_headers_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
hcf->expires = ngx_parse_time(&value[1], 1);
|
hcf->expires = ngx_parse_time(&value[1], 1);
|
||||||
|
|
||||||
if (hcf->expires == NGX_ERROR) {
|
if (hcf->expires == NGX_ERROR) {
|
||||||
return "invalid value";
|
return "invalid value";
|
||||||
}
|
}
|
@ -93,10 +93,10 @@ ngx_module_t ngx_http_index_module = {
|
|||||||
/*
|
/*
|
||||||
* Try to open the first index file before the test of the directory existence
|
* Try to open the first index file before the test of the directory existence
|
||||||
* because the valid requests should be many more than invalid ones.
|
* because the valid requests should be many more than invalid ones.
|
||||||
* If open() failed then stat() should be more quickly because some data
|
* If open() would fail, then stat() should be more quickly because some data
|
||||||
* is already cached in the kernel.
|
* is already cached in the kernel.
|
||||||
* Besides Win32 has ERROR_PATH_NOT_FOUND (NGX_ENOTDIR).
|
* Besides, Win32 has ERROR_PATH_NOT_FOUND (NGX_ENOTDIR).
|
||||||
* Unix has ENOTDIR error, although it less helpfull - it shows only
|
* Unix has ENOTDIR error, although it less helpfull - it points only
|
||||||
* that path contains the usual file in place of the directory.
|
* that path contains the usual file in place of the directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -137,9 +137,13 @@ static ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
|
|||||||
|
|
||||||
ctx = ngx_http_get_module_ctx(r, ngx_http_index_module);
|
ctx = ngx_http_get_module_ctx(r, ngx_http_index_module);
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
ngx_http_create_ctx(r, ctx, ngx_http_index_module,
|
|
||||||
sizeof(ngx_http_index_ctx_t),
|
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_index_ctx_t));
|
||||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
if (ctx == NULL) {
|
||||||
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_http_set_ctx(r, ctx, ngx_http_index_module);
|
||||||
|
|
||||||
#if (NGX_HTTP_CACHE)
|
#if (NGX_HTTP_CACHE)
|
||||||
|
|
||||||
@ -417,7 +421,7 @@ static ngx_int_t ngx_http_index_init(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||||
|
|
||||||
h = ngx_push_array(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -432,11 +436,17 @@ static void *ngx_http_index_create_loc_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_index_loc_conf_t *conf;
|
ngx_http_index_loc_conf_t *conf;
|
||||||
|
|
||||||
ngx_test_null(conf, ngx_palloc(cf->pool, sizeof(ngx_http_index_loc_conf_t)),
|
conf = ngx_palloc(cf->pool, sizeof(ngx_http_index_loc_conf_t));
|
||||||
NGX_CONF_ERROR);
|
if (conf == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_array_init(&conf->indices, cf->pool, 2, sizeof(ngx_str_t))
|
||||||
|
== NGX_ERROR)
|
||||||
|
{
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ngx_init_array(conf->indices, cf->pool, 3, sizeof(ngx_str_t),
|
|
||||||
NGX_CONF_ERROR);
|
|
||||||
conf->max_index_len = 0;
|
conf->max_index_len = 0;
|
||||||
|
|
||||||
conf->index_cache = NULL;
|
conf->index_cache = NULL;
|
||||||
@ -461,7 +471,11 @@ static char *ngx_http_index_merge_loc_conf(ngx_conf_t *cf,
|
|||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_test_null(index, ngx_push_array(&conf->indices), NGX_CONF_ERROR);
|
index = ngx_array_push(&conf->indices);
|
||||||
|
if (index == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
index->len = sizeof(NGX_HTTP_DEFAULT_INDEX) - 1;
|
index->len = sizeof(NGX_HTTP_DEFAULT_INDEX) - 1;
|
||||||
index->data = (u_char *) NGX_HTTP_DEFAULT_INDEX;
|
index->data = (u_char *) NGX_HTTP_DEFAULT_INDEX;
|
||||||
conf->max_index_len = sizeof(NGX_HTTP_DEFAULT_INDEX);
|
conf->max_index_len = sizeof(NGX_HTTP_DEFAULT_INDEX);
|
||||||
@ -475,8 +489,11 @@ static char *ngx_http_index_merge_loc_conf(ngx_conf_t *cf,
|
|||||||
|
|
||||||
prev_index = prev->indices.elts;
|
prev_index = prev->indices.elts;
|
||||||
for (i = 0; i < prev->indices.nelts; i++) {
|
for (i = 0; i < prev->indices.nelts; i++) {
|
||||||
ngx_test_null(index, ngx_push_array(&conf->indices),
|
index = ngx_array_push(&conf->indices);
|
||||||
NGX_CONF_ERROR);
|
if (index == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
index->len = prev_index[i].len;
|
index->len = prev_index[i].len;
|
||||||
index->data = prev_index[i].data;
|
index->data = prev_index[i].data;
|
||||||
}
|
}
|
||||||
@ -524,7 +541,11 @@ static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_test_null(index, ngx_push_array(&ilcf->indices), NGX_CONF_ERROR);
|
index = ngx_array_push(&ilcf->indices);
|
||||||
|
if (index == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
index->len = value[i].len;
|
index->len = value[i].len;
|
||||||
index->data = value[i].data;
|
index->data = value[i].data;
|
||||||
|
|
@ -186,7 +186,8 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
|
|||||||
while (*p == ' ') { p++; }
|
while (*p == ' ') { p++; }
|
||||||
|
|
||||||
if (*p == ',' || *p == '\0') {
|
if (*p == ',' || *p == '\0') {
|
||||||
if (!(range = ngx_array_push(&r->headers_out.ranges))) {
|
range = ngx_array_push(&r->headers_out.ranges);
|
||||||
|
if (range == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +232,8 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(range = ngx_array_push(&r->headers_out.ranges))) {
|
range = ngx_array_push(&r->headers_out.ranges);
|
||||||
|
if (range == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +262,8 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
|
|||||||
r->headers_out.status = rc;
|
r->headers_out.status = rc;
|
||||||
r->headers_out.ranges.nelts = 0;
|
r->headers_out.ranges.nelts = 0;
|
||||||
|
|
||||||
if (!(content_range = ngx_list_push(&r->headers_out.headers))) {
|
content_range = ngx_list_push(&r->headers_out.headers);
|
||||||
|
if (content_range == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,9 +272,8 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
|
|||||||
content_range->key.len = sizeof("Content-Range") - 1;
|
content_range->key.len = sizeof("Content-Range") - 1;
|
||||||
content_range->key.data = (u_char *) "Content-Range";
|
content_range->key.data = (u_char *) "Content-Range";
|
||||||
|
|
||||||
content_range->value.data =
|
content_range->value.data = ngx_palloc(r->pool,
|
||||||
ngx_palloc(r->pool, sizeof("bytes */") - 1 + NGX_OFF_T_LEN);
|
sizeof("bytes */") - 1 + NGX_OFF_T_LEN);
|
||||||
|
|
||||||
if (content_range->value.data == NULL) {
|
if (content_range->value.data == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -294,7 +296,8 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
|
|||||||
|
|
||||||
if (r->headers_out.ranges.nelts == 1) {
|
if (r->headers_out.ranges.nelts == 1) {
|
||||||
|
|
||||||
if (!(content_range = ngx_list_push(&r->headers_out.headers))) {
|
content_range = ngx_list_push(&r->headers_out.headers);
|
||||||
|
if (content_range == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,8 +328,12 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
|
|||||||
|
|
||||||
/* TODO: what if no content_type ?? */
|
/* TODO: what if no content_type ?? */
|
||||||
|
|
||||||
ngx_http_create_ctx(r, ctx, ngx_http_range_body_filter_module,
|
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_range_filter_ctx_t));
|
||||||
sizeof(ngx_http_range_filter_ctx_t), NGX_ERROR);
|
if (ctx == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module);
|
||||||
|
|
||||||
|
|
||||||
len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN
|
len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN
|
||||||
@ -338,7 +345,8 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
|
|||||||
len += sizeof("; charset=") - 1 + r->headers_out.charset.len;
|
len += sizeof("; charset=") - 1 + r->headers_out.charset.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ctx->boundary_header.data = ngx_palloc(r->pool, len))) {
|
ctx->boundary_header.data = ngx_palloc(r->pool, len);
|
||||||
|
if (ctx->boundary_header.data == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +474,8 @@ ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
* "Content-Range: bytes "
|
* "Content-Range: bytes "
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,7 +483,8 @@ ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
b->pos = ctx->boundary_header.data;
|
b->pos = ctx->boundary_header.data;
|
||||||
b->last = ctx->boundary_header.data + ctx->boundary_header.len;
|
b->last = ctx->boundary_header.data + ctx->boundary_header.len;
|
||||||
|
|
||||||
if (!(hcl = ngx_alloc_chain_link(r->pool))) {
|
hcl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (hcl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +493,8 @@ ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
/* "SSSS-EEEE/TTTT" CRLF CRLF */
|
/* "SSSS-EEEE/TTTT" CRLF CRLF */
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,7 +502,8 @@ ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
b->pos = range[i].content_range.data;
|
b->pos = range[i].content_range.data;
|
||||||
b->last = range[i].content_range.data + range[i].content_range.len;
|
b->last = range[i].content_range.data + range[i].content_range.len;
|
||||||
|
|
||||||
if (!(rcl = ngx_alloc_chain_link(r->pool))) {
|
rcl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (rcl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +512,8 @@ ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
/* the range data */
|
/* the range data */
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +522,8 @@ ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
b->file_last = range[i].end;
|
b->file_last = range[i].end;
|
||||||
b->file = in->buf->file;
|
b->file = in->buf->file;
|
||||||
|
|
||||||
if (!(dcl = ngx_alloc_chain_link(r->pool))) {
|
dcl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (dcl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +537,8 @@ ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
/* the last boundary CRLF "--0123456789--" CRLF */
|
/* the last boundary CRLF "--0123456789--" CRLF */
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,7 +555,8 @@ ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
*b->last++ = '-'; *b->last++ = '-';
|
*b->last++ = '-'; *b->last++ = '-';
|
||||||
*b->last++ = CR; *b->last++ = LF;
|
*b->last++ = CR; *b->last++ = LF;
|
||||||
|
|
||||||
if (!(hcl = ngx_alloc_chain_link(r->pool))) {
|
hcl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (hcl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
@ -20,6 +20,12 @@ typedef struct {
|
|||||||
} ngx_http_rewrite_referer_t;
|
} ngx_http_rewrite_referer_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ngx_str_t *name;
|
||||||
|
ngx_http_variable_value_t *value;
|
||||||
|
} ngx_http_rewrite_variable_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_array_t *codes; /* uintptr_t */
|
ngx_array_t *codes; /* uintptr_t */
|
||||||
ngx_array_t *referers; /* ngx_http_rewrite_referer_t */
|
ngx_array_t *referers; /* ngx_http_rewrite_referer_t */
|
||||||
@ -41,6 +47,7 @@ typedef struct {
|
|||||||
uintptr_t status;
|
uintptr_t status;
|
||||||
uintptr_t next;
|
uintptr_t next;
|
||||||
|
|
||||||
|
uintptr_t test:1;
|
||||||
uintptr_t uri:1;
|
uintptr_t uri:1;
|
||||||
|
|
||||||
/* add the r->args to the new arguments */
|
/* add the r->args to the new arguments */
|
||||||
@ -90,6 +97,14 @@ typedef struct {
|
|||||||
} ngx_http_rewrite_if_code_t;
|
} ngx_http_rewrite_if_code_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ngx_http_rewrite_code_pt code;
|
||||||
|
uintptr_t value;
|
||||||
|
uintptr_t text_len;
|
||||||
|
uintptr_t text_data;
|
||||||
|
} ngx_http_rewrite_value_code_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_http_rewrite_code_pt code;
|
ngx_http_rewrite_code_pt code;
|
||||||
uintptr_t index;
|
uintptr_t index;
|
||||||
@ -98,7 +113,7 @@ typedef struct {
|
|||||||
|
|
||||||
struct ngx_http_rewrite_engine_s {
|
struct ngx_http_rewrite_engine_s {
|
||||||
u_char *ip;
|
u_char *ip;
|
||||||
uintptr_t *sp;
|
ngx_http_variable_value_t *sp;
|
||||||
|
|
||||||
ngx_str_t buf;
|
ngx_str_t buf;
|
||||||
ngx_str_t *line;
|
ngx_str_t *line;
|
||||||
@ -128,8 +143,14 @@ static char *ngx_http_rewrite_return(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
void *conf);
|
void *conf);
|
||||||
static char *ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
void *conf);
|
void *conf);
|
||||||
|
static char * ngx_http_rewrite_if_condition(ngx_conf_t *cf,
|
||||||
|
ngx_http_rewrite_loc_conf_t *lcf);
|
||||||
|
static char *ngx_http_rewrite_variable(ngx_conf_t *cf,
|
||||||
|
ngx_http_rewrite_loc_conf_t *lcf, ngx_str_t *value);
|
||||||
static char *ngx_http_rewrite_valid_referers(ngx_conf_t *cf,
|
static char *ngx_http_rewrite_valid_referers(ngx_conf_t *cf,
|
||||||
ngx_command_t *cmd, void *conf);
|
ngx_command_t *cmd, void *conf);
|
||||||
|
static char * ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
|
void *conf);
|
||||||
static void *ngx_http_rewrite_start_code(ngx_pool_t *pool,
|
static void *ngx_http_rewrite_start_code(ngx_pool_t *pool,
|
||||||
ngx_array_t **codes, size_t size);
|
ngx_array_t **codes, size_t size);
|
||||||
static void *ngx_http_rewrite_add_code(ngx_array_t *codes, size_t size,
|
static void *ngx_http_rewrite_add_code(ngx_array_t *codes, size_t size,
|
||||||
@ -168,6 +189,14 @@ static ngx_command_t ngx_http_rewrite_commands[] = {
|
|||||||
0,
|
0,
|
||||||
NULL },
|
NULL },
|
||||||
|
|
||||||
|
{ ngx_string("set"),
|
||||||
|
NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
||||||
|
|NGX_CONF_TAKE2,
|
||||||
|
ngx_http_rewrite_set,
|
||||||
|
NGX_HTTP_LOC_CONF_OFFSET,
|
||||||
|
0,
|
||||||
|
NULL },
|
||||||
|
|
||||||
{ ngx_string("rewrite_log"),
|
{ ngx_string("rewrite_log"),
|
||||||
NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
||||||
|NGX_CONF_TAKE1,
|
|NGX_CONF_TAKE1,
|
||||||
@ -208,6 +237,9 @@ ngx_module_t ngx_http_rewrite_module = {
|
|||||||
|
|
||||||
uintptr_t ngx_http_rewrite_exit_code = (uintptr_t) NULL;
|
uintptr_t ngx_http_rewrite_exit_code = (uintptr_t) NULL;
|
||||||
|
|
||||||
|
static ngx_http_variable_value_t ngx_http_rewrite_null_value =
|
||||||
|
{ 0, ngx_string("") };
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_rewrite_handler(ngx_http_request_t *r)
|
ngx_http_rewrite_handler(ngx_http_request_t *r)
|
||||||
@ -222,11 +254,13 @@ ngx_http_rewrite_handler(ngx_http_request_t *r)
|
|||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(e = ngx_palloc(r->pool, sizeof(ngx_http_rewrite_engine_t)))) {
|
e = ngx_palloc(r->pool, sizeof(ngx_http_rewrite_engine_t));
|
||||||
|
if (e == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
e->sp = ngx_palloc(r->pool, cf->stack_size * sizeof(ngx_int_t));
|
e->sp = ngx_palloc(r->pool,
|
||||||
|
cf->stack_size * sizeof(ngx_http_variable_value_t));
|
||||||
if (e->sp == NULL) {
|
if (e->sp == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
@ -274,12 +308,13 @@ ngx_http_rewrite_regex_start_code(ngx_http_rewrite_engine_t *e)
|
|||||||
r = e->request;
|
r = e->request;
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
"http rewrite start: \"%V\"", &code->name);
|
"http rewrite regex: \"%V\"", &code->name);
|
||||||
|
|
||||||
if (code->uri) {
|
if (code->uri) {
|
||||||
e->line = &r->uri;
|
e->line = &r->uri;
|
||||||
} else {
|
} else {
|
||||||
e->line = *(ngx_str_t **) e->sp--;
|
e->sp--;
|
||||||
|
e->line = &e->sp->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ngx_regex_exec(code->regex, e->line, e->captures, code->ncaptures);
|
rc = ngx_regex_exec(code->regex, e->line, e->captures, code->ncaptures);
|
||||||
@ -290,6 +325,16 @@ ngx_http_rewrite_regex_start_code(ngx_http_rewrite_engine_t *e)
|
|||||||
"\"%V\" does not match \"%V\"", &code->name, e->line);
|
"\"%V\" does not match \"%V\"", &code->name, e->line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code->test) {
|
||||||
|
e->sp->value = 0;
|
||||||
|
e->sp->text.len = 0;
|
||||||
|
e->sp->text.data = (u_char *) "";
|
||||||
|
e->sp++;
|
||||||
|
|
||||||
|
e->ip += sizeof(ngx_http_rewrite_regex_code_t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
e->ip += code->next;
|
e->ip += code->next;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -309,6 +354,16 @@ ngx_http_rewrite_regex_start_code(ngx_http_rewrite_engine_t *e)
|
|||||||
"\"%V\" matches \"%V\"", &code->name, e->line);
|
"\"%V\" matches \"%V\"", &code->name, e->line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code->test) {
|
||||||
|
e->sp->value = 1;
|
||||||
|
e->sp->text.len = 1;
|
||||||
|
e->sp->text.data = (u_char *) "1";
|
||||||
|
e->sp++;
|
||||||
|
|
||||||
|
e->ip += sizeof(ngx_http_rewrite_regex_code_t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (code->status) {
|
if (code->status) {
|
||||||
e->status = code->status;
|
e->status = code->status;
|
||||||
|
|
||||||
@ -339,7 +394,8 @@ ngx_http_rewrite_regex_start_code(ngx_http_rewrite_engine_t *e)
|
|||||||
e->buf.len += r->args.len + 1;
|
e->buf.len += r->args.len + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(e->buf.data = ngx_palloc(r->pool, e->buf.len))) {
|
e->buf.data = ngx_palloc(r->pool, e->buf.len);
|
||||||
|
if (e->buf.data == NULL) {
|
||||||
e->ip = ngx_http_rewrite_exit;
|
e->ip = ngx_http_rewrite_exit;
|
||||||
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
return;
|
return;
|
||||||
@ -366,7 +422,7 @@ ngx_http_rewrite_regex_end_code(ngx_http_rewrite_engine_t *e)
|
|||||||
e->quote = 0;
|
e->quote = 0;
|
||||||
|
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
"http rewrite end");
|
"http rewrite regex end");
|
||||||
|
|
||||||
if (e->args) {
|
if (e->args) {
|
||||||
e->buf.len = e->args - e->buf.data;
|
e->buf.len = e->args - e->buf.data;
|
||||||
@ -414,7 +470,8 @@ ngx_http_rewrite_regex_end_code(ngx_http_rewrite_engine_t *e)
|
|||||||
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
||||||
"rewritten redirect: \"%V\"", &e->buf);
|
"rewritten redirect: \"%V\"", &e->buf);
|
||||||
|
|
||||||
if (!(r->headers_out.location = ngx_list_push(&r->headers_out.headers))) {
|
r->headers_out.location = ngx_list_push(&r->headers_out.headers);
|
||||||
|
if (r->headers_out.location == NULL) {
|
||||||
e->ip = ngx_http_rewrite_exit;
|
e->ip = ngx_http_rewrite_exit;
|
||||||
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
return;
|
return;
|
||||||
@ -468,7 +525,7 @@ ngx_http_rewrite_copy_code(ngx_http_rewrite_engine_t *e)
|
|||||||
code->len);
|
code->len);
|
||||||
|
|
||||||
e->ip += sizeof(ngx_http_rewrite_copy_code_t)
|
e->ip += sizeof(ngx_http_rewrite_copy_code_t)
|
||||||
+ ((code->len + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1));
|
+ ((code->len + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1));
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||||
"http rewrite copy: \"%V\"", &e->buf);
|
"http rewrite copy: \"%V\"", &e->buf);
|
||||||
@ -509,7 +566,9 @@ ngx_http_rewrite_if_code(ngx_http_rewrite_engine_t *e)
|
|||||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||||
"http rewrite if");
|
"http rewrite if");
|
||||||
|
|
||||||
if (*e->sp--) {
|
e->sp--;
|
||||||
|
|
||||||
|
if (e->sp->value) {
|
||||||
if (code->loc_conf) {
|
if (code->loc_conf) {
|
||||||
e->request->loc_conf = code->loc_conf;
|
e->request->loc_conf = code->loc_conf;
|
||||||
}
|
}
|
||||||
@ -525,6 +584,69 @@ ngx_http_rewrite_if_code(ngx_http_rewrite_engine_t *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
ngx_http_rewrite_value_code(ngx_http_rewrite_engine_t *e)
|
||||||
|
{
|
||||||
|
ngx_http_rewrite_value_code_t *code;
|
||||||
|
|
||||||
|
code = (ngx_http_rewrite_value_code_t *) e->ip;
|
||||||
|
|
||||||
|
e->ip += sizeof(ngx_http_rewrite_value_code_t);
|
||||||
|
|
||||||
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||||
|
"http rewrite value");
|
||||||
|
|
||||||
|
e->sp->value = (ngx_uint_t) code->value;
|
||||||
|
e->sp->text.len = (size_t) code->text_len;
|
||||||
|
e->sp->text.data = (u_char *) code->text_data;
|
||||||
|
e->sp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
ngx_http_rewrite_set_var_code(ngx_http_rewrite_engine_t *e)
|
||||||
|
{
|
||||||
|
ngx_http_request_t *r;
|
||||||
|
ngx_http_variable_value_t *value;
|
||||||
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
|
ngx_http_rewrite_var_code_t *code;
|
||||||
|
|
||||||
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||||
|
"http rewrite set var");
|
||||||
|
|
||||||
|
code = (ngx_http_rewrite_var_code_t *) e->ip;
|
||||||
|
|
||||||
|
e->ip += sizeof(ngx_http_rewrite_var_code_t);
|
||||||
|
|
||||||
|
r = e->request;
|
||||||
|
|
||||||
|
if (r->variables == NULL) {
|
||||||
|
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
||||||
|
|
||||||
|
r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts
|
||||||
|
* sizeof(ngx_http_variable_value_t *));
|
||||||
|
if (r->variables == NULL) {
|
||||||
|
e->ip = ngx_http_rewrite_exit;
|
||||||
|
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
value = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t));
|
||||||
|
if (value == NULL) {
|
||||||
|
e->ip = ngx_http_rewrite_exit;
|
||||||
|
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
e->sp--;
|
||||||
|
|
||||||
|
*value = *e->sp;
|
||||||
|
|
||||||
|
r->variables[code->index] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ngx_http_rewrite_var_code(ngx_http_rewrite_engine_t *e)
|
ngx_http_rewrite_var_code(ngx_http_rewrite_engine_t *e)
|
||||||
{
|
{
|
||||||
@ -536,19 +658,24 @@ ngx_http_rewrite_var_code(ngx_http_rewrite_engine_t *e)
|
|||||||
|
|
||||||
code = (ngx_http_rewrite_var_code_t *) e->ip;
|
code = (ngx_http_rewrite_var_code_t *) e->ip;
|
||||||
|
|
||||||
e->sp++;
|
|
||||||
|
|
||||||
e->ip += sizeof(ngx_http_rewrite_var_code_t);
|
e->ip += sizeof(ngx_http_rewrite_var_code_t);
|
||||||
|
|
||||||
if (!(value = ngx_http_get_indexed_variable(e->request, code->index))) {
|
value = ngx_http_get_indexed_variable(e->request, code->index);
|
||||||
*e->sp = (uintptr_t) 0;
|
|
||||||
|
if (value == NULL || value == NGX_HTTP_VARIABLE_NOT_FOUND) {
|
||||||
|
e->sp->value = 0;
|
||||||
|
e->sp->text.len = 0;
|
||||||
|
e->sp->text.data = (u_char *) "";
|
||||||
|
e->sp++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
||||||
"http rewrite var: %p", value->value);
|
"http rewrite var: %ui, \"%V\"", value->value, &value->text);
|
||||||
|
|
||||||
*e->sp = value->value;
|
*e->sp = *value;
|
||||||
|
e->sp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -569,20 +696,31 @@ ngx_http_rewrite_invalid_referer_code(ngx_http_rewrite_engine_t *e)
|
|||||||
|
|
||||||
cf = ngx_http_get_module_loc_conf(r, ngx_http_rewrite_module);
|
cf = ngx_http_get_module_loc_conf(r, ngx_http_rewrite_module);
|
||||||
|
|
||||||
e->sp++;
|
|
||||||
e->ip += sizeof(uintptr_t);
|
e->ip += sizeof(uintptr_t);
|
||||||
|
|
||||||
if (cf->referers == NULL) {
|
if (cf->referers == NULL) {
|
||||||
*e->sp = (uintptr_t) 0;
|
e->sp->value = 0;
|
||||||
|
e->sp->text.len = 0;
|
||||||
|
e->sp->text.data = (u_char *) "";
|
||||||
|
e->sp++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r->headers_in.referer == NULL) {
|
if (r->headers_in.referer == NULL) {
|
||||||
if (cf->no_referer) {
|
if (cf->no_referer) {
|
||||||
*e->sp = (uintptr_t) 0;
|
e->sp->value = 0;
|
||||||
|
e->sp->text.len = 0;
|
||||||
|
e->sp->text.data = (u_char *) "";
|
||||||
|
e->sp++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
*e->sp = (uintptr_t) 1;
|
e->sp->value = 1;
|
||||||
|
e->sp->text.len = 1;
|
||||||
|
e->sp->text.data = (u_char *) "1";
|
||||||
|
e->sp++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -593,7 +731,11 @@ ngx_http_rewrite_invalid_referer_code(ngx_http_rewrite_engine_t *e)
|
|||||||
if (len < sizeof("http://i.ru") - 1
|
if (len < sizeof("http://i.ru") - 1
|
||||||
|| (ngx_strncasecmp(ref, "http://", 7) != 0))
|
|| (ngx_strncasecmp(ref, "http://", 7) != 0))
|
||||||
{
|
{
|
||||||
*e->sp = (uintptr_t) 1;
|
e->sp->value = 1;
|
||||||
|
e->sp->text.len = 1;
|
||||||
|
e->sp->text.data = (u_char *) "1";
|
||||||
|
e->sp++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -620,7 +762,11 @@ ngx_http_rewrite_invalid_referer_code(ngx_http_rewrite_engine_t *e)
|
|||||||
if (ngx_strncmp(&ref[n], refs[i].name.data,
|
if (ngx_strncmp(&ref[n], refs[i].name.data,
|
||||||
refs[i].name.len) == 0)
|
refs[i].name.len) == 0)
|
||||||
{
|
{
|
||||||
*e->sp = (uintptr_t) 0;
|
e->sp->value = 0;
|
||||||
|
e->sp->text.len = 0;
|
||||||
|
e->sp->text.data = (u_char *) "";
|
||||||
|
e->sp++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -628,13 +774,20 @@ ngx_http_rewrite_invalid_referer_code(ngx_http_rewrite_engine_t *e)
|
|||||||
} else {
|
} else {
|
||||||
if (ngx_strncasecmp(refs[i].name.data, ref, refs[i].name.len) == 0)
|
if (ngx_strncasecmp(refs[i].name.data, ref, refs[i].name.len) == 0)
|
||||||
{
|
{
|
||||||
*e->sp = (uintptr_t) 0;
|
e->sp->value = 0;
|
||||||
|
e->sp->text.len = 0;
|
||||||
|
e->sp->text.data = (u_char *) "";
|
||||||
|
e->sp++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*e->sp = (uintptr_t) 1;
|
e->sp->value = 1;
|
||||||
|
e->sp->text.len = 1;
|
||||||
|
e->sp->text.data = (u_char *) "1";
|
||||||
|
e->sp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -645,6 +798,29 @@ ngx_http_rewrite_nop_code(ngx_http_rewrite_engine_t *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_http_variable_value_t *
|
||||||
|
ngx_http_rewrite_var(ngx_http_request_t *r, uintptr_t data)
|
||||||
|
{
|
||||||
|
ngx_http_variable_t *var;
|
||||||
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
|
|
||||||
|
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
||||||
|
|
||||||
|
var = cmcf->variables.elts;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* the ngx_http_rewrite_module sets variables directly in r->variables,
|
||||||
|
* and they should be handle by ngx_http_get_indexed_variable(),
|
||||||
|
* so the handler is called only if the variable is not initialized
|
||||||
|
*/
|
||||||
|
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
||||||
|
"using uninitialized \"%V\" variable", &var[data].name);
|
||||||
|
|
||||||
|
return &ngx_http_rewrite_null_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_rewrite_init(ngx_cycle_t *cycle)
|
ngx_http_rewrite_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
@ -653,7 +829,7 @@ ngx_http_rewrite_init(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||||
|
|
||||||
h = ngx_push_array(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers);
|
h = ngx_array_push(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers);
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -669,7 +845,8 @@ ngx_http_rewrite_create_loc_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_rewrite_loc_conf_t *conf;
|
ngx_http_rewrite_loc_conf_t *conf;
|
||||||
|
|
||||||
if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_rewrite_loc_conf_t)))) {
|
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_rewrite_loc_conf_t));
|
||||||
|
if (conf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,30 +901,53 @@ ngx_http_rewrite_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||||||
conf->max_captures = regex->ncaptures;
|
conf->max_captures = regex->ncaptures;
|
||||||
}
|
}
|
||||||
code = (uintptr_t *) ((u_char *) code + regex->next);
|
code = (uintptr_t *) ((u_char *) code + regex->next);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*code == (uintptr_t) &ngx_http_rewrite_if_code) {
|
if (*code == (uintptr_t) &ngx_http_rewrite_if_code) {
|
||||||
code += sizeof(ngx_http_rewrite_if_code_t) / sizeof(uintptr_t);
|
code += sizeof(ngx_http_rewrite_if_code_t) / sizeof(uintptr_t);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*code == (uintptr_t) &ngx_http_rewrite_return_code) {
|
if (*code == (uintptr_t) &ngx_http_rewrite_return_code) {
|
||||||
code += sizeof(ngx_http_rewrite_return_code_t) / sizeof(uintptr_t);
|
code += sizeof(ngx_http_rewrite_return_code_t) / sizeof(uintptr_t);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*code == (uintptr_t) &ngx_http_rewrite_set_var_code) {
|
||||||
|
code += sizeof(ngx_http_rewrite_var_code_t) / sizeof(uintptr_t);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*code == (uintptr_t) &ngx_http_rewrite_var_code) {
|
if (*code == (uintptr_t) &ngx_http_rewrite_var_code) {
|
||||||
code += sizeof(ngx_http_rewrite_var_code_t) / sizeof(uintptr_t);
|
code += sizeof(ngx_http_rewrite_var_code_t) / sizeof(uintptr_t);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*code == (uintptr_t) &ngx_http_rewrite_value_code) {
|
||||||
|
code += sizeof(ngx_http_rewrite_value_code_t) / sizeof(uintptr_t);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*code == (uintptr_t) &ngx_http_rewrite_invalid_referer_code) {
|
if (*code == (uintptr_t) &ngx_http_rewrite_invalid_referer_code) {
|
||||||
code++;
|
code++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*code == (uintptr_t) &ngx_http_rewrite_nop_code) {
|
if (*code == (uintptr_t) &ngx_http_rewrite_nop_code) {
|
||||||
code++;
|
code++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (NGX_DEBUG)
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||||
|
"unknown rewrite code: %p", *code);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(code = ngx_array_push_n(conf->codes, sizeof(uintptr_t)))) {
|
code = ngx_array_push_n(conf->codes, sizeof(uintptr_t));
|
||||||
|
if (code == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,7 +965,8 @@ ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
u_char *data;
|
u_char *data;
|
||||||
size_t len, size;
|
size_t len, size;
|
||||||
ngx_str_t *value, err;
|
ngx_str_t *value, err;
|
||||||
ngx_uint_t i, n, last;
|
ngx_int_t n;
|
||||||
|
ngx_uint_t i, last;
|
||||||
ngx_http_rewrite_code_pt *code;
|
ngx_http_rewrite_code_pt *code;
|
||||||
ngx_http_rewrite_copy_code_t *copy;
|
ngx_http_rewrite_copy_code_t *copy;
|
||||||
ngx_http_rewrite_regex_code_t *regex;
|
ngx_http_rewrite_regex_code_t *regex;
|
||||||
@ -797,6 +998,7 @@ ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
regex->size = 0;
|
regex->size = 0;
|
||||||
regex->ncaptures = 0;
|
regex->ncaptures = 0;
|
||||||
regex->status = 0;
|
regex->status = 0;
|
||||||
|
regex->test = 0;
|
||||||
regex->uri = 1;
|
regex->uri = 1;
|
||||||
regex->args = 1;
|
regex->args = 1;
|
||||||
regex->redirect = 0;
|
regex->redirect = 0;
|
||||||
@ -946,7 +1148,14 @@ ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
n = ngx_regex_capture_count(regex->regex);
|
n = ngx_regex_capture_count(regex->regex);
|
||||||
|
|
||||||
if (regex->ncaptures > n) {
|
if (n < 0) {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
ngx_regex_capture_count_n " failed for "
|
||||||
|
"pattern \"%V\"", &value[1]);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regex->ncaptures > (ngx_uint_t) n) {
|
||||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
"pattern \"%V\" has less captures "
|
"pattern \"%V\" has less captures "
|
||||||
"than referrenced in substitution \"%V\"",
|
"than referrenced in substitution \"%V\"",
|
||||||
@ -954,8 +1163,8 @@ ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regex->ncaptures < n) {
|
if (regex->ncaptures < (ngx_uint_t) n) {
|
||||||
regex->ncaptures = n;
|
regex->ncaptures = (ngx_uint_t) n;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regex->ncaptures) {
|
if (regex->ncaptures) {
|
||||||
@ -1028,20 +1237,16 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
void *mconf;
|
void *mconf;
|
||||||
char *rv;
|
char *rv;
|
||||||
u_char *elts;
|
u_char *elts;
|
||||||
ngx_str_t *value;
|
|
||||||
ngx_int_t index;
|
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_conf_t save;
|
ngx_conf_t save;
|
||||||
ngx_http_rewrite_code_pt *code;
|
|
||||||
ngx_http_module_t *module;
|
ngx_http_module_t *module;
|
||||||
ngx_http_conf_ctx_t *ctx, *pctx;
|
ngx_http_conf_ctx_t *ctx, *pctx;
|
||||||
ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp;
|
ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp;
|
||||||
ngx_http_core_main_conf_t *cmcf;
|
|
||||||
ngx_http_rewrite_if_code_t *if_code;
|
ngx_http_rewrite_if_code_t *if_code;
|
||||||
ngx_http_rewrite_var_code_t *var_code;
|
|
||||||
ngx_http_rewrite_loc_conf_t *nlcf;
|
ngx_http_rewrite_loc_conf_t *nlcf;
|
||||||
|
|
||||||
if (!(ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)))) {
|
ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
|
||||||
|
if (ctx == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1063,7 +1268,8 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
if (module->create_loc_conf) {
|
if (module->create_loc_conf) {
|
||||||
|
|
||||||
if (!(mconf = module->create_loc_conf(cf))) {
|
mconf = module->create_loc_conf(cf);
|
||||||
|
if (mconf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,63 +1292,18 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(clcfp = ngx_push_array(&pclcf->locations))) {
|
clcfp = ngx_array_push(&pclcf->locations);
|
||||||
|
if (clcfp == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
*clcfp = clcf;
|
*clcfp = clcf;
|
||||||
|
|
||||||
|
|
||||||
/* STUB: "if ($var)" */
|
if (ngx_http_rewrite_if_condition(cf, lcf) != NGX_CONF_OK) {
|
||||||
|
|
||||||
value = cf->args->elts;
|
|
||||||
|
|
||||||
if (value[1].len < 2
|
|
||||||
|| value[1].data[0] != '('
|
|
||||||
|| value[1].data[1] != '$'
|
|
||||||
|| value[1].data[value[1].len - 1] != ')')
|
|
||||||
{
|
|
||||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
||||||
"invalid condition \"%V\"", &value[1]);
|
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
value[1].len -= 3;
|
|
||||||
value[1].data += 2;
|
|
||||||
|
|
||||||
if (value[1].len == sizeof("invalid_referer") - 1
|
|
||||||
&& ngx_strncmp(value[1].data, "invalid_referer",
|
|
||||||
sizeof("invalid_referer") - 1) == 0)
|
|
||||||
{
|
|
||||||
code = ngx_http_rewrite_start_code(cf->pool, &lcf->codes,
|
|
||||||
sizeof(ngx_http_rewrite_code_pt));
|
|
||||||
if (code == NULL) {
|
|
||||||
return NGX_CONF_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
*code = ngx_http_rewrite_invalid_referer_code;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
|
||||||
|
|
||||||
index = ngx_http_get_variable_index(cmcf, &value[1]);
|
|
||||||
|
|
||||||
if (index == -1) {
|
|
||||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
||||||
"unknown variable name \"%V\"", &value[1]);
|
|
||||||
return NGX_CONF_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
var_code = ngx_http_rewrite_start_code(cf->pool, &lcf->codes,
|
|
||||||
sizeof(ngx_http_rewrite_var_code_t));
|
|
||||||
if (var_code == NULL) {
|
|
||||||
return NGX_CONF_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
var_code->code = ngx_http_rewrite_var_code;
|
|
||||||
var_code->index = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
if_code = ngx_array_push_n(lcf->codes, sizeof(ngx_http_rewrite_if_code_t));
|
if_code = ngx_array_push_n(lcf->codes, sizeof(ngx_http_rewrite_if_code_t));
|
||||||
if (if_code == NULL) {
|
if (if_code == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1192,6 +1353,156 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *
|
||||||
|
ngx_http_rewrite_if_condition(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf)
|
||||||
|
{
|
||||||
|
ngx_str_t *value, err;
|
||||||
|
ngx_uint_t cur, last;
|
||||||
|
ngx_http_rewrite_regex_code_t *regex;
|
||||||
|
u_char errstr[NGX_MAX_CONF_ERRSTR];
|
||||||
|
|
||||||
|
value = cf->args->elts;
|
||||||
|
last = cf->args->nelts - 1;
|
||||||
|
|
||||||
|
if (value[1].len < 1 || value[1].data[0] != '(') {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"invalid condition \"%V\"", &value[1]);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value[1].len == 1) {
|
||||||
|
cur = 2;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cur = 1;
|
||||||
|
value[1].len--;
|
||||||
|
value[1].data++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value[last].len < 1 || value[last].data[value[last].len - 1] != ')') {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"invalid condition \"%V\"", &value[last]);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value[last].len == 1) {
|
||||||
|
last--;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
value[last].len--;
|
||||||
|
value[last].data[value[last].len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value[cur].len > 1 && value[cur].data[0] == '$') {
|
||||||
|
|
||||||
|
if (cur != last && cur + 2 != last) {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"invalid condition \"%V\"", &value[cur]);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_http_rewrite_variable(cf, lcf, &value[cur])!= NGX_CONF_OK) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cur == last) {
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
cur++;
|
||||||
|
|
||||||
|
if ((value[cur].len == 1 && value[cur].data[0] != '~')
|
||||||
|
|| (value[cur].len == 2
|
||||||
|
&& value[cur].data[0] != '~' && value[cur].data[1] != '*'))
|
||||||
|
{
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"unexpected \"%V\" in condition", &value[cur]);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
regex = ngx_http_rewrite_start_code(cf->pool, &lcf->codes,
|
||||||
|
sizeof(ngx_http_rewrite_regex_code_t));
|
||||||
|
if (regex == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
err.len = NGX_MAX_CONF_ERRSTR;
|
||||||
|
err.data = errstr;
|
||||||
|
|
||||||
|
regex->regex = ngx_regex_compile(&value[last],
|
||||||
|
(value[cur].len == 2) ? NGX_REGEX_CASELESS : 0,
|
||||||
|
cf->pool, &err);
|
||||||
|
|
||||||
|
if (regex->regex == NULL) {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s", err.data);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
regex->code = ngx_http_rewrite_regex_start_code;
|
||||||
|
regex->size = 0;
|
||||||
|
regex->ncaptures = 0;
|
||||||
|
regex->status = 0;
|
||||||
|
regex->next = sizeof(ngx_http_rewrite_regex_code_t);
|
||||||
|
regex->test = 1;
|
||||||
|
regex->uri = 0;
|
||||||
|
regex->args = 0;
|
||||||
|
regex->redirect = 0;
|
||||||
|
regex->name = value[last];
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"invalid condition \"%V\"", &value[cur]);
|
||||||
|
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *
|
||||||
|
ngx_http_rewrite_variable(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf,
|
||||||
|
ngx_str_t *value)
|
||||||
|
{
|
||||||
|
ngx_http_variable_t *var;
|
||||||
|
ngx_http_rewrite_code_pt *code;
|
||||||
|
ngx_http_rewrite_var_code_t *var_code;
|
||||||
|
|
||||||
|
value->len--;
|
||||||
|
value->data++;
|
||||||
|
|
||||||
|
if (value->len == sizeof("invalid_referer") - 1
|
||||||
|
&& ngx_strncmp(value->data, "invalid_referer",
|
||||||
|
sizeof("invalid_referer") - 1) == 0)
|
||||||
|
{
|
||||||
|
code = ngx_http_rewrite_start_code(cf->pool, &lcf->codes,
|
||||||
|
sizeof(ngx_http_rewrite_code_pt));
|
||||||
|
if (code == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*code = ngx_http_rewrite_invalid_referer_code;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var = ngx_http_add_variable(cf, value, 0);
|
||||||
|
|
||||||
|
if (var == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
var_code = ngx_http_rewrite_start_code(cf->pool, &lcf->codes,
|
||||||
|
sizeof(ngx_http_rewrite_var_code_t));
|
||||||
|
if (var_code == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
var_code->code = ngx_http_rewrite_var_code;
|
||||||
|
var_code->index = var->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
ngx_http_rewrite_valid_referers(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
ngx_http_rewrite_valid_referers(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
{
|
{
|
||||||
@ -1234,7 +1545,8 @@ ngx_http_rewrite_valid_referers(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ref = ngx_array_push(lcf->referers))) {
|
ref = ngx_array_push(lcf->referers);
|
||||||
|
if (ref == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1261,12 +1573,14 @@ ngx_http_rewrite_valid_referers(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
sn = cscf->server_names.elts;
|
sn = cscf->server_names.elts;
|
||||||
for (i = 0; i < cscf->server_names.nelts; i++) {
|
for (i = 0; i < cscf->server_names.nelts; i++) {
|
||||||
if (!(ref = ngx_array_push(lcf->referers))) {
|
ref = ngx_array_push(lcf->referers);
|
||||||
|
if (ref == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ref->name.len = sn[i].name.len + 1;
|
ref->name.len = sn[i].name.len + 1;
|
||||||
if (!(ref->name.data = ngx_palloc(cf->pool, ref->name.len))) {
|
ref->name.data = ngx_palloc(cf->pool, ref->name.len);
|
||||||
|
if (ref->name.data == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1279,11 +1593,72 @@ ngx_http_rewrite_valid_referers(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *
|
||||||
|
ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||||
|
{
|
||||||
|
ngx_http_rewrite_loc_conf_t *lcf = conf;
|
||||||
|
|
||||||
|
ngx_int_t n;
|
||||||
|
ngx_str_t *value;
|
||||||
|
ngx_http_variable_t *v;
|
||||||
|
ngx_http_rewrite_var_code_t *var;
|
||||||
|
ngx_http_rewrite_value_code_t *val;
|
||||||
|
|
||||||
|
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++;
|
||||||
|
|
||||||
|
v = ngx_http_add_variable(cf, &value[1], 1);
|
||||||
|
if (v == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
v->handler = ngx_http_rewrite_var;
|
||||||
|
v->data = v->index;
|
||||||
|
|
||||||
|
val = ngx_http_rewrite_start_code(cf->pool, &lcf->codes,
|
||||||
|
sizeof(ngx_http_rewrite_value_code_t));
|
||||||
|
if (val == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = ngx_atoi(value[2].data, value[2].len);
|
||||||
|
|
||||||
|
if (n == NGX_ERROR) {
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
val->code = ngx_http_rewrite_value_code;
|
||||||
|
val->value = (uintptr_t) n;
|
||||||
|
val->text_len = (uintptr_t) value[2].len;
|
||||||
|
val->text_data = (uintptr_t) value[2].data;
|
||||||
|
|
||||||
|
var = ngx_http_rewrite_start_code(cf->pool, &lcf->codes,
|
||||||
|
sizeof(ngx_http_rewrite_var_code_t));
|
||||||
|
if (var == NULL) {
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
var->code = ngx_http_rewrite_set_var_code;
|
||||||
|
var->index = (uintptr_t) v->index;
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
ngx_http_rewrite_start_code(ngx_pool_t *pool, ngx_array_t **codes, size_t size)
|
ngx_http_rewrite_start_code(ngx_pool_t *pool, ngx_array_t **codes, size_t size)
|
||||||
{
|
{
|
||||||
if (*codes == NULL) {
|
if (*codes == NULL) {
|
||||||
if (!(*codes = ngx_array_create(pool, 256, 1))) {
|
*codes = ngx_array_create(pool, 256, 1);
|
||||||
|
if (*codes == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1300,7 +1675,8 @@ ngx_http_rewrite_add_code(ngx_array_t *codes, size_t size, void *code)
|
|||||||
|
|
||||||
elts = codes->elts;
|
elts = codes->elts;
|
||||||
|
|
||||||
if (!(new = ngx_array_push_n(codes, size))) {
|
new = ngx_array_push_n(codes, size);
|
||||||
|
if (new == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
@ -98,8 +98,6 @@ typedef enum {
|
|||||||
} ngx_http_ssi_state_e;
|
} ngx_http_ssi_state_e;
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_ssi_error(ngx_http_request_t *r,
|
|
||||||
ngx_http_ssi_ctx_t *ctx);
|
|
||||||
static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r,
|
static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r,
|
||||||
ngx_http_ssi_ctx_t *ctx);
|
ngx_http_ssi_ctx_t *ctx);
|
||||||
|
|
||||||
@ -1147,21 +1145,25 @@ static ngx_int_t
|
|||||||
ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
|
ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
|
||||||
ngx_str_t **params)
|
ngx_str_t **params)
|
||||||
{
|
{
|
||||||
|
ngx_uint_t i;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_str_t *var, *value;
|
ngx_str_t *var, *value;
|
||||||
ngx_chain_t *cl;
|
ngx_chain_t *cl;
|
||||||
ngx_http_variable_value_t *v;
|
ngx_http_variable_value_t *vv;
|
||||||
|
|
||||||
var = params[NGX_HTTP_SSI_ECHO_VAR];
|
var = params[NGX_HTTP_SSI_ECHO_VAR];
|
||||||
value = NULL;
|
|
||||||
|
|
||||||
v = ngx_http_get_variable(r, var);
|
for (i = 0; i < var->len; i++) {
|
||||||
|
var->data[i] = ngx_toupper(var->data[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (v == NULL) {
|
vv = ngx_http_get_variable(r, var);
|
||||||
|
|
||||||
|
if (vv == NULL) {
|
||||||
return NGX_HTTP_SSI_ERROR;
|
return NGX_HTTP_SSI_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v == NGX_HTTP_VARIABLE_NOT_FOUND) {
|
if (vv == NGX_HTTP_VARIABLE_NOT_FOUND) {
|
||||||
value = params[NGX_HTTP_SSI_ECHO_DEFAULT];
|
value = params[NGX_HTTP_SSI_ECHO_DEFAULT];
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
@ -1172,7 +1174,7 @@ ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
value = &v->text;
|
value = &vv->text;
|
||||||
|
|
||||||
if (value->len == 0) {
|
if (value->len == 0) {
|
||||||
return NGX_OK;
|
return NGX_OK;
|
@ -19,7 +19,7 @@ static void *ngx_http_ssl_create_main_conf(ngx_conf_t *cf);
|
|||||||
static char *ngx_http_ssl_init_main_conf(ngx_conf_t *cf, void *conf);
|
static char *ngx_http_ssl_init_main_conf(ngx_conf_t *cf, void *conf);
|
||||||
static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf);
|
static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf);
|
||||||
static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf,
|
static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf,
|
||||||
void *parent, void *child);
|
void *parent, void *child);
|
||||||
|
|
||||||
|
|
||||||
static ngx_command_t ngx_http_ssl_commands[] = {
|
static ngx_command_t ngx_http_ssl_commands[] = {
|
||||||
@ -87,11 +87,13 @@ ngx_module_t ngx_http_ssl_module = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_ssl_create_main_conf(ngx_conf_t *cf)
|
static void *
|
||||||
|
ngx_http_ssl_create_main_conf(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
ngx_http_ssl_main_conf_t *mcf;
|
ngx_http_ssl_main_conf_t *mcf;
|
||||||
|
|
||||||
if (!(mcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssl_main_conf_t)))) {
|
mcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssl_main_conf_t));
|
||||||
|
if (mcf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +108,8 @@ static void *ngx_http_ssl_create_main_conf(ngx_conf_t *cf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_ssl_init_main_conf(ngx_conf_t *cf, void *conf)
|
static char *
|
||||||
|
ngx_http_ssl_init_main_conf(ngx_conf_t *cf, void *conf)
|
||||||
{
|
{
|
||||||
ngx_http_ssl_main_conf_t *mcf = conf;
|
ngx_http_ssl_main_conf_t *mcf = conf;
|
||||||
|
|
||||||
@ -137,11 +140,13 @@ static char *ngx_http_ssl_init_main_conf(ngx_conf_t *cf, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf)
|
static void *
|
||||||
|
ngx_http_ssl_create_srv_conf(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
ngx_http_ssl_srv_conf_t *scf;
|
ngx_http_ssl_srv_conf_t *scf;
|
||||||
|
|
||||||
if (!(scf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssl_srv_conf_t)))) {
|
scf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssl_srv_conf_t));
|
||||||
|
if (scf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,8 +167,8 @@ static void *ngx_http_ssl_create_srv_conf(ngx_conf_t *cf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf,
|
static char *
|
||||||
void *parent, void *child)
|
ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||||
{
|
{
|
||||||
ngx_http_ssl_srv_conf_t *prev = parent;
|
ngx_http_ssl_srv_conf_t *prev = parent;
|
||||||
ngx_http_ssl_srv_conf_t *conf = child;
|
ngx_http_ssl_srv_conf_t *conf = child;
|
||||||
@ -226,7 +231,8 @@ static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf,
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
static ngx_int_t ngx_http_ssl_init_process(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_http_ssl_init_process(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_http_ssl_srv_conf_t *sscf;
|
ngx_http_ssl_srv_conf_t *sscf;
|
||||||
|
@ -32,7 +32,7 @@ typedef struct {
|
|||||||
ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t size);
|
ngx_int_t ngx_http_ssl_read(ngx_http_request_t *r, u_char *buf, size_t size);
|
||||||
ngx_int_t ngx_http_ssl_shutdown(ngx_http_request_t *r);
|
ngx_int_t ngx_http_ssl_shutdown(ngx_http_request_t *r);
|
||||||
ngx_chain_t *ngx_http_ssl_write(ngx_connection_t *c, ngx_chain_t *in,
|
ngx_chain_t *ngx_http_ssl_write(ngx_connection_t *c, ngx_chain_t *in,
|
||||||
off_t limit);
|
off_t limit);
|
||||||
|
|
||||||
void ngx_http_ssl_close_connection(SSL *ssl, ngx_log_t *log);
|
void ngx_http_ssl_close_connection(SSL *ssl, ngx_log_t *log);
|
||||||
|
|
||||||
|
@ -75,10 +75,13 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
|||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_chain_t out;
|
ngx_chain_t out;
|
||||||
ngx_file_info_t fi;
|
ngx_file_info_t fi;
|
||||||
ngx_http_cleanup_t *file_cleanup, *redirect_cleanup;
|
ngx_http_cleanup_t *file_cleanup;
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
|
||||||
ngx_http_static_loc_conf_t *slcf;
|
|
||||||
#if (NGX_HTTP_CACHE)
|
#if (NGX_HTTP_CACHE)
|
||||||
|
ngx_http_cleanup_t *redirect_cleanup;
|
||||||
|
#endif
|
||||||
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
|
#if (NGX_HTTP_CACHE)
|
||||||
|
ngx_http_static_loc_conf_t *slcf;
|
||||||
uint32_t file_crc, redirect_crc;
|
uint32_t file_crc, redirect_crc;
|
||||||
ngx_http_cache_t *file, *redirect;
|
ngx_http_cache_t *file, *redirect;
|
||||||
#endif
|
#endif
|
||||||
@ -176,14 +179,18 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
|||||||
|
|
||||||
/* allocate cleanups */
|
/* allocate cleanups */
|
||||||
|
|
||||||
if (!(file_cleanup = ngx_push_array(&r->cleanup))) {
|
file_cleanup = ngx_array_push(&r->cleanup);
|
||||||
|
if (file_cleanup == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
file_cleanup->valid = 0;
|
file_cleanup->valid = 0;
|
||||||
|
|
||||||
|
#if (NGX_HTTP_CACHE)
|
||||||
|
|
||||||
slcf = ngx_http_get_module_loc_conf(r, ngx_http_static_module);
|
slcf = ngx_http_get_module_loc_conf(r, ngx_http_static_module);
|
||||||
if (slcf->redirect_cache) {
|
if (slcf->redirect_cache) {
|
||||||
if (!(redirect_cleanup = ngx_push_array(&r->cleanup))) {
|
redirect_cleanup = ngx_array_push(&r->cleanup);
|
||||||
|
if (redirect_cleanup == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
redirect_cleanup->valid = 0;
|
redirect_cleanup->valid = 0;
|
||||||
@ -192,8 +199,6 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
|||||||
redirect_cleanup = NULL;
|
redirect_cleanup = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_HTTP_CACHE)
|
|
||||||
|
|
||||||
/* look up an open files cache */
|
/* look up an open files cache */
|
||||||
|
|
||||||
if (clcf->open_files) {
|
if (clcf->open_files) {
|
||||||
@ -232,9 +237,9 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
|||||||
* should keep more popular redirects in cache.
|
* should keep more popular redirects in cache.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!(r->headers_out.location =
|
r->headers_out.location = ngx_http_add_header(&r->headers_out,
|
||||||
ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
|
ngx_http_headers_out);
|
||||||
{
|
if (r->headers_out.location == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,9 +288,9 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
|||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
|
||||||
"HTTP DIR: \"%s\"", name.data);
|
"HTTP DIR: \"%s\"", name.data);
|
||||||
|
|
||||||
if (!(r->headers_out.location =
|
r->headers_out.location = ngx_http_add_header(&r->headers_out,
|
||||||
ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
|
ngx_http_headers_out);
|
||||||
{
|
if (r->headers_out.location == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,11 +511,13 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
|||||||
if (!r->header_only) {
|
if (!r->header_only) {
|
||||||
/* we need to allocate all before the header would be sent */
|
/* we need to allocate all before the header would be sent */
|
||||||
|
|
||||||
if (!(b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)))) {
|
b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t)))) {
|
b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t));
|
||||||
|
if (b->file == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,7 +554,8 @@ static void *ngx_http_static_create_loc_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_static_loc_conf_t *conf;
|
ngx_http_static_loc_conf_t *conf;
|
||||||
|
|
||||||
if (!(conf = ngx_palloc(cf->pool, sizeof(ngx_http_static_loc_conf_t)))) {
|
conf = ngx_palloc(cf->pool, sizeof(ngx_http_static_loc_conf_t));
|
||||||
|
if (conf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +586,7 @@ static ngx_int_t ngx_http_static_init(ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||||
|
|
||||||
h = ngx_push_array(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
@ -88,7 +88,8 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
|
|||||||
+ 6 + 3 * NGX_ATOMIC_T_LEN
|
+ 6 + 3 * NGX_ATOMIC_T_LEN
|
||||||
+ sizeof("Reading: Writing: Waiting: \n") + 3 * NGX_ATOMIC_T_LEN;
|
+ sizeof("Reading: Writing: Waiting: \n") + 3 * NGX_ATOMIC_T_LEN;
|
||||||
|
|
||||||
if (!(b = ngx_create_temp_buf(r->pool, size))) {
|
b = ngx_create_temp_buf(r->pool, size);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,7 +618,7 @@ ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = ngx_cpymem(new, "; domain=", sizeof("; domain=") - 1);
|
p = ngx_cpymem(new, "; domain=", sizeof("; domain=") - 1);
|
||||||
p = ngx_cpymem(p, domain->data, domain->len);
|
ngx_memcpy(p, domain->data, domain->len);
|
||||||
|
|
||||||
domain->len += sizeof("; domain=") - 1;
|
domain->len += sizeof("; domain=") - 1;
|
||||||
domain->data = new;
|
domain->data = new;
|
||||||
@ -640,7 +640,7 @@ ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = ngx_cpymem(new, "; path=", sizeof("; path=") - 1);
|
p = ngx_cpymem(new, "; path=", sizeof("; path=") - 1);
|
||||||
p = ngx_cpymem(p, path->data, path->len);
|
ngx_memcpy(p, path->data, path->len);
|
||||||
|
|
||||||
path->len += sizeof("; path=") - 1;
|
path->len += sizeof("; path=") - 1;
|
||||||
path->data = new;
|
path->data = new;
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r);
|
static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r);
|
||||||
|
#if 0
|
||||||
static ngx_int_t ngx_http_proxy_cache_get(ngx_http_proxy_ctx_t *p);
|
static ngx_int_t ngx_http_proxy_cache_get(ngx_http_proxy_ctx_t *p);
|
||||||
|
#endif
|
||||||
|
|
||||||
static size_t ngx_http_proxy_log_proxy_state_getlen(ngx_http_request_t *r,
|
static size_t ngx_http_proxy_log_proxy_state_getlen(ngx_http_request_t *r,
|
||||||
uintptr_t data);
|
uintptr_t data);
|
||||||
@ -33,8 +35,6 @@ static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf,
|
|||||||
|
|
||||||
static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
void *conf);
|
void *conf);
|
||||||
static char *ngx_http_proxy_parse_upstream(ngx_str_t *url,
|
|
||||||
ngx_http_proxy_upstream_conf_t *u);
|
|
||||||
|
|
||||||
static char *ngx_http_proxy_set_x_var(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *ngx_http_proxy_set_x_var(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
void *conf);
|
void *conf);
|
||||||
@ -362,13 +362,20 @@ static ngx_str_t cache_reasons[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_str_t ngx_http_proxy_uri = ngx_string("/");
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r)
|
static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ngx_http_proxy_ctx_t *p;
|
ngx_http_proxy_ctx_t *p;
|
||||||
|
|
||||||
ngx_http_create_ctx(r, p, ngx_http_proxy_module,
|
p = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_ctx_t));
|
||||||
sizeof(ngx_http_proxy_ctx_t),
|
if (p == NULL) {
|
||||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_http_set_ctx(r, p, ngx_http_proxy_module);
|
||||||
|
|
||||||
|
|
||||||
p->lcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module);
|
p->lcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module);
|
||||||
p->request = r;
|
p->request = r;
|
||||||
@ -382,7 +389,8 @@ static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r)
|
|||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(p->state = ngx_array_push(&p->states))) {
|
p->state = ngx_array_push(&p->states);
|
||||||
|
if (p->state == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,7 +447,8 @@ static ngx_int_t ngx_http_proxy_cache_get(ngx_http_proxy_ctx_t *p)
|
|||||||
u = p->lcf->upstream;
|
u = p->lcf->upstream;
|
||||||
|
|
||||||
ctx.key.len = u->url.len + r->uri.len - u->location->len + r->args.len;
|
ctx.key.len = u->url.len + r->uri.len - u->location->len + r->args.len;
|
||||||
if (!(ctx.key.data = ngx_palloc(r->pool, ctx.key.len))) {
|
ctx.key.data = ngx_palloc(r->pool, ctx.key.len);
|
||||||
|
if (ctx.key.data == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1072,7 +1081,8 @@ static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_proxy_loc_conf_t *conf;
|
ngx_http_proxy_loc_conf_t *conf;
|
||||||
|
|
||||||
if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t)))) {
|
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t));
|
||||||
|
if (conf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1332,7 +1342,8 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
unix_upstream.url.data = url->data + 7;
|
unix_upstream.url.data = url->data + 7;
|
||||||
unix_upstream.uri_part = 1;
|
unix_upstream.uri_part = 1;
|
||||||
|
|
||||||
if (!(lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream))) {
|
lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream);
|
||||||
|
if (lcf->peers == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1359,7 +1370,8 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
inet_upstream.default_port_value = 80;
|
inet_upstream.default_port_value = 80;
|
||||||
inet_upstream.uri_part = 1;
|
inet_upstream.uri_part = 1;
|
||||||
|
|
||||||
if (!(lcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream))) {
|
lcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream);
|
||||||
|
if (lcf->peers == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1372,9 +1384,14 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
|
|
||||||
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
||||||
|
|
||||||
lcf->upstream->location = &clcf->name;
|
|
||||||
clcf->handler = ngx_http_proxy_handler;
|
clcf->handler = ngx_http_proxy_handler;
|
||||||
|
|
||||||
|
#if (NGX_PCRE)
|
||||||
|
lcf->upstream->location = clcf->regex ? &ngx_http_proxy_uri : &clcf->name;
|
||||||
|
#else
|
||||||
|
lcf->upstream->location = &clcf->name;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (clcf->name.data[clcf->name.len - 1] == '/') {
|
if (clcf->name.data[clcf->name.len - 1] == '/') {
|
||||||
clcf->auto_redirect = 1;
|
clcf->auto_redirect = 1;
|
||||||
}
|
}
|
||||||
@ -1409,7 +1426,8 @@ static char *ngx_http_proxy_set_x_var(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
for (i = 0; i < cmcf->variables.nelts; i++) {
|
for (i = 0; i < cmcf->variables.nelts; i++) {
|
||||||
if (ngx_strcasecmp(var[i].name.data, value[1].data) == 0) {
|
if (ngx_strcasecmp(var[i].name.data, value[1].data) == 0) {
|
||||||
|
|
||||||
if (!(index = ngx_array_push(lcf->x_vars))) {
|
index = ngx_array_push(lcf->x_vars);
|
||||||
|
if (index == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,8 @@ int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p,
|
|||||||
|
|
||||||
/* copy some header pointers and set up r->headers_out */
|
/* copy some header pointers and set up r->headers_out */
|
||||||
|
|
||||||
if (!(ho = ngx_list_push(&r->headers_out.headers))) {
|
ho = ngx_list_push(&r->headers_out.headers);
|
||||||
|
if (ho == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +163,8 @@ static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p,
|
|||||||
r = p->request;
|
r = p->request;
|
||||||
uc = p->lcf->upstream;
|
uc = p->lcf->upstream;
|
||||||
|
|
||||||
if (!(location = ngx_list_push(&r->headers_out.headers))) {
|
location = ngx_list_push(&r->headers_out.headers);
|
||||||
|
if (location == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +191,8 @@ static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p,
|
|||||||
|
|
||||||
location->value.len = uc->location->len
|
location->value.len = uc->location->len
|
||||||
+ (loc->value.len - uc->url.len) + 1;
|
+ (loc->value.len - uc->url.len) + 1;
|
||||||
if (!(location->value.data = ngx_palloc(r->pool, location->value.len))) {
|
location->value.data = ngx_palloc(r->pool, location->value.len);
|
||||||
|
if (location->value.data == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,8 @@ int ngx_http_proxy_request_upstream(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
r = p->request;
|
r = p->request;
|
||||||
|
|
||||||
if (!(u = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_upstream_t)))) {
|
u = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_upstream_t));
|
||||||
|
if (u == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ int ngx_http_proxy_request_upstream(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len, loc_len;
|
||||||
ngx_uint_t i, escape, *index;
|
ngx_uint_t i, escape, *index;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_chain_t *chain;
|
ngx_chain_t *chain;
|
||||||
@ -94,6 +95,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
|||||||
ngx_http_request_t *r;
|
ngx_http_request_t *r;
|
||||||
ngx_http_variable_t *var;
|
ngx_http_variable_t *var;
|
||||||
ngx_http_variable_value_t *value;
|
ngx_http_variable_value_t *value;
|
||||||
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
ngx_http_core_main_conf_t *cmcf;
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
ngx_http_proxy_upstream_conf_t *uc;
|
ngx_http_proxy_upstream_conf_t *uc;
|
||||||
|
|
||||||
@ -112,16 +114,23 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
|||||||
len = r->method_name.len;
|
len = r->method_name.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||||
|
|
||||||
|
#if (NGX_PCRE)
|
||||||
|
loc_len = (clcf->regex) ? 1 : clcf->name.len;
|
||||||
|
#else
|
||||||
|
loc_len = clcf->name.len;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (r->quoted_uri) {
|
if (r->quoted_uri) {
|
||||||
escape = 2 * ngx_escape_uri(NULL, r->uri.data + uc->location->len,
|
escape = 2 * ngx_escape_uri(NULL, r->uri.data + loc_len,
|
||||||
r->uri.len - uc->location->len,
|
r->uri.len - loc_len, NGX_ESCAPE_URI);
|
||||||
NGX_ESCAPE_URI);
|
|
||||||
} else {
|
} else {
|
||||||
escape = 0;
|
escape = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len += uc->uri.len
|
len += uc->uri.len
|
||||||
+ r->uri.len - uc->location->len + escape
|
+ r->uri.len - loc_len + escape
|
||||||
+ sizeof("?") - 1 + r->args.len
|
+ sizeof("?") - 1 + r->args.len
|
||||||
+ sizeof(http_version) - 1
|
+ sizeof(http_version) - 1
|
||||||
+ sizeof(connection_close_header) - 1
|
+ sizeof(connection_close_header) - 1
|
||||||
@ -190,7 +199,8 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
for (i = 0; i < p->lcf->x_vars->nelts; i++) {
|
for (i = 0; i < p->lcf->x_vars->nelts; i++) {
|
||||||
|
|
||||||
if (!(value = ngx_http_get_indexed_variable(r, index[i]))) {
|
value = ngx_http_get_indexed_variable(r, index[i]);
|
||||||
|
if (value == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,11 +243,13 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
|||||||
len++;
|
len++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(b = ngx_create_temp_buf(r->pool, len))) {
|
b = ngx_create_temp_buf(r->pool, len);
|
||||||
|
if (b == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(chain = ngx_alloc_chain_link(r->pool))) {
|
chain = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (chain == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,14 +270,13 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
|||||||
b->last = ngx_cpymem(b->last, uc->uri.data, uc->uri.len);
|
b->last = ngx_cpymem(b->last, uc->uri.data, uc->uri.len);
|
||||||
|
|
||||||
if (escape) {
|
if (escape) {
|
||||||
ngx_escape_uri(b->last, r->uri.data + uc->location->len,
|
ngx_escape_uri(b->last, r->uri.data + loc_len,
|
||||||
r->uri.len - uc->location->len, NGX_ESCAPE_URI);
|
r->uri.len - loc_len, NGX_ESCAPE_URI);
|
||||||
b->last += r->uri.len - uc->location->len + escape;
|
b->last += r->uri.len - loc_len + escape;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
b->last = ngx_cpymem(b->last,
|
b->last = ngx_cpymem(b->last, r->uri.data + loc_len,
|
||||||
r->uri.data + uc->location->len,
|
r->uri.len - loc_len);
|
||||||
r->uri.len - uc->location->len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r->args.len > 0) {
|
if (r->args.len > 0) {
|
||||||
@ -379,7 +390,8 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
|||||||
if (p->lcf->x_vars) {
|
if (p->lcf->x_vars) {
|
||||||
for (i = 0; i < p->lcf->x_vars->nelts; i++) {
|
for (i = 0; i < p->lcf->x_vars->nelts; i++) {
|
||||||
|
|
||||||
if (!(value = ngx_http_get_indexed_variable(r, index[i]))) {
|
value = ngx_http_get_indexed_variable(r, index[i]);
|
||||||
|
if (value == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +518,8 @@ static void ngx_http_proxy_init_upstream(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!(cl = ngx_http_proxy_create_request(p))) {
|
cl = ngx_http_proxy_create_request(p);
|
||||||
|
if (cl == NULL) {
|
||||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -517,7 +530,8 @@ static void ngx_http_proxy_init_upstream(ngx_http_request_t *r)
|
|||||||
|
|
||||||
r->request_body->bufs = cl;
|
r->request_body->bufs = cl;
|
||||||
|
|
||||||
if (!(ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_log_ctx_t)))) {
|
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_log_ctx_t));
|
||||||
|
if (ctx == NULL) {
|
||||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -531,7 +545,8 @@ static void ngx_http_proxy_init_upstream(ngx_http_request_t *r)
|
|||||||
r->connection->log->handler = ngx_http_proxy_log_error;
|
r->connection->log->handler = ngx_http_proxy_log_error;
|
||||||
p->action = "connecting to upstream";
|
p->action = "connecting to upstream";
|
||||||
|
|
||||||
if (!(output = ngx_pcalloc(r->pool, sizeof(ngx_output_chain_ctx_t)))) {
|
output = ngx_pcalloc(r->pool, sizeof(ngx_output_chain_ctx_t));
|
||||||
|
if (output == NULL) {
|
||||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -544,7 +559,8 @@ static void ngx_http_proxy_init_upstream(ngx_http_request_t *r)
|
|||||||
output->tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
|
output->tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
|
||||||
output->output_filter = ngx_chain_writer;
|
output->output_filter = ngx_chain_writer;
|
||||||
|
|
||||||
if (!(writer = ngx_palloc(r->pool, sizeof(ngx_chain_writer_ctx_t)))) {
|
writer = ngx_palloc(r->pool, sizeof(ngx_chain_writer_ctx_t));
|
||||||
|
if (writer == NULL) {
|
||||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -603,7 +619,8 @@ static void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
state = p->state->cache_state;
|
state = p->state->cache_state;
|
||||||
|
|
||||||
if (!(p->state = ngx_push_array(&p->states))) {
|
p->state = ngx_array_push(&p->states);
|
||||||
|
if (p->state == NULL) {
|
||||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -775,7 +792,8 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
|
|||||||
if (r->request_body->buf) {
|
if (r->request_body->buf) {
|
||||||
if (r->request_body->temp_file) {
|
if (r->request_body->temp_file) {
|
||||||
|
|
||||||
if (!(output->free = ngx_alloc_chain_link(r->pool))) {
|
output->free = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (output->free == NULL) {
|
||||||
ngx_http_proxy_finalize_request(p,
|
ngx_http_proxy_finalize_request(p,
|
||||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
@ -1005,7 +1023,7 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev)
|
|||||||
rc = ngx_http_proxy_parse_status_line(p);
|
rc = ngx_http_proxy_parse_status_line(p);
|
||||||
|
|
||||||
if (rc == NGX_AGAIN) {
|
if (rc == NGX_AGAIN) {
|
||||||
if (p->header_in->pos == p->header_in->last) {
|
if (p->header_in->pos == p->header_in->end) {
|
||||||
ngx_log_error(NGX_LOG_ERR, rev->log, 0,
|
ngx_log_error(NGX_LOG_ERR, rev->log, 0,
|
||||||
"upstream sent too long status line");
|
"upstream sent too long status line");
|
||||||
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_INVALID_HEADER);
|
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_INVALID_HEADER);
|
||||||
@ -1158,7 +1176,8 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev)
|
|||||||
|
|
||||||
/* a header line has been parsed successfully */
|
/* a header line has been parsed successfully */
|
||||||
|
|
||||||
if (!(h = ngx_list_push(&p->upstream->headers_in.headers))) {
|
h = ngx_list_push(&p->upstream->headers_in.headers);
|
||||||
|
if (h == NULL) {
|
||||||
ngx_http_proxy_finalize_request(p,
|
ngx_http_proxy_finalize_request(p,
|
||||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
@ -1315,6 +1334,11 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
rc = ngx_http_send_header(r);
|
rc = ngx_http_send_header(r);
|
||||||
|
|
||||||
|
if (rc == NGX_ERROR || rc > NGX_OK) {
|
||||||
|
ngx_http_proxy_finalize_request(p, rc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
p->header_sent = 1;
|
p->header_sent = 1;
|
||||||
|
|
||||||
if (p->cache && p->cache->ctx.file.fd != NGX_INVALID_FILE) {
|
if (p->cache && p->cache->ctx.file.fd != NGX_INVALID_FILE) {
|
||||||
@ -1361,7 +1385,8 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p)
|
|||||||
|
|
||||||
ep->cachable = p->cachable;
|
ep->cachable = p->cachable;
|
||||||
|
|
||||||
if (!(ep->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) {
|
ep->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
|
||||||
|
if (ep->temp_file == NULL) {
|
||||||
ngx_http_proxy_finalize_request(p, 0);
|
ngx_http_proxy_finalize_request(p, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1381,7 +1406,8 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p)
|
|||||||
ep->max_temp_file_size = p->lcf->max_temp_file_size;
|
ep->max_temp_file_size = p->lcf->max_temp_file_size;
|
||||||
ep->temp_file_write_size = p->lcf->temp_file_write_size;
|
ep->temp_file_write_size = p->lcf->temp_file_write_size;
|
||||||
|
|
||||||
if (!(ep->preread_bufs = ngx_alloc_chain_link(r->pool))) {
|
ep->preread_bufs = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (ep->preread_bufs == NULL) {
|
||||||
ngx_http_proxy_finalize_request(p, 0);
|
ngx_http_proxy_finalize_request(p, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1467,7 +1493,6 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev)
|
|||||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
|
||||||
"http proxy process upstream");
|
"http proxy process upstream");
|
||||||
p = c->data;
|
p = c->data;
|
||||||
r = p->request;
|
|
||||||
p->action = "reading upstream body";
|
p->action = "reading upstream body";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,8 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
/* the main http context */
|
/* the main http context */
|
||||||
|
|
||||||
if (!(ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)))) {
|
ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
|
||||||
|
if (ctx == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,19 +163,22 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (module->create_main_conf) {
|
if (module->create_main_conf) {
|
||||||
if (!(ctx->main_conf[mi] = module->create_main_conf(cf))) {
|
ctx->main_conf[mi] = module->create_main_conf(cf);
|
||||||
|
if (ctx->main_conf[mi] == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module->create_srv_conf) {
|
if (module->create_srv_conf) {
|
||||||
if (!(ctx->srv_conf[mi] = module->create_srv_conf(cf))) {
|
ctx->srv_conf[mi] = module->create_srv_conf(cf);
|
||||||
|
if (ctx->srv_conf[mi] == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module->create_loc_conf) {
|
if (module->create_loc_conf) {
|
||||||
if (!(ctx->loc_conf[mi] = module->create_loc_conf(cf))) {
|
ctx->loc_conf[mi] = module->create_loc_conf(cf);
|
||||||
|
if (ctx->loc_conf[mi] == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,13 +265,14 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
|
|
||||||
/* we needed http{}'s cf->ctx while the merging configuration */
|
/* we needed http{}'s cf->ctx while the merging configuration */
|
||||||
|
|
||||||
*cf = pcf;
|
*cf = pcf;
|
||||||
|
|
||||||
|
|
||||||
/* init lists of the handlers */
|
/* init lists of the handlers */
|
||||||
|
|
||||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers,
|
if (ngx_array_init(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers,
|
||||||
cf->pool, 1, sizeof(ngx_http_handler_pt)) == NGX_ERROR)
|
cf->pool, 1, sizeof(ngx_http_handler_pt)) != NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -278,14 +283,14 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
/* the special find config phase for a single handler */
|
/* the special find config phase for a single handler */
|
||||||
|
|
||||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers,
|
if (ngx_array_init(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers,
|
||||||
cf->pool, 1, sizeof(ngx_http_handler_pt)) == NGX_ERROR)
|
cf->pool, 1, sizeof(ngx_http_handler_pt)) != NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].type = NGX_OK;
|
cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].type = NGX_OK;
|
||||||
|
|
||||||
h = ngx_push_array(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers);
|
h = ngx_array_push(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers);
|
||||||
if (h == NULL) {
|
if (h == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -294,7 +299,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
|
|
||||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers,
|
if (ngx_array_init(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers,
|
||||||
cf->pool, 1, sizeof(ngx_http_handler_pt)) == NGX_ERROR)
|
cf->pool, 1, sizeof(ngx_http_handler_pt)) != NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -303,7 +308,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
|
|
||||||
if (ngx_array_init(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers,
|
if (ngx_array_init(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers,
|
||||||
cf->pool, 4, sizeof(ngx_http_handler_pt)) == NGX_ERROR)
|
cf->pool, 4, sizeof(ngx_http_handler_pt)) != NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -317,7 +322,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (ngx_array_init(&in_ports, cf->pool, 10, sizeof(ngx_http_in_port_t))
|
if (ngx_array_init(&in_ports, cf->pool, 10, sizeof(ngx_http_in_port_t))
|
||||||
== NGX_ERROR)
|
!= NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -354,7 +359,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
/* the address is already in the address list */
|
/* the address is already in the address list */
|
||||||
|
|
||||||
if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
|
if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
|
||||||
== NGX_ERROR)
|
!= NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -386,7 +391,8 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
/* the INADDR_ANY is always the last address */
|
/* the INADDR_ANY is always the last address */
|
||||||
|
|
||||||
if (!(inaddr = ngx_array_push(&in_port[p].addrs))) {
|
inaddr = ngx_array_push(&in_port[p].addrs);
|
||||||
|
if (inaddr == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +413,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
in_addr[a].core_srv_conf = cscfp[s];
|
in_addr[a].core_srv_conf = cscfp[s];
|
||||||
|
|
||||||
if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
|
if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
|
||||||
== NGX_ERROR)
|
!= NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -426,7 +432,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (ngx_http_add_address(cf, &in_port[p], &lscf[l],
|
if (ngx_http_add_address(cf, &in_port[p], &lscf[l],
|
||||||
cscfp[s]) == NGX_ERROR)
|
cscfp[s]) != NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -438,14 +444,16 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
/* add the port to the in_port list */
|
/* add the port to the in_port list */
|
||||||
|
|
||||||
if (!(in_port = ngx_array_push(&in_ports))) {
|
in_port = ngx_array_push(&in_ports);
|
||||||
|
if (in_port == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_port->port = lscf[l].port;
|
in_port->port = lscf[l].port;
|
||||||
in_port->addrs.elts = NULL;
|
in_port->addrs.elts = NULL;
|
||||||
|
|
||||||
if (!(in_port->port_text.data = ngx_palloc(cf->pool, 7))) {
|
in_port->port_text.data = ngx_palloc(cf->pool, 7);
|
||||||
|
if (in_port->port_text.data == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +462,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
- in_port->port_text.data;
|
- in_port->port_text.data;
|
||||||
|
|
||||||
if (ngx_http_add_address(cf, in_port, &lscf[l], cscfp[s])
|
if (ngx_http_add_address(cf, in_port, &lscf[l], cscfp[s])
|
||||||
== NGX_ERROR)
|
!= NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -484,7 +492,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
for (n = 0; n < in_addr[a].names.nelts; n++) {
|
for (n = 0; n < in_addr[a].names.nelts; n++) {
|
||||||
if (in_addr[a].core_srv_conf != name[n].core_srv_conf
|
if (in_addr[a].core_srv_conf != name[n].core_srv_conf
|
||||||
|| name[n].core_srv_conf->restrict_host_names
|
|| name[n].core_srv_conf->restrict_host_names
|
||||||
!= NGX_HTTP_RESTRICT_HOST_OFF)
|
!= NGX_HTTP_RESTRICT_HOST_OFF)
|
||||||
{
|
{
|
||||||
virtual_names = 1;
|
virtual_names = 1;
|
||||||
break;
|
break;
|
||||||
@ -496,7 +504,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
for (n = 0; n < in_addr[a].wildcards.nelts; n++) {
|
for (n = 0; n < in_addr[a].wildcards.nelts; n++) {
|
||||||
if (in_addr[a].core_srv_conf != name[n].core_srv_conf
|
if (in_addr[a].core_srv_conf != name[n].core_srv_conf
|
||||||
|| name[n].core_srv_conf->restrict_host_names
|
|| name[n].core_srv_conf->restrict_host_names
|
||||||
!= NGX_HTTP_RESTRICT_HOST_OFF)
|
!= NGX_HTTP_RESTRICT_HOST_OFF)
|
||||||
{
|
{
|
||||||
virtual_names = 1;
|
virtual_names = 1;
|
||||||
break;
|
break;
|
||||||
@ -532,7 +540,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
for (n = 0; n < cmcf->server_names_hash; n++) {
|
for (n = 0; n < cmcf->server_names_hash; n++) {
|
||||||
if (ngx_array_init(&in_addr[a].hash[n], cf->pool, 5,
|
if (ngx_array_init(&in_addr[a].hash[n], cf->pool, 5,
|
||||||
sizeof(ngx_http_server_name_t)) == NGX_ERROR)
|
sizeof(ngx_http_server_name_t)) != NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
@ -544,7 +552,8 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
name[s].name.len,
|
name[s].name.len,
|
||||||
cmcf->server_names_hash);
|
cmcf->server_names_hash);
|
||||||
|
|
||||||
if (!(s_name = ngx_array_push(&in_addr[a].hash[key]))) {
|
s_name = ngx_array_push(&in_addr[a].hash[key]);
|
||||||
|
if (s_name == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,13 +584,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ls->backlog = -1;
|
ls->backlog = -1;
|
||||||
#if 0
|
|
||||||
#if 0
|
|
||||||
ls->nonblocking = 1;
|
|
||||||
#else
|
|
||||||
ls->nonblocking = 0;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
ls->addr_ntop = 1;
|
ls->addr_ntop = 1;
|
||||||
|
|
||||||
ls->handler = ngx_http_init_connection;
|
ls->handler = ngx_http_init_connection;
|
||||||
@ -612,19 +615,21 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
* the separate ngx_http_in_port_t for the all bindings
|
* the separate ngx_http_in_port_t for the all bindings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ngx_test_null(inport,
|
inport = ngx_palloc(cf->pool, sizeof(ngx_http_in_port_t));
|
||||||
ngx_palloc(cf->pool,
|
if (inport == NULL) {
|
||||||
sizeof(ngx_http_in_port_t)),
|
return NGX_CONF_ERROR;
|
||||||
NGX_CONF_ERROR);
|
}
|
||||||
|
|
||||||
inport->port = in_port[p].port;
|
inport->port = in_port[p].port;
|
||||||
inport->port_text = in_port[p].port_text;
|
inport->port_text = in_port[p].port_text;
|
||||||
|
|
||||||
/* init list of the addresses ... */
|
/* init list of the addresses ... */
|
||||||
|
|
||||||
ngx_init_array(inport->addrs, cf->pool, 1,
|
if (ngx_array_init(&inport->addrs, cf->pool, 1,
|
||||||
sizeof(ngx_http_in_addr_t),
|
sizeof(ngx_http_in_addr_t)) != NGX_OK)
|
||||||
NGX_CONF_ERROR);
|
{
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* ... and set up it with the first address */
|
/* ... and set up it with the first address */
|
||||||
|
|
||||||
@ -636,7 +641,7 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
/* prepare for the next cycle */
|
/* prepare for the next cycle */
|
||||||
|
|
||||||
in_port[p].addrs.elts = (char *) in_port[p].addrs.elts
|
in_port[p].addrs.elts = (char *) in_port[p].addrs.elts
|
||||||
+ in_port[p].addrs.size;
|
+ in_port[p].addrs.size;
|
||||||
in_port[p].addrs.nelts--;
|
in_port[p].addrs.nelts--;
|
||||||
|
|
||||||
in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts;
|
in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts;
|
||||||
@ -705,13 +710,14 @@ ngx_http_add_address(ngx_conf_t *cf, ngx_http_in_port_t *in_port,
|
|||||||
|
|
||||||
if (in_port->addrs.elts == NULL) {
|
if (in_port->addrs.elts == NULL) {
|
||||||
if (ngx_array_init(&in_port->addrs, cf->pool, 10,
|
if (ngx_array_init(&in_port->addrs, cf->pool, 10,
|
||||||
sizeof(ngx_http_in_addr_t)) == NGX_ERROR)
|
sizeof(ngx_http_in_addr_t)) != NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(in_addr = ngx_array_push(&in_port->addrs))) {
|
in_addr = ngx_array_push(&in_port->addrs);
|
||||||
|
if (in_addr == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +756,7 @@ ngx_http_add_names(ngx_conf_t *cf, ngx_http_in_addr_t *in_addr,
|
|||||||
|
|
||||||
if (in_addr->names.elts == NULL) {
|
if (in_addr->names.elts == NULL) {
|
||||||
if (ngx_array_init(&in_addr->names, cf->pool, 10,
|
if (ngx_array_init(&in_addr->names, cf->pool, 10,
|
||||||
sizeof(ngx_http_server_name_t)) == NGX_ERROR)
|
sizeof(ngx_http_server_name_t)) != NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -758,7 +764,7 @@ ngx_http_add_names(ngx_conf_t *cf, ngx_http_in_addr_t *in_addr,
|
|||||||
|
|
||||||
if (in_addr->wildcards.elts == NULL) {
|
if (in_addr->wildcards.elts == NULL) {
|
||||||
if (ngx_array_init(&in_addr->wildcards, cf->pool, 10,
|
if (ngx_array_init(&in_addr->wildcards, cf->pool, 10,
|
||||||
sizeof(ngx_http_server_name_t)) == NGX_ERROR)
|
sizeof(ngx_http_server_name_t)) != NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -785,7 +791,8 @@ ngx_http_add_names(ngx_conf_t *cf, ngx_http_in_addr_t *in_addr,
|
|||||||
array = &in_addr->names;
|
array = &in_addr->names;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(name = ngx_array_push(array))) {
|
name = ngx_array_push(array);
|
||||||
|
if (name == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ typedef struct ngx_http_request_s ngx_http_request_t;
|
|||||||
typedef struct ngx_http_log_ctx_s ngx_http_log_ctx_t;
|
typedef struct ngx_http_log_ctx_s ngx_http_log_ctx_t;
|
||||||
typedef struct ngx_http_cleanup_s ngx_http_cleanup_t;
|
typedef struct ngx_http_cleanup_s ngx_http_cleanup_t;
|
||||||
typedef struct ngx_http_in_addr_s ngx_http_in_addr_t;
|
typedef struct ngx_http_in_addr_s ngx_http_in_addr_t;
|
||||||
|
typedef struct ngx_http_variable_value_s ngx_http_variable_value_t;
|
||||||
|
|
||||||
|
|
||||||
#if (NGX_HTTP_CACHE)
|
#if (NGX_HTTP_CACHE)
|
||||||
#include <ngx_http_cache.h>
|
#include <ngx_http_cache.h>
|
||||||
@ -27,7 +29,7 @@ typedef struct ngx_http_in_addr_s ngx_http_in_addr_t;
|
|||||||
#include <ngx_http_request.h>
|
#include <ngx_http_request.h>
|
||||||
#include <ngx_http_config.h>
|
#include <ngx_http_config.h>
|
||||||
#include <ngx_http_busy_lock.h>
|
#include <ngx_http_busy_lock.h>
|
||||||
#include <ngx_http_log_handler.h>
|
#include <ngx_http_log_module.h>
|
||||||
#include <ngx_http_core_module.h>
|
#include <ngx_http_core_module.h>
|
||||||
#include <ngx_http_variables.h>
|
#include <ngx_http_variables.h>
|
||||||
|
|
||||||
@ -46,16 +48,7 @@ struct ngx_http_log_ctx_s {
|
|||||||
#define ngx_http_get_module_err_ctx(r, module) \
|
#define ngx_http_get_module_err_ctx(r, module) \
|
||||||
((r)->err_ctx ? (r)->err_ctx[module.ctx_index] : (r)->ctx[module.ctx_index])
|
((r)->err_ctx ? (r)->err_ctx[module.ctx_index] : (r)->ctx[module.ctx_index])
|
||||||
|
|
||||||
/* STUB */
|
|
||||||
#define ngx_http_create_ctx(r, cx, module, size, error) \
|
|
||||||
do { \
|
|
||||||
ngx_test_null(cx, ngx_pcalloc(r->pool, size), error); \
|
|
||||||
r->ctx[module.ctx_index] = cx; \
|
|
||||||
} while (0)
|
|
||||||
/**/
|
|
||||||
|
|
||||||
#define ngx_http_set_ctx(r, c, module) r->ctx[module.ctx_index] = c;
|
#define ngx_http_set_ctx(r, c, module) r->ctx[module.ctx_index] = c;
|
||||||
|
|
||||||
#define ngx_http_delete_ctx(r, module) r->ctx[module.ctx_index] = NULL;
|
#define ngx_http_delete_ctx(r, module) r->ctx[module.ctx_index] = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,13 +205,15 @@ char *ngx_http_set_busy_lock_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ngx_calloc_shared() */
|
/* ngx_calloc_shared() */
|
||||||
if (!(bl = ngx_pcalloc(cf->pool, sizeof(ngx_http_busy_lock_t)))) {
|
bl = ngx_pcalloc(cf->pool, sizeof(ngx_http_busy_lock_t));
|
||||||
|
if (bl == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
*blp = bl;
|
*blp = bl;
|
||||||
|
|
||||||
/* ngx_calloc_shared() */
|
/* ngx_calloc_shared() */
|
||||||
if (!(bl->mutex = ngx_pcalloc(cf->pool, sizeof(ngx_event_mutex_t)))) {
|
bl->mutex = ngx_pcalloc(cf->pool, sizeof(ngx_event_mutex_t));
|
||||||
|
if (bl->mutex == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,15 +59,15 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define ngx_http_conf_get_module_main_conf(cf, module) \
|
#define ngx_http_conf_get_module_main_conf(cf, module) \
|
||||||
((ngx_http_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index]
|
((ngx_http_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index]
|
||||||
#define ngx_http_conf_get_module_srv_conf(cf, module) \
|
#define ngx_http_conf_get_module_srv_conf(cf, module) \
|
||||||
((ngx_http_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index]
|
((ngx_http_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index]
|
||||||
#define ngx_http_conf_get_module_loc_conf(cf, module) \
|
#define ngx_http_conf_get_module_loc_conf(cf, module) \
|
||||||
((ngx_http_conf_ctx_t *) cf->ctx)->loc_conf[module.ctx_index]
|
((ngx_http_conf_ctx_t *) cf->ctx)->loc_conf[module.ctx_index]
|
||||||
|
|
||||||
#define ngx_http_cycle_get_module_main_conf(cycle, module) \
|
#define ngx_http_cycle_get_module_main_conf(cycle, module) \
|
||||||
((ngx_http_conf_ctx_t *) \
|
((ngx_http_conf_ctx_t *) \
|
||||||
cycle->conf_ctx[ngx_http_module.index])->main_conf[module.ctx_index]
|
cycle->conf_ctx[ngx_http_module.index])->main_conf[module.ctx_index]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,20 +16,20 @@ typedef struct {
|
|||||||
|
|
||||||
static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf);
|
static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf);
|
||||||
static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf,
|
static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf,
|
||||||
void *parent, void *child);
|
void *parent, void *child);
|
||||||
static ngx_int_t ngx_http_copy_filter_init(ngx_cycle_t *cycle);
|
static ngx_int_t ngx_http_copy_filter_init(ngx_cycle_t *cycle);
|
||||||
|
|
||||||
|
|
||||||
static ngx_command_t ngx_http_copy_filter_commands[] = {
|
static ngx_command_t ngx_http_copy_filter_commands[] = {
|
||||||
|
|
||||||
{ngx_string("output_buffers"),
|
{ ngx_string("output_buffers"),
|
||||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
|
||||||
ngx_conf_set_bufs_slot,
|
ngx_conf_set_bufs_slot,
|
||||||
NGX_HTTP_LOC_CONF_OFFSET,
|
NGX_HTTP_LOC_CONF_OFFSET,
|
||||||
offsetof(ngx_http_copy_filter_conf_t, bufs),
|
offsetof(ngx_http_copy_filter_conf_t, bufs),
|
||||||
NULL},
|
NULL },
|
||||||
|
|
||||||
ngx_null_command
|
ngx_null_command
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -60,7 +60,8 @@ ngx_module_t ngx_http_copy_filter_module = {
|
|||||||
static ngx_http_output_body_filter_pt ngx_http_next_filter;
|
static ngx_http_output_body_filter_pt ngx_http_next_filter;
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
static ngx_int_t
|
||||||
|
ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
||||||
{
|
{
|
||||||
ngx_output_chain_ctx_t *ctx;
|
ngx_output_chain_ctx_t *ctx;
|
||||||
ngx_http_copy_filter_conf_t *conf;
|
ngx_http_copy_filter_conf_t *conf;
|
||||||
@ -76,8 +77,12 @@ ngx_int_t ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
conf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
|
conf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
|
||||||
ngx_http_copy_filter_module);
|
ngx_http_copy_filter_module);
|
||||||
|
|
||||||
ngx_http_create_ctx(r, ctx, ngx_http_copy_filter_module,
|
ctx = ngx_pcalloc(r->pool, sizeof(ngx_output_chain_ctx_t));
|
||||||
sizeof(ngx_output_chain_ctx_t), NGX_ERROR);
|
if (ctx == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_http_set_ctx(r, ctx, ngx_http_copy_filter_module);
|
||||||
|
|
||||||
ctx->sendfile = r->connection->sendfile;
|
ctx->sendfile = r->connection->sendfile;
|
||||||
ctx->need_in_memory = r->filter_need_in_memory;
|
ctx->need_in_memory = r->filter_need_in_memory;
|
||||||
@ -96,13 +101,15 @@ ngx_int_t ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf)
|
static void *
|
||||||
|
ngx_http_copy_filter_create_conf(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
ngx_http_copy_filter_conf_t *conf;
|
ngx_http_copy_filter_conf_t *conf;
|
||||||
|
|
||||||
ngx_test_null(conf,
|
conf = ngx_palloc(cf->pool, sizeof(ngx_http_copy_filter_conf_t));
|
||||||
ngx_palloc(cf->pool, sizeof(ngx_http_copy_filter_conf_t)),
|
if (conf == NULL) {
|
||||||
NULL);
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
conf->bufs.num = 0;
|
conf->bufs.num = 0;
|
||||||
|
|
||||||
@ -110,8 +117,8 @@ static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf,
|
static char *
|
||||||
void *parent, void *child)
|
ngx_http_copy_filter_merge_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||||
{
|
{
|
||||||
ngx_http_copy_filter_conf_t *prev = parent;
|
ngx_http_copy_filter_conf_t *prev = parent;
|
||||||
ngx_http_copy_filter_conf_t *conf = child;
|
ngx_http_copy_filter_conf_t *conf = child;
|
||||||
@ -122,7 +129,8 @@ static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_copy_filter_init(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_http_copy_filter_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_http_next_filter = ngx_http_top_body_filter;
|
ngx_http_next_filter = ngx_http_top_body_filter;
|
||||||
ngx_http_top_body_filter = ngx_http_copy_filter;
|
ngx_http_top_body_filter = ngx_http_copy_filter;
|
@ -785,7 +785,8 @@ ngx_http_set_content_type(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i < r->exten.len) {
|
if (i < r->exten.len) {
|
||||||
if (!(p = ngx_palloc(r->pool, r->exten.len))) {
|
p = ngx_palloc(r->pool, r->exten.len);
|
||||||
|
if (p == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -897,7 +898,8 @@ ngx_http_set_exten(ngx_http_request_t *r)
|
|||||||
r->exten.len = r->uri.len - i - 1;
|
r->exten.len = r->uri.len - i - 1;
|
||||||
|
|
||||||
if (r->exten.len > 0) {
|
if (r->exten.len > 0) {
|
||||||
if (!(r->exten.data = ngx_palloc(r->pool, r->exten.len + 1))) {
|
r->exten.data = ngx_palloc(r->pool, r->exten.len + 1);
|
||||||
|
if (r->exten.data == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -997,7 +999,8 @@ ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
|||||||
ngx_http_core_srv_conf_t *cscf, **cscfp;
|
ngx_http_core_srv_conf_t *cscf, **cscfp;
|
||||||
ngx_http_core_main_conf_t *cmcf;
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
|
|
||||||
if (!(ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)))) {
|
ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
|
||||||
|
if (ctx == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1026,7 +1029,8 @@ ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
|||||||
module = ngx_modules[m]->ctx;
|
module = ngx_modules[m]->ctx;
|
||||||
|
|
||||||
if (module->create_srv_conf) {
|
if (module->create_srv_conf) {
|
||||||
if (!(mconf = module->create_srv_conf(cf))) {
|
mconf = module->create_srv_conf(cf);
|
||||||
|
if (mconf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1034,7 +1038,8 @@ ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (module->create_loc_conf) {
|
if (module->create_loc_conf) {
|
||||||
if (!(mconf = module->create_loc_conf(cf))) {
|
mconf = module->create_loc_conf(cf);
|
||||||
|
if (mconf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1051,7 +1056,8 @@ ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
|||||||
|
|
||||||
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
|
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
|
||||||
|
|
||||||
if (!(cscfp = ngx_array_push(&cmcf->servers))) {
|
cscfp = ngx_array_push(&cmcf->servers);
|
||||||
|
if (cscfp == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1095,7 +1101,8 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
|||||||
u_char errstr[NGX_MAX_CONF_ERRSTR];
|
u_char errstr[NGX_MAX_CONF_ERRSTR];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)))) {
|
ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
|
||||||
|
if (ctx == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,7 +1188,9 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
|||||||
|
|
||||||
if (pclcf->name.len == 0) {
|
if (pclcf->name.len == 0) {
|
||||||
cscf = ctx->srv_conf[ngx_http_core_module.ctx_index];
|
cscf = ctx->srv_conf[ngx_http_core_module.ctx_index];
|
||||||
if (!(clcfp = ngx_array_push(&cscf->locations))) {
|
|
||||||
|
clcfp = ngx_array_push(&cscf->locations);
|
||||||
|
if (clcfp == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1214,11 +1223,15 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pclcf->locations.elts == NULL) {
|
if (pclcf->locations.elts == NULL) {
|
||||||
ngx_init_array(pclcf->locations, cf->pool, 4, sizeof(void *),
|
if (ngx_array_init(&pclcf->locations, cf->pool, 4, sizeof(void *))
|
||||||
NGX_CONF_ERROR);
|
!= NGX_OK)
|
||||||
|
{
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(clcfp = ngx_push_array(&pclcf->locations))) {
|
clcfp = ngx_array_push(&pclcf->locations);
|
||||||
|
if (clcfp == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1347,7 +1360,8 @@ ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
|||||||
for (i = 1; i < cf->args->nelts; i++) {
|
for (i = 1; i < cf->args->nelts; i++) {
|
||||||
ngx_http_types_hash_key(key, value[i]);
|
ngx_http_types_hash_key(key, value[i]);
|
||||||
|
|
||||||
if (!(type = ngx_array_push(&lcf->types[key]))) {
|
type = ngx_array_push(&lcf->types[key]);
|
||||||
|
if (type == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1364,7 +1378,8 @@ ngx_http_core_create_main_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_core_main_conf_t *cmcf;
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
|
|
||||||
if (!(cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t)))) {
|
cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t));
|
||||||
|
if (cmcf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1403,7 +1418,8 @@ ngx_http_core_create_srv_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_core_srv_conf_t *cscf;
|
ngx_http_core_srv_conf_t *cscf;
|
||||||
|
|
||||||
if (!(cscf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t)))) {
|
cscf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t));
|
||||||
|
if (cscf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1455,7 +1471,8 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||||||
/* TODO: it does not merge, it inits only */
|
/* TODO: it does not merge, it inits only */
|
||||||
|
|
||||||
if (conf->listen.nelts == 0) {
|
if (conf->listen.nelts == 0) {
|
||||||
if (!(ls = ngx_array_push(&conf->listen))) {
|
ls = ngx_array_push(&conf->listen);
|
||||||
|
if (ls == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1470,11 +1487,13 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (conf->server_names.nelts == 0) {
|
if (conf->server_names.nelts == 0) {
|
||||||
if (!(sn = ngx_array_push(&conf->server_names))) {
|
sn = ngx_array_push(&conf->server_names);
|
||||||
|
if (sn == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sn->name.data = ngx_palloc(cf->pool, NGX_MAXHOSTNAMELEN))) {
|
sn->name.data = ngx_palloc(cf->pool, NGX_MAXHOSTNAMELEN);
|
||||||
|
if (sn->name.data == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1528,7 +1547,8 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_core_loc_conf_t *lcf;
|
ngx_http_core_loc_conf_t *lcf;
|
||||||
|
|
||||||
if (!(lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t)))) {
|
lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t));
|
||||||
|
if (lcf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1618,7 +1638,8 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
|
|||||||
ngx_http_types_hash_key(key,
|
ngx_http_types_hash_key(key,
|
||||||
ngx_http_core_default_types[i].exten);
|
ngx_http_core_default_types[i].exten);
|
||||||
|
|
||||||
if (!(type = ngx_array_push(&conf->types[key]))) {
|
type = ngx_array_push(&conf->types[key]);
|
||||||
|
if (type == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1700,7 +1721,8 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
* add resolved name to server names ???
|
* add resolved name to server names ???
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!(ls = ngx_array_push(&scf->listen))) {
|
ls = ngx_array_push(&scf->listen);
|
||||||
|
if (ls == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1796,7 +1818,8 @@ ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sn = ngx_array_push(&scf->server_names))) {
|
sn = ngx_array_push(&scf->server_names);
|
||||||
|
if (sn == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1908,7 +1931,8 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i < cf->args->nelts - n; i++) {
|
for (i = 1; i < cf->args->nelts - n; i++) {
|
||||||
if (!(err = ngx_array_push(lcf->error_pages))) {
|
err = ngx_array_push(lcf->error_pages);
|
||||||
|
if (err == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1981,7 +2005,8 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
{
|
{
|
||||||
ngx_http_core_loc_conf_t *lcf = conf;
|
ngx_http_core_loc_conf_t *lcf = conf;
|
||||||
|
|
||||||
if (!(lcf->err_log = ngx_log_create_errlog(cf->cycle, cf->args))) {
|
lcf->err_log = ngx_log_create_errlog(cf->cycle, cf->args);
|
||||||
|
if (lcf->err_log == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2021,5 +2046,5 @@ ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data)
|
|||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_core_init(ngx_cycle_t *cycle)
|
ngx_http_core_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
return ngx_http_core_variables_init(cycle);
|
return ngx_http_variables_init(cycle);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
size_t len;
|
size_t len;
|
||||||
ngx_uint_t status, i;
|
ngx_uint_t status, i;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_chain_t *ln;
|
ngx_chain_t out;
|
||||||
ngx_list_part_t *part;
|
ngx_list_part_t *part;
|
||||||
ngx_table_elt_t *header;
|
ngx_table_elt_t *header;
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
@ -311,7 +311,8 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
+ sizeof(CRLF) - 1;
|
+ sizeof(CRLF) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(b = ngx_create_temp_buf(r->pool, len))) {
|
b = ngx_create_temp_buf(r->pool, len);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,14 +462,10 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
b->last_buf = 1;
|
b->last_buf = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ln = ngx_alloc_chain_link(r->pool))) {
|
out.buf = b;
|
||||||
return NGX_ERROR;
|
out.next = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
ln->buf = b;
|
return ngx_http_write_filter(r, &out);
|
||||||
ln->next = NULL;
|
|
||||||
|
|
||||||
return ngx_http_write_filter(r, ln);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,8 +36,8 @@ static size_t ngx_http_log_request_getlen(ngx_http_request_t *r,
|
|||||||
static u_char *ngx_http_log_request(ngx_http_request_t *r, u_char *buf,
|
static u_char *ngx_http_log_request(ngx_http_request_t *r, u_char *buf,
|
||||||
ngx_http_log_op_t *op);
|
ngx_http_log_op_t *op);
|
||||||
|
|
||||||
static ngx_int_t ngx_http_log_header_in_compile(ngx_http_log_op_t *op,
|
static ngx_int_t ngx_http_log_header_in_compile(ngx_conf_t *cf,
|
||||||
ngx_str_t *value);
|
ngx_http_log_op_t *op, ngx_str_t *value);
|
||||||
static size_t ngx_http_log_header_in_getlen(ngx_http_request_t *r,
|
static size_t ngx_http_log_header_in_getlen(ngx_http_request_t *r,
|
||||||
uintptr_t data);
|
uintptr_t data);
|
||||||
static u_char *ngx_http_log_header_in(ngx_http_request_t *r, u_char *buf,
|
static u_char *ngx_http_log_header_in(ngx_http_request_t *r, u_char *buf,
|
||||||
@ -47,8 +47,8 @@ static size_t ngx_http_log_unknown_header_in_getlen(ngx_http_request_t *r,
|
|||||||
static u_char *ngx_http_log_unknown_header_in(ngx_http_request_t *r,
|
static u_char *ngx_http_log_unknown_header_in(ngx_http_request_t *r,
|
||||||
u_char *buf, ngx_http_log_op_t *op);
|
u_char *buf, ngx_http_log_op_t *op);
|
||||||
|
|
||||||
static ngx_int_t ngx_http_log_header_out_compile(ngx_http_log_op_t *op,
|
static ngx_int_t ngx_http_log_header_out_compile(ngx_conf_t *cf,
|
||||||
ngx_str_t *value);
|
ngx_http_log_op_t *op, ngx_str_t *value);
|
||||||
static size_t ngx_http_log_header_out_getlen(ngx_http_request_t *r,
|
static size_t ngx_http_log_header_out_getlen(ngx_http_request_t *r,
|
||||||
uintptr_t data);
|
uintptr_t data);
|
||||||
static u_char *ngx_http_log_header_out(ngx_http_request_t *r, u_char *buf,
|
static u_char *ngx_http_log_header_out(ngx_http_request_t *r, u_char *buf,
|
||||||
@ -66,6 +66,14 @@ static u_char *ngx_http_log_transfer_encoding_header_out(ngx_http_request_t *r,
|
|||||||
static ngx_table_elt_t *ngx_http_log_unknown_header(ngx_list_t *headers,
|
static ngx_table_elt_t *ngx_http_log_unknown_header(ngx_list_t *headers,
|
||||||
ngx_str_t *value);
|
ngx_str_t *value);
|
||||||
|
|
||||||
|
static ngx_int_t ngx_http_log_variable_compile(ngx_conf_t *cf,
|
||||||
|
ngx_http_log_op_t *op, ngx_str_t *value);
|
||||||
|
static size_t ngx_http_log_variable_getlen(ngx_http_request_t *r,
|
||||||
|
uintptr_t data);
|
||||||
|
static u_char *ngx_http_log_variable(ngx_http_request_t *r, u_char *buf,
|
||||||
|
ngx_http_log_op_t *op);
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_log_set_formats(ngx_conf_t *cf);
|
static ngx_int_t ngx_http_log_set_formats(ngx_conf_t *cf);
|
||||||
static void *ngx_http_log_create_main_conf(ngx_conf_t *cf);
|
static void *ngx_http_log_create_main_conf(ngx_conf_t *cf);
|
||||||
static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf);
|
static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf);
|
||||||
@ -75,8 +83,6 @@ static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd,
|
|||||||
void *conf);
|
void *conf);
|
||||||
static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd,
|
static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||||
void *conf);
|
void *conf);
|
||||||
static ngx_int_t ngx_http_log_parse_format(ngx_conf_t *cf, ngx_array_t *ops,
|
|
||||||
ngx_str_t *line);
|
|
||||||
|
|
||||||
|
|
||||||
static ngx_command_t ngx_http_log_commands[] = {
|
static ngx_command_t ngx_http_log_commands[] = {
|
||||||
@ -152,13 +158,12 @@ ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = {
|
|||||||
ngx_http_log_request_getlen,
|
ngx_http_log_request_getlen,
|
||||||
ngx_http_log_request },
|
ngx_http_log_request },
|
||||||
|
|
||||||
{ ngx_string("i"), 0, ngx_http_log_header_in_compile,
|
{ ngx_string("i"), 0, ngx_http_log_header_in_compile, NULL,
|
||||||
ngx_http_log_header_in_getlen,
|
|
||||||
ngx_http_log_header_in },
|
ngx_http_log_header_in },
|
||||||
|
{ ngx_string("o"), 0, ngx_http_log_header_out_compile, NULL,
|
||||||
{ ngx_string("o"), 0, ngx_http_log_header_out_compile,
|
|
||||||
ngx_http_log_header_out_getlen,
|
|
||||||
ngx_http_log_header_out },
|
ngx_http_log_header_out },
|
||||||
|
{ ngx_string("v"), 0, ngx_http_log_variable_compile, NULL,
|
||||||
|
ngx_http_log_variable },
|
||||||
|
|
||||||
{ ngx_null_string, 0, NULL, NULL, NULL }
|
{ ngx_null_string, 0, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
@ -206,7 +211,8 @@ ngx_http_log_handler(ngx_http_request_t *r)
|
|||||||
len++;
|
len++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(line = ngx_palloc(r->pool, len))) {
|
line = ngx_palloc(r->pool, len);
|
||||||
|
if (line == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +378,8 @@ ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf,
|
|||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_log_header_in_compile(ngx_http_log_op_t *op, ngx_str_t *value)
|
ngx_http_log_header_in_compile(ngx_conf_t *cf, ngx_http_log_op_t *op,
|
||||||
|
ngx_str_t *value)
|
||||||
{
|
{
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
|
|
||||||
@ -385,7 +392,7 @@ ngx_http_log_header_in_compile(ngx_http_log_op_t *op, ngx_str_t *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_strncasecmp(ngx_http_headers_in[i].name.data, value->data,
|
if (ngx_strncasecmp(ngx_http_headers_in[i].name.data, value->data,
|
||||||
value->len) == 0)
|
value->len) == 0)
|
||||||
{
|
{
|
||||||
op->getlen = ngx_http_log_header_in_getlen;
|
op->getlen = ngx_http_log_header_in_getlen;
|
||||||
op->run = ngx_http_log_header_in;
|
op->run = ngx_http_log_header_in;
|
||||||
@ -471,7 +478,8 @@ ngx_http_log_unknown_header_in(ngx_http_request_t *r, u_char *buf,
|
|||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_log_header_out_compile(ngx_http_log_op_t *op, ngx_str_t *value)
|
ngx_http_log_header_out_compile(ngx_conf_t *cf, ngx_http_log_op_t *op,
|
||||||
|
ngx_str_t *value)
|
||||||
{
|
{
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
|
|
||||||
@ -721,6 +729,68 @@ ngx_http_log_transfer_encoding_header_out(ngx_http_request_t *r, u_char *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_int_t
|
||||||
|
ngx_http_log_variable_compile(ngx_conf_t *cf, ngx_http_log_op_t *op,
|
||||||
|
ngx_str_t *value)
|
||||||
|
{
|
||||||
|
ngx_uint_t i;
|
||||||
|
ngx_http_variable_t *var;
|
||||||
|
|
||||||
|
for (i = 0; i < value->len; i++) {
|
||||||
|
value->data[i] = ngx_toupper(value->data[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var = ngx_http_add_variable(cf, value, 0);
|
||||||
|
if (var == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
op->len = 0;
|
||||||
|
op->getlen = ngx_http_log_variable_getlen;
|
||||||
|
op->run = ngx_http_log_variable;
|
||||||
|
op->data = var->index;
|
||||||
|
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
ngx_http_log_variable_getlen(ngx_http_request_t *r, uintptr_t data)
|
||||||
|
{
|
||||||
|
ngx_http_variable_value_t *value;
|
||||||
|
|
||||||
|
value = ngx_http_get_indexed_variable(r, data);
|
||||||
|
|
||||||
|
if (value == NULL
|
||||||
|
|| value == NGX_HTTP_VARIABLE_NOT_FOUND
|
||||||
|
|| value->text.len == 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value->text.len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static u_char *
|
||||||
|
ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
|
||||||
|
{
|
||||||
|
ngx_http_variable_value_t *value;
|
||||||
|
|
||||||
|
value = ngx_http_get_indexed_variable(r, op->data);
|
||||||
|
|
||||||
|
if (value == NULL
|
||||||
|
|| value == NGX_HTTP_VARIABLE_NOT_FOUND
|
||||||
|
|| value->text.len == 0)
|
||||||
|
{
|
||||||
|
*buf = '-';
|
||||||
|
return buf + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ngx_cpymem(buf, value->text.data, value->text.len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_log_set_formats(ngx_conf_t *cf)
|
ngx_http_log_set_formats(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
@ -741,7 +811,8 @@ ngx_http_log_create_main_conf(ngx_conf_t *cf)
|
|||||||
char *rc;
|
char *rc;
|
||||||
ngx_str_t *value;
|
ngx_str_t *value;
|
||||||
|
|
||||||
if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_main_conf_t)))) {
|
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_main_conf_t));
|
||||||
|
if (conf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,18 +824,21 @@ ngx_http_log_create_main_conf(ngx_conf_t *cf)
|
|||||||
|
|
||||||
cf->args->nelts = 0;
|
cf->args->nelts = 0;
|
||||||
|
|
||||||
if (!(value = ngx_array_push(cf->args))) {
|
value = ngx_array_push(cf->args);
|
||||||
|
if (value == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(value = ngx_array_push(cf->args))) {
|
value = ngx_array_push(cf->args);
|
||||||
|
if (value == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
value->len = sizeof("combined") - 1;
|
value->len = sizeof("combined") - 1;
|
||||||
value->data = (u_char *) "combined";
|
value->data = (u_char *) "combined";
|
||||||
|
|
||||||
if (!(value = ngx_array_push(cf->args))) {
|
value = ngx_array_push(cf->args);
|
||||||
|
if (value == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,7 +858,8 @@ ngx_http_log_create_loc_conf(ngx_conf_t *cf)
|
|||||||
{
|
{
|
||||||
ngx_http_log_loc_conf_t *conf;
|
ngx_http_log_loc_conf_t *conf;
|
||||||
|
|
||||||
if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)))) {
|
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t));
|
||||||
|
if (conf == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,7 +898,8 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(log = ngx_array_push(conf->logs))) {
|
log = ngx_array_push(conf->logs);
|
||||||
|
if (log == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,11 +947,13 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
|
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
|
||||||
|
|
||||||
if (!(log = ngx_array_push(llcf->logs))) {
|
log = ngx_array_push(llcf->logs);
|
||||||
|
if (log == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(log->file = ngx_conf_open_file(cf->cycle, &value[1]))) {
|
log->file = ngx_conf_open_file(cf->cycle, &value[1]);
|
||||||
|
if (log->file == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -927,19 +1005,21 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(fmt = ngx_push_array(&lmcf->formats))) {
|
fmt = ngx_array_push(&lmcf->formats);
|
||||||
|
if (fmt == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt->name = value[1];
|
fmt->name = value[1];
|
||||||
|
|
||||||
if (!(fmt->ops = ngx_array_create(cf->pool, 20, sizeof(ngx_http_log_op_t))))
|
fmt->ops = ngx_array_create(cf->pool, 20, sizeof(ngx_http_log_op_t));
|
||||||
{
|
if (fmt->ops == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
invalid = 0;
|
invalid = 0;
|
||||||
data = NULL;
|
data = NULL;
|
||||||
|
arg.data = NULL;
|
||||||
|
|
||||||
for (s = 2; s < cf->args->nelts && !invalid; s++) {
|
for (s = 2; s < cf->args->nelts && !invalid; s++) {
|
||||||
|
|
||||||
@ -947,7 +1027,8 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
while (i < value[s].len) {
|
while (i < value[s].len) {
|
||||||
|
|
||||||
if (!(op = ngx_push_array(fmt->ops))) {
|
op = ngx_array_push(fmt->ops);
|
||||||
|
if (op == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1032,12 +1113,13 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(a = ngx_palloc(cf->pool, sizeof(ngx_str_t)))) {
|
a = ngx_palloc(cf->pool, sizeof(ngx_str_t));
|
||||||
|
if (a == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
*a = arg;
|
*a = arg;
|
||||||
if (name->compile(op, a) == NGX_ERROR) {
|
if (name->compile(cf, op, a) == NGX_ERROR) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1076,7 +1158,8 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
} else {
|
} else {
|
||||||
op->run = ngx_http_log_copy_long;
|
op->run = ngx_http_log_copy_long;
|
||||||
|
|
||||||
if (!(p = ngx_palloc(cf->pool, len))) {
|
p = ngx_palloc(cf->pool, len);
|
||||||
|
if (p == NULL) {
|
||||||
return NGX_CONF_ERROR;
|
return NGX_CONF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
@ -4,8 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _NGX_HTTP_LOG_HANDLER_H_INCLUDED_
|
#ifndef _NGX_HTTP_LOG_MODULE_H_INCLUDED_
|
||||||
#define _NGX_HTTP_LOG_HANDLER_H_INCLUDED_
|
#define _NGX_HTTP_LOG_MODULE_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
#include <ngx_config.h>
|
#include <ngx_config.h>
|
||||||
@ -16,13 +16,14 @@
|
|||||||
typedef struct ngx_http_log_op_s ngx_http_log_op_t;
|
typedef struct ngx_http_log_op_s ngx_http_log_op_t;
|
||||||
|
|
||||||
typedef u_char *(*ngx_http_log_op_run_pt) (ngx_http_request_t *r, u_char *buf,
|
typedef u_char *(*ngx_http_log_op_run_pt) (ngx_http_request_t *r, u_char *buf,
|
||||||
ngx_http_log_op_t *op);
|
ngx_http_log_op_t *op);
|
||||||
|
|
||||||
typedef size_t (*ngx_http_log_op_getlen_pt) (ngx_http_request_t *r,
|
typedef size_t (*ngx_http_log_op_getlen_pt) (ngx_http_request_t *r,
|
||||||
uintptr_t data);
|
uintptr_t data);
|
||||||
|
|
||||||
|
typedef ngx_int_t (*ngx_http_log_op_compile_pt) (ngx_conf_t *cf,
|
||||||
|
ngx_http_log_op_t *op, ngx_str_t *value);
|
||||||
|
|
||||||
typedef ngx_int_t (*ngx_http_log_op_compile_pt) (ngx_http_log_op_t *op,
|
|
||||||
ngx_str_t *value);
|
|
||||||
|
|
||||||
struct ngx_http_log_op_s {
|
struct ngx_http_log_op_s {
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -67,4 +68,4 @@ typedef struct {
|
|||||||
extern ngx_http_log_op_name_t ngx_http_log_fmt_ops[];
|
extern ngx_http_log_op_name_t ngx_http_log_fmt_ops[];
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_HTTP_LOG_HANDLER_H_INCLUDED_ */
|
#endif /* _NGX_HTTP_LOG_MODULE_H_INCLUDED_ */
|
@ -461,7 +461,6 @@ ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|||||||
default:
|
default:
|
||||||
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,7 +645,6 @@ ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|||||||
default:
|
default:
|
||||||
return NGX_HTTP_PARSE_INVALID_HEADER;
|
return NGX_HTTP_PARSE_INVALID_HEADER;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
/* end of header */
|
/* end of header */
|
||||||
case sw_header_almost_done:
|
case sw_header_almost_done:
|
||||||
@ -656,7 +654,6 @@ ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|||||||
default:
|
default:
|
||||||
return NGX_HTTP_PARSE_INVALID_HEADER;
|
return NGX_HTTP_PARSE_INVALID_HEADER;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,10 +229,14 @@ time_t ngx_http_parse_time(u_char *value, size_t len)
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeof(time_t) <= 4 && year >= 2038) {
|
#if (NGX_TIME_T_SIZE <= 4)
|
||||||
|
|
||||||
|
if (year >= 2038) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* shift new year to March 1 and start months from 1 (not 0),
|
* shift new year to March 1 and start months from 1 (not 0),
|
||||||
* it is needed for Gauss's formula
|
* it is needed for Gauss's formula
|
||||||
|
@ -18,7 +18,7 @@ static void ngx_http_process_request_line(ngx_event_t *rev);
|
|||||||
static void ngx_http_process_request_headers(ngx_event_t *rev);
|
static void ngx_http_process_request_headers(ngx_event_t *rev);
|
||||||
static ssize_t ngx_http_read_request_header(ngx_http_request_t *r);
|
static ssize_t ngx_http_read_request_header(ngx_http_request_t *r);
|
||||||
static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
|
static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
|
||||||
ngx_uint_t request_line);
|
ngx_uint_t request_line);
|
||||||
static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r);
|
static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r);
|
||||||
static ngx_int_t ngx_http_find_virtual_server(ngx_http_request_t *r);
|
static ngx_int_t ngx_http_find_virtual_server(ngx_http_request_t *r);
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ static void ngx_http_set_lingering_close(ngx_http_request_t *r);
|
|||||||
static void ngx_http_lingering_close_handler(ngx_event_t *ev);
|
static void ngx_http_lingering_close_handler(ngx_event_t *ev);
|
||||||
|
|
||||||
static void ngx_http_client_error(ngx_http_request_t *r,
|
static void ngx_http_client_error(ngx_http_request_t *r,
|
||||||
int client_error, int error);
|
int client_error, int error);
|
||||||
static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len);
|
static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len);
|
||||||
|
|
||||||
|
|
||||||
@ -100,19 +100,22 @@ ngx_http_header_t ngx_http_headers_in[] = {
|
|||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void ngx_http_dummy(ngx_event_t *wev)
|
static void
|
||||||
|
ngx_http_dummy(ngx_event_t *wev)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void ngx_http_init_connection(ngx_connection_t *c)
|
void
|
||||||
|
ngx_http_init_connection(ngx_connection_t *c)
|
||||||
{
|
{
|
||||||
ngx_event_t *rev;
|
ngx_event_t *rev;
|
||||||
ngx_http_log_ctx_t *ctx;
|
ngx_http_log_ctx_t *ctx;
|
||||||
|
|
||||||
if (!(ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
|
ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t));
|
||||||
|
if (ctx == NULL) {
|
||||||
ngx_http_close_connection(c);
|
ngx_http_close_connection(c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -186,7 +189,8 @@ void ngx_http_init_connection(ngx_connection_t *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_init_request(ngx_event_t *rev)
|
static
|
||||||
|
void ngx_http_init_request(ngx_event_t *rev)
|
||||||
{
|
{
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
socklen_t len;
|
socklen_t len;
|
||||||
@ -225,7 +229,8 @@ static void ngx_http_init_request(ngx_event_t *rev)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!(hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)))) {
|
hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t));
|
||||||
|
if (hc == NULL) {
|
||||||
|
|
||||||
#if (NGX_STAT_STUB)
|
#if (NGX_STAT_STUB)
|
||||||
ngx_atomic_dec(ngx_stat_reading);
|
ngx_atomic_dec(ngx_stat_reading);
|
||||||
@ -248,7 +253,8 @@ static void ngx_http_init_request(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) {
|
r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t));
|
||||||
|
if (r == NULL) {
|
||||||
|
|
||||||
#if (NGX_STAT_STUB)
|
#if (NGX_STAT_STUB)
|
||||||
ngx_atomic_dec(ngx_stat_reading);
|
ngx_atomic_dec(ngx_stat_reading);
|
||||||
@ -388,7 +394,8 @@ static void ngx_http_init_request(ngx_event_t *rev)
|
|||||||
r->header_in = c->buffer;
|
r->header_in = c->buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(r->pool = ngx_create_pool(cscf->request_pool_size, c->log))) {
|
r->pool = ngx_create_pool(cscf->request_pool_size, c->log);
|
||||||
|
if (r->pool == NULL) {
|
||||||
ngx_http_close_connection(c);
|
ngx_http_close_connection(c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -444,7 +451,8 @@ static void ngx_http_init_request(ngx_event_t *rev)
|
|||||||
|
|
||||||
#if (NGX_HTTP_SSL)
|
#if (NGX_HTTP_SSL)
|
||||||
|
|
||||||
static void ngx_http_ssl_handshake(ngx_event_t *rev)
|
static void
|
||||||
|
ngx_http_ssl_handshake(ngx_event_t *rev)
|
||||||
{
|
{
|
||||||
u_char buf[1];
|
u_char buf[1];
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
@ -504,7 +512,8 @@ static void ngx_http_ssl_handshake(ngx_event_t *rev)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_process_request_line(ngx_event_t *rev)
|
static void
|
||||||
|
ngx_http_process_request_line(ngx_event_t *rev)
|
||||||
{
|
{
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
ngx_int_t rc, rv;
|
ngx_int_t rc, rv;
|
||||||
@ -554,7 +563,8 @@ static void ngx_http_process_request_line(ngx_event_t *rev)
|
|||||||
|
|
||||||
if (r->complex_uri || r->quoted_uri) {
|
if (r->complex_uri || r->quoted_uri) {
|
||||||
|
|
||||||
if (!(r->uri.data = ngx_palloc(r->pool, r->uri.len + 1))) {
|
r->uri.data = ngx_palloc(r->pool, r->uri.len + 1);
|
||||||
|
if (r->uri.data == NULL) {
|
||||||
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
ngx_http_close_connection(c);
|
ngx_http_close_connection(c);
|
||||||
return;
|
return;
|
||||||
@ -707,7 +717,8 @@ static void ngx_http_process_request_line(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_process_request_headers(ngx_event_t *rev)
|
static void
|
||||||
|
ngx_http_process_request_headers(ngx_event_t *rev)
|
||||||
{
|
{
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
ngx_int_t rc, rv, i;
|
ngx_int_t rc, rv, i;
|
||||||
@ -764,7 +775,8 @@ static void ngx_http_process_request_headers(ngx_event_t *rev)
|
|||||||
|
|
||||||
r->headers_n++;
|
r->headers_n++;
|
||||||
|
|
||||||
if (!(h = ngx_list_push(&r->headers_in.headers))) {
|
h = ngx_list_push(&r->headers_in.headers);
|
||||||
|
if (h == NULL) {
|
||||||
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
ngx_http_close_connection(c);
|
ngx_http_close_connection(c);
|
||||||
return;
|
return;
|
||||||
@ -781,7 +793,8 @@ static void ngx_http_process_request_headers(ngx_event_t *rev)
|
|||||||
if (h->key.len == sizeof("Cookie") - 1
|
if (h->key.len == sizeof("Cookie") - 1
|
||||||
&& ngx_strcasecmp(h->key.data, "Cookie") == 0)
|
&& ngx_strcasecmp(h->key.data, "Cookie") == 0)
|
||||||
{
|
{
|
||||||
if (!(cookie = ngx_array_push(&r->headers_in.cookies))) {
|
cookie = ngx_array_push(&r->headers_in.cookies);
|
||||||
|
if (cookie == NULL) {
|
||||||
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
ngx_http_close_connection(c);
|
ngx_http_close_connection(c);
|
||||||
return;
|
return;
|
||||||
@ -879,7 +892,8 @@ static void ngx_http_process_request_headers(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ssize_t ngx_http_read_request_header(ngx_http_request_t *r)
|
static ssize_t
|
||||||
|
ngx_http_read_request_header(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
ngx_event_t *rev;
|
ngx_event_t *rev;
|
||||||
@ -933,8 +947,9 @@ static ssize_t ngx_http_read_request_header(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
|
static ngx_int_t
|
||||||
ngx_uint_t request_line)
|
ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
|
||||||
|
ngx_uint_t request_line)
|
||||||
{
|
{
|
||||||
u_char *old, *new;
|
u_char *old, *new;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
@ -1076,7 +1091,8 @@ static ngx_int_t ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
|
static ngx_int_t
|
||||||
|
ngx_http_process_request_header(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
u_char *ua, *user_agent, ch;
|
u_char *ua, *user_agent, ch;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -1106,7 +1122,7 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
|
|||||||
|
|
||||||
if (r->headers_in.content_length) {
|
if (r->headers_in.content_length) {
|
||||||
r->headers_in.content_length_n =
|
r->headers_in.content_length_n =
|
||||||
ngx_atoi(r->headers_in.content_length->value.data,
|
ngx_atosz(r->headers_in.content_length->value.data,
|
||||||
r->headers_in.content_length->value.len);
|
r->headers_in.content_length->value.len);
|
||||||
|
|
||||||
if (r->headers_in.content_length_n == NGX_ERROR) {
|
if (r->headers_in.content_length_n == NGX_ERROR) {
|
||||||
@ -1137,7 +1153,7 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
|
|||||||
|
|
||||||
if (r->headers_in.keep_alive) {
|
if (r->headers_in.keep_alive) {
|
||||||
r->headers_in.keep_alive_n =
|
r->headers_in.keep_alive_n =
|
||||||
ngx_atoi(r->headers_in.keep_alive->value.data,
|
ngx_atotm(r->headers_in.keep_alive->value.data,
|
||||||
r->headers_in.keep_alive->value.len);
|
r->headers_in.keep_alive->value.len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1191,7 +1207,8 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_find_virtual_server(ngx_http_request_t *r)
|
static ngx_int_t
|
||||||
|
ngx_http_find_virtual_server(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ngx_int_t rc;
|
ngx_int_t rc;
|
||||||
ngx_uint_t i, n, key, found;
|
ngx_uint_t i, n, key, found;
|
||||||
@ -1297,7 +1314,8 @@ static ngx_int_t ngx_http_find_virtual_server(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_http_finalize_request(ngx_http_request_t *r, int rc)
|
void
|
||||||
|
ngx_http_finalize_request(ngx_http_request_t *r, int rc)
|
||||||
{
|
{
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
|
|
||||||
@ -1380,7 +1398,8 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int rc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_set_write_handler(ngx_http_request_t *r)
|
static void
|
||||||
|
ngx_http_set_write_handler(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ngx_event_t *wev;
|
ngx_event_t *wev;
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
@ -1409,7 +1428,8 @@ static void ngx_http_set_write_handler(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_http_writer(ngx_event_t *wev)
|
void
|
||||||
|
ngx_http_writer(ngx_event_t *wev)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
@ -1486,7 +1506,8 @@ void ngx_http_writer(ngx_event_t *wev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_block_read(ngx_event_t *rev)
|
static void
|
||||||
|
ngx_http_block_read(ngx_event_t *rev)
|
||||||
{
|
{
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
ngx_http_request_t *r;
|
ngx_http_request_t *r;
|
||||||
@ -1506,7 +1527,8 @@ static void ngx_http_block_read(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_http_discard_body(ngx_http_request_t *r)
|
ngx_int_t
|
||||||
|
ngx_http_discard_body(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
ngx_event_t *rev;
|
ngx_event_t *rev;
|
||||||
@ -1546,7 +1568,8 @@ ngx_int_t ngx_http_discard_body(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_read_discarded_body_event(ngx_event_t *rev)
|
static void
|
||||||
|
ngx_http_read_discarded_body_event(ngx_event_t *rev)
|
||||||
{
|
{
|
||||||
ngx_int_t rc;
|
ngx_int_t rc;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
@ -1572,7 +1595,8 @@ static void ngx_http_read_discarded_body_event(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r)
|
static ngx_int_t
|
||||||
|
ngx_http_read_discarded_body(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ssize_t size, n;
|
ssize_t size, n;
|
||||||
u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE];
|
u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE];
|
||||||
@ -1615,7 +1639,8 @@ static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_set_keepalive(ngx_http_request_t *r)
|
static void
|
||||||
|
ngx_http_set_keepalive(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
int tcp_nodelay;
|
int tcp_nodelay;
|
||||||
ngx_int_t i;
|
ngx_int_t i;
|
||||||
@ -1776,7 +1801,7 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
|
|||||||
c->log->action = "keepalive";
|
c->log->action = "keepalive";
|
||||||
|
|
||||||
if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) {
|
if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) {
|
||||||
if (ngx_tcp_push(c->fd) == NGX_ERROR) {
|
if (ngx_tcp_push(c->fd) == -1) {
|
||||||
ngx_connection_error(c, ngx_socket_errno, ngx_tcp_push_n " failed");
|
ngx_connection_error(c, ngx_socket_errno, ngx_tcp_push_n " failed");
|
||||||
ngx_http_close_connection(c);
|
ngx_http_close_connection(c);
|
||||||
return;
|
return;
|
||||||
@ -1818,13 +1843,13 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_keepalive_handler(ngx_event_t *rev)
|
static void
|
||||||
|
ngx_http_keepalive_handler(ngx_event_t *rev)
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
ngx_http_connection_t *hc;
|
|
||||||
|
|
||||||
c = rev->data;
|
c = rev->data;
|
||||||
|
|
||||||
@ -1855,7 +1880,6 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hc = c->data;
|
|
||||||
b = c->buffer;
|
b = c->buffer;
|
||||||
size = b->end - b->start;
|
size = b->end - b->start;
|
||||||
|
|
||||||
@ -1867,7 +1891,8 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
|
|||||||
* to keep the buffer size.
|
* to keep the buffer size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!(b->pos = ngx_palloc(c->pool, size))) {
|
b->pos = ngx_palloc(c->pool, size);
|
||||||
|
if (b->pos == NULL) {
|
||||||
ngx_http_close_connection(c);
|
ngx_http_close_connection(c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1919,7 +1944,8 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_set_lingering_close(ngx_http_request_t *r)
|
static void
|
||||||
|
ngx_http_set_lingering_close(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ngx_event_t *rev, *wev;
|
ngx_event_t *rev, *wev;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
@ -1977,7 +2003,8 @@ static void ngx_http_set_lingering_close(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_lingering_close_handler(ngx_event_t *rev)
|
static void
|
||||||
|
ngx_http_lingering_close_handler(ngx_event_t *rev)
|
||||||
{
|
{
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
ngx_msec_t timer;
|
ngx_msec_t timer;
|
||||||
@ -2036,7 +2063,8 @@ static void ngx_http_lingering_close_handler(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_http_empty_handler(ngx_event_t *wev)
|
void
|
||||||
|
ngx_http_empty_handler(ngx_event_t *wev)
|
||||||
{
|
{
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http empty handler");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http empty handler");
|
||||||
|
|
||||||
@ -2044,12 +2072,14 @@ void ngx_http_empty_handler(ngx_event_t *wev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_http_send_last(ngx_http_request_t *r)
|
ngx_int_t
|
||||||
|
ngx_http_send_last(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_chain_t out;
|
ngx_chain_t out;
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2061,7 +2091,8 @@ ngx_int_t ngx_http_send_last(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ngx_http_close_request(ngx_http_request_t *r, int error)
|
void
|
||||||
|
ngx_http_close_request(ngx_http_request_t *r, int error)
|
||||||
{
|
{
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_log_t *log;
|
ngx_log_t *log;
|
||||||
@ -2171,7 +2202,8 @@ void ngx_http_close_request(ngx_http_request_t *r, int error)
|
|||||||
|
|
||||||
#if (NGX_HTTP_SSL)
|
#if (NGX_HTTP_SSL)
|
||||||
|
|
||||||
void ngx_ssl_close_handler(ngx_event_t *ev)
|
void
|
||||||
|
ngx_ssl_close_handler(ngx_event_t *ev)
|
||||||
{
|
{
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
|
|
||||||
@ -2189,7 +2221,8 @@ void ngx_ssl_close_handler(ngx_event_t *ev)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void ngx_http_close_connection(ngx_connection_t *c)
|
void
|
||||||
|
ngx_http_close_connection(ngx_connection_t *c)
|
||||||
{
|
{
|
||||||
ngx_pool_t *pool;
|
ngx_pool_t *pool;
|
||||||
|
|
||||||
@ -2216,12 +2249,12 @@ void ngx_http_close_connection(ngx_connection_t *c)
|
|||||||
|
|
||||||
ngx_close_connection(c);
|
ngx_close_connection(c);
|
||||||
|
|
||||||
ngx_destroy_pool(c->pool);
|
ngx_destroy_pool(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_client_error(ngx_http_request_t *r,
|
static void
|
||||||
int client_error, int error)
|
ngx_http_client_error(ngx_http_request_t *r, int client_error, int error)
|
||||||
{
|
{
|
||||||
u_char *p;
|
u_char *p;
|
||||||
ngx_http_log_ctx_t *ctx;
|
ngx_http_log_ctx_t *ctx;
|
||||||
@ -2315,7 +2348,8 @@ static void ngx_http_client_error(ngx_http_request_t *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len)
|
static u_char *
|
||||||
|
ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len)
|
||||||
{
|
{
|
||||||
u_char *p;
|
u_char *p;
|
||||||
ngx_http_log_ctx_t *ctx;
|
ngx_http_log_ctx_t *ctx;
|
||||||
|
@ -119,91 +119,91 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_str_t name;
|
ngx_str_t name;
|
||||||
ngx_uint_t offset;
|
ngx_uint_t offset;
|
||||||
} ngx_http_header_t;
|
} ngx_http_header_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_list_t headers;
|
ngx_list_t headers;
|
||||||
|
|
||||||
ngx_table_elt_t *host;
|
ngx_table_elt_t *host;
|
||||||
ngx_table_elt_t *connection;
|
ngx_table_elt_t *connection;
|
||||||
ngx_table_elt_t *if_modified_since;
|
ngx_table_elt_t *if_modified_since;
|
||||||
ngx_table_elt_t *user_agent;
|
ngx_table_elt_t *user_agent;
|
||||||
ngx_table_elt_t *referer;
|
ngx_table_elt_t *referer;
|
||||||
ngx_table_elt_t *content_length;
|
ngx_table_elt_t *content_length;
|
||||||
ngx_table_elt_t *content_type;
|
ngx_table_elt_t *content_type;
|
||||||
|
|
||||||
ngx_table_elt_t *range;
|
ngx_table_elt_t *range;
|
||||||
|
|
||||||
#if (NGX_HTTP_GZIP)
|
#if (NGX_HTTP_GZIP)
|
||||||
ngx_table_elt_t *accept_encoding;
|
ngx_table_elt_t *accept_encoding;
|
||||||
ngx_table_elt_t *via;
|
ngx_table_elt_t *via;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ngx_table_elt_t *authorization;
|
ngx_table_elt_t *authorization;
|
||||||
|
|
||||||
ngx_table_elt_t *keep_alive;
|
ngx_table_elt_t *keep_alive;
|
||||||
|
|
||||||
#if (NGX_HTTP_PROXY)
|
#if (NGX_HTTP_PROXY)
|
||||||
ngx_table_elt_t *x_forwarded_for;
|
ngx_table_elt_t *x_forwarded_for;
|
||||||
ngx_table_elt_t *x_real_ip;
|
ngx_table_elt_t *x_real_ip;
|
||||||
ngx_table_elt_t *x_url;
|
ngx_table_elt_t *x_url;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (NGX_HTTP_HEADERS)
|
#if (NGX_HTTP_HEADERS)
|
||||||
ngx_table_elt_t *accept;
|
ngx_table_elt_t *accept;
|
||||||
ngx_table_elt_t *accept_language;
|
ngx_table_elt_t *accept_language;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ngx_array_t cookies;
|
ngx_array_t cookies;
|
||||||
|
|
||||||
size_t host_name_len;
|
size_t host_name_len;
|
||||||
ssize_t content_length_n;
|
ssize_t content_length_n;
|
||||||
size_t connection_type;
|
time_t keep_alive_n;
|
||||||
ssize_t keep_alive_n;
|
|
||||||
|
|
||||||
unsigned msie:1;
|
unsigned connection_type:2;
|
||||||
unsigned msie4:1;
|
unsigned msie:1;
|
||||||
unsigned opera:1;
|
unsigned msie4:1;
|
||||||
unsigned gecko:1;
|
unsigned opera:1;
|
||||||
unsigned konqueror:1;
|
unsigned gecko:1;
|
||||||
|
unsigned konqueror:1;
|
||||||
} ngx_http_headers_in_t;
|
} ngx_http_headers_in_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
off_t start;
|
off_t start;
|
||||||
off_t end;
|
off_t end;
|
||||||
ngx_str_t content_range;
|
ngx_str_t content_range;
|
||||||
} ngx_http_range_t;
|
} ngx_http_range_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_list_t headers;
|
ngx_list_t headers;
|
||||||
|
|
||||||
ngx_uint_t status;
|
ngx_uint_t status;
|
||||||
ngx_str_t status_line;
|
ngx_str_t status_line;
|
||||||
|
|
||||||
ngx_table_elt_t *server;
|
ngx_table_elt_t *server;
|
||||||
ngx_table_elt_t *date;
|
ngx_table_elt_t *date;
|
||||||
ngx_table_elt_t *content_type;
|
ngx_table_elt_t *content_type;
|
||||||
ngx_table_elt_t *content_length;
|
ngx_table_elt_t *content_length;
|
||||||
ngx_table_elt_t *content_encoding;
|
ngx_table_elt_t *content_encoding;
|
||||||
ngx_table_elt_t *location;
|
ngx_table_elt_t *location;
|
||||||
ngx_table_elt_t *last_modified;
|
ngx_table_elt_t *last_modified;
|
||||||
ngx_table_elt_t *content_range;
|
ngx_table_elt_t *content_range;
|
||||||
ngx_table_elt_t *accept_ranges;
|
ngx_table_elt_t *accept_ranges;
|
||||||
ngx_table_elt_t *expires;
|
ngx_table_elt_t *expires;
|
||||||
ngx_table_elt_t *cache_control;
|
ngx_table_elt_t *cache_control;
|
||||||
ngx_table_elt_t *etag;
|
ngx_table_elt_t *etag;
|
||||||
|
|
||||||
ngx_str_t charset;
|
ngx_str_t charset;
|
||||||
ngx_array_t ranges;
|
ngx_array_t ranges;
|
||||||
|
|
||||||
off_t content_length_n;
|
off_t content_length_n;
|
||||||
time_t date_time;
|
time_t date_time;
|
||||||
time_t last_modified_time;
|
time_t last_modified_time;
|
||||||
} ngx_http_headers_out_t;
|
} ngx_http_headers_out_t;
|
||||||
|
|
||||||
|
|
||||||
@ -221,172 +221,171 @@ typedef struct {
|
|||||||
struct ngx_http_cleanup_s {
|
struct ngx_http_cleanup_s {
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
ngx_fd_t fd;
|
ngx_fd_t fd;
|
||||||
u_char *name;
|
u_char *name;
|
||||||
} file;
|
} file;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
ngx_http_cache_hash_t *hash;
|
ngx_http_cache_hash_t *hash;
|
||||||
ngx_http_cache_entry_t *cache;
|
ngx_http_cache_entry_t *cache;
|
||||||
} cache;
|
} cache;
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
unsigned valid:1;
|
unsigned valid:1;
|
||||||
unsigned cache:1;
|
unsigned cache:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_http_request_t *request;
|
ngx_http_request_t *request;
|
||||||
|
|
||||||
ngx_buf_t **busy;
|
ngx_buf_t **busy;
|
||||||
ngx_int_t nbusy;
|
ngx_int_t nbusy;
|
||||||
|
|
||||||
ngx_buf_t **free;
|
ngx_buf_t **free;
|
||||||
ngx_int_t nfree;
|
ngx_int_t nfree;
|
||||||
|
|
||||||
ngx_uint_t pipeline; /* unsigned pipeline:1; */
|
ngx_uint_t pipeline; /* unsigned pipeline:1; */
|
||||||
} ngx_http_connection_t;
|
} ngx_http_connection_t;
|
||||||
|
|
||||||
|
|
||||||
typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r);
|
typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r);
|
||||||
|
|
||||||
struct ngx_http_request_s {
|
struct ngx_http_request_s {
|
||||||
uint32_t signature; /* "HTTP" */
|
uint32_t signature; /* "HTTP" */
|
||||||
|
|
||||||
ngx_connection_t *connection;
|
ngx_connection_t *connection;
|
||||||
|
|
||||||
void **ctx;
|
void **ctx;
|
||||||
void **main_conf;
|
void **main_conf;
|
||||||
void **srv_conf;
|
void **srv_conf;
|
||||||
void **loc_conf;
|
void **loc_conf;
|
||||||
|
|
||||||
ngx_http_cache_t *cache;
|
ngx_http_cache_t *cache;
|
||||||
|
|
||||||
ngx_http_upstream_t *upstream;
|
ngx_http_upstream_t *upstream;
|
||||||
|
|
||||||
ngx_file_t file;
|
ngx_file_t file;
|
||||||
|
|
||||||
ngx_pool_t *pool;
|
ngx_pool_t *pool;
|
||||||
ngx_buf_t *header_in;
|
ngx_buf_t *header_in;
|
||||||
|
|
||||||
ngx_http_headers_in_t headers_in;
|
ngx_http_headers_in_t headers_in;
|
||||||
ngx_http_headers_out_t headers_out;
|
ngx_http_headers_out_t headers_out;
|
||||||
|
|
||||||
ngx_http_request_body_t *request_body;
|
ngx_http_request_body_t *request_body;
|
||||||
|
|
||||||
time_t lingering_time;
|
time_t lingering_time;
|
||||||
time_t start_time;
|
time_t start_time;
|
||||||
|
|
||||||
ngx_uint_t method;
|
ngx_uint_t method;
|
||||||
ngx_uint_t http_version;
|
ngx_uint_t http_version;
|
||||||
ngx_uint_t http_major;
|
ngx_uint_t http_major;
|
||||||
ngx_uint_t http_minor;
|
ngx_uint_t http_minor;
|
||||||
|
|
||||||
ngx_str_t request_line;
|
ngx_str_t request_line;
|
||||||
ngx_str_t uri;
|
ngx_str_t uri;
|
||||||
ngx_str_t args;
|
ngx_str_t args;
|
||||||
ngx_str_t exten;
|
ngx_str_t exten;
|
||||||
ngx_str_t unparsed_uri;
|
ngx_str_t unparsed_uri;
|
||||||
|
|
||||||
ngx_str_t method_name;
|
ngx_str_t method_name;
|
||||||
ngx_str_t http_protocol;
|
ngx_str_t http_protocol;
|
||||||
|
|
||||||
ngx_http_request_t *main;
|
ngx_http_request_t *main;
|
||||||
|
|
||||||
uint32_t in_addr;
|
uint32_t in_addr;
|
||||||
ngx_uint_t port;
|
ngx_uint_t port;
|
||||||
ngx_str_t *port_text; /* ":80" */
|
ngx_str_t *port_text; /* ":80" */
|
||||||
ngx_str_t server_name;
|
ngx_str_t server_name;
|
||||||
ngx_http_in_addr_t *virtual_names;
|
ngx_http_in_addr_t *virtual_names;
|
||||||
|
|
||||||
ngx_uint_t phase;
|
ngx_uint_t phase;
|
||||||
ngx_int_t phase_handler;
|
ngx_int_t phase_handler;
|
||||||
ngx_http_handler_pt content_handler;
|
ngx_http_handler_pt content_handler;
|
||||||
|
|
||||||
ngx_uint_t nvariables;
|
ngx_http_variable_value_t **variables;
|
||||||
void **variables;
|
|
||||||
|
|
||||||
ngx_array_t cleanup;
|
ngx_array_t cleanup;
|
||||||
|
|
||||||
/* used to learn the Apache compatible response length without a header */
|
/* used to learn the Apache compatible response length without a header */
|
||||||
size_t header_size;
|
size_t header_size;
|
||||||
|
|
||||||
size_t request_length;
|
size_t request_length;
|
||||||
|
|
||||||
u_char *discarded_buffer;
|
u_char *discarded_buffer;
|
||||||
void **err_ctx;
|
void **err_ctx;
|
||||||
ngx_uint_t err_status;
|
ngx_uint_t err_status;
|
||||||
|
|
||||||
ngx_http_connection_t *http_connection;
|
ngx_http_connection_t *http_connection;
|
||||||
|
|
||||||
unsigned http_state:4;
|
unsigned http_state:4;
|
||||||
|
|
||||||
/* URI with "/." and on Win32 with "//" */
|
/* URI with "/." and on Win32 with "//" */
|
||||||
unsigned complex_uri:1;
|
unsigned complex_uri:1;
|
||||||
|
|
||||||
/* URI with "%" */
|
/* URI with "%" */
|
||||||
unsigned quoted_uri:1;
|
unsigned quoted_uri:1;
|
||||||
|
|
||||||
/* URI with "+" */
|
/* URI with "+" */
|
||||||
unsigned plus_in_uri:1;
|
unsigned plus_in_uri:1;
|
||||||
|
|
||||||
/* URI with "\0" or "%00" */
|
/* URI with "\0" or "%00" */
|
||||||
unsigned zero_in_uri:1;
|
unsigned zero_in_uri:1;
|
||||||
|
|
||||||
unsigned uri_changed:1;
|
unsigned uri_changed:1;
|
||||||
unsigned uri_changes:4;
|
unsigned uri_changes:4;
|
||||||
|
|
||||||
unsigned low_case_exten:1;
|
unsigned low_case_exten:1;
|
||||||
unsigned header_timeout_set:1;
|
unsigned header_timeout_set:1;
|
||||||
|
|
||||||
unsigned proxy:1;
|
unsigned proxy:1;
|
||||||
unsigned bypass_cache:1;
|
unsigned bypass_cache:1;
|
||||||
unsigned no_cache:1;
|
unsigned no_cache:1;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
unsigned cachable:1;
|
unsigned cachable:1;
|
||||||
#endif
|
#endif
|
||||||
unsigned pipeline:1;
|
unsigned pipeline:1;
|
||||||
|
|
||||||
unsigned plain_http:1;
|
unsigned plain_http:1;
|
||||||
unsigned chunked:1;
|
unsigned chunked:1;
|
||||||
unsigned header_only:1;
|
unsigned header_only:1;
|
||||||
unsigned keepalive:1;
|
unsigned keepalive:1;
|
||||||
unsigned lingering_close:1;
|
unsigned lingering_close:1;
|
||||||
unsigned closed:1;
|
unsigned closed:1;
|
||||||
|
|
||||||
unsigned filter_need_in_memory:1;
|
unsigned filter_need_in_memory:1;
|
||||||
unsigned filter_ssi_need_in_memory:1;
|
unsigned filter_ssi_need_in_memory:1;
|
||||||
unsigned filter_need_temporary:1;
|
unsigned filter_need_temporary:1;
|
||||||
unsigned filter_allow_ranges:1;
|
unsigned filter_allow_ranges:1;
|
||||||
|
|
||||||
#if (NGX_STAT_STUB)
|
#if (NGX_STAT_STUB)
|
||||||
unsigned stat_reading:1;
|
unsigned stat_reading:1;
|
||||||
unsigned stat_writing:1;
|
unsigned stat_writing:1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ngx_uint_t headers_n;
|
ngx_uint_t headers_n;
|
||||||
|
|
||||||
/* used to parse HTTP headers */
|
/* used to parse HTTP headers */
|
||||||
ngx_uint_t state;
|
ngx_uint_t state;
|
||||||
u_char *uri_start;
|
u_char *uri_start;
|
||||||
u_char *uri_end;
|
u_char *uri_end;
|
||||||
u_char *uri_ext;
|
u_char *uri_ext;
|
||||||
u_char *args_start;
|
u_char *args_start;
|
||||||
u_char *request_start;
|
u_char *request_start;
|
||||||
u_char *request_end;
|
u_char *request_end;
|
||||||
u_char *method_end;
|
u_char *method_end;
|
||||||
u_char *schema_start;
|
u_char *schema_start;
|
||||||
u_char *schema_end;
|
u_char *schema_end;
|
||||||
u_char *host_start;
|
u_char *host_start;
|
||||||
u_char *host_end;
|
u_char *host_end;
|
||||||
u_char *port_start;
|
u_char *port_start;
|
||||||
u_char *port_end;
|
u_char *port_end;
|
||||||
u_char *header_name_start;
|
u_char *header_name_start;
|
||||||
u_char *header_name_end;
|
u_char *header_name_end;
|
||||||
u_char *header_start;
|
u_char *header_start;
|
||||||
u_char *header_end;
|
u_char *header_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
static void ngx_http_read_client_request_body_handler(ngx_event_t *rev);
|
static void ngx_http_read_client_request_body_handler(ngx_event_t *rev);
|
||||||
static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
|
static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
|
||||||
ngx_connection_t *c);
|
ngx_connection_t *c);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* on completion ngx_http_read_client_request_body() adds to
|
* on completion ngx_http_read_client_request_body() adds to
|
||||||
@ -21,22 +21,35 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
|
|||||||
* *) one memory or file buf that contains the rest of the body
|
* *) one memory or file buf that contains the rest of the body
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
|
ngx_int_t
|
||||||
ngx_http_client_body_handler_pt post_handler)
|
ngx_http_read_client_request_body(ngx_http_request_t *r,
|
||||||
|
ngx_http_client_body_handler_pt post_handler)
|
||||||
|
|
||||||
{
|
{
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_chain_t *cl;
|
ngx_chain_t *cl;
|
||||||
|
ngx_connection_t *c;
|
||||||
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 (!(rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t)))) {
|
rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
|
||||||
|
if (rb == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->request_body = rb;
|
r->request_body = rb;
|
||||||
|
|
||||||
|
/* STUB */
|
||||||
|
if (r->file.fd != NGX_INVALID_FILE) {
|
||||||
|
if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
|
||||||
|
ngx_close_file_n " \"%V\" failed", &r->file.name);
|
||||||
|
}
|
||||||
|
r->file.fd = NGX_INVALID_FILE;
|
||||||
|
}
|
||||||
|
/**/
|
||||||
|
|
||||||
if (r->headers_in.content_length_n <= 0) {
|
if (r->headers_in.content_length_n <= 0) {
|
||||||
post_handler(r);
|
post_handler(r);
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
@ -58,7 +71,8 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
|
|||||||
|
|
||||||
/* there is the pre-read part of the request body */
|
/* there is the pre-read part of the request body */
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +80,8 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
|
|||||||
b->start = b->pos = r->header_in->pos;
|
b->start = b->pos = r->header_in->pos;
|
||||||
b->end = b->last = r->header_in->last;
|
b->end = b->last = r->header_in->last;
|
||||||
|
|
||||||
if (!(rb->bufs = ngx_alloc_chain_link(r->pool))) {
|
rb->bufs = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (rb->bufs == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,11 +118,13 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
|
|||||||
size = clcf->client_body_buffer_size;
|
size = clcf->client_body_buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(rb->buf = ngx_create_temp_buf(r->pool, size))) {
|
rb->buf = ngx_create_temp_buf(r->pool, size);
|
||||||
|
if (rb->buf == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cl = ngx_alloc_chain_link(r->pool))) {
|
cl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,14 +138,16 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
|
|||||||
rb->bufs = cl;
|
rb->bufs = cl;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->connection->read->event_handler =
|
c = r->connection;
|
||||||
ngx_http_read_client_request_body_handler;
|
|
||||||
|
|
||||||
return ngx_http_do_read_client_request_body(r, r->connection);
|
c->read->event_handler = ngx_http_read_client_request_body_handler;
|
||||||
|
|
||||||
|
return ngx_http_do_read_client_request_body(r, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ngx_http_read_client_request_body_handler(ngx_event_t *rev)
|
static void
|
||||||
|
ngx_http_read_client_request_body_handler(ngx_event_t *rev)
|
||||||
{
|
{
|
||||||
ngx_int_t rc;
|
ngx_int_t rc;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
@ -150,8 +169,9 @@ static void ngx_http_read_client_request_body_handler(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
|
static ngx_int_t
|
||||||
ngx_connection_t *c)
|
ngx_http_do_read_client_request_body(ngx_http_request_t *r,
|
||||||
|
ngx_connection_t *c)
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
@ -169,7 +189,8 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
|
|||||||
if (rb->buf->last == rb->buf->end) {
|
if (rb->buf->last == rb->buf->end) {
|
||||||
|
|
||||||
if (rb->temp_file == NULL) {
|
if (rb->temp_file == NULL) {
|
||||||
if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) {
|
tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
|
||||||
|
if (tf == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +289,8 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r,
|
|||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ static u_char error_tail[] =
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
static u_char msie_stub[] =
|
static u_char ngx_http_msie_stub[] =
|
||||||
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
||||||
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
||||||
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
"<!-- The padding to disable MSIE's friendly error page -->" CRLF
|
||||||
@ -234,9 +234,9 @@ ngx_int_t
|
|||||||
ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
||||||
{
|
{
|
||||||
ngx_int_t rc;
|
ngx_int_t rc;
|
||||||
ngx_uint_t err, i, msie_padding;
|
ngx_uint_t i, err, msie_padding;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_chain_t *out, **ll, *cl;
|
ngx_chain_t *out, *cl;
|
||||||
ngx_http_err_page_t *err_page;
|
ngx_http_err_page_t *err_page;
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
|||||||
&& error >= NGX_HTTP_BAD_REQUEST
|
&& error >= NGX_HTTP_BAD_REQUEST
|
||||||
&& error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
|
&& error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
|
||||||
{
|
{
|
||||||
r->headers_out.content_length_n += sizeof(msie_stub) - 1;
|
r->headers_out.content_length_n += sizeof(ngx_http_msie_stub) - 1;
|
||||||
msie_padding = 1;
|
msie_padding = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,43 +360,64 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
|||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
out = NULL;
|
|
||||||
ll = NULL;
|
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
b->memory = 1;
|
b->memory = 1;
|
||||||
b->pos = error_pages[err].data;
|
b->pos = error_pages[err].data;
|
||||||
b->last = error_pages[err].data + error_pages[err].len;
|
b->last = error_pages[err].data + error_pages[err].len;
|
||||||
|
|
||||||
ngx_alloc_link_and_set_buf(cl, b, r->pool, NGX_ERROR);
|
cl = ngx_alloc_chain_link(r->pool);
|
||||||
ngx_chain_add_link(out, ll, cl);
|
if (cl == NULL) {
|
||||||
|
|
||||||
|
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cl->buf = b;
|
||||||
|
out = cl;
|
||||||
|
|
||||||
|
|
||||||
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
b->memory = 1;
|
b->memory = 1;
|
||||||
b->pos = error_tail;
|
b->pos = error_tail;
|
||||||
b->last = error_tail + sizeof(error_tail) - 1;
|
b->last = error_tail + sizeof(error_tail) - 1;
|
||||||
|
|
||||||
ngx_alloc_link_and_set_buf(cl, b, r->pool, NGX_ERROR);
|
cl->next = ngx_alloc_chain_link(r->pool);
|
||||||
ngx_chain_add_link(out, ll, cl);
|
if (cl->next == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
cl = cl->next;
|
||||||
|
cl->buf = b;
|
||||||
|
|
||||||
if (msie_padding) {
|
if (msie_padding) {
|
||||||
if (!(b = ngx_calloc_buf(r->pool))) {
|
b = ngx_calloc_buf(r->pool);
|
||||||
|
if (b == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
b->memory = 1;
|
|
||||||
b->pos = msie_stub;
|
|
||||||
b->last = msie_stub + sizeof(msie_stub) - 1;
|
|
||||||
|
|
||||||
ngx_alloc_link_and_set_buf(cl, b, r->pool, NGX_ERROR);
|
b->memory = 1;
|
||||||
ngx_chain_add_link(out, ll, cl);
|
b->pos = ngx_http_msie_stub;
|
||||||
|
b->last = ngx_http_msie_stub + sizeof(ngx_http_msie_stub) - 1;
|
||||||
|
|
||||||
|
cl->next = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl->next == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
cl = cl->next;
|
||||||
|
cl->buf = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
b->last_buf = 1;
|
b->last_buf = 1;
|
||||||
|
|
||||||
|
cl->next = NULL;
|
||||||
|
|
||||||
return ngx_http_output_filter(r, out);
|
return ngx_http_output_filter(r, out);
|
||||||
}
|
}
|
||||||
|
@ -129,13 +129,14 @@ ngx_http_upstream_init(ngx_http_request_t *r)
|
|||||||
u->writer.pool = r->pool;
|
u->writer.pool = r->pool;
|
||||||
|
|
||||||
if (ngx_array_init(&u->states, r->pool, u->peer.peers->number,
|
if (ngx_array_init(&u->states, r->pool, u->peer.peers->number,
|
||||||
sizeof(ngx_http_upstream_state_t)) == NGX_ERROR)
|
sizeof(ngx_http_upstream_state_t)) != NGX_OK)
|
||||||
{
|
{
|
||||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(u->state = ngx_push_array(&u->states))) {
|
u->state = ngx_array_push(&u->states);
|
||||||
|
if (u->state == NULL) {
|
||||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -317,7 +318,8 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
if (r->request_body->buf) {
|
if (r->request_body->buf) {
|
||||||
if (r->request_body->temp_file) {
|
if (r->request_body->temp_file) {
|
||||||
|
|
||||||
if (!(u->output.free = ngx_alloc_chain_link(r->pool))) {
|
u->output.free = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (u->output.free == NULL) {
|
||||||
ngx_http_upstream_finalize_request(r, u,
|
ngx_http_upstream_finalize_request(r, u,
|
||||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
@ -392,7 +394,8 @@ ngx_http_upstream_reinit(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
|
|
||||||
/* add one more state */
|
/* add one more state */
|
||||||
|
|
||||||
if (!(u->state = ngx_push_array(&u->states))) {
|
u->state = ngx_array_push(&u->states);
|
||||||
|
if (u->state == NULL) {
|
||||||
ngx_http_upstream_finalize_request(r, u,
|
ngx_http_upstream_finalize_request(r, u,
|
||||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||||
return;
|
return;
|
||||||
@ -739,7 +742,8 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
|
|
||||||
p->cachable = u->cachable;
|
p->cachable = u->cachable;
|
||||||
|
|
||||||
if (!(p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) {
|
p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
|
||||||
|
if (p->temp_file == NULL) {
|
||||||
ngx_http_upstream_finalize_request(r, u, 0);
|
ngx_http_upstream_finalize_request(r, u, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -759,7 +763,8 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
p->max_temp_file_size = u->conf->max_temp_file_size;
|
p->max_temp_file_size = u->conf->max_temp_file_size;
|
||||||
p->temp_file_write_size = u->conf->temp_file_write_size;
|
p->temp_file_write_size = u->conf->temp_file_write_size;
|
||||||
|
|
||||||
if (!(p->preread_bufs = ngx_alloc_chain_link(r->pool))) {
|
p->preread_bufs = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (p->preread_bufs == NULL) {
|
||||||
ngx_http_upstream_finalize_request(r, u, 0);
|
ngx_http_upstream_finalize_request(r, u, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
static ngx_http_variable_value_t *
|
static ngx_http_variable_value_t *
|
||||||
ngx_http_variable_header(ngx_http_request_t *r, uintptr_t data);
|
ngx_http_variable_header(ngx_http_request_t *r, uintptr_t data);
|
||||||
static ngx_http_variable_value_t *
|
static ngx_http_variable_value_t *
|
||||||
ngx_http_variable_unknown_header(ngx_http_request_t *r, ngx_str_t *var);
|
ngx_http_variable_unknown_header(ngx_http_request_t *r, uintptr_t data);
|
||||||
static ngx_http_variable_value_t *
|
static ngx_http_variable_value_t *
|
||||||
ngx_http_variable_remote_addr(ngx_http_request_t *r, uintptr_t data);
|
ngx_http_variable_remote_addr(ngx_http_request_t *r, uintptr_t data);
|
||||||
static ngx_http_variable_value_t *
|
static ngx_http_variable_value_t *
|
||||||
@ -69,39 +69,71 @@ static ngx_http_core_variable_t ngx_http_core_variables[] = {
|
|||||||
|
|
||||||
|
|
||||||
ngx_http_variable_t *
|
ngx_http_variable_t *
|
||||||
ngx_http_add_variable(ngx_conf_t *cf)
|
ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name, ngx_uint_t set)
|
||||||
{
|
{
|
||||||
ngx_http_variable_t *var;
|
ngx_uint_t i;
|
||||||
|
ngx_http_variable_t *v;
|
||||||
ngx_http_core_main_conf_t *cmcf;
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
|
|
||||||
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
||||||
|
|
||||||
if (cmcf->variables.elts == NULL) {
|
v = cmcf->variables.elts;
|
||||||
|
|
||||||
|
if (v == NULL) {
|
||||||
if (ngx_array_init(&cmcf->variables, cf->pool, 4,
|
if (ngx_array_init(&cmcf->variables, cf->pool, 4,
|
||||||
sizeof(ngx_http_variable_t)) == NGX_ERROR)
|
sizeof(ngx_http_variable_t)) == NGX_ERROR)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < cmcf->variables.nelts; i++) {
|
||||||
|
if (name->len != v[i].name.len
|
||||||
|
|| ngx_strncasecmp(name->data, v[i].name.data, name->len) != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (set && v[i].handler) {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"the duplicate \"%V\" variable", name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &v[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(var = ngx_array_push(&cmcf->variables))) {
|
v = ngx_array_push(&cmcf->variables);
|
||||||
|
if (v == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
var->index = cmcf->variables.nelts - 1;
|
v->name.len = name->len;
|
||||||
|
v->name.data = ngx_palloc(cf->pool, name->len);
|
||||||
|
if (v->name.data == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return var;
|
for (i = 0; i < name->len; i++) {
|
||||||
|
v->name.data[i] = ngx_toupper(name->data[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
v->index = cmcf->variables.nelts - 1;
|
||||||
|
v->handler = NULL;
|
||||||
|
v->data = 0;
|
||||||
|
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_http_variable_value_t *
|
ngx_http_variable_value_t *
|
||||||
ngx_http_get_indexed_variable(ngx_http_request_t *r, ngx_uint_t index)
|
ngx_http_get_indexed_variable(ngx_http_request_t *r, ngx_uint_t index)
|
||||||
{
|
{
|
||||||
ngx_http_variable_t *var;
|
ngx_http_variable_t *v;
|
||||||
|
ngx_http_variable_value_t *vv;
|
||||||
ngx_http_core_main_conf_t *cmcf;
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
|
|
||||||
/* TODO: cached variables */
|
|
||||||
|
|
||||||
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
||||||
|
|
||||||
if (cmcf->variables.elts == NULL || cmcf->variables.nelts <= index) {
|
if (cmcf->variables.elts == NULL || cmcf->variables.nelts <= index) {
|
||||||
@ -110,70 +142,70 @@ ngx_http_get_indexed_variable(ngx_http_request_t *r, ngx_uint_t index)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
var = cmcf->variables.elts;
|
if (r->variables && r->variables[index]) {
|
||||||
|
return r->variables[index];
|
||||||
|
}
|
||||||
|
|
||||||
return var[index].handler(r, var[index].data);
|
v = cmcf->variables.elts;
|
||||||
}
|
|
||||||
|
|
||||||
|
vv = v[index].handler(r, v[index].data);
|
||||||
|
|
||||||
ngx_int_t
|
if (r->variables == NULL) {
|
||||||
ngx_http_get_variable_index(ngx_http_core_main_conf_t *cmcf, ngx_str_t *name)
|
r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts
|
||||||
{
|
* sizeof(ngx_http_variable_value_t *));
|
||||||
ngx_uint_t i;
|
if (r->variables == NULL) {
|
||||||
ngx_http_variable_t *var;
|
return NULL;
|
||||||
|
|
||||||
var = cmcf->variables.elts;
|
|
||||||
for (i = 0; i < cmcf->variables.nelts; i++) {
|
|
||||||
if (var[i].name.len != name->len) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ngx_strncasecmp(var[i].name.data, name->data, name->len) == 0) {
|
|
||||||
return var[i].index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
r->variables[index] = vv;
|
||||||
|
|
||||||
|
return vv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_http_variable_value_t *
|
ngx_http_variable_value_t *
|
||||||
ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name)
|
ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name)
|
||||||
{
|
{
|
||||||
ngx_int_t index;
|
|
||||||
ngx_uint_t i, key;
|
ngx_uint_t i, key;
|
||||||
ngx_http_core_variable_t *var;
|
ngx_http_variable_t *v;
|
||||||
|
ngx_http_core_variable_t *cv;
|
||||||
ngx_http_core_main_conf_t *cmcf;
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
|
|
||||||
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
||||||
|
|
||||||
index = ngx_http_get_variable_index(cmcf, name);
|
v = cmcf->variables.elts;
|
||||||
|
for (i = 0; i < cmcf->variables.nelts; i++) {
|
||||||
|
if (v[i].name.len != name->len) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (index != -1) {
|
if (ngx_strncmp(v[i].name.data, name->data, name->len) == 0) {
|
||||||
return ngx_http_get_indexed_variable(r, index);
|
return ngx_http_get_indexed_variable(r, v[i].index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_http_vars_hash_key(key, name);
|
ngx_http_vars_hash_key(key, name);
|
||||||
|
|
||||||
var = ngx_http_core_variables_hash[key].elts;
|
cv = ngx_http_core_variables_hash[key].elts;
|
||||||
for (i = 0; i < ngx_http_core_variables_hash[key].nelts; i++) {
|
for (i = 0; i < ngx_http_core_variables_hash[key].nelts; i++) {
|
||||||
|
if (cv[i].name.len != name->len) {
|
||||||
if (var[i].name.len != name->len
|
|
||||||
|| ngx_strncasecmp(var[i].name.data, name->data, name->len) != 0)
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return var[i].handler(r, var[i].data);
|
if (ngx_strncmp(cv[i].name.data, name->data, name->len) == 0) {
|
||||||
|
return cv[i].handler(r, cv[i].data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_strncasecmp(name->data, "HTTP_", 5) != 0) {
|
if (ngx_strncmp(name->data, "HTTP_", 5) == 0) {
|
||||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
return ngx_http_variable_unknown_header(r, (uintptr_t) name);
|
||||||
"unknown \"%V\" variable", name);
|
|
||||||
return NGX_HTTP_VARIABLE_NOT_FOUND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ngx_http_variable_unknown_header(r, name);
|
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||||
|
"unknown \"%V\" variable", name);
|
||||||
|
|
||||||
|
return NGX_HTTP_VARIABLE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -181,7 +213,7 @@ static ngx_http_variable_value_t *
|
|||||||
ngx_http_variable_header(ngx_http_request_t *r, uintptr_t data)
|
ngx_http_variable_header(ngx_http_request_t *r, uintptr_t data)
|
||||||
{
|
{
|
||||||
ngx_table_elt_t *h;
|
ngx_table_elt_t *h;
|
||||||
ngx_http_variable_value_t *v;
|
ngx_http_variable_value_t *vv;
|
||||||
|
|
||||||
h = *(ngx_table_elt_t **) ((char *) &r->headers_in + data);
|
h = *(ngx_table_elt_t **) ((char *) &r->headers_in + data);
|
||||||
|
|
||||||
@ -189,25 +221,28 @@ ngx_http_variable_header(ngx_http_request_t *r, uintptr_t data)
|
|||||||
return NGX_HTTP_VARIABLE_NOT_FOUND;
|
return NGX_HTTP_VARIABLE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
|
vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t));
|
||||||
|
if (vv == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
v->value = 0;
|
vv->value = 0;
|
||||||
v->text = h->value;
|
vv->text = h->value;
|
||||||
|
|
||||||
return v;
|
return vv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_http_variable_value_t *
|
static ngx_http_variable_value_t *
|
||||||
ngx_http_variable_unknown_header(ngx_http_request_t *r, ngx_str_t *var)
|
ngx_http_variable_unknown_header(ngx_http_request_t *r, uintptr_t data)
|
||||||
{
|
{
|
||||||
|
ngx_str_t *var = (ngx_str_t *) data;
|
||||||
|
|
||||||
u_char ch;
|
u_char ch;
|
||||||
ngx_uint_t i, n;
|
ngx_uint_t i, n;
|
||||||
ngx_list_part_t *part;
|
ngx_list_part_t *part;
|
||||||
ngx_table_elt_t *header;
|
ngx_table_elt_t *header;
|
||||||
ngx_http_variable_value_t *v;
|
ngx_http_variable_value_t *vv;
|
||||||
|
|
||||||
part = &r->headers_in.headers.part;
|
part = &r->headers_in.headers.part;
|
||||||
header = part->elts;
|
header = part->elts;
|
||||||
@ -241,13 +276,14 @@ ngx_http_variable_unknown_header(ngx_http_request_t *r, ngx_str_t *var)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (n + 5 == var->len) {
|
if (n + 5 == var->len) {
|
||||||
if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
|
vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t));
|
||||||
|
if (vv == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
v->value = 0;
|
vv->value = 0;
|
||||||
v->text = header[i].value;
|
vv->text = header[i].value;
|
||||||
return v;
|
return vv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,56 +294,61 @@ ngx_http_variable_unknown_header(ngx_http_request_t *r, ngx_str_t *var)
|
|||||||
static ngx_http_variable_value_t *
|
static ngx_http_variable_value_t *
|
||||||
ngx_http_variable_remote_addr(ngx_http_request_t *r, uintptr_t data)
|
ngx_http_variable_remote_addr(ngx_http_request_t *r, uintptr_t data)
|
||||||
{
|
{
|
||||||
ngx_http_variable_value_t *v;
|
ngx_http_variable_value_t *vv;
|
||||||
|
|
||||||
if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
|
vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t));
|
||||||
|
if (vv == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
v->value = 0;
|
vv->value = 0;
|
||||||
v->text = r->connection->addr_text;
|
vv->text = r->connection->addr_text;
|
||||||
|
|
||||||
return v;
|
return vv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_http_variable_value_t *
|
static ngx_http_variable_value_t *
|
||||||
ngx_http_variable_uri(ngx_http_request_t *r, uintptr_t data)
|
ngx_http_variable_uri(ngx_http_request_t *r, uintptr_t data)
|
||||||
{
|
{
|
||||||
ngx_http_variable_value_t *v;
|
ngx_http_variable_value_t *vv;
|
||||||
|
|
||||||
if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
|
vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t));
|
||||||
|
if (vv == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
v->value = 0;
|
vv->value = 0;
|
||||||
v->text = r->uri;
|
vv->text = r->uri;
|
||||||
|
|
||||||
return v;
|
return vv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_http_variable_value_t *
|
static ngx_http_variable_value_t *
|
||||||
ngx_http_variable_query_string(ngx_http_request_t *r, uintptr_t data)
|
ngx_http_variable_query_string(ngx_http_request_t *r, uintptr_t data)
|
||||||
{
|
{
|
||||||
ngx_http_variable_value_t *v;
|
ngx_http_variable_value_t *vv;
|
||||||
|
|
||||||
if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
|
vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t));
|
||||||
|
if (vv == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
v->value = 0;
|
vv->value = 0;
|
||||||
v->text = r->args;
|
vv->text = r->args;
|
||||||
|
|
||||||
return v;
|
return vv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_http_core_variables_init(ngx_cycle_t *cycle)
|
ngx_http_variables_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_uint_t i, key;
|
ngx_uint_t i, j, key;
|
||||||
ngx_http_core_variable_t *var, *v;
|
ngx_http_variable_t *v;
|
||||||
|
ngx_http_core_variable_t *cv, *vp;
|
||||||
|
ngx_http_core_main_conf_t *cmcf;
|
||||||
|
|
||||||
ngx_http_core_variables_hash = ngx_palloc(cycle->pool,
|
ngx_http_core_variables_hash = ngx_palloc(cycle->pool,
|
||||||
NGX_HTTP_VARS_HASH_PRIME
|
NGX_HTTP_VARS_HASH_PRIME
|
||||||
@ -324,14 +365,54 @@ ngx_http_core_variables_init(ngx_cycle_t *cycle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var = ngx_http_core_variables; var->name.len; var++) {
|
for (cv = ngx_http_core_variables; cv->name.len; cv++) {
|
||||||
ngx_http_vars_hash_key(key, &var->name);
|
ngx_http_vars_hash_key(key, &cv->name);
|
||||||
|
|
||||||
if (!(v = ngx_array_push(&ngx_http_core_variables_hash[key]))) {
|
vp = ngx_array_push(&ngx_http_core_variables_hash[key]);
|
||||||
|
if (vp == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
*v = *var;
|
*vp = *cv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
|
||||||
|
|
||||||
|
v = cmcf->variables.elts;
|
||||||
|
for (i = 0; i < cmcf->variables.nelts; i++) {
|
||||||
|
|
||||||
|
if (v[i].handler) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_http_vars_hash_key(key, &v[i].name);
|
||||||
|
|
||||||
|
cv = ngx_http_core_variables_hash[key].elts;
|
||||||
|
for (j = 0; j < ngx_http_core_variables_hash[key].nelts; j++) {
|
||||||
|
if (cv[j].name.len != v[i].name.len) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_strncmp(cv[j].name.data, v[i].name.data, v[i].name.len)
|
||||||
|
== 0)
|
||||||
|
{
|
||||||
|
v[i].handler = cv[j].handler;
|
||||||
|
v[i].data = cv[j].data;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_strncmp(v[i].name.data, "HTTP_", 5) == 0) {
|
||||||
|
v[i].handler = ngx_http_variable_unknown_header;
|
||||||
|
v[i].data = (uintptr_t) &v[i].name;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_error(NGX_LOG_ERR, cycle->log, 0,
|
||||||
|
"unknown \"%V\" variable", &v[i].name);
|
||||||
|
|
||||||
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
|
@ -17,45 +17,41 @@
|
|||||||
#define NGX_HTTP_VARIABLE_NOT_FOUND (ngx_http_variable_value_t *) -1
|
#define NGX_HTTP_VARIABLE_NOT_FOUND (ngx_http_variable_value_t *) -1
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
struct ngx_http_variable_value_s {
|
||||||
ngx_uint_t value;
|
ngx_uint_t value;
|
||||||
ngx_str_t text;
|
ngx_str_t text;
|
||||||
} ngx_http_variable_value_t;
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct ngx_http_variable_s ngx_http_variable_t;
|
typedef struct ngx_http_variable_s ngx_http_variable_t;
|
||||||
|
|
||||||
typedef ngx_http_variable_value_t *
|
typedef ngx_http_variable_value_t *
|
||||||
(*ngx_http_get_variable_pt) (ngx_http_request_t *r, void *var);
|
(*ngx_http_get_variable_pt) (ngx_http_request_t *r, uintptr_t data);
|
||||||
|
|
||||||
|
|
||||||
struct ngx_http_variable_s {
|
struct ngx_http_variable_s {
|
||||||
ngx_str_t name;
|
ngx_str_t name;
|
||||||
ngx_uint_t index;
|
ngx_uint_t index;
|
||||||
ngx_http_get_variable_pt handler;
|
ngx_http_get_variable_pt handler;
|
||||||
void *data;
|
uintptr_t data;
|
||||||
ngx_uint_t uses;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef ngx_http_variable_value_t *
|
|
||||||
(*ngx_http_get_core_variable_pt) (ngx_http_request_t *r, uintptr_t data);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_str_t name;
|
ngx_str_t name;
|
||||||
ngx_http_get_core_variable_pt handler;
|
ngx_http_get_variable_pt handler;
|
||||||
uintptr_t data;
|
uintptr_t data;
|
||||||
} ngx_http_core_variable_t;
|
} ngx_http_core_variable_t;
|
||||||
|
|
||||||
|
|
||||||
ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf);
|
ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name,
|
||||||
|
ngx_uint_t set);
|
||||||
ngx_int_t ngx_http_get_variable_index(ngx_http_core_main_conf_t *cmcf,
|
ngx_int_t ngx_http_get_variable_index(ngx_http_core_main_conf_t *cmcf,
|
||||||
ngx_str_t *name);
|
ngx_str_t *name);
|
||||||
ngx_http_variable_value_t *ngx_http_get_indexed_variable(ngx_http_request_t *r,
|
ngx_http_variable_value_t *ngx_http_get_indexed_variable(ngx_http_request_t *r,
|
||||||
ngx_uint_t index);
|
ngx_uint_t index);
|
||||||
ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r,
|
ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r,
|
||||||
ngx_str_t *name);
|
ngx_str_t *name);
|
||||||
ngx_int_t ngx_http_core_variables_init(ngx_cycle_t *cycle);
|
ngx_int_t ngx_http_variables_init(ngx_cycle_t *cycle);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_HTTP_VARIABLES_H_INCLUDED_ */
|
#endif /* _NGX_HTTP_VARIABLES_H_INCLUDED_ */
|
||||||
|
@ -42,7 +42,8 @@ ngx_module_t ngx_http_write_filter_module = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
ngx_int_t
|
||||||
|
ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
||||||
{
|
{
|
||||||
off_t size, sent;
|
off_t size, sent;
|
||||||
ngx_uint_t last, flush;
|
ngx_uint_t last, flush;
|
||||||
@ -55,8 +56,13 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
ngx_http_write_filter_module);
|
ngx_http_write_filter_module);
|
||||||
|
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
ngx_http_create_ctx(r, ctx, ngx_http_write_filter_module,
|
|
||||||
sizeof(ngx_http_write_filter_ctx_t), NGX_ERROR);
|
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_write_filter_ctx_t));
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_http_set_ctx(r, ctx, ngx_http_write_filter_module);
|
||||||
}
|
}
|
||||||
|
|
||||||
size = 0;
|
size = 0;
|
||||||
@ -112,7 +118,8 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
/* add the new chain to the existent one */
|
/* add the new chain to the existent one */
|
||||||
|
|
||||||
for (ln = in; ln; ln = ln->next) {
|
for (ln = in; ln; ln = ln->next) {
|
||||||
if (!(cl = ngx_alloc_chain_link(r->pool))) {
|
cl = ngx_alloc_chain_link(r->pool);
|
||||||
|
if (cl == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +197,11 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flush) {
|
if (flush) {
|
||||||
while ((ctx->out = ctx->out->next)) { /* void */ }
|
do {
|
||||||
|
ctx->out = ctx->out->next;
|
||||||
|
}
|
||||||
|
while (ctx->out);
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +241,8 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle)
|
static ngx_int_t
|
||||||
|
ngx_http_write_filter_init(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
ngx_http_top_body_filter = ngx_http_write_filter;
|
ngx_http_top_body_filter = ngx_http_write_filter;
|
||||||
|
|
@ -17,7 +17,9 @@ static ngx_int_t ngx_pop3_read_command(ngx_imap_session_t *s);
|
|||||||
|
|
||||||
|
|
||||||
static u_char pop3_greeting[] = "+OK " NGINX_VER " ready" CRLF;
|
static u_char pop3_greeting[] = "+OK " NGINX_VER " ready" CRLF;
|
||||||
|
#if 0
|
||||||
static u_char imap_greeting[] = "* OK " NGINX_VER " ready" CRLF;
|
static u_char imap_greeting[] = "* OK " NGINX_VER " ready" CRLF;
|
||||||
|
#endif
|
||||||
|
|
||||||
static u_char pop3_ok[] = "+OK" CRLF;
|
static u_char pop3_ok[] = "+OK" CRLF;
|
||||||
static u_char pop3_invalid_command[] = "-ERR invalid command" CRLF;
|
static u_char pop3_invalid_command[] = "-ERR invalid command" CRLF;
|
||||||
@ -69,7 +71,8 @@ static void ngx_imap_init_session(ngx_event_t *rev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(s = ngx_pcalloc(c->pool, sizeof(ngx_imap_session_t)))) {
|
s = ngx_pcalloc(c->pool, sizeof(ngx_imap_session_t));
|
||||||
|
if (s == NULL) {
|
||||||
ngx_imap_close_connection(c);
|
ngx_imap_close_connection(c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -307,5 +310,5 @@ void ngx_imap_close_connection(ngx_connection_t *c)
|
|||||||
|
|
||||||
ngx_close_connection(c);
|
ngx_close_connection(c);
|
||||||
|
|
||||||
ngx_destroy_pool(c->pool);
|
ngx_destroy_pool(pool);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,8 @@ ngx_int_t ngx_pop3_parse_command(ngx_imap_session_t *s)
|
|||||||
case ' ':
|
case ' ':
|
||||||
case CR:
|
case CR:
|
||||||
case LF:
|
case LF:
|
||||||
if (!(arg = ngx_array_push(&s->args))) {
|
arg = ngx_array_push(&s->args);
|
||||||
|
if (arg == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
arg->len = p - 1 - s->arg_start;
|
arg->len = p - 1 - s->arg_start;
|
||||||
@ -169,7 +170,8 @@ ngx_int_t ngx_pop3_parse_command(ngx_imap_session_t *s)
|
|||||||
|
|
||||||
if (state == sw_done) {
|
if (state == sw_done) {
|
||||||
if (s->arg_start) {
|
if (s->arg_start) {
|
||||||
if (!(arg = ngx_array_push(&s->args))) {
|
arg = ngx_array_push(&s->args);
|
||||||
|
if (arg == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
arg->len = s->arg_end - s->arg_start;
|
arg->len = s->arg_end - s->arg_start;
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
static void ngx_imap_proxy_block_read(ngx_event_t *rev);
|
static void ngx_imap_proxy_block_read(ngx_event_t *rev);
|
||||||
static void ngx_imap_proxy_auth_handler(ngx_event_t *rev);
|
static void ngx_imap_proxy_auth_handler(ngx_event_t *rev);
|
||||||
static void ngx_imap_proxy_init_handler(ngx_event_t *wev);
|
|
||||||
static void ngx_imap_proxy_dummy_handler(ngx_event_t *ev);
|
static void ngx_imap_proxy_dummy_handler(ngx_event_t *ev);
|
||||||
static ngx_int_t ngx_imap_proxy_read_response(ngx_imap_session_t *s);
|
static ngx_int_t ngx_imap_proxy_read_response(ngx_imap_session_t *s);
|
||||||
static void ngx_imap_proxy_handler(ngx_event_t *ev);
|
static void ngx_imap_proxy_handler(ngx_event_t *ev);
|
||||||
@ -27,7 +26,8 @@ void ngx_imap_proxy_init(ngx_imap_session_t *s)
|
|||||||
struct sockaddr_in *sin;
|
struct sockaddr_in *sin;
|
||||||
ngx_imap_proxy_ctx_t *p;
|
ngx_imap_proxy_ctx_t *p;
|
||||||
|
|
||||||
if (!(p = ngx_pcalloc(s->connection->pool, sizeof(ngx_imap_proxy_ctx_t)))) {
|
p = ngx_pcalloc(s->connection->pool, sizeof(ngx_imap_proxy_ctx_t));
|
||||||
|
if (p == NULL) {
|
||||||
ngx_imap_close_connection(s->connection);
|
ngx_imap_close_connection(s->connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -36,7 +36,8 @@ void ngx_imap_proxy_init(ngx_imap_session_t *s)
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
if (!(peers = ngx_pcalloc(s->connection->pool, sizeof(ngx_peers_t)))) {
|
peers = ngx_pcalloc(s->connection->pool, sizeof(ngx_peers_t));
|
||||||
|
if (peers == NULL) {
|
||||||
ngx_imap_close_connection(s->connection);
|
ngx_imap_close_connection(s->connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -45,7 +46,8 @@ void ngx_imap_proxy_init(ngx_imap_session_t *s)
|
|||||||
p->upstream.log = s->connection->log;
|
p->upstream.log = s->connection->log;
|
||||||
p->upstream.log_error = NGX_ERROR_ERR;
|
p->upstream.log_error = NGX_ERROR_ERR;
|
||||||
|
|
||||||
if (!(sin = ngx_pcalloc(s->connection->pool, sizeof(struct sockaddr_in)))) {
|
sin = ngx_pcalloc(s->connection->pool, sizeof(struct sockaddr_in));
|
||||||
|
if (sin == NULL) {
|
||||||
ngx_imap_close_connection(s->connection);
|
ngx_imap_close_connection(s->connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -146,14 +148,15 @@ static void ngx_imap_proxy_auth_handler(ngx_event_t *rev)
|
|||||||
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send user");
|
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send user");
|
||||||
|
|
||||||
line.len = sizeof("USER ") + s->login.len - 1 + 2;
|
line.len = sizeof("USER ") + s->login.len - 1 + 2;
|
||||||
if (!(line.data = ngx_palloc(c->pool, line.len))) {
|
line.data = ngx_palloc(c->pool, line.len);
|
||||||
|
if (line.data == NULL) {
|
||||||
ngx_imap_proxy_close_session(s);
|
ngx_imap_proxy_close_session(s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ngx_cpymem(line.data, "USER ", sizeof("USER ") - 1);
|
p = ngx_cpymem(line.data, "USER ", sizeof("USER ") - 1);
|
||||||
p = ngx_cpymem(p, s->login.data, s->login.len);
|
p = ngx_cpymem(p, s->login.data, s->login.len);
|
||||||
*p++ = CR; *p++ = LF;
|
*p++ = CR; *p = LF;
|
||||||
|
|
||||||
if (ngx_send(c, line.data, line.len) < (ssize_t) line.len) {
|
if (ngx_send(c, line.data, line.len) < (ssize_t) line.len) {
|
||||||
/*
|
/*
|
||||||
@ -175,14 +178,15 @@ static void ngx_imap_proxy_auth_handler(ngx_event_t *rev)
|
|||||||
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send pass");
|
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, rev->log, 0, "imap proxy send pass");
|
||||||
|
|
||||||
line.len = sizeof("PASS ") + s->passwd.len - 1 + 2;
|
line.len = sizeof("PASS ") + s->passwd.len - 1 + 2;
|
||||||
if (!(line.data = ngx_palloc(c->pool, line.len))) {
|
line.data = ngx_palloc(c->pool, line.len);
|
||||||
|
if (line.data == NULL) {
|
||||||
ngx_imap_proxy_close_session(s);
|
ngx_imap_proxy_close_session(s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ngx_cpymem(line.data, "PASS ", sizeof("PASS ") - 1);
|
p = ngx_cpymem(line.data, "PASS ", sizeof("PASS ") - 1);
|
||||||
p = ngx_cpymem(p, s->passwd.data, s->passwd.len);
|
p = ngx_cpymem(p, s->passwd.data, s->passwd.len);
|
||||||
*p++ = CR; *p++ = LF;
|
*p++ = CR; *p = LF;
|
||||||
|
|
||||||
if (ngx_send(c, line.data, line.len) < (ssize_t) line.len) {
|
if (ngx_send(c, line.data, line.len) < (ssize_t) line.len) {
|
||||||
/*
|
/*
|
||||||
|
@ -16,7 +16,6 @@ ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
|
|||||||
u_char *buf, *prev;
|
u_char *buf, *prev;
|
||||||
size_t size;
|
size_t size;
|
||||||
ssize_t total;
|
ssize_t total;
|
||||||
ngx_err_t err;
|
|
||||||
|
|
||||||
if (c->read->pending_eof) {
|
if (c->read->pending_eof) {
|
||||||
c->read->ready = 0;
|
c->read->ready = 0;
|
||||||
|
@ -17,7 +17,6 @@ ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in,
|
|||||||
off_t send, sent;
|
off_t send, sent;
|
||||||
size_t len;
|
size_t len;
|
||||||
ssize_t n, size;
|
ssize_t n, size;
|
||||||
ngx_err_t err;
|
|
||||||
ngx_chain_t *cl;
|
ngx_chain_t *cl;
|
||||||
|
|
||||||
/* the maximum limit size is the maximum size_t value - the page size */
|
/* the maximum limit size is the maximum size_t value - the page size */
|
||||||
|
@ -11,11 +11,13 @@
|
|||||||
int ngx_pagesize;
|
int ngx_pagesize;
|
||||||
|
|
||||||
|
|
||||||
void *ngx_alloc(size_t size, ngx_log_t *log)
|
void *
|
||||||
|
ngx_alloc(size_t size, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
if (!(p = malloc(size))) {
|
p = malloc(size);
|
||||||
|
if (p == NULL) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
||||||
"malloc() %uz bytes failed", size);
|
"malloc() %uz bytes failed", size);
|
||||||
}
|
}
|
||||||
@ -26,7 +28,8 @@ void *ngx_alloc(size_t size, ngx_log_t *log)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *ngx_calloc(size_t size, ngx_log_t *log)
|
void *
|
||||||
|
ngx_calloc(size_t size, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
@ -42,7 +45,8 @@ void *ngx_calloc(size_t size, ngx_log_t *log)
|
|||||||
|
|
||||||
#if (NGX_HAVE_POSIX_MEMALIGN)
|
#if (NGX_HAVE_POSIX_MEMALIGN)
|
||||||
|
|
||||||
void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
|
void *
|
||||||
|
ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
@ -60,11 +64,13 @@ void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
|
|||||||
|
|
||||||
#elif (NGX_HAVE_MEMALIGN)
|
#elif (NGX_HAVE_MEMALIGN)
|
||||||
|
|
||||||
void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
|
void *
|
||||||
|
ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
if (!(p = memalign(alignment, size))) {
|
p = memalign(alignment, size);
|
||||||
|
if (p == NULL) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
||||||
"memalign() %uz bytes aligned to %uz failed",
|
"memalign() %uz bytes aligned to %uz failed",
|
||||||
size, alignment);
|
size, alignment);
|
||||||
|
@ -34,8 +34,7 @@ u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
|
|||||||
|
|
||||||
u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
|
u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -25,7 +25,7 @@ typedef int ngx_err_t;
|
|||||||
#define NGX_ENOTDIR ENOTDIR
|
#define NGX_ENOTDIR ENOTDIR
|
||||||
#define NGX_EINVAL EINVAL
|
#define NGX_EINVAL EINVAL
|
||||||
#define NGX_EPIPE EPIPE
|
#define NGX_EPIPE EPIPE
|
||||||
#define NGX_EAGAIN EWOULDBLOCK
|
#define NGX_EAGAIN EAGAIN
|
||||||
#define NGX_EINPROGRESS EINPROGRESS
|
#define NGX_EINPROGRESS EINPROGRESS
|
||||||
#define NGX_EADDRINUSE EADDRINUSE
|
#define NGX_EADDRINUSE EADDRINUSE
|
||||||
#define NGX_ECONNABORTED ECONNABORTED
|
#define NGX_ECONNABORTED ECONNABORTED
|
||||||
@ -52,10 +52,10 @@ u_char *ngx_strerror_r(int err, u_char *errstr, size_t size);
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Solaris has threads-safe strerror() */
|
/* Solaris has thread-safe strerror() */
|
||||||
|
|
||||||
#define ngx_strerror_r(err, errstr, size) \
|
#define ngx_strerror_r(err, errstr, size) \
|
||||||
ngx_cpystrn(errstr, (u_char *) strerror(err), size)
|
ngx_cpystrn(errstr, (u_char *) strerror(err), size)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -131,7 +131,6 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl,
|
|||||||
u_char *prev;
|
u_char *prev;
|
||||||
size_t size;
|
size_t size;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
ngx_err_t err;
|
|
||||||
ngx_array_t vec;
|
ngx_array_t vec;
|
||||||
struct iovec *iov, iovs[NGX_IOVS];
|
struct iovec *iov, iovs[NGX_IOVS];
|
||||||
|
|
||||||
@ -162,7 +161,8 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl,
|
|||||||
iov->iov_len += cl->buf->last - cl->buf->pos;
|
iov->iov_len += cl->buf->last - cl->buf->pos;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!(iov = ngx_array_push(&vec))) {
|
iov = ngx_array_push(&vec);
|
||||||
|
if (iov == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ char ngx_freebsd_kern_osrelease[128];
|
|||||||
int ngx_freebsd_kern_osreldate;
|
int ngx_freebsd_kern_osreldate;
|
||||||
int ngx_freebsd_hw_ncpu;
|
int ngx_freebsd_hw_ncpu;
|
||||||
int ngx_freebsd_net_inet_tcp_sendspace;
|
int ngx_freebsd_net_inet_tcp_sendspace;
|
||||||
|
int ngx_freebsd_kern_ipc_somaxconn;
|
||||||
|
|
||||||
/* FreeBSD 4.9 */
|
/* FreeBSD 4.9 */
|
||||||
int ngx_freebsd_machdep_hlt_logical_cpus;
|
int ngx_freebsd_machdep_hlt_logical_cpus;
|
||||||
@ -61,6 +62,10 @@ sysctl_t sysctls[] = {
|
|||||||
&ngx_freebsd_net_inet_tcp_sendspace,
|
&ngx_freebsd_net_inet_tcp_sendspace,
|
||||||
sizeof(int), 0 },
|
sizeof(int), 0 },
|
||||||
|
|
||||||
|
{ "kern.ipc.somaxconn",
|
||||||
|
&ngx_freebsd_kern_ipc_somaxconn,
|
||||||
|
sizeof(int), 0 },
|
||||||
|
|
||||||
{ "kern.ipc.zero_copy.send",
|
{ "kern.ipc.zero_copy.send",
|
||||||
&ngx_freebsd_kern_ipc_zero_copy_send,
|
&ngx_freebsd_kern_ipc_zero_copy_send,
|
||||||
sizeof(int), 0 },
|
sizeof(int), 0 },
|
||||||
@ -85,7 +90,7 @@ void ngx_debug_init()
|
|||||||
|
|
||||||
ngx_int_t ngx_os_init(ngx_log_t *log)
|
ngx_int_t ngx_os_init(ngx_log_t *log)
|
||||||
{
|
{
|
||||||
int version;
|
int version, somaxconn;
|
||||||
size_t size;
|
size_t size;
|
||||||
ngx_err_t err;
|
ngx_err_t err;
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
@ -203,6 +208,18 @@ ngx_int_t ngx_os_init(ngx_log_t *log)
|
|||||||
ngx_ncpu = ngx_freebsd_hw_ncpu;
|
ngx_ncpu = ngx_freebsd_hw_ncpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version < 600008) {
|
||||||
|
somaxconn = 32767;
|
||||||
|
} else {
|
||||||
|
somaxconn = 65535;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_freebsd_kern_ipc_somaxconn > somaxconn) {
|
||||||
|
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||||
|
"sysctl kern.ipc.somaxconn must be no more than %d",
|
||||||
|
somaxconn);
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ngx_tcp_nodelay_and_tcp_nopush = 1;
|
ngx_tcp_nodelay_and_tcp_nopush = 1;
|
||||||
|
|
||||||
|
@ -227,13 +227,15 @@ ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
/* create the thread errno' array */
|
/* create the thread errno' array */
|
||||||
|
|
||||||
if (!(errnos = ngx_calloc(n * sizeof(int), cycle->log))) {
|
errnos = ngx_calloc(n * sizeof(int), cycle->log);
|
||||||
|
if (errnos == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create the thread tids array */
|
/* create the thread tids array */
|
||||||
|
|
||||||
if (!(tids = ngx_calloc((n + 1) * sizeof(ngx_tid_t), cycle->log))) {
|
tids = ngx_calloc((n + 1) * sizeof(ngx_tid_t), cycle->log);
|
||||||
|
if (tids == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,8 +266,7 @@ ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle)
|
|||||||
|
|
||||||
ngx_tid_t ngx_thread_self()
|
ngx_tid_t ngx_thread_self()
|
||||||
{
|
{
|
||||||
int tid;
|
ngx_int_t tid;
|
||||||
ngx_tid_t pid;
|
|
||||||
|
|
||||||
tid = ngx_gettid();
|
tid = ngx_gettid();
|
||||||
|
|
||||||
@ -305,7 +306,8 @@ ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags)
|
|||||||
ngx_mutex_t *m;
|
ngx_mutex_t *m;
|
||||||
union semun op;
|
union semun op;
|
||||||
|
|
||||||
if (!(m = ngx_alloc(sizeof(ngx_mutex_t), log))) {
|
m = ngx_alloc(sizeof(ngx_mutex_t), log);
|
||||||
|
if (m == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +355,7 @@ void ngx_mutex_destroy(ngx_mutex_t *m)
|
|||||||
|
|
||||||
ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try)
|
ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try)
|
||||||
{
|
{
|
||||||
uint32_t lock, new, old;
|
uint32_t lock, old;
|
||||||
ngx_uint_t tries;
|
ngx_uint_t tries;
|
||||||
struct sembuf op;
|
struct sembuf op;
|
||||||
|
|
||||||
@ -483,7 +485,7 @@ ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try)
|
|||||||
|
|
||||||
ngx_int_t ngx_mutex_unlock(ngx_mutex_t *m)
|
ngx_int_t ngx_mutex_unlock(ngx_mutex_t *m)
|
||||||
{
|
{
|
||||||
uint32_t lock, new, old;
|
uint32_t lock, old;
|
||||||
struct sembuf op;
|
struct sembuf op;
|
||||||
|
|
||||||
if (!ngx_threaded) {
|
if (!ngx_threaded) {
|
||||||
@ -576,7 +578,8 @@ ngx_cond_t *ngx_cond_init(ngx_log_t *log)
|
|||||||
{
|
{
|
||||||
ngx_cond_t *cv;
|
ngx_cond_t *cv;
|
||||||
|
|
||||||
if (!(cv = ngx_alloc(sizeof(ngx_cond_t), log))) {
|
cv = ngx_alloc(sizeof(ngx_cond_t), log);
|
||||||
|
if (cv == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user