nginx-0.1.2-RELEASE import

*) Feature: the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS
       options in configure.

    *) Feature: the server_name directive supports *.domain.tld.

    *) Bugfix: the portability improvements.

    *) Bugfix: if configuration file was set in command line, the
       reconfiguration was impossible; the bug had appeared in 0.1.1.

    *) Bugfix: proxy module may get caught in an endless loop when sendfile
       is not used.

    *) Bugfix: with sendfile the response was not recoded according to the
       charset module directives; the bug had appeared in 0.1.1.

    *) Bugfix: very seldom bug in the kqueue processing.

    *) Bugfix: the gzip module compressed the proxied responses that was
       already compressed.
This commit is contained in:
Igor Sysoev 2004-10-21 15:34:38 +00:00
parent ac64333a44
commit c0edbcce58
106 changed files with 2513 additions and 1059 deletions

48
auto/cc/bcc Normal file
View File

@ -0,0 +1,48 @@
# Copyright (C) Igor Sysoev
# Borland C++ 5.5
# optimizations
# maximize speed
CFLAGS="$CFLAGS -O2"
case $CPU in
pentium)
# optimize for Pentium and Athlon
CPU_OPT="-5"
;;
pentiumpro)
# optimize for Pentium Pro, Pentium II and Pentium III
CPU_OPT="-6"
;;
esac
CFLAGS="$CFLAGS $CPU_OPT"
# multithreaded
CFLAGS="$CFLAGS -tWM"
# stop on warning
CFLAGS="$CFLAGS -w!"
# disable logo
CFLAGS="$CFLAGS -q"
# precompiled headers
CORE_DEPS="$CORE_DEPS $OBJS/ngx_config.csm"
NGX_PCH="$OBJS/ngx_config.csm"
NGX_BUILD_PCH="-H=$OBJS/ngx_config.csm"
NGX_USE_PCH="-Hu -H=$OBJS/ngx_config.csm"
LINK="\$(CC)"
ngx_include_opt="-I"
ngx_objout="-o"
ngx_binout="-e"
ngx_objext="obj"
ngx_binext=".exe"
ngx_dirsep='\\'

119
auto/cc/conf Normal file
View File

@ -0,0 +1,119 @@
# Copyright (C) Igor Sysoev
ngx_include_opt="-I "
ngx_compile_opt="-c"
ngx_objout="-o "
ngx_binout="-o "
ngx_objext="o"
ngx_binext=
ngx_regex_dirsep="\/"
ngx_dirsep='/'
ngx_regex_cont=' \\\
'
ngx_cont=' \
'
ngx_tab=' \
'
ngx_spacer=
. auto/cc/name
if test -n "$CFLAGS"; then
CC_TEST_FLAGS="$CFLAGS $NGX_CC_OPT"
case $NGX_CC_NAME in
ccc)
# Compaq C V6.5-207
ngx_include_opt="-I"
;;
esac
else
case $NGX_CC_NAME in
gcc)
# gcc 2.7.2.3, 2.8.1, 2.95.4,
# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4
. auto/cc/gcc
;;
icc)
# Intel C++ compiler 7.1, 8.0
. auto/cc/icc
;;
# ccc)
# # Compaq C V6.5-207
#
# . auto/cc/ccc
# ;;
# acc)
# # aCC: HP ANSI C++ B3910B A.03.55.02
#
# . auto/cc/acc
# ;;
msvc)
# MSVC 6.0 SP2
. auto/cc/msvc
;;
owc)
# Open Watcom C 1.0, 1.2
. auto/cc/owc
;;
bcc)
# Borland C++ 5.5
. auto/cc/bcc
;;
esac
CC_TEST_FLAGS=$NGX_CC_OPT
fi
CFLAGS="$CFLAGS $NGX_CC_OPT"
if [ "$PLATFORM" != win32 ]; then
ngx_feature="gcc variadic macros"
ngx_feature_name=HAVE_GCC_VARIADIC_MACROS
ngx_feature_run=yes
ngx_feature_incs="#include <stdio.h>
#define var(dummy, args...) sprintf(args)"
ngx_feature_libs=
ngx_feature_test="char buf[30]; buf[0] = '0';
var(0, buf, \"%d\", 1);
if (buf[0] != '1') return 1"
. auto/feature
ngx_feature="C99 variadic macros"
ngx_feature_name=HAVE_C99_VARIADIC_MACROS
ngx_feature_run=yes
ngx_feature_incs="#include <stdio.h>
#define var(dummy, ...) sprintf(__VA_ARGS__)"
ngx_feature_libs=
ngx_feature_test="char buf[30]; buf[0] = '0';
var(0, buf, \"%d\", 1);
if (buf[0] != '1') return 1"
. auto/feature
fi

109
auto/cc/gcc Normal file
View File

@ -0,0 +1,109 @@
# Copyright (C) Igor Sysoev
# gcc 2.7.2.3, 2.8.1, 2.95.4,
# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4
# Solaris 7's /usr/ccs/bin/as does not support "-pipe"
CC_TEST_FLAGS="-pipe"
ngx_feature="gcc -pipe switch"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_libs=
ngx_feature_test=
. auto/feature
CC_TEST_FLAGS=
if [ $ngx_found = yes ]; then
PIPE="-pipe"
fi
# optimizations
#CFLAGS="$CFLAGS -O2 -fomit-frame-pointer"
case $CPU in
pentium)
# optimize for Pentium and Athlon
CPU_OPT="-march=pentium"
;;
pentiumpro)
# optimize for Pentium Pro, Pentium II and Pentium III
CPU_OPT="-march=pentiumpro"
;;
pentium4)
# optimize for Pentium 4, gcc 3.x
CPU_OPT="-march=pentium4"
;;
sparc64)
# build 64-bit UltraSparc binary
CPU_OPT="-m64"
CORE_LINK="$CORE_LINK -m64"
CC_AUX_FLAGS="$CC_AUX_FLAGS -m64"
;;
esac
# STUB for batch builds
if [ $CC = gcc27 ]; then CPU_OPT=; fi
CFLAGS="$CFLAGS $PIPE $CPU_OPT"
if [ ".$PCRE_OPT" = "." ]; then
PCRE_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
else
PCRE_OPT="$PCRE_OPT $PIPE"
fi
if [ ".$MD5_OPT" = "." ]; then
MD5_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
else
MD5_OPT="$MD5_OPT $PIPE"
fi
if [ ".$ZLIB_OPT" = "." ]; then
ZLIB_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
else
ZLIB_OPT="$ZLIB_OPT $PIPE"
fi
# warnings
CFLAGS="$CFLAGS -O -W"
CFLAGS="$CFLAGS -Wall -Wpointer-arith"
#CFLAGS="$CFLAGS -Wconversion"
#CFLAGS="$CFLAGS -Winline"
# we have a lot of the unused function arguments
CFLAGS="$CFLAGS -Wno-unused"
# stop on warning
CFLAGS="$CFLAGS -Werror"
# debug
CFLAGS="$CFLAGS -g"
# DragonFly's gcc3 generates DWARF
#CFLAGS="$CFLAGS -g -gstabs"
if [ ".$CPP" = "." ]; then
CPP="$CC -E"
fi
LINK="\$(CC)"
CC_STRONG="-Wall -Werror"

69
auto/cc/icc Normal file
View File

@ -0,0 +1,69 @@
# Copyright (C) Igor Sysoev
# Intel C++ compiler 7.1, 8.0
# optimizations
CFLAGS="$CFLAGS -O"
# inline functions declared with __inline
#CFLAGS="$CFLAGS -Ob1"
# inline any function, at the compiler's discretion
CFLAGS="$CFLAGS -Ob2"
# single-file IP optimizations
#IPO="-ip"
# multi-file IP optimizations
IPO="-ipo -ipo_obj"
CFLAGS="$CFLAGS $IPO"
CORE_LINK="$CORE_LINK $IPO"
CORE_LINK="$CORE_LINK -opt_report_file=$OBJS/opt_report_file"
case $CPU in
pentium)
# optimize for Pentium and Athlon
CPU_OPT="-march=pentium"
;;
pentiumpro)
# optimize for Pentium Pro, Pentium II and Pentium III
CPU_OPT="-mcpu=pentiumpro -march=pentiumpro"
;;
pentium4)
# optimize for Pentium 4, default
CPU_OPT="-march=pentium4"
;;
esac
CFLAGS="$CFLAGS $CPU_OPT"
if [ ".$PCRE_OPT" = "." ]; then
PCRE_OPT="-O $IPO $CPU_OPT"
fi
if [ ".$MD5_OPT" = "." ]; then
MD5_OPT="-O $IPO $CPU_OPT"
fi
if [ ".$ZLIB_OPT" = "." ]; then
ZLIB_OPT="-O $IPO $CPU_OPT"
fi
# warnings
CFLAGS="$CFLAGS -w1"
#CFLAGS="$CFLAGS -w2"
# stop on warning
CFLAGS="$CFLAGS -Werror"
# debug
CFLAGS="$CFLAGS -g"
LINK="\$(CC)"
CC_STRONG="-w1 -Werror"

81
auto/cc/msvc Normal file
View File

@ -0,0 +1,81 @@
# Copyright (C) Igor Sysoev
# MSVC 6.0 SP2
# optimizations
# maximize speed
CFLAGS="$CFLAGS -O2"
# enable global optimization
CFLAGS="$CFLAGS -Og"
# enable intrinsic functions
CFLAGS="$CFLAGS -Oi"
# inline expansion
CFLAGS="$CFLAGS -Ob1"
# enable frame pointer omission
CFLAGS="$CFLAGS -Oy"
# disable stack checking calls
CFLAGS="$CFLAGS -Gs"
case $CPU in
pentium)
# optimize for Pentium and Athlon
CPU_OPT="-G5"
;;
pentiumpro)
# optimize for Pentium Pro, Pentium II and Pentium III
CPU_OPT="-G6"
;;
pentium4)
# optimize for Pentium 4
#CPU_OPT="-G7"
;;
esac
CFLAGS="$CFLAGS $CPU_OPT"
# warnings
#CFLAGS="$CFLAGS -W3"
CFLAGS="$CFLAGS -W4"
# stop on warning
CFLAGS="$CFLAGS -WX"
# link with libcmt.lib, multithreaded
#LIBC="-MT"
# link with msvcrt.dll
LIBC="-MD"
CFLAGS="$CFLAGS $LIBC"
# disable logo
CFLAGS="$CFLAGS -nologo"
LINK="\$(CC)"
# link flags
CORE_LINK="$CORE_LINK -link -verbose:lib"
# debug
CFLAGS="$CFLAGS -Yd"
CORE_LINK="$CORE_LINK -debug -debugtype:coff"
# precompiled headers
CORE_DEPS="$CORE_DEPS $OBJS/ngx_config.pch"
NGX_PCH="$OBJS/ngx_config.pch"
NGX_BUILD_PCH="-Ycngx_config.h -Fp$OBJS/ngx_config.pch"
NGX_USE_PCH="-Yungx_config.h -Fp$OBJS/ngx_config.pch"
ngx_objout="-Fo"
ngx_binout="-Fe"
ngx_objext="obj"
ngx_binext=".exe"
#ngx_regex_dirsep='\\'
#ngx_dirsep="\\"

51
auto/cc/name Normal file
View File

@ -0,0 +1,51 @@
# Copyright (C) Igor Sysoev
echo $ngx_n "checking for C compiler ...$ngx_c"
if [ $CC = cl ]; then
NGX_CC_NAME=msvc
echo " using Microsoft Visual C compiler"
else
if [ $CC = wcl386 ]; then
NGX_CC_NAME=owc
echo " using Open Watcom C compiler"
else
if [ $CC = bcc32 ]; then
NGX_CC_NAME=bcc
echo " using Borland C++ compiler"
else
if `$CC -v 2>&1 | grep '^gcc version' 2>&1 >/dev/null`; then
NGX_CC_NAME=gcc
echo " using GNU C compiler"
else
if `$CC -V 2>&1 | grep '^Intel(R) C++ Compiler' 2>&1 >/dev/null`; then
NGX_CC_NAME=icc
echo " using Intel C++ compiler"
else
if `$CC -V 2>&1 | grep '^Compaq C' 2>&1 >/dev/null`; then
NGX_CC_NAME=ccc
echo " using Compaq C compiler"
else
if `$CC -V 2>&1 | grep '^aCC: ' 2>&1 >/dev/null`; then
NGX_CC_NAME=acc
echo " using HP aC++ compiler"
else
echo " unknown"
fi # acc
fi # ccc
fi # icc
fi # gcc
fi # bcc
fi # owc
fi # msvc

82
auto/cc/owc Normal file
View File

@ -0,0 +1,82 @@
# Copyright (C) Igor Sysoev
# Open Watcom C 1.0, 1.2
# optimizations
# maximize speed
CFLAGS="$CFLAGS -ot"
# reorder instructions for best pipeline usage
CFLAGS="$CFLAGS -op"
# inline intrinsic functions
CFLAGS="$CFLAGS -oi"
# inline expansion
CFLAGS="$CFLAGS -oe"
# disable stack checking calls
CFLAGS="$CFLAGS -s"
case $CPU in
pentium)
# optimize for Pentium and Athlon
# register-based arguments passing conventions
CPU_OPT="-5r"
# stack-based arguments passing conventions
#CPU_OPT="-5s"
;;
pentiumpro)
# optimize for Pentium Pro, Pentium II and Pentium III
# register-based arguments passing conventions
CPU_OPT="-6r"
# stack-based arguments passing conventions
#CPU_OPT="-6s"
;;
esac
CFLAGS="$CFLAGS $CPU_OPT"
# warnings
#CFLAGS="$CFLAGS -w3"
CFLAGS="$CFLAGS -wx"
# stop on warning
CFLAGS="$CFLAGS -we"
# built target is NT
CFLAGS="$CFLAGS -bt=nt"
# multithreaded
CFLAGS="$CFLAGS -bm"
# debug
CFLAGS="$CFLAGS -d2"
# quiet
CFLAGS="$CFLAGS -zq"
# Open Watcom C 1.2
#have=HAVE_C99_VARIADIC_MACROS . auto/have
# precompiled headers
CORE_DEPS="$CORE_DEPS $OBJS/ngx_config.pch"
NGX_PCH="$OBJS/ngx_config.pch"
NGX_BUILD_PCH="-fhq=$OBJS/ngx_config.pch"
NGX_USE_PCH="-fh=$OBJS/ngx_config.pch"
LINK="\$(CC)"
# link flags
CORE_LINK="$CORE_LINK -l=nt"
ngx_include_opt="-i="
ngx_objout="-fo"
ngx_binout="-fe="
ngx_objext="obj"
ngx_binext=".exe"
ngx_regex_dirsep='\\'
ngx_dirsep="\\"

14
auto/configure vendored
View File

@ -8,24 +8,22 @@
. auto/sources . auto/sources
test -d $OBJS || mkdir $OBJS test -d $OBJS || mkdir $OBJS
echo > $NGX_AUTO_HEADERS_H
echo > $NGX_AUTO_CONFIG_H echo > $NGX_AUTO_CONFIG_H
if [ $DEBUG = YES ]; then if [ $DEBUG = YES ]; then
have=NGX_DEBUG . auto/have have=NGX_DEBUG . auto/have
fi fi
have=NGX_USE_HTTP_FILE_CACHE_UNIQ . auto/have
have=NGX_SUPPRESS_WARN . auto/have
if [ "$PLATFORM" != win32 ]; then if [ "$PLATFORM" != win32 ]; then
. auto/headers . auto/headers
fi fi
. auto/cc/conf
. auto/os/conf . auto/os/conf
. auto/modules . auto/modules
. auto/cc
. auto/lib/conf . auto/lib/conf
if [ "$PLATFORM" != win32 ]; then if [ "$PLATFORM" != win32 ]; then
@ -40,7 +38,8 @@ if [ "$PLATFORM" != win32 ]; then
. auto/unix . auto/unix
fi fi
have=NGX_SMP . auto/have # STUB
. auto/stubs
have=NGX_PREFIX value="\"$PREFIX/\"" . auto/define have=NGX_PREFIX value="\"$PREFIX/\"" . auto/define
have=NGX_SBIN_PATH value="\"$SBIN_PATH\"" . auto/define have=NGX_SBIN_PATH value="\"$SBIN_PATH\"" . auto/define
@ -51,4 +50,7 @@ if [ ".$ERROR_LOG_PATH" != "." ]; then
fi fi
have=NGX_HTTP_LOG_PATH value="\"$HTTP_LOG_PATH\"" . auto/define have=NGX_HTTP_LOG_PATH value="\"$HTTP_LOG_PATH\"" . auto/define
have=NGX_USER value="\"$NGX_USER\"" . auto/define
have=NGX_GROUP value="\"$NGX_GROUP\"" . auto/define
. auto/summary . auto/summary

View File

@ -2,7 +2,7 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
echo $ngx_n "checking for system endianess ..." $ngx_c echo $ngx_n "checking for system endianess ...$ngx_c"
echo >> $NGX_ERR echo >> $NGX_ERR
echo "checking for system endianess" >> $NGX_ERR echo "checking for system endianess" >> $NGX_ERR

View File

@ -2,19 +2,28 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
echo $ngx_n "checking for $ngx_feature ..." $ngx_c echo $ngx_n "checking for $ngx_feature ...$ngx_c"
echo >> $NGX_ERR
echo "checking for $ngx_feature" >> $NGX_ERR cat << END >> $NGX_AUTOCONF_ERR
----------------------------------------
checking for $ngx_feature
END
ngx_found=no ngx_found=no
feature=`echo $ngx_feature_name | tr '[a-z]' '[A-Z]'` if test -n "$ngx_feature_name"; then
ngx_have_feature=`echo NGX_$ngx_feature_name | tr '[a-z]' '[A-Z]'`
# STUB
ngx_have_feature0=`echo HAVE_$ngx_feature_name | tr '[a-z]' '[A-Z]'`
fi
cat << END > $NGX_AUTOTEST.c cat << END > $NGX_AUTOTEST.c
#include <sys/types.h> #include <sys/types.h>
$NGX_UNISTD_H $NGX_INCLUDE_UNISTD_H
$ngx_feature_inc $ngx_feature_incs
int main() { int main() {
$ngx_feature_test; $ngx_feature_test;
@ -23,34 +32,56 @@ int main() {
END END
test="$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c \
$ngx_feature_libs" ngx_test="$CC $CC_TEST_FLAGS $CC_WARN $CC_AUX_FLAGS \
eval "$test >> $NGX_ERR 2>&1" -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then if [ -x $NGX_AUTOTEST ]; then
if [ $ngx_feature_run = yes ]; then if [ $ngx_feature_run = yes ]; then
if $NGX_AUTOTEST 2>&1 > /dev/null; then if $NGX_AUTOTEST 2>&1 > /dev/null; then
echo " found" echo " found"
have=HAVE_$feature . auto/have
ngx_found=yes ngx_found=yes
if test -n "$ngx_feature_name"; then
have=$ngx_have_feature . auto/have
fi
#STUB
if test -n "$ngx_feature_name"; then
have=$ngx_have_feature0 . auto/have
fi
else else
echo " found but is not working" echo " found but is not working"
fi fi
else else
echo " found" echo " found"
have=HAVE_$feature . auto/have
ngx_found=yes ngx_found=yes
if test -n "$ngx_feature_name"; then
have=$ngx_have_feature . auto/have
fi
#STUB
if test -n "$ngx_feature_name"; then
have=$ngx_have_feature0 . auto/have
fi
fi fi
else else
echo " not found" echo " not found"
echo "---------" >> $NGX_ERR
cat $NGX_AUTOTEST.c >> $NGX_ERR echo "----------" >> $NGX_AUTOCONF_ERR
echo "---------" >> $NGX_ERR cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
echo $test >> $NGX_ERR echo "----------" >> $NGX_AUTOCONF_ERR
echo "---------" >> $NGX_ERR echo $ngx_test >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
fi fi
rm $NGX_AUTOTEST* rm $NGX_AUTOTEST*

View File

@ -2,14 +2,21 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
echo $ngx_n "checking for $ngx_type printf() format ..." $ngx_c echo $ngx_n "checking for $ngx_type printf() format ...$ngx_c"
echo >> $NGX_ERR
echo "checking for $ngx_type printf() format" >> $NGX_ERR
ngx_fmt=no cat << END >> $NGX_AUTOCONF_ERR
comma=
for fmt in $ngx_formats ----------------------------------------
checking for $ngx_type printf() format
END
ngx_format=no
ngx_comma=
for ngx_fmt in $ngx_formats
do do
cat << END > $NGX_AUTOTEST.c cat << END > $NGX_AUTOTEST.c
@ -18,52 +25,63 @@ do
#include <sys/time.h> #include <sys/time.h>
#include <stdio.h> #include <stdio.h>
#include <sys/resource.h> #include <sys/resource.h>
$NGX_INTTYPES_H $NGX_INCLUDE_INTTYPES_H
$NGX_AUTO_CONFIG $NGX_INCLUDE_AUTO_CONFIG_H
int main() { int main() {
printf("$fmt", ($ngx_type) $ngx_max_value); printf("$ngx_fmt", ($ngx_type) $ngx_max_value);
return 0; return 0;
} }
END END
eval "$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c \ ngx_test="$CC $CC_TEST_FLAGS $CC_WARN $CC_AUX_FLAGS \
>> $NGX_ERR 2>&1" -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
max_value=`echo $ngx_max_value | sed -e "s/L*\$//"` ngx_max_val=`echo $ngx_max_value | sed -e "s/L*\$//"`
if [ -x $NGX_AUTOTEST ]; then if [ -x $NGX_AUTOTEST ]; then
if [ "`$NGX_AUTOTEST`" = $max_value ]; then
if [ "`$NGX_AUTOTEST`" = $ngx_max_val ]; then
if [ $ngx_fmt_collect = yes ]; then if [ $ngx_fmt_collect = yes ]; then
echo $ngx_n "$comma \"${fmt}\" is appropriate" $ngx_c echo $ngx_n "$ngx_comma \"${ngx_fmt}\" is appropriate$ngx_c"
else else
echo $ngx_n "$comma \"${fmt}\" used" $ngx_c echo $ngx_n "$ngx_comma \"${ngx_fmt}\" used$ngx_c"
fi fi
ngx_fmt=$fmt
ngx_format=$ngx_fmt
fi fi
fi fi
rm $NGX_AUTOTEST* rm -f $NGX_AUTOTEST
if [ $ngx_fmt != no ]; then if [ $ngx_format != no ]; then
if [ $ngx_fmt_collect = yes ]; then if [ $ngx_fmt_collect = yes ]; then
eval "ngx_${ngx_size}_fmt=\"\${ngx_${ngx_size}_fmt} \$ngx_fmt\"" eval "ngx_${ngx_size}_fmt=\"\${ngx_${ngx_size}_fmt} \$ngx_format\""
comma="," ngx_comma=","
continue continue
else else
break break
fi fi
fi fi
echo $ngx_n "$comma \"${fmt}\" is not appropriate" $ngx_c echo $ngx_n "$ngx_comma \"${ngx_fmt}\" is not appropriate$ngx_c"
comma="," ngx_comma=","
echo "----------" >> $NGX_AUTOCONF_ERR
cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
echo $ngx_test >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
done done
echo echo
if [ $ngx_fmt = no ]; then if [ $ngx_format = no ]; then
echo "$0: error: printf() $ngx_type format not found" echo "$0: error: printf() $ngx_type format not found"
exit 1 exit 1
fi fi
@ -72,7 +90,7 @@ if [ $ngx_fmt_collect = no ]; then
cat << END >> $NGX_AUTO_CONFIG_H cat << END >> $NGX_AUTO_CONFIG_H
#ifndef $ngx_fmt_name #ifndef $ngx_fmt_name
#define $ngx_fmt_name "$ngx_fmt" #define $ngx_fmt_name "$ngx_format"
#endif #endif
END END

View File

@ -2,71 +2,85 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
echo $ngx_n "checking for $ngx_type printf() format ..." $ngx_c echo $ngx_n "checking for $ngx_type printf() format ...$ngx_c"
echo >> $NGX_ERR
echo "checking for $ngx_type printf() format" >> $NGX_ERR
ngx_fmt=no cat << END >> $NGX_AUTOCONF_ERR
comma=
fmtX=
for fmt in $ngx_formats ----------------------------------------
checking for $ngx_type printf() format
END
ngx_format=no
ngx_comma=
ngx_fmt_x=
for ngx_fmt in $ngx_formats
do do
cat << END > $NGX_AUTOTEST.c cat << END > $NGX_AUTOTEST.c
int main() { int main() {
printf("$fmt", ($ngx_type) $ngx_max_value); printf("$ngx_fmt", ($ngx_type) $ngx_max_value);
return 0; return 0;
} }
END END
eval "$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c \ ngx_test="$CC $CC_TEST_FLAGS $CC_WARN $CC_AUX_FLAGS \
>> $NGX_ERR 2>&1" -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
max_value=`echo $ngx_max_value | sed -e "s/L*\$//"` ngx_max_val=`echo $ngx_max_value | sed -e "s/L*\$//"`
if [ -x $NGX_AUTOTEST ]; then if [ -x $NGX_AUTOTEST ]; then
if [ "`$NGX_AUTOTEST`" = $max_value ]; then if [ "`$NGX_AUTOTEST`" = $ngx_max_val ]; then
ngx_fmt=$fmt ngx_format=$ngx_fmt
fi fi
fi fi
rm $NGX_AUTOTEST* rm $NGX_AUTOTEST
if [ $ngx_fmt != no ]; then if [ $ngx_format != no ]; then
break break
fi fi
fmtX=`echo $fmt | sed -e "s/d/X/"` ngx_fmt_x=`echo $ngx_fmt | sed -e "s/d/X/"`
echo $ngx_n "$comma \"${fmtX}\" is not appropriate" $ngx_c echo $ngx_n "$ngx_comma \"${ngx_fmt_x}\" is not appropriate$ngx_c"
comma="," ngx_comma=","
echo "----------" >> $NGX_AUTOCONF_ERR
cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
echo $ngx_test >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
done done
if [ $ngx_fmt = no ]; then if [ $ngx_format = no ]; then
echo "$0: error: printf() $ngx_type format not found" echo "$0: error: printf() $ngx_type format not found"
exit 1 exit 1
fi fi
if [ $ngx_ptr_size = 4 ]; then if [ $ngx_ptr_size = 4 ]; then
fmtX="%0`expr 2 \* $ngx_ptr_size`" ngx_fmt_x="%0`expr 2 \* $ngx_ptr_size`"
else else
fmtX="%" ngx_fmt_x="%"
fi fi
ngx_fmt=`echo $ngx_fmt | sed -e "s/d/X/" -e "s/^%/$fmtX/"` ngx_format=`echo $ngx_format | sed -e "s/d/X/" -e "s/^%/$ngx_fmt_x/"`
echo "$comma \"${ngx_fmt}\" used" echo "$ngx_comma \"${ngx_format}\" used"
cat << END >> $NGX_AUTO_CONFIG_H cat << END >> $NGX_AUTO_CONFIG_H
#ifndef $ngx_fmt_name #ifndef $ngx_fmt_name
#define $ngx_fmt_name "$ngx_fmt" #define $ngx_fmt_name "$ngx_format"
#endif #endif
END END

View File

@ -2,5 +2,7 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
ngx_inc="unistd.h"; . auto/inc ngx_include="unistd.h"; . auto/include
ngx_inc="inttypes.h"; . auto/inc ngx_include="inttypes.h"; . auto/include
ngx_include="limits.h"; . auto/include
ngx_include="sys/filio.h"; . auto/include

View File

@ -1,35 +0,0 @@
# Copyright (C) Igor Sysoev
echo $ngx_n "checking for $ngx_inc ..." $ngx_c
echo >> $NGX_ERR
echo "checking for $ngx_inc" >> $NGX_ERR
ngx_found=no
inc=`echo $ngx_inc | sed -e 's/\./_/' | sed -e 's/\//_/' | tr '[a-z]' '[A-Z]'`
cat << END > $NGX_AUTOTEST.c
#include <$ngx_inc>
int main() {
return 0;
}
END
eval "${CC} -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
echo " found"
have=HAVE_$inc . auto/have
eval "NGX_$inc='#include <$ngx_inc>'"
ngx_found=yes
else
echo " not found"
fi
rm $NGX_AUTOTEST*

66
auto/include Normal file
View File

@ -0,0 +1,66 @@
# Copyright (C) Igor Sysoev
echo $ngx_n "checking for $ngx_include ...$ngx_c"
cat << END >> $NGX_AUTOCONF_ERR
----------------------------------------
checking for $ngx_include
END
ngx_found=no
cat << END > $NGX_AUTOTEST.c
#include <$ngx_include>
int main() {
return 0;
}
END
ngx_test="$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
ngx_found=yes
echo " found"
ngx_name=`echo $ngx_include | sed -e 's/\./_/' -e 's/\//_/' \
| tr '[a-z]' '[A-Z]'`
cat << END >> $NGX_AUTO_HEADERS_H
#ifndef NGX_HAVE_$ngx_name
#define NGX_HAVE_$ngx_name 1
#endif
END
eval "NGX_INCLUDE_$ngx_name='#include <$ngx_include>'"
#STUB
eval "NGX_$ngx_name='#include <$ngx_include>'"
else
echo " not found"
echo "----------" >> $NGX_AUTOCONF_ERR
cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
echo $ngx_test >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
fi
rm $NGX_AUTOTEST*

View File

@ -2,31 +2,33 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
NGX_MAKEFILE=$NGX_OBJS/Makefile
NGX_MODULES_C=$NGX_OBJS/ngx_modules.c
NGX_AUTO_HEADERS_H=$NGX_OBJS/ngx_auto_headers.h
NGX_AUTO_CONFIG_H=$NGX_OBJS/ngx_auto_config.h
NGX_AUTOTEST=$NGX_OBJS/autotest
NGX_AUTOCONF_ERR=$NGX_OBJS/autoconf.err
# STUBs
OBJS=$NGX_OBJS
NGX_ERR=$OBJS/autoconf.err
MAKEFILE=$OBJS/Makefile MAKEFILE=$OBJS/Makefile
NGX_AUTO_CONFIG_H=$OBJS/ngx_auto_config.h
NGX_MODULES_C=$OBJS/ngx_modules.c
NGX_AUTOTEST=$OBJS/autotest NGX_PCH=
NGX_ERR=$OBJS/autoconf.err NGX_USE_PCH=
CC_WARN=$CC
PCH=NO
USEPCH=
OBJEXT=
BINEXT=
DIRSEP='\/'
MAKE_SL=NO
# checking echo's "-n" option and "\c" capabilties # check the echo's "-n" option and "\c" capability
if echo "test\c" | grep c >/dev/null; then if echo "test\c" | grep c >/dev/null; then
if echo -n test | grep n >/dev/null; then if echo -n test | grep n >/dev/null; then
ngx_n= ngx_n=
ngx_c= ngx_c=
else else
ngx_n=-n ngx_n=-n
ngx_c= ngx_c=
@ -38,19 +40,18 @@ else
fi fi
# create Makefile
if test ! -f Makefile; then
cat << END > Makefile cat << END > Makefile
build: build:
\$(MAKE) -f $OBJS/Makefile \$(MAKE) -f $NGX_MAKEFILE
install: install:
\$(MAKE) -f $OBJS/Makefile install \$(MAKE) -f $NGX_MAKEFILE install
clean: clean:
rm -rf Makefile $OBJS rm -rf Makefile $NGX_OBJS
upgrade: upgrade:
$SBIN_PATH -t $SBIN_PATH -t
@ -58,7 +59,4 @@ upgrade:
sleep 1 sleep 1
test -f $PID_PATH.newbin test -f $PID_PATH.newbin
kill -WINCH \`cat $PID_PATH\` kill -WINCH \`cat $PID_PATH\`
END END
fi

View File

@ -8,7 +8,7 @@ install:
test -d `dirname $SBIN_PATH` || mkdir -p `dirname $SBIN_PATH` test -d `dirname $SBIN_PATH` || mkdir -p `dirname $SBIN_PATH`
test ! -f $SBIN_PATH || mv $SBIN_PATH $SBIN_PATH.old test ! -f $SBIN_PATH || mv $SBIN_PATH $SBIN_PATH.old
cp nginx $SBIN_PATH cp $OBJS/nginx $SBIN_PATH
test -d `dirname $CONF_PATH` || mkdir -p `dirname $CONF_PATH` test -d `dirname $CONF_PATH` || mkdir -p `dirname $CONF_PATH`

View File

@ -15,14 +15,14 @@ if [ $MD5 != NONE ]; then
CORE_INCS="$CORE_INCS $MD5" CORE_INCS="$CORE_INCS $MD5"
case "$CC" in case "$NGX_CC_NAME" in
cl | wcl386 | bcc32) msvc | owc | bcc)
LINK_DEPS="$LINK_DEPS $MD5/md5.lib" LINK_DEPS="$LINK_DEPS $MD5/md5.lib"
CORE_LIBS="$CORE_LIBS $MD5/md5.lib" CORE_LIBS="$CORE_LIBS $MD5/md5.lib"
;; ;;
*icc) icc)
LINK_DEPS="$LINK_DEPS $MD5/libmd5.a" LINK_DEPS="$LINK_DEPS $MD5/libmd5.a"
# to allow -ipo optimization we link with the *.o but not library # to allow -ipo optimization we link with the *.o but not library
@ -45,20 +45,19 @@ else
if [ $PLATFORM != win32 ]; then if [ $PLATFORM != win32 ]; then
MD5=NO MD5=NO
ngx_lib_cflags=
# Solaris 8/9 # Solaris 8/9
ngx_lib_inc="#include <sys/types.h> ngx_feature="rsaref md5 library"
#include <md5.h>" ngx_feature_name="rsaref_md5"
ngx_lib="rsaref md5 library" ngx_feature_run=no
ngx_lib_test="MD5_CTX md5; MD5Init(&md5)" ngx_feature_incs="#include <md5.h>"
ngx_libs=-lmd5 ngx_feature_libs="-lmd5"
. auto/lib/test ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
. auto/feature
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_libs" CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES MD5=YES
MD5_LIB=md5 MD5_LIB=md5
ngx_found=no ngx_found=no
@ -66,15 +65,18 @@ else
else else
# FreeBSD # FreeBSD
ngx_lib="rsaref md library" ngx_feature="rsaref md library"
ngx_lib_test="MD5_CTX md5; MD5Init(&md5)" ngx_feature_name="rsaref_md5"
ngx_libs=-lmd ngx_feature_run=no
. auto/lib/test ngx_feature_incs="#include <md5.h>"
ngx_feature_libs="-lmd"
ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
. auto/feature
fi fi
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_libs" CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES MD5=YES
MD5_LIB=md MD5_LIB=md
ngx_found=no ngx_found=no
@ -84,19 +86,20 @@ else
# OpenSSL crypto library # OpenSSL crypto library
ngx_lib_inc="#include <openssl/md5.h>" ngx_feature="OpenSSL md5 crypto library"
ngx_lib="OpenSSL md5 crypto library" ngx_feature_name="OpenSSL_md5"
ngx_lib_test="MD5_CTX md5; MD5_Init(&md5)" ngx_feature_run=no
ngx_libs=-lcrypto ngx_feature_incs="#include <openssl/md5.h>"
. auto/lib/test ngx_feature_libs="-lcrypto"
ngx_feature_test="MD5_CTX md5; MD5_Init(&md5)"
. auto/feature
fi fi
fi fi
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then
have=HAVE_OPENSSL_MD5 . auto/have
have=HAVE_OPENSSL_MD5_H . auto/have have=HAVE_OPENSSL_MD5_H . auto/have
CORE_LIBS="$CORE_LIBS $ngx_libs" CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES MD5=YES
MD5_LIB=crypto MD5_LIB=crypto
fi fi

View File

@ -25,7 +25,7 @@ esac
case $PLATFORM in case $PLATFORM in
win32) win32)
line=`echo $MD5/md5.lib: | sed -e "s/\//$DIRSEP/g"` line=`echo $MD5/md5.lib: | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE echo "$line" >> $MAKEFILE
;; ;;
@ -42,7 +42,7 @@ done=NO
case $PLATFORM in case $PLATFORM in
win32) win32)
md5=`echo $MD5 | sed -e "s/\//$DIRSEP/g"` md5=`echo $MD5 | sed -e "s/\//$ngx_regex_dirsep/g"`
cp auto/lib/md5/$makefile $MD5 cp auto/lib/md5/$makefile $MD5
echo " cd $md5" >> $MAKEFILE echo " cd $md5" >> $MAKEFILE

View File

@ -20,22 +20,21 @@ else
if [ $PLATFORM != win32 ]; then if [ $PLATFORM != win32 ]; then
OPENSSL=NO OPENSSL=NO
ngx_lib_cflags=
ngx_lib_inc="#include <openssl/ssl.h>"
ngx_lib="OpenSSL library"
ngx_lib_test="SSL_library_init()"
ngx_libs="-lssl -lcrypto"
. auto/lib/test
ngx_feature="OpenSSL library"
ngx_feature_name="OpenSSL"
ngx_feature_run=no
ngx_feature_incs="#include <openssl/ssl.h>"
ngx_feature_libs="-lssl -lcrypto"
ngx_feature_test="SSL_library_init()"
. auto/feature
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then
have=NGX_OPENSSL . auto/have have=NGX_OPENSSL . auto/have
CORE_DEPS="$CORE_DEPS $OPENSSL_DEPS" CORE_DEPS="$CORE_DEPS $OPENSSL_DEPS"
CORE_SRCS="$CORE_SRCS $OPENSSL_SRCS" CORE_SRCS="$CORE_SRCS $OPENSSL_SRCS"
CORE_LIBS="$CORE_LIBS $ngx_libs" CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
OPENSSL=YES OPENSSL=YES
ngx_found=no
fi fi
fi fi

View File

@ -7,18 +7,18 @@ if [ $PCRE != NONE ]; then
CORE_DEPS="$CORE_DEPS $REGEX_DEPS" CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS" CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
case "$CC" in case "$NGX_CC_NAME" in
cl | wcl386 | bcc32) msvc | owc | bcc)
have=HAVE_PCRE . auto/have have=NGX_PCRE . auto/have
have=PCRE_STATIC . auto/have have=PCRE_STATIC . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h" CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
LINK_DEPS="$LINK_DEPS $PCRE/pcre.lib" LINK_DEPS="$LINK_DEPS $PCRE/pcre.lib"
CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib" CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib"
;; ;;
*icc) icc)
have=HAVE_PCRE . auto/have have=NGX_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h" CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a" LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
@ -31,7 +31,7 @@ if [ $PCRE != NONE ]; then
;; ;;
*) *)
have=HAVE_PCRE . auto/have have=NGX_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h" CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a" LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
CORE_LIBS="$CORE_LIBS $PCRE/.libs/libpcre.a" CORE_LIBS="$CORE_LIBS $PCRE/.libs/libpcre.a"
@ -44,43 +44,24 @@ else
if [ $PLATFORM != win32 ]; then if [ $PLATFORM != win32 ]; then
PCRE=NO PCRE=NO
ngx_lib_cflags=
# Linux # FreeBSD PCRE port requires --with-cc-opt="-I /usr/local/include"
# --with-ld-opt="-L /usr/local/lib"
ngx_lib_inc="#include <pcre.h>"
ngx_lib="PCRE library"
ngx_lib_test="pcre *re; re = pcre_compile(NULL, 0, NULL, 0, NULL)"
ngx_libs="-lpcre"
. auto/lib/test
ngx_feature="PCRE library"
ngx_feature_name="PCRE"
ngx_feature_run=no
ngx_feature_incs="#include <pcre.h>"
ngx_feature_libs="-lpcre"
ngx_feature_test="pcre *re; re = pcre_compile(NULL, 0, NULL, 0, NULL)"
. auto/feature
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then
have=HAVE_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $REGEX_DEPS" CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS" CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
CORE_LIBS="$CORE_LIBS $ngx_libs" CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES PCRE=YES
ngx_found=no ngx_found=no
else
# FreeBSD PCRE port.
ngx_lib="PCRE library in /usr/local/"
ngx_lib_cflags="-I /usr/local/include"
ngx_libs="-L /usr/local/lib -lpcre"
. auto/lib/test
fi
if [ $ngx_found = yes ]; then
have=HAVE_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_INCS="$CORE_INCS /usr/local/include"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
CORE_LIBS="$CORE_LIBS $ngx_libs"
PCRE=YES
fi fi
fi fi
fi fi

View File

@ -29,8 +29,8 @@ case $PLATFORM in
cp auto/lib/pcre/patch.config.in $PCRE cp auto/lib/pcre/patch.config.in $PCRE
cp auto/lib/pcre/$makefile $PCRE cp auto/lib/pcre/$makefile $PCRE
pcre=`echo $PCRE | sed -e "s/\//$DIRSEP/g"` pcre=`echo $PCRE | sed -e "s/\//$ngx_regex_dirsep/g"`
line=`echo $PCRE/pcre.h: | sed -e "s/\//$DIRSEP/g"` line=`echo $PCRE/pcre.h: | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE echo "$line" >> $MAKEFILE
echo " cd $pcre" >> $MAKEFILE echo " cd $pcre" >> $MAKEFILE
@ -39,7 +39,7 @@ case $PLATFORM in
echo >> $MAKEFILE echo >> $MAKEFILE
line="$PCRE/pcre.lib: $PCRE/pcre.h" line="$PCRE/pcre.lib: $PCRE/pcre.h"
line=`echo $line | sed -e "s/\//$DIRSEP/g"` line=`echo $line | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE echo "$line" >> $MAKEFILE
echo " cd $pcre" >> $MAKEFILE echo " cd $pcre" >> $MAKEFILE

View File

@ -2,14 +2,26 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
echo $ngx_n "checking for $ngx_lib ..." $ngx_c echo $ngx_n "checking for $ngx_lib ...$ngx_c"
echo >> $NGX_ERR
echo "checking for $ngx_lib library" >> $NGX_ERR cat << END >> $NGX_AUTOCONF_ERR
----------------------------------------
checking for $ngx_lib
END
ngx_found=no ngx_found=no
echo "$ngx_lib_inc" > $NGX_AUTOTEST.c cat << END > $NGX_AUTOTEST.c
echo "int main() { $ngx_lib_test; return 0; }" >> $NGX_AUTOTEST.c
$ngx_lib_incs
int main() {
$ngx_lib_test;
return 0;
}
eval "$CC $cc_test_flags $ngx_lib_cflags \ eval "$CC $cc_test_flags $ngx_lib_cflags \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_libs \ -o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_libs \

View File

@ -5,14 +5,14 @@
if [ $ZLIB != NONE ]; then if [ $ZLIB != NONE ]; then
CORE_INCS="$CORE_INCS $ZLIB" CORE_INCS="$CORE_INCS $ZLIB"
case "$CC" in case "$NGX_CC_NAME" in
cl | wcl386 | bcc32) msvc | owc | bcc)
LINK_DEPS="$LINK_DEPS $ZLIB/zlib.lib" LINK_DEPS="$LINK_DEPS $ZLIB/zlib.lib"
CORE_LIBS="$CORE_LIBS $ZLIB/zlib.lib" CORE_LIBS="$CORE_LIBS $ZLIB/zlib.lib"
;; ;;
*icc) icc)
LINK_DEPS="$LINK_DEPS $ZLIB/libz.a" LINK_DEPS="$LINK_DEPS $ZLIB/libz.a"
# to allow -ipo optimization we link with the *.o but not library # to allow -ipo optimization we link with the *.o but not library
@ -38,22 +38,23 @@ if [ $ZLIB != NONE ]; then
else else
if [ $PLATFORM != win32 ]; then if [ $PLATFORM != win32 ]; then
ZLIB=NO
# FreeBSD, Solaris, Linux # FreeBSD, Solaris, Linux
ngx_lib_cflags= ngx_feature="zlib library"
ngx_lib_inc="#include <zlib.h>" ngx_feature_name="zlib"
ngx_lib="zlib library" ngx_feature_run=no
ngx_lib_test="z_stream z; deflate(&z, Z_NO_FLUSH)" ngx_feature_incs="#include <zlib.h>"
ngx_libs=-lz ngx_feature_libs="-lz"
. auto/lib/test ngx_feature_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
. auto/feature
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_libs" CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
ZLIB=YES ZLIB=YES
else ngx_found=no
ZLIB=NO
fi fi
fi fi

View File

@ -26,7 +26,7 @@ esac
case $PLATFORM in case $PLATFORM in
win32) win32)
line=`echo $ZLIB/zlib.lib: | sed -e "s/\//$DIRSEP/g"` line=`echo $ZLIB/zlib.lib: | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE echo "$line" >> $MAKEFILE
;; ;;
@ -43,7 +43,7 @@ done=NO
case $PLATFORM in case $PLATFORM in
win32) win32)
zlib=`echo $ZLIB | sed -e "s/\//$DIRSEP/g"` zlib=`echo $ZLIB | sed -e "s/\//$ngx_regex_dirsep/g"`
cp auto/lib/zlib/$makefile $ZLIB cp auto/lib/zlib/$makefile $ZLIB
echo " cd $zlib" >> $MAKEFILE echo " cd $zlib" >> $MAKEFILE

422
auto/make
View File

@ -8,353 +8,271 @@ mkdir -p $OBJS/src/core $OBJS/src/event $OBJS/src/event/modules \
$OBJS/src/imap $OBJS/src/imap
echo "CC = $CC" > $MAKEFILE ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
echo "CPP = $CPP" >> $MAKEFILE ngx_use_pch=`echo $NGX_USE_PCH | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "LINK = $LINK" >> $MAKEFILE
cat << END >> $NGX_MAKEFILE
CC = $CC
CFLAGS = $CFLAGS
CPP = $CPP
LINK = $LINK
END
if [ "$CC" = wcl386 ]; then if [ "$CC" = wcl386 ]; then
echo MAKE = wmake >> $MAKEFILE echo MAKE = wmake >> $NGX_MAKEFILE
fi
echo "CFLAGS = $CFLAGS" >> $MAKEFILE
echo >> $MAKEFILE
ngx_regex_cont=' '
ngx_cont=' '
ngx_tab=' '
if [ $MAKE_SL = YES ]; then
echo >> $MAKEFILE
fi fi
all_inc="$CORE_INCS $OBJS $HTTP_INCS $IMAP_INCS"
all_inc=`echo " $all_inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g"`
all_inc=`echo $all_inc | sed -e "s/\//$DIRSEP/g"`
echo "ALL_INCS = $all_inc" >> $MAKEFILE # ALL_INCS, required by OpenWatcom C precompiled headers
echo >> $MAKEFILE
all_srcs="$CORE_SRCS" ngx_incs=`echo $CORE_INCS $OBJS $HTTP_INCS $IMAP_INCS\
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
cat << END >> $NGX_MAKEFILE
ALL_INCS = $ngx_include_opt$ngx_incs
END
# CORE_DEPS ngx_all_srcs="$CORE_SRCS"
if [ $MAKE_SL = YES ]; then
echo $ngx_n "CORE_DEPS =" $ngx_c >> $MAKEFILE
else
echo "CORE_DEPS = \\" >> $MAKEFILE
fi
for dep in $CORE_DEPS
do
dep=`echo $dep | sed -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then
echo $ngx_n " $dep" $ngx_c >> $MAKEFILE
else
echo " $dep \\" >> $MAKEFILE
fi
done
echo >> $MAKEFILE
# CORE_INCS # the core dependences and include pathes
if [ $MAKE_SL = YES ]; then ngx_deps=`echo $CORE_DEPS $NGX_PCH \
echo >> $MAKEFILE | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
fi -e "s/\//$ngx_regex_dirsep/g"`
inc="$CORE_INCS $OBJS" ngx_incs=`echo $CORE_INCS $OBJS \
inc=`echo " $inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g" -e "s/\//$DIRSEP/g"` | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
echo "CORE_INCS = $inc" >> $MAKEFILE cat << END >> $NGX_MAKEFILE
echo >> $MAKEFILE
CORE_DEPS = $ngx_deps
CORE_INCS = $ngx_include_opt$ngx_incs
END
# the http dependences and include pathes
if [ $HTTP = YES ]; then if [ $HTTP = YES ]; then
all_srcs="$all_srcs $HTTP_SRCS" ngx_all_srcs="$ngx_all_srcs $HTTP_SRCS"
# HTTP_DEPS ngx_deps=`echo $HTTP_DEPS \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
if [ $MAKE_SL = YES ]; then ngx_incs=`echo $HTTP_INCS \
echo $ngx_n "HTTP_DEPS =" $ngx_c >> $MAKEFILE | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
else -e "s/\//$ngx_regex_dirsep/g"`
echo "HTTP_DEPS = \\" >> $MAKEFILE
fi
for dep in $HTTP_DEPS cat << END >> $NGX_MAKEFILE
do
dep=`echo $dep | sed -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then HTTP_DEPS = $ngx_deps
echo $ngx_n " $dep" $ngx_c >> $MAKEFILE
else
echo " $dep \\" >> $MAKEFILE
fi
done
echo >> $MAKEFILE
# HTTP_INCS HTTP_INCS = $ngx_include_opt$ngx_incs
if [ $MAKE_SL = YES ]; then END
echo >> $MAKEFILE
fi
inc="$HTTP_INCS $OBJS"
inc=`echo " $inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g" -e "s/\//$DIRSEP/g"`
echo "HTTP_INCS = $inc" >> $MAKEFILE
echo >> $MAKEFILE
fi fi
# the imap dependences and include pathes
if [ $IMAP = YES ]; then if [ $IMAP = YES ]; then
all_srcs="$all_srcs $IMAP_SRCS" ngx_all_srcs="$ngx_all_srcs $IMAP_SRCS"
# IMAP_DEPS ngx_deps=`echo $IMAP_DEPS \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`
if [ $MAKE_SL = YES ]; then ngx_incs=`echo $IMAP_INCS \
echo $ngx_n "IMAP_DEPS =" $ngx_c >> $MAKEFILE | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
else -e "s/\//$ngx_regex_dirsep/g"`
echo "IMAP_DEPS = \\" >> $MAKEFILE
fi
for dep in $IMAP_DEPS cat << END >> $NGX_MAKEFILE
do
dep=`echo $dep | sed -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then IMAP_DEPS = $ngx_deps
echo $ngx_n " $dep" $ngx_c >> $MAKEFILE
else
echo " $dep \\" >> $MAKEFILE
fi
done
echo >> $MAKEFILE
# IMAP_INCS IMAP_INCS = $ngx_include_opt$ngx_incs
if [ $MAKE_SL = YES ]; then END
echo >> $MAKEFILE
fi
inc="$IMAP_INCS $OBJS"
inc=`echo " $inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g" -e "s/\//$DIRSEP/g"`
echo "IMAP_INCS = $inc" >> $MAKEFILE
echo >> $MAKEFILE
fi fi
# nginx # nginx
if [ $MAKE_SL = YES ]; then ngx_all_srcs=`echo $ngx_all_srcs | sed -e "s/\//$ngx_regex_dirsep/g"`
echo $ngx_n "nginx$BINEXT: " $ngx_c >> $MAKEFILE ngx_modules_c=`echo $NGX_MODULES_C | sed -e "s/\//$ngx_regex_dirsep/g"`
else
echo "nginx$BINEXT: \\" >> $MAKEFILE
fi
ngx_all_objs=`echo $ngx_all_srcs \
| sed -e "s/\([^ ]*\.\)cpp/$NGX_OBJS\/\1$ngx_objext/g" \
-e "s/\([^ ]*\.\)cc/$NGX_OBJS\/\1$ngx_objext/g" \
-e "s/\([^ ]*\.\)c/$NGX_OBJS\/\1$ngx_objext/g" \
-e "s/\([^ ]*\.\)S/$NGX_OBJS\/\1$ngx_objext/g"`
# nginx deps ngx_modules_obj=`echo $ngx_modules_c | sed -e "s/\(.*\.\)c/\1$ngx_objext/"`
for src in $all_srcs ngx_deps=`echo $ngx_all_objs $ngx_modules_obj $LINK_DEPS \
do | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"` -e "s/\//$ngx_regex_dirsep/g"`
obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then ngx_objs=`echo $ngx_all_objs $ngx_modules_obj \
echo $ngx_n " $obj" $ngx_c >> $MAKEFILE | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
else -e "s/\//$ngx_regex_dirsep/g"`
echo " $obj \\" >> $MAKEFILE
fi
done
for src in $NGX_MODULES_C $LINK_DEPS ngx_libs=${CORE_LIBS:+`echo $NGX_LD_OPT $CORE_LIBS \
do | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_regex_cont/"`}
obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"`
obj=`echo $obj | sed -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then ngx_link=${CORE_LINK:+`echo $CORE_LINK \
echo $ngx_n " $obj" $ngx_c >> $MAKEFILE | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_regex_cont/"`}
else
echo " $obj \\" >> $MAKEFILE
fi
done
echo >> $MAKEFILE
cat << END >> $NGX_MAKEFILE
# nginx build $NGX_OBJS${ngx_dirsep}nginx${ngx_binext}: $ngx_deps$ngx_spacer
\$(LINK) ${ngx_binout}$NGX_OBJS${ngx_dirsep}nginx$ngx_cont$ngx_objs$ngx_libs$ngx_link
if [ $MAKE_SL = YES ]; then END
echo $ngx_n " \$(LINK) ${BINOUT}nginx" $ngx_c >> $MAKEFILE
else
echo " \$(LINK) ${BINOUT}nginx \\" >> $MAKEFILE
fi
# nginx build sources
for src in $all_srcs
do
obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"`
obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then
echo $ngx_n " $obj" $ngx_c >> $MAKEFILE
else
echo " $obj \\" >> $MAKEFILE
fi
done
# nginx build ngx_modules.c and libs
obj=`echo $NGX_MODULES_C | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\//$DIRSEP/g"`
src=`echo $NGX_MODULES_C | sed -e "s/\//$DIRSEP/g"`
libs=`echo $CORE_LIBS | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\//$DIRSEP/g"`
link=`echo $CORE_LINK | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then
echo " $obj $libs $CORE_LINK" >> $MAKEFILE
echo >> $MAKEFILE
else
echo " $obj \\" >> $MAKEFILE
echo " $libs \\" >> $MAKEFILE
echo " $link" >> $MAKEFILE
echo >> $MAKEFILE
fi
# ngx_modules.c # ngx_modules.c
deps="\$(CORE_DEPS)" if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
if [ $PCH != NO ]; then
args="\$(CFLAGS) $USEPCH \$(ALL_INCS)"
else else
args="\$(CFLAGS) $USEPCH \$(CORE_INCS)" ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS)"
fi fi
if [ $MAKE_SL = YES ]; then cat << END >> $NGX_MAKEFILE
echo "$obj: $NGX_MODULES_C $deps" >> $MAKEFILE
echo $ngx_n " \$(CC) $COMPOPT $args" $ngx_c >> $MAKEFILE $ngx_modules_obj: \$(CORE_DEPS)$ngx_cont$ngx_modules_c
echo " $OBJOUT$obj $src" >> $MAKEFILE $ngx_cc$ngx_tab$ngx_objout$ngx_modules_obj$ngx_tab$ngx_modules_c
echo >> $MAKEFILE
else END
echo "$obj: \\" >> $MAKEFILE
echo " $NGX_MODULES_C $deps" >> $MAKEFILE
echo " \$(CC) $COMPOPT $args \\" >> $MAKEFILE
echo " $OBJOUT$obj \\" >> $MAKEFILE
echo " $src" >> $MAKEFILE
echo >> $MAKEFILE
fi
# core sources # the core sources
for src in $CORE_SRCS for ngx_src in $CORE_SRCS
do do
obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"`
obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
src=`echo $src | sed -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$obj: $src $deps" >> $MAKEFILE ngx_obj=`echo $ngx_src \
echo " \$(CC) $COMPOPT $args $OBJOUT$obj $src" >> $MAKEFILE | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
echo >> $MAKEFILE -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
else -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
echo "$obj: \\" >> $MAKEFILE -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
echo " $src $deps" >> $MAKEFILE
echo " \$(CC) $COMPOPT $args \\" >> $MAKEFILE cat << END >> $NGX_MAKEFILE
echo " $OBJOUT$obj \\" >> $MAKEFILE
echo " $src" >> $MAKEFILE $ngx_obj: \$(CORE_DEPS)$ngx_cont$ngx_src
echo >> $MAKEFILE $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src
fi
END
done done
# http sources # the http sources
if [ $HTTP = YES ]; then if [ $HTTP = YES ]; then
deps="\$(CORE_DEPS) \$(HTTP_DEPS)" if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
if [ $PCH != NO ]; then
args="\$(CFLAGS) $USEPCH \$(ALL_INCS)"
else else
args="\$(CFLAGS) $USEPCH \$(CORE_INCS) \$(HTTP_INCS)" ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS)"
fi fi
for src in $HTTP_SRCS for ngx_src in $HTTP_SRCS
do do
obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"`
obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
src=`echo $src | sed -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$obj: $src $deps" >> $MAKEFILE ngx_obj=`echo $ngx_src \
echo " \$(CC) $COMPOPT $args $OBJOUT$obj $src" >> $MAKEFILE | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
echo >> $MAKEFILE -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
else -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
echo "$obj: \\" >> $MAKEFILE -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
echo " $src $deps" >> $MAKEFILE
echo " \$(CC) $COMPOPT $args \\" >> $MAKEFILE cat << END >> $NGX_MAKEFILE
echo " $OBJOUT$obj \\" >> $MAKEFILE
echo " $src" >> $MAKEFILE $ngx_obj: \$(CORE_DEPS) \$(HTTP_DEPS)$ngx_cont$ngx_src
echo >> $MAKEFILE $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src
fi
END
done done
fi fi
# imap sources # the imap sources
if [ $IMAP = YES ]; then if [ $IMAP = YES ]; then
deps="\$(CORE_DEPS) \$(IMAP_DEPS)" if test -n "$NGX_PCH"; then
ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
if [ $PCH != NO ]; then
args="\$(CFLAGS) $USEPCH \$(ALL_INCS)"
else else
args="\$(CFLAGS) $USEPCH \$(CORE_INCS) \$(IMAP_INCS)" ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(IMAP_INCS)"
fi fi
for src in $IMAP_SRCS for ngx_src in $IMAP_SRCS
do do
obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"`
obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
src=`echo $src | sed -e "s/\//$DIRSEP/g"`
if [ $MAKE_SL = YES ]; then ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$obj: $src $deps" >> $MAKEFILE ngx_obj=`echo $ngx_src \
echo " \$(CC) $COMPOPT $args $OBJOUT$obj $src" >> $MAKEFILE | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
echo >> $MAKEFILE -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
else -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
echo "$obj: \\" >> $MAKEFILE -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
echo " $src $deps" >> $MAKEFILE
echo " \$(CC) $COMPOPT $args \\" >> $MAKEFILE cat << END >> $NGX_MAKEFILE
echo " $OBJOUT$obj \\" >> $MAKEFILE
echo " $src" >> $MAKEFILE $ngx_obj: \$(CORE_DEPS) \$(IMAP_DEPS)$ngx_cont$ngx_src
echo >> $MAKEFILE $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src
fi
END
done done
fi fi
# precompiled headers # the precompiled headers
if [ $PCH != NO ]; then if test -n "$NGX_PCH"; then
echo "#include <ngx_config.h>" > $OBJS/pch.c echo "#include <ngx_config.h>" > $OBJS/ngx_pch.c
pch="$PCH: src/core/ngx_config.h $OS_CONFIG $OBJS/ngx_auto_config.h" ngx_pch="src/core/ngx_config.h $OS_CONFIG $OBJS/ngx_auto_config.h"
pch=`echo $pch | sed -e "s/\//$DIRSEP/g"` ngx_pch=`echo "$NGX_PCH: $ngx_pch" | sed -e "s/\//$ngx_regex_dirsep/g"`
src="\$(CC) \$(CFLAGS) $BUILDPCH $COMPOPT \$(ALL_INCS)"
src="$src $OBJOUT$OBJS/pch.obj $OBJS/pch.c" ngx_src="\$(CC) \$(CFLAGS) $NGX_BUILD_PCH $ngx_compile_opt \$(ALL_INCS)"
src=`echo $src | sed -e "s/\//$DIRSEP/g"` ngx_src="$ngx_src $ngx_objout$OBJS/ngx_pch.obj $OBJS/ngx_pch.c"
ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
cat << END >> $NGX_MAKEFILE
$ngx_pch
$ngx_src
END
echo "$pch" >> $MAKEFILE
echo " $src" >> $MAKEFILE
echo >> $MAKEFILE
fi fi

View File

@ -1,21 +1,25 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
help=no help=no
PREFIX= PREFIX=
SBIN_PATH= SBIN_PATH=
CONF_PATH= CONF_PATH=
HTTP_LOG_PATH=
ERROR_LOG_PATH= ERROR_LOG_PATH=
PID_PATH= PID_PATH=
NGX_USER=
NGX_GROUP=
HTTP_LOG_PATH=
CC=gcc CC=${CC:-gcc}
CPP= CPP=
OBJS=objs NGX_OBJS=objs
DEBUG=NO DEBUG=NO
CC_OPT= NGX_CC_OPT=
NGX_LD_OPT=
CPU=NO CPU=NO
TEST_BUILD_DEVPOLL=NO TEST_BUILD_DEVPOLL=NO
@ -77,10 +81,12 @@ do
--conf-path=*) CONF_PATH="$value" ;; --conf-path=*) CONF_PATH="$value" ;;
--error-log-path=*) ERROR_LOG_PATH="$value" ;; --error-log-path=*) ERROR_LOG_PATH="$value" ;;
--pid-path=*) PID_PATH="$value" ;; --pid-path=*) PID_PATH="$value" ;;
--user=*) NGX_USER="$value" ;;
--group=*) NGX_GROUP="$value" ;;
--crossbuild=*) PLATFORM="$value" ;; --crossbuild=*) PLATFORM="$value" ;;
--builddir=*) OBJS="$value" ;; --builddir=*) NGX_OBJS="$value" ;;
--with-rtsig_module) EVENT_RTSIG=YES ;; --with-rtsig_module) EVENT_RTSIG=YES ;;
--with-select_module) EVENT_SELECT=YES ;; --with-select_module) EVENT_SELECT=YES ;;
@ -109,7 +115,8 @@ do
--with-cc=*) CC="$value" ;; --with-cc=*) CC="$value" ;;
--with-cpp=*) CPP="$value" ;; --with-cpp=*) CPP="$value" ;;
--with-cc-opt=*) CC_OPT="$value" ;; --with-cc-opt=*) NGX_CC_OPT="$value" ;;
--with-ld-opt=*) NGX_LD_OPT="$value" ;;
--with-cpu-opt=*) CPU="$value" ;; --with-cpu-opt=*) CPU="$value" ;;
--with-debug) DEBUG=YES ;; --with-debug) DEBUG=YES ;;
@ -140,24 +147,35 @@ done
if [ $help = yes ]; then if [ $help = yes ]; then
echo
echo " --help this message"
echo
echo " --without-select_module disable select_module" cat << END
echo " --without-poll_module disable poll_module"
echo " --without-http_rewrite_module disable http_rewrite_module" --help this message
echo " --without-http_gzip_module disable http_gzip_module"
echo " --without-http_proxy_module disable http_proxy_module"
echo " --with-cc=NAME name of or path to C compiler" --user=USER set non-privilege user
echo for the worker processes
--group=GROUP set non-privilege group
for the worker processes
echo " --with-pcre=DIR path to PCRE library" --with-select_module enable select module
echo " --with-md5=DIR path to md5 library" --without-select_module disable select module
echo " --with-zlib=DIR path to zlib library" --with-poll_module enable poll module
echo --without-poll_module disable poll module
--without-http_charset_module disable ngx_http_charset_module
--without-http_rewrite_module disable ngx_http_rewrite_module
--without-http_gzip_module disable ngx_http_gzip_module
--without-http_proxy_module disable ngx_http_proxy_module
--with-cc-opt=OPTIONS additional options for compiler
--with-ld-opt=OPTIONS additional options for linker
--with-pcre=DIR path to PCRE library
--with-md5=DIR path to md5 library
--with-zlib=DIR path to zlib library
--with-openssl=DIR path to OpenSSL library
END
exit 1 exit 1
fi fi
@ -181,11 +199,22 @@ if [ ".$PLATFORM" = ".win32" -a $EVENT_POLL = YES ]; then
fi fi
if [ ".$PREFIX" = "." ]; then if test -z "$PREFIX"; then
PREFIX=/usr/local/nginx PREFIX=/usr/local/nginx
fi fi
if test -z "$NGX_GROUP"; then
NGX_GROUP=NGX_USER
fi
if test -z "$NGX_USER"; then
NGX_USER=nobody
NGX_GROUP=nobody
fi
case ".$SBIN_PATH" in case ".$SBIN_PATH" in
./*) ./*)
;; ;;

View File

@ -31,21 +31,7 @@ case $PLATFORM in
;; ;;
win32) win32)
CORE_INCS="$WIN32_INCS" . auto/os/win32
CORE_DEPS="$WIN32_DEPS"
CORE_SRCS="$WIN32_SRCS $IOCP_SRCS"
OS_CONFIG="$WIN32_CONFIG"
EVENT_MODULES="$EVENT_MODULES $IOCP_MODULE"
EVENT_FOUND=YES
if [ $EVENT_SELECT = NO ]; then
CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
fi
have=HAVE_AIO . auto/have
have=HAVE_IOCP . auto/have
CORE_LIBS="$CORE_LIBS ws2_32.lib"
;; ;;
*) *)
@ -55,3 +41,56 @@ case $PLATFORM in
;; ;;
esac esac
if [ $PLATFORM != win32 ]; then
ngx_feature="/dev/poll"
ngx_feature_name="devpoll"
ngx_feature_run=no
ngx_feature_incs="#include <sys/devpoll.h>"
ngx_feature_libs=
ngx_feature_test="int n, dp; struct dvpoll dvp;
dp = 0;
dvp.dp_fds = NULL;
dvp.dp_nfds = 0;
dvp.dp_timeout = 0;
n = ioctl(dp, DP_POLL, &dvp)"
. auto/feature
if [ $ngx_found = yes ]; then
have=HAVE_DEVPOLL . auto/have
CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
EVENT_FOUND=YES
fi
if test -z "$NGX_KQUEUE_CHECKED"; then
ngx_feature="kqueue"
ngx_feature_name="kqueue"
ngx_feature_run=no
ngx_feature_incs="#include <sys/event.h>"
ngx_feature_libs=
ngx_feature_test="int kq; kq = kqueue()"
. auto/feature
if [ $ngx_found = yes ]; then
have=HAVE_KQUEUE . auto/have
have=HAVE_CLEAR_EVENT . auto/have
EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
EVENT_FOUND=YES
ngx_feature="kqueue's NOTE_LOWAT"
ngx_feature_name="HAVE_LOWAT_EVENT"
ngx_feature_run=no
ngx_feature_incs="#include <sys/event.h>"
ngx_feature_libs=
ngx_feature_test="struct kevent kev;
kev.fflags = NOTE_LOWAT;"
. auto/feature
fi
fi
fi

View File

@ -2,19 +2,33 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
cat << END >> $NGX_AUTO_HEADERS_H
#ifndef NGX_FREEBSD
#define NGX_FREEBSD 1
#endif
END
CORE_INCS="$UNIX_INCS" CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $FREEBSD_DEPS" CORE_DEPS="$UNIX_DEPS $FREEBSD_DEPS"
CORE_SRCS="$UNIX_SRCS $FREEBSD_SRCS" CORE_SRCS="$UNIX_SRCS $FREEBSD_SRCS"
PIPE="-pipe" ngx_spacer='
'
# __FreeBSD_version is the best way to determine whether # __FreeBSD_version and sysctl kern.osreldate are the best ways
# some capability exists and is safe to use # to determine whether some capability exists and is safe to use.
# __FreeBSD_version is used for the testing of the build enviroment.
# sysctl kern.osreldate is used for the testing of the kernel capabilities.
version=`grep "#define __FreeBSD_version" /usr/include/osreldate.h \ version=`grep "#define __FreeBSD_version" /usr/include/osreldate.h \
| sed -e 's/^.* \(.*\)$/\1/'` | sed -e 's/^.* \(.*\)$/\1/'`
osreldate=`/sbin/sysctl -n kern.osreldate`
# setproctitle() in libutil # setproctitle() in libutil
@ -28,7 +42,7 @@ fi
# sendfile # sendfile
if [ $version -gt 300007 ]; then if [ $osreldate -gt 300007 ]; then
echo " + using sendfile()" echo " + using sendfile()"
have=HAVE_SENDFILE . auto/have have=HAVE_SENDFILE . auto/have
@ -38,8 +52,8 @@ fi
# kqueue # kqueue
if [ \( $version -lt 500000 -a $version -ge 410000 \) \ if [ \( $osreldate -lt 500000 -a $osreldate -ge 410000 \) \
-o $version -ge 500011 ] -o $osreldate -ge 500011 ]
then then
echo " + using kqueue" echo " + using kqueue"
@ -50,6 +64,8 @@ then
EVENT_FOUND=YES EVENT_FOUND=YES
fi fi
NGX_KQUEUE_CHECKED=YES
# kqueue's NOTE_LAWAT # kqueue's NOTE_LAWAT

View File

@ -2,15 +2,23 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
cat << END >> $NGX_AUTO_HEADERS_H
#ifndef NGX_LINUX
#define NGX_LINUX 1
#endif
END
CORE_INCS="$UNIX_INCS" CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $LINUX_DEPS" CORE_DEPS="$UNIX_DEPS $LINUX_DEPS"
CORE_SRCS="$UNIX_SRCS $LINUX_SRCS" CORE_SRCS="$UNIX_SRCS $LINUX_SRCS"
EVENT_MODULES="$EVENT_MODULES" EVENT_MODULES="$EVENT_MODULES"
PIPE="-pipe" ngx_spacer='
'
CC_AUX_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
CC_TEST_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
# Linux kernel version # Linux kernel version
@ -31,14 +39,18 @@ fi
# epoll, EPOLLET version # epoll, EPOLLET version
ngx_func="epoll"; ngx_feature="epoll"
ngx_func_inc="#include <sys/epoll.h>" ngx_feature_name="epoll"
ngx_func_test="int efd = 0, fd = 1, n; ngx_feature_run=yes
ngx_feature_incs="#include <sys/epoll.h>"
ngx_feature_libs=
ngx_feature_test="int efd = 0, fd = 1, n;
struct epoll_event ee; struct epoll_event ee;
ee.events = EPOLLIN|EPOLLOUT|EPOLLET; ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
ee.data.ptr = NULL; ee.data.ptr = NULL;
n = epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)" efd = epoll_create(100);
. auto/func if (efd == -1) return 1;"
. auto/feature
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then
have=HAVE_EPOLL . auto/have have=HAVE_EPOLL . auto/have
@ -51,13 +63,16 @@ fi
# sendfile() # sendfile()
CC_TEST_FLAGS="-D_GNU_SOURCE" CC_AUX_FLAGS="-D_GNU_SOURCE"
ngx_func="sendfile()"; ngx_feature="sendfile()"
ngx_func_inc="#include <sys/sendfile.h>" ngx_feature_name="sendfile"
ngx_func_test="int s = 0, fd = 1; ngx_feature_run=no
ngx_feature_incs="#include <sys/sendfile.h>"
ngx_feature_libs=
ngx_feature_test="int s = 0, fd = 1;
ssize_t n; off_t off = 0; ssize_t n; off_t off = 0;
n = sendfile(s, fd, &off, 1)" n = sendfile(s, fd, &off, 1)"
. auto/func . auto/feature
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then
CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS" CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS"
@ -66,17 +81,26 @@ fi
# sendfile64() # sendfile64()
CC_TEST_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" CC_AUX_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
ngx_func="sendfile64()"; . auto/func ngx_feature="sendfile64()"
ngx_feature_name="HAVE_SENDFILE64"
ngx_feature_run=no
ngx_feature_incs="#include <sys/sendfile.h>"
ngx_feature_libs=
ngx_feature_test="int s = 0, fd = 1;
ssize_t n; off_t off = 0;
n = sendfile(s, fd, &off, 1)"
. auto/feature
ngx_include="sys/prctl.h"; . auto/include
# prctl(PR_SET_DUMPABLE) # prctl(PR_SET_DUMPABLE)
ngx_func="prctl()"; ngx_feature="prctl(PR_SET_DUMPABLE)"
ngx_func_inc="#include <sys/prctl.h>" ngx_feature_name="HAVE_PR_SET_DUMPABLE"
ngx_func_test="prctl(PR_SET_DUMPABLE, 1, 0, 0, 0)" ngx_feature_run=yes
. auto/func ngx_feature_incs="#include <sys/prctl.h>"
ngx_feature_libs=
if [ $ngx_found = yes ]; then ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1"
have=HAVE_PR_SET_DUMPABLE . auto/have . auto/feature
fi

View File

@ -2,6 +2,14 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
cat << END >> $NGX_AUTO_HEADERS_H
#ifndef NGX_SOLARIS
#define NGX_SOLARIS 1
#endif
END
CORE_INCS="$UNIX_INCS" CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $SOLARIS_DEPS" CORE_DEPS="$UNIX_DEPS $SOLARIS_DEPS"
CORE_SRCS="$UNIX_SRCS $SOLARIS_SRCS " CORE_SRCS="$UNIX_SRCS $SOLARIS_SRCS "
@ -9,40 +17,17 @@ EVENT_MODULES="$EVENT_MODULES"
CORE_LIBS="$CORE_LIBS -lsocket -lnsl -lrt" CORE_LIBS="$CORE_LIBS -lsocket -lnsl -lrt"
# the Solaris's make support # Solaris's make does not support a blank line between target and rules
MAKE_SL=YES ngx_spacer=
CC_AUX_FLAGS="-D_FILE_OFFSET_BITS=64 -lrt"
CC_TEST_FLAGS="-D_FILE_OFFSET_BITS=64"
case $PLATFORM in
SunOS:5.[89]:* | SunOS:5.10:*)
PIPE="-pipe"
;;
*)
# Solaris 7's /usr/ccs/bin/as does not support "-pipe"
;;
esac
case $PLATFORM in case $PLATFORM in
*:sun4u) *:sun4u)
# "-mcpu=v9" enables the "casa" assembler instruction
CFLAGS="$CFLAGS -mcpu=v9" CFLAGS="$CFLAGS -mcpu=v9"
if [ ".$CPU" = ".sparc64" ]; then
CFLAGS="$CFLAGS -m64"
CPU_OPT="-m64"
CORE_LINK="$CORE_LINK -m64"
CC_TEST_FLAGS="$CC_TEST_FLAGS -mcpu=v9 -m64"
fi
;;
*)
;; ;;
esac esac
@ -57,23 +42,15 @@ if [ $ZLIB_ASM != NO ]; then
fi fi
ngx_inc="sys/devpoll.h"; . auto/inc ngx_feature="sendfilev()"
ngx_feature_name="sendfile"
if [ $ngx_found = yes ]; then ngx_feature_run=no
have=HAVE_DEVPOLL . auto/have ngx_feature_incs="#include <sys/sendfile.h>"
CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS" ngx_feature_libs="-lsendfile"
EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE" ngx_feature_test="int fd = 1; sendfilevec_t vec[1];
EVENT_FOUND=YES
fi
ngx_func="sendfilev()";
ngx_func_inc="#include <sys/sendfile.h>"
ngx_func_libs="-lsendfile"
ngx_func_test="int fd = 1; sendfilevec_t vec[1];
size_t sent; ssize_t n; size_t sent; ssize_t n;
n = sendfilev(fd, vec, 1, &sent)" n = sendfilev(fd, vec, 1, &sent)"
. auto/func . auto/feature
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then

29
auto/os/win32 Normal file
View File

@ -0,0 +1,29 @@
# Copyright (C) Igor Sysoev
cat << END >> $NGX_AUTO_HEADERS_H
#ifndef NGX_WIN32
#define NGX_WIN32 1
#endif
END
CORE_INCS="$WIN32_INCS"
CORE_DEPS="$WIN32_DEPS"
CORE_SRCS="$WIN32_SRCS $IOCP_SRCS"
OS_CONFIG="$WIN32_CONFIG"
CORE_LIBS="$CORE_LIBS ws2_32.lib"
EVENT_MODULES="$EVENT_MODULES $IOCP_MODULE"
EVENT_FOUND=YES
if [ $EVENT_SELECT = NO ]; then
CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
fi
have=HAVE_AIO . auto/have
have=HAVE_IOCP . auto/have

8
auto/stubs Normal file
View File

@ -0,0 +1,8 @@
# Copyright (C) Igor Sysoev
have=NGX_USE_HTTP_FILE_CACHE_UNIQ . auto/have
have=NGX_SUPPRESS_WARN . auto/have
have=NGX_SMP . auto/have

View File

@ -2,9 +2,14 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
echo $ngx_n "checking for $ngx_type size ..." $ngx_c echo $ngx_n "checking for $ngx_type size ...$ngx_c"
echo >> $NGX_ERR
echo "checking for $ngx_type size" >> $NGX_ERR cat << END >> $NGX_AUTOCONF_ERR
----------------------------------------
checking for $ngx_type size
END
ngx_size= ngx_size=
@ -12,11 +17,11 @@ cat << END > $NGX_AUTOTEST.c
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
$NGX_UNISTD_H $NGX_INCLUDE_UNISTD_H
#include <signal.h> #include <signal.h>
#include <sys/resource.h> #include <sys/resource.h>
$NGX_INTTYPES_H $NGX_INCLUDE_INTTYPES_H
$NGX_AUTO_CONFIG $NGX_INCLUDE_AUTO_CONFIG_H
int main() { int main() {
printf("%d", sizeof($ngx_type)); printf("%d", sizeof($ngx_type));
@ -25,14 +30,19 @@ int main() {
END END
eval "$CC $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then if [ -x $NGX_AUTOTEST ]; then
ngx_size=`$NGX_AUTOTEST` ngx_size=`$NGX_AUTOTEST`
echo " $ngx_size bytes" echo " $ngx_size bytes"
fi fi
rm $NGX_AUTOTEST*
rm -f $NGX_AUTOTEST
case $ngx_size in case $ngx_size in
4) 4)
@ -58,5 +68,13 @@ case $ngx_size in
*) *)
echo echo
echo "$0: error: can not detect $ngx_type size" echo "$0: error: can not detect $ngx_type size"
echo "----------" >> $NGX_AUTOCONF_ERR
cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
echo $ngx_test >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
exit 1 exit 1
esac esac

View File

@ -2,13 +2,18 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
echo $ngx_n "checking for $ngx_type ..." $ngx_c echo $ngx_n "checking for $ngx_type ...$ngx_c"
echo >> $NGX_ERR
echo "checking for $ngx_type" >> $NGX_ERR
found=no cat << END >> $NGX_AUTOCONF_ERR
for type in $ngx_type $ngx_types ----------------------------------------
checking for $ngx_type
END
ngx_found=no
for ngx_try in $ngx_type $ngx_types
do do
cat << END > $NGX_AUTOTEST.c cat << END > $NGX_AUTOTEST.c
@ -19,42 +24,51 @@ do
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <netinet/in.h> #include <netinet/in.h>
$NGX_INTTYPES_H $NGX_INCLUDE_INTTYPES_H
int main() { int main() {
$type i = 0; $ngx_try i = 0;
return 0; return 0;
} }
END END
eval "$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1" ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then if [ -x $NGX_AUTOTEST ]; then
if [ $type = $ngx_type ]; then if [ $ngx_try = $ngx_type ]; then
echo " found" echo " found"
found=yes ngx_found=yes
else else
echo ", $type used" echo ", $ngx_try used"
found=$type ngx_found=$ngx_try
fi fi
fi fi
rm $NGX_AUTOTEST* rm -f $NGX_AUTOTEST
if [ $ngx_found = no ]; then
echo $ngx_n " $ngx_try not found$ngx_c"
echo "----------" >> $NGX_AUTOCONF_ERR
cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
echo $ngx_test >> $NGX_AUTOCONF_ERR
echo "----------" >> $NGX_AUTOCONF_ERR
if [ $found = no ]; then
echo $ngx_n " $type not found" $ngx_c
else else
break break
fi fi
done done
if [ $found = no ]; then if [ $ngx_found = no ]; then
echo echo
echo "$0: error: can not define $ngx_type" echo "$0: error: can not define $ngx_type"
exit 1 exit 1
fi fi
if [ $found != yes ]; then if [ $ngx_found != yes ]; then
echo "typedef $found $ngx_type;" >> $NGX_AUTO_CONFIG_H echo "typedef $ngx_found $ngx_type;" >> $NGX_AUTO_CONFIG_H
fi fi

View File

@ -2,7 +2,7 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
echo $ngx_n "checking for uintptr_t ... " $ngx_c echo $ngx_n "checking for uintptr_t ...$ngx_c"
echo >> $NGX_ERR echo >> $NGX_ERR
echo "checking for uintptr_t" >> $NGX_ERR echo "checking for uintptr_t" >> $NGX_ERR

139
auto/unix
View File

@ -2,7 +2,7 @@
# Copyright (C) Igor Sysoev # Copyright (C) Igor Sysoev
CC_WARN=$CC CC_WARN=
ngx_fmt_collect=yes ngx_fmt_collect=yes
# C types # C types
@ -23,7 +23,7 @@ eval ngx_formats=\${ngx_${ngx_ptr_size}_fmt}; . auto/fmt/ptrfmt
# POSIX types # POSIX types
NGX_AUTO_CONFIG="#include \"../$NGX_AUTO_CONFIG_H\"" NGX_INCLUDE_AUTO_CONFIG_H="#include \"../$NGX_AUTO_CONFIG_H\""
ngx_type="uint64_t"; ngx_types="u_int64_t"; . auto/types/typedef ngx_type="uint64_t"; ngx_types="u_int64_t"; . auto/types/typedef
@ -72,75 +72,98 @@ eval ngx_formats=\${ngx_${ngx_size}_fmt}; . auto/fmt/fmt
# syscalls, libc calls and some features # syscalls, libc calls and some features
ngx_feature="pread()"
ngx_feature_name="pread"
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_libs= ngx_feature_libs=
ngx_func_libs= ngx_feature_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0)"
. auto/feature
ngx_func="pread()" ngx_feature="pwrite()"
ngx_func_inc= ngx_feature_name="pwrite"
ngx_func_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0)" ngx_feature_run=no
. auto/func ngx_feature_incs=
ngx_feature_libs=
ngx_feature_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0)"
. auto/feature
ngx_func="pwrite()" ngx_feature="strerror_r()"
ngx_func_inc= ngx_feature_name="strerror_r"
ngx_func_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0)" ngx_feature_run=no
. auto/func ngx_feature_incs="#include <string.h>"
ngx_feature_libs=
ngx_feature_test="char buf[20]; int n; n = strerror_r(1, buf, 20)"
. auto/feature
#ngx_func="strsignal()" ngx_feature="gnu_strerror_r()"
#ngx_func_inc="#include <string.h>" ngx_feature_name="gnu_strerror_r"
#ngx_func_test="char *s = strsignal(1)" ngx_feature_run=no
#. auto/func ngx_feature_incs="#include <string.h>"
ngx_feature_libs=
ngx_feature_test="char buf[20], *str; str = strerror_r(1, buf, 20)"
. auto/feature
ngx_func="strerror_r()" ngx_feature="localtime_r()"
ngx_func_inc="#include <string.h>" ngx_feature_name="localtime_r"
ngx_func_test="char buf[20]; int n; n = strerror_r(1, buf, 20)" ngx_feature_run=no
. auto/func ngx_feature_incs="#include <time.h>"
ngx_feature_libs=
ngx_feature_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
. auto/feature
ngx_func="gnu_strerror_r()" ngx_feature="posix_memalign()"
ngx_func_inc="#include <string.h>" ngx_feature_name="posix_memalign"
ngx_func_test="char buf[20], *str; str = strerror_r(1, buf, 20)" ngx_feature_run=no
. auto/func ngx_feature_incs="#include <stdlib.h>"
ngx_feature_libs=
ngx_feature_test="void *p; int n; n = posix_memalign(&p, 4096, 4096)"
. auto/feature
ngx_func="localtime_r()" ngx_feature="memalign()"
ngx_func_inc="#include <time.h>" ngx_feature_name="memalign"
ngx_func_test="struct tm t; time_t c=0; localtime_r(&c, &t)" ngx_feature_run=no
. auto/func ngx_feature_incs="#include <stdlib.h>"
ngx_feature_libs=
ngx_feature_test="void *p; p = memalign(4096, 4096)"
. auto/feature
ngx_func="posix_memalign()" ngx_feature="sched_yield()"
ngx_func_inc="#include <stdlib.h>" ngx_feature_name="HAVE_SCHED_YIELD"
ngx_func_test="void *p; int n; n = posix_memalign(&p, 4096, 4096)" ngx_feature_run=no
. auto/func ngx_feature_incs="#include <sched.h>"
ngx_feature_libs=
ngx_feature_test="sched_yield()"
ngx_func="memalign()" . auto/feature
ngx_func_inc="#include <stdlib.h>"
ngx_func_test="void *p; p = memalign(4096, 4096)"
. auto/func
ngx_feature="mmap(MAP_ANON|MAP_SHARED)" ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
ngx_feature_name="MAP_ANON" ngx_feature_name="MAP_ANON"
ngx_feature_inc="#include <sys/mman.h>" ngx_feature_run=yes
ngx_feature_incs="#include <sys/mman.h>"
ngx_feature_libs=
ngx_feature_test="void *p; ngx_feature_test="void *p;
p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, p = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_SHARED, -1, 0); MAP_ANON|MAP_SHARED, -1, 0);
if (p == MAP_FAILED) return 1;" if (p == MAP_FAILED) return 1;"
ngx_feature_run=yes
. auto/feature . auto/feature
ngx_feature='mmap("/dev/zero", MAP_SHARED)' ngx_feature='mmap("/dev/zero", MAP_SHARED)'
ngx_feature_name="MAP_DEVZERO" ngx_feature_name="MAP_DEVZERO"
ngx_feature_inc="#include <sys/mman.h> ngx_feature_run=yes
ngx_feature_incs="#include <sys/mman.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h>" #include <fcntl.h>"
ngx_feature_libs=
ngx_feature_test='void *p; int fd; ngx_feature_test='void *p; int fd;
fd = open("/dev/zero", O_RDWR); fd = open("/dev/zero", O_RDWR);
p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
@ -150,8 +173,10 @@ ngx_feature_test='void *p; int fd;
ngx_feature="System V shared memory" ngx_feature="System V shared memory"
ngx_feature_name="SYSVSHM" ngx_feature_name="SYSVSHM"
ngx_feature_inc="#include <sys/ipc.h> ngx_feature_run=yes
ngx_feature_incs="#include <sys/ipc.h>
#include <sys/shm.h>" #include <sys/shm.h>"
ngx_feature_libs=
ngx_feature_test="int id; ngx_feature_test="int id;
id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT)); id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
if (id == -1) return 1; if (id == -1) return 1;
@ -159,41 +184,39 @@ ngx_feature_test="int id;
. auto/feature . auto/feature
ngx_feature="struct sockaddr_in.sin_len" ngx_feature="struct sockaddr_in.sin_len"
ngx_feature_name="sin_len" ngx_feature_name="sin_len"
ngx_feature_inc="#include <sys/socket.h>
#include <netinet/in.h>"
ngx_feature_test="struct sockaddr_in sa; sa.sin_len = 5"
ngx_feature_run=no ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>"
ngx_feature_libs=
ngx_feature_test="struct sockaddr_in sa; sa.sin_len = 5"
. auto/feature . auto/feature
ngx_feature="struct msghdr.msg_control" ngx_feature="struct msghdr.msg_control"
ngx_feature_name="msghdr_msg_control" ngx_feature_name="msghdr_msg_control"
ngx_feature_inc="#include <sys/socket.h>" ngx_feature_run=no
ngx_feature_incs="#include <sys/socket.h>"
ngx_feature_libs=
ngx_feature_test="struct msghdr msg; msg.msg_control = NULL" ngx_feature_test="struct msghdr msg; msg.msg_control = NULL"
. auto/feature . auto/feature
case $PLATFORM in
Linux:*)
ngx_feature_inc="#include <sys/ioctl.h>"
;;
*)
ngx_feature_inc="#include <sys/filio.h>"
;;
esac
ngx_feature="ioctl(FIONBIO)" ngx_feature="ioctl(FIONBIO)"
ngx_feature_name="FIONBIO" ngx_feature_name="FIONBIO"
ngx_feature_run=no
ngx_feature_incs="#include <sys/ioctl.h>
$NGX_INCLUDE_SYS_FILIO_H"
ngx_feature_libs=
ngx_feature_test="int i; i = FIONBIO" ngx_feature_test="int i; i = FIONBIO"
. auto/feature . auto/feature
ngx_feature="struct tm.tm_gmtoff" ngx_feature="struct tm.tm_gmtoff"
ngx_feature_name="gmtoff" ngx_feature_name="gmtoff"
ngx_feature_inc="#include <time.h>" ngx_feature_run=no
ngx_feature_incs="#include <time.h>"
ngx_feature_libs=
ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0" ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0"
. auto/feature . auto/feature

View File

@ -1,5 +1,5 @@
user nobody; #user nobody;
worker_processes 3; worker_processes 3;
#error_log logs/error.log; #error_log logs/error.log;

View File

@ -6,6 +6,92 @@
title="nginx"> title="nginx">
<changes ver="0.1.2" date="21.10.2004">
<change type="feature">
<para lang="ru">
ÐÁÒÁÍÅÔÒÙ --user=USER, --group=GROUP É --with-ld-opt=OPTIONS × configure.
</para>
<para lang="en">
the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS options in configure.
</para>
</change>
<change type="feature">
<para lang="ru">
ÄÉÒÅËÔÉ×Á server_name ÐÏÄÄÅÒÖÉ×ÁÅÔ *.domain.tld.
</para>
<para lang="en">
the server_name directive supports *.domain.tld.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÕÌÕÞÛÅÎÁ ÐÅÒÅÎÏÓÉÍÏÓÔØ ÎÁ ÎÅÉÚ×ÅÓÔÎÙÅ ÐÌÁÔÆÏÒÍÙ.
</para>
<para lang="en">
the portability improvements.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÎÅÌØÚÑ ÐÅÒÅËÏÎÆÉÇÕÒÉÒÏ×ÁÔØ nginx, ÅÓÌÉ ËÏÎÆÉÇÕÒÁÃÉÏÎÎÙÊ ÆÁÊÌ ÕËÁÚÁÎ
× ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÅ,
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.1.
</para>
<para lang="en">
if configuration file was set in command line, the reconfiguration
was impossible,
bug appeared in 0.1.1.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÍÏÄÕÌØ ÐÒÏËÓÉÒÏ×ÁÎÉÉ ÍÏÇ ÐÒÉ×ÅÓÔÉ Ë ÚÁÃÉËÌÉ×ÁÎÉÀ, ÅÓÌÉ ÎÅ ÉÓÐÏÌØÚÏ×ÁÌÓÑ
sendfile.
</para>
<para lang="en">
proxy module may get caught in an endless loop when sendfile is not used.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÐÒÉ ÉÓÐÏÌØÚÏ×ÁÎÉÉ sendfile ÔÅËÓÔ ÏÔ×ÅÔÁ ÎÅ ÐÅÒÅËÏÄÉÒÏ×ÁÌÓÑ
ÓÏÇÌÁÓÎÏ ÄÉÒÅËÔÉ×ÁÍ ÍÏÄÕÌÑ charset,
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.1.
</para>
<para lang="en">
with sendfile the response was not recoded according to the charset
module directives,
bug appeared in 0.1.1.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÏÞÅÎØ ÒÅÄËÁÑ ÏÛÉÂËÁ ÐÒÉ ÏÂÒÁÂÏÔËÅ kqueue.
</para>
<para lang="en">
very seldom bug in the kqueue processing.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÍÏÄÕÌØ ÓÖÁÔÉÑ ÓÖÉÍÁÌ ÕÖÅ ÓÖÁÔÙÅ ÏÔ×ÅÔÙ, ÐÏÌÕÞÅÎÎÙÅ ÐÒÉ ÐÒÏËÓÉÒÏ×ÁÎÉÉ.
</para>
<para lang="en">
the gzip module compressed the proxied responses that was already compressed.
</para>
</change>
</changes>
<changes ver="0.1.1" date="11.10.2004"> <changes ver="0.1.1" date="11.10.2004">
<change type="feature"> <change type="feature">
@ -60,7 +146,7 @@ the "Location" header rewrite bug fixed while the proxing.
ÏÛÉÂËÁ × ÍÏÄÕÌÅ ngx_http_chunked_module, ÐÒÉ×ÏÄÉ×ÛÁÑ Ë ÚÁÃÉËÌÉ×ÁÎÉÀ. ÏÛÉÂËÁ × ÍÏÄÕÌÅ ngx_http_chunked_module, ÐÒÉ×ÏÄÉ×ÛÁÑ Ë ÚÁÃÉËÌÉ×ÁÎÉÀ.
</para> </para>
<para lang="en"> <para lang="en">
the ngx_http_chunked_module module bug fixed that caused an endless loop. the ngx_http_chunked_module module may get caught in an endless loop.
</para> </para>
</change> </change>

View File

@ -104,7 +104,7 @@ int main(int argc, char *const *argv, char *const *envp)
ngx_cycle_t *cycle, init_cycle; ngx_cycle_t *cycle, init_cycle;
ngx_core_conf_t *ccf; ngx_core_conf_t *ccf;
#if defined __FreeBSD__ #if (NGX_FREEBSD)
ngx_debug_init(); ngx_debug_init();
#endif #endif
@ -112,7 +112,7 @@ int main(int argc, char *const *argv, char *const *envp)
ngx_time_init(); ngx_time_init();
#if (HAVE_PCRE) #if (NGX_PCRE)
ngx_regex_init(); ngx_regex_init();
#endif #endif
@ -136,11 +136,11 @@ int main(int argc, char *const *argv, char *const *envp)
return 1; return 1;
} }
if (ngx_getopt(&init_cycle, argc, argv) == NGX_ERROR) { if (ngx_save_argv(&init_cycle, argc, argv) == NGX_ERROR) {
return 1; return 1;
} }
if (ngx_save_argv(&init_cycle, argc, argv) == NGX_ERROR) { if (ngx_getopt(&init_cycle, argc, ngx_argv) == NGX_ERROR) {
return 1; return 1;
} }
@ -175,7 +175,7 @@ int main(int argc, char *const *argv, char *const *envp)
if (ngx_test_config) { if (ngx_test_config) {
ngx_log_error(NGX_LOG_INFO, log, 0, ngx_log_error(NGX_LOG_INFO, log, 0,
"the configuration file %s was tested successfully", "the configuration file %s was tested successfully",
init_cycle.conf_file.data); cycle->conf_file.data);
return 0; return 0;
} }
@ -387,7 +387,7 @@ static ngx_int_t ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv)
ngx_argc = argc; ngx_argc = argc;
#if __FreeBSD__ #if (NGX_FREEBSD)
ngx_argv = (char **) argv; ngx_argv = (char **) argv;
@ -462,28 +462,26 @@ static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
#if !(WIN32) #if !(WIN32)
#if 0
if (ccf->user == (uid_t) NGX_CONF_UNSET) { if (ccf->user == (uid_t) NGX_CONF_UNSET) {
pwd = getpwnam("nobody"); pwd = getpwnam(NGX_USER);
if (pwd == NULL) { if (pwd == NULL) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"getpwnam(\"nobody\") failed"); "getpwnam(\"" NGX_USER "\") failed");
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
ccf->user = pwd->pw_uid; ccf->user = pwd->pw_uid;
grp = getgrnam("nobody"); grp = getgrnam(NGX_GROUP);
if (grp == NULL) { if (grp == NULL) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"getgrnam(\"nobody\") failed"); "getgrnam(\"" NGX_GROUP "\") failed");
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
ccf->group = grp->gr_gid; ccf->group = grp->gr_gid;
} }
#endif
if (ccf->pid.len == 0) { if (ccf->pid.len == 0) {
ccf->pid.len = sizeof(NGX_PID_PATH) - 1; ccf->pid.len = sizeof(NGX_PID_PATH) - 1;
@ -522,6 +520,7 @@ static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_core_conf_t *ccf = conf; ngx_core_conf_t *ccf = conf;
char *group;
struct passwd *pwd; struct passwd *pwd;
struct group *grp; struct group *grp;
ngx_str_t *value; ngx_str_t *value;
@ -530,6 +529,14 @@ static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return "is duplicate"; return "is duplicate";
} }
if (geteuid() != 0) {
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
"the \"user\" directive makes sense only "
"if the master process runs "
"with super-user privileges, ignored");
return NGX_CONF_OK;
}
value = (ngx_str_t *) cf->args->elts; value = (ngx_str_t *) cf->args->elts;
pwd = getpwnam((const char *) value[1].data); pwd = getpwnam((const char *) value[1].data);
@ -541,14 +548,12 @@ static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ccf->user = pwd->pw_uid; ccf->user = pwd->pw_uid;
if (cf->args->nelts == 2) { group = (char *) ((cf->args->nelts == 2) ? value[1].data : value[2].data);
return NGX_CONF_OK;
}
grp = getgrnam((const char *) value[2].data); grp = getgrnam(group);
if (grp == NULL) { if (grp == NULL) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
"getgrnam(\"%s\") failed", value[2].data); "getgrnam(\"%s\") failed", group);
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }

View File

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

View File

@ -126,12 +126,11 @@ void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
*busy = *out; *busy = *out;
} else { } else {
for (tl = *busy; /* void */ ; tl = tl->next) { for (tl = *busy; tl->next; tl = tl->next) {
if (tl->next == NULL) { /* void */;
}
tl->next = *out; tl->next = *out;
break;
}
}
} }
*out = NULL; *out = NULL;

View File

@ -22,7 +22,6 @@ struct ngx_buf_s {
off_t file_pos; off_t file_pos;
off_t file_last; off_t file_last;
int type;
u_char *start; /* start of buffer */ u_char *start; /* start of buffer */
u_char *end; /* end of buffer */ u_char *end; /* end of buffer */
ngx_buf_tag_t tag; ngx_buf_tag_t tag;

View File

@ -579,10 +579,20 @@ 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 (!(name->data = ngx_palloc(cycle->pool, name->len + 1))) { if (!(name->data = ngx_palloc(cycle->pool, name->len + 1))) {
return NGX_ERROR; return NGX_ERROR;
} }
} else {
/* the init_cycle */
if (!(name->data = ngx_alloc(name->len + 1, cycle->log))) {
return NGX_ERROR;
}
}
p = ngx_cpymem(name->data, cycle->root.data, cycle->root.len), p = ngx_cpymem(name->data, cycle->root.data, cycle->root.len),
ngx_cpystrn(p, old.data, old.len + 1); ngx_cpystrn(p, old.data, old.len + 1);

View File

@ -8,30 +8,32 @@
#define _NGX_CONFIG_H_INCLUDED_ #define _NGX_CONFIG_H_INCLUDED_
#include <ngx_auto_headers.h>
#if defined __DragonFly__ && !defined __FreeBSD__ #if defined __DragonFly__ && !defined __FreeBSD__
#define __FreeBSD__ 4 #define __FreeBSD__ 4
#define __FreeBSD_version 480101 #define __FreeBSD_version 480101
#endif #endif
#if defined __FreeBSD__ #if (NGX_FREEBSD)
#include <ngx_freebsd_config.h> #include <ngx_freebsd_config.h>
#elif defined __linux__ #elif (NGX_LINUX)
#include <ngx_linux_config.h> #include <ngx_linux_config.h>
/* Solaris */ #elif (NGX_SOLARIS)
#elif defined sun && (defined __svr4__ || defined __SVR4)
#include <ngx_solaris_config.h> #include <ngx_solaris_config.h>
#elif defined _WIN32 #elif (NGX_WIN32)
#include <ngx_win32_config.h> #include <ngx_win32_config.h>
#else /* posix */ #else /* POSIX */
#include <ngx_posix_config.h> #include <ngx_posix_config.h>
#endif #endif
@ -89,8 +91,10 @@ typedef long ngx_flag_t;
#define NGX_INT64_LEN sizeof("-9223372036854775808") - 1 #define NGX_INT64_LEN sizeof("-9223372036854775808") - 1
#define NGX_OFF_T_LEN sizeof("-9223372036854775808") - 1 #define NGX_OFF_T_LEN sizeof("-9223372036854775808") - 1
#define NGX_MAX_INT_LEN (sizeof("-9223372036854775808") - 1)
#if (SOLARIS)
#if (NGX_SOLARIS)
/* TODO: auto_conf */ /* TODO: auto_conf */
#define NGX_ALIGN (_MAX_ALIGNMENT - 1) /* platform word */ #define NGX_ALIGN (_MAX_ALIGNMENT - 1) /* platform word */

View File

@ -40,7 +40,7 @@ typedef struct {
time_t post_accept_timeout; /* should be here because time_t post_accept_timeout; /* should be here because
of the deferred accept */ of the deferred accept */
unsigned new:1; unsigned open:1;
unsigned remain:1; unsigned remain:1;
unsigned ignore:1; unsigned ignore:1;

View File

@ -54,7 +54,7 @@ typedef void (*ngx_event_handler_pt)(ngx_event_t *ev);
#include <ngx_file.h> #include <ngx_file.h>
#include <ngx_files.h> #include <ngx_files.h>
#include <ngx_crc.h> #include <ngx_crc.h>
#if (HAVE_PCRE) #if (NGX_PCRE)
#include <ngx_regex.h> #include <ngx_regex.h>
#endif #endif
#include <ngx_rbtree.h> #include <ngx_rbtree.h>

View File

@ -158,6 +158,9 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
conf.module_type = NGX_CORE_MODULE; conf.module_type = NGX_CORE_MODULE;
conf.cmd_type = NGX_MAIN_CONF; conf.cmd_type = NGX_MAIN_CONF;
#if 0
log->log_level = NGX_LOG_DEBUG_ALL;
#endif
if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) { if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) {
ngx_destroy_pool(pool); ngx_destroy_pool(pool);
@ -223,9 +226,6 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
NGX_FILE_RDWR, NGX_FILE_RDWR,
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND); NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
#if 0
log->log_level = NGX_LOG_DEBUG_ALL;
#endif
ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0, ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
"log: %0X %d \"%s\"", "log: %0X %d \"%s\"",
&file[i], file[i].fd, file[i].name.data); &file[i], file[i].fd, file[i].name.data);
@ -310,14 +310,14 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
} }
if (nls[n].fd == -1) { if (nls[n].fd == -1) {
nls[n].new = 1; nls[n].open = 1;
} }
} }
} else { } else {
ls = cycle->listening.elts; ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) { for (i = 0; i < cycle->listening.nelts; i++) {
ls[i].new = 1; ls[i].open = 1;
} }
} }
@ -366,7 +366,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
ls = cycle->listening.elts; ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) { for (i = 0; i < cycle->listening.nelts; i++) {
if (ls[i].fd == -1 || !ls[i].new) { if (ls[i].fd == -1 || !ls[i].open) {
continue; continue;
} }

View File

@ -57,7 +57,7 @@ static const char *debug_levels[] = {
}; };
#if (HAVE_VARIADIC_MACROS) #if (NGX_HAVE_VARIADIC_MACROS)
void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
const char *fmt, ...) const char *fmt, ...)
#else #else
@ -67,7 +67,7 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
{ {
char errstr[MAX_ERROR_STR]; char errstr[MAX_ERROR_STR];
size_t len, max; size_t len, max;
#if (HAVE_VARIADIC_MACROS) #if (NGX_HAVE_VARIADIC_MACROS)
va_list args; va_list args;
#endif #endif
@ -97,7 +97,7 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
"*%u ", *(u_int *) log->data); "*%u ", *(u_int *) log->data);
} }
#if (HAVE_VARIADIC_MACROS) #if (NGX_HAVE_VARIADIC_MACROS)
va_start(args, fmt); va_start(args, fmt);
len += ngx_vsnprintf(errstr + len, max - len, fmt, args); len += ngx_vsnprintf(errstr + len, max - len, fmt, args);
@ -187,7 +187,7 @@ static void ngx_log_write(ngx_log_t *log, char *errstr, size_t len)
} }
#if !(HAVE_VARIADIC_MACROS) #if !(NGX_HAVE_VARIADIC_MACROS)
void ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, void ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
const char *fmt, ...) const char *fmt, ...)
@ -253,7 +253,7 @@ ngx_log_t *ngx_log_init_stderr()
#endif #endif
ngx_log.file = &ngx_stderr; ngx_log.file = &ngx_stderr;
ngx_log.log_level = NGX_LOG_ERR; ngx_log.log_level = NGX_LOG_NOTICE;
return &ngx_log; return &ngx_log;
} }

View File

@ -55,9 +55,9 @@ struct ngx_log_s {
/*********************************/ /*********************************/
#if (HAVE_GCC_VARIADIC_MACROS) #if (NGX_HAVE_GCC_VARIADIC_MACROS)
#define HAVE_VARIADIC_MACROS 1 #define NGX_HAVE_VARIADIC_MACROS 1
#define ngx_log_error(level, log, args...) \ #define ngx_log_error(level, log, args...) \
if (log->log_level >= level) ngx_log_error_core(level, log, args) if (log->log_level >= level) ngx_log_error_core(level, log, args)
@ -67,9 +67,9 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
/*********************************/ /*********************************/
#elif (HAVE_C99_VARIADIC_MACROS) #elif (NGX_HAVE_C99_VARIADIC_MACROS)
#define HAVE_VARIADIC_MACROS 1 #define NGX_HAVE_VARIADIC_MACROS 1
#define ngx_log_error(level, log, ...) \ #define ngx_log_error(level, log, ...) \
if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__) if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
@ -81,7 +81,7 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
#else /* NO VARIADIC MACROS */ #else /* NO VARIADIC MACROS */
#define HAVE_VARIADIC_MACROS 0 #define NGX_HAVE_VARIADIC_MACROS 0
void ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, void ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
const char *fmt, ...); const char *fmt, ...);
@ -98,7 +98,7 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...);
#if (NGX_DEBUG) #if (NGX_DEBUG)
#if (HAVE_VARIADIC_MACROS) #if (NGX_HAVE_VARIADIC_MACROS)
#define ngx_log_debug0(level, log, err, fmt) \ #define ngx_log_debug0(level, log, err, fmt) \
if (log->log_level & level) \ if (log->log_level & level) \

View File

@ -24,14 +24,14 @@ ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
size_t size, bsize; size_t size, bsize;
ngx_chain_t *cl, *out, **last_out; ngx_chain_t *cl, *out, **last_out;
if (ctx->in == NULL && ctx->busy == NULL) {
/* /*
* the short path for the case when the ctx->in chain is empty * the short path for the case when the ctx->in and ctx->busy chains
* and the incoming chain is empty too or it has the single buf * are empty, the incoming chain is empty too or has the single buf
* that does not require the copy * that does not require the copy
*/ */
if (ctx->in == NULL) {
if (in == NULL) { if (in == NULL) {
return ctx->output_filter(ctx->filter_ctx, in); return ctx->output_filter(ctx->filter_ctx, in);
} }
@ -192,6 +192,7 @@ ngx_inline static ngx_int_t
} }
if (!ctx->sendfile) { if (!ctx->sendfile) {
if (!ngx_buf_in_memory(buf)) { if (!ngx_buf_in_memory(buf)) {
return 1; return 1;
} }
@ -228,12 +229,19 @@ static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
src->pos += size; src->pos += size;
dst->last += size; dst->last += size;
if (src->in_file && sendfile) { if (src->in_file) {
if (sendfile) {
dst->in_file = 1; dst->in_file = 1;
dst->file = src->file; dst->file = src->file;
dst->file_pos = src->file_pos; dst->file_pos = src->file_pos;
dst->file_last = src->file_pos + size;
} else {
dst->in_file = 0;
}
src->file_pos += size; src->file_pos += size;
dst->file_last = src->file_pos;
} else { } else {
dst->in_file = 0; dst->in_file = 0;
@ -271,14 +279,14 @@ static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
dst->in_file = 1; dst->in_file = 1;
dst->file = src->file; dst->file = src->file;
dst->file_pos = src->file_pos; dst->file_pos = src->file_pos;
src->file_pos += size; dst->file_last = src->file_pos + n;
dst->file_last = src->file_pos;
} else { } else {
dst->in_file = 0; dst->in_file = 0;
src->file_pos += n;
} }
src->file_pos += n;
if (src->last_buf && src->file_pos == src->file_last) { if (src->last_buf && src->file_pos == src->file_last) {
dst->last_buf = 1; dst->last_buf = 1;
} }

View File

@ -28,6 +28,238 @@ u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n)
} }
/*
* supported formats:
* %[0][width]O off_t
* %[0][width]T time_t
* %[0][width]S ssize_t
* %[0][width]uS size_t
* %[0][width]uxS size_t in hex
* %[0][width]l long
* %[0][width]d int
* %[0][width]i ngx_int_t
* %[0][width]ui ngx_uint_t
* %[0][width]uxi ngx_uint_t in hex
* %s null-terminated string
* %% %
*
*/
u_char *ngx_sprintf(u_char *buf, char *fmt, ...)
{
u_char *p, c, temp[NGX_MAX_INT_LEN];
int d;
long l;
off_t offset;
size_t size, len;
ssize_t ssize;
time_t sec;
va_list arg;
ngx_int_t i;
ngx_uint_t ui, zero, width, sign, hexadecimal;
static u_char hex[] = "0123456789abcdef";
va_start(arg, fmt);
while (*fmt) {
if (*fmt == '%') {
zero = (*++fmt == '0') ? 1 : 0;
width = 0;
sign = 1;
hexadecimal = 0;
p = temp + NGX_MAX_INT_LEN;
while (*fmt >= '0' && *fmt <= '9') {
width = width * 10 + *fmt++ - '0';
}
for ( ;; ) {
switch (*fmt) {
case 'u':
sign = 0;
fmt++;
continue;
case 'x':
hexadecimal = 1;
fmt++;
continue;
default:
break;
}
break;
}
switch (*fmt) {
case 'O':
offset = va_arg(arg, off_t);
if (offset < 0) {
*buf++ = '-';
offset = -offset;
}
do {
*--p = (u_char) (offset % 10 + '0');
} while (offset /= 10);
break;
case 'T':
sec = va_arg(arg, time_t);
if (sec < 0) {
*buf++ = '-';
sec = -sec;
}
do {
*--p = (u_char) (sec % 10 + '0');
} while (sec /= 10);
break;
case 'S':
if (sign) {
ssize = va_arg(arg, ssize_t);
if (ssize < 0) {
*buf++ = '-';
size = (size_t) -ssize;
} else {
size = (size_t) ssize;
}
} else {
size = va_arg(arg, size_t);
}
if (hexadecimal) {
do {
*--p = hex[size & 0xf];
} while (size >>= 4);
} else {
do {
*--p = (u_char) (size % 10 + '0');
} while (size /= 10);
}
break;
case 'l':
l = va_arg(arg, long);
if (l < 0) {
*buf++ = '-';
l = -l;
}
do {
*--p = (u_char) (l % 10 + '0');
} while (l /= 10);
break;
case 'd':
d = va_arg(arg, int);
if (d < 0) {
*buf++ = '-';
d = -d;
}
do {
*--p = (u_char) (d % 10 + '0');
} while (d /= 10);
break;
case 'i':
if (sign) {
i = va_arg(arg, ngx_int_t);
if (i < 0) {
*buf++ = '-';
ui = (ngx_uint_t) -i;
} else {
ui = (ngx_uint_t) i;
}
} else {
ui = va_arg(arg, ngx_uint_t);
}
if (hexadecimal) {
do {
*--p = hex[ui & 0xf];
} while (ui >>= 4);
} else {
do {
*--p = (u_char) (ui % 10 + '0');
} while (ui /= 10);
}
break;
case 's':
p = va_arg(arg, u_char *);
while (*p) {
*buf++ = *p++;
}
fmt++;
continue;
case '%':
*buf++ = '%';
fmt++;
continue;
default:
*buf++ = *fmt++;
continue;
}
len = (temp + NGX_MAX_INT_LEN) - p;
c = (u_char) (zero ? '0' : ' ');
while (len++ < width) {
*buf++ = c;
}
buf = ngx_cpymem(buf, p, ((temp + NGX_MAX_INT_LEN) - p));
fmt++;
} else {
*buf++ = *fmt++;
}
}
va_end(arg);
*buf = '\0';
return buf;
}
ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n) ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n)
{ {
if (n == 0) { if (n == 0) {
@ -50,6 +282,40 @@ 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)
{
u_char c1, c2;
if (n == 0) {
return 0;
}
n--;
for ( ;; ) {
c1 = s1[n];
if (c1 >= 'a' && c1 <= 'z') {
c1 -= 'a' - 'A';
}
c2 = s2[n];
if (c2 >= 'a' && c2 <= 'z') {
c2 -= 'a' - 'A';
}
if (c1 != c2) {
return c1 - c2;
}
if (n == 0) {
return 0;
}
n--;
}
}
ngx_int_t ngx_atoi(u_char *line, size_t n) ngx_int_t ngx_atoi(u_char *line, size_t n)
{ {
ngx_int_t value; ngx_int_t value;

View File

@ -70,7 +70,10 @@ typedef struct {
#define ngx_memcmp memcmp #define ngx_memcmp memcmp
u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n); u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n);
u_char *ngx_sprintf(u_char *buf, char *fmt, ...);
ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n); 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_atoi(u_char *line, size_t n); ngx_int_t ngx_atoi(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);

View File

@ -212,12 +212,25 @@ void ngx_time_update(time_t s)
} }
u_char *ngx_http_time(u_char *buf, time_t t)
#if 0
size_t ngx_http_time(u_char *buf, time_t t) size_t ngx_http_time(u_char *buf, time_t t)
#endif
{ {
ngx_tm_t tm; ngx_tm_t tm;
ngx_gmtime(t, &tm); ngx_gmtime(t, &tm);
return ngx_sprintf(buf, "%s, %02d %s %4d %02d:%02d:%02d GMT",
week[tm.ngx_tm_wday],
tm.ngx_tm_mday,
months[tm.ngx_tm_mon - 1],
tm.ngx_tm_year,
tm.ngx_tm_hour,
tm.ngx_tm_min,
tm.ngx_tm_sec);
#if 0
return ngx_snprintf((char *) buf, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"), return ngx_snprintf((char *) buf, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
"%s, %02d %s %4d %02d:%02d:%02d GMT", "%s, %02d %s %4d %02d:%02d:%02d GMT",
week[tm.ngx_tm_wday], week[tm.ngx_tm_wday],
@ -227,10 +240,14 @@ size_t ngx_http_time(u_char *buf, time_t t)
tm.ngx_tm_hour, tm.ngx_tm_hour,
tm.ngx_tm_min, tm.ngx_tm_min,
tm.ngx_tm_sec); tm.ngx_tm_sec);
#endif
} }
u_char *ngx_http_cookie_time(u_char *buf, time_t t)
#if 0
size_t ngx_http_cookie_time(u_char *buf, time_t t) size_t ngx_http_cookie_time(u_char *buf, time_t t)
#endif
{ {
ngx_tm_t tm; ngx_tm_t tm;
@ -241,6 +258,20 @@ size_t ngx_http_cookie_time(u_char *buf, time_t t)
* 2-digit years more than "37" * 2-digit years more than "37"
*/ */
return ngx_sprintf(buf,
(tm.ngx_tm_year > 2037) ?
"%s, %02d-%s-%d %02d:%02d:%02d GMT":
"%s, %02d-%s-%02d %02d:%02d:%02d GMT",
week[tm.ngx_tm_wday],
tm.ngx_tm_mday,
months[tm.ngx_tm_mon - 1],
(tm.ngx_tm_year > 2037) ? tm.ngx_tm_year:
tm.ngx_tm_year % 100,
tm.ngx_tm_hour,
tm.ngx_tm_min,
tm.ngx_tm_sec);
#if 0
if (tm.ngx_tm_year > 2037) { if (tm.ngx_tm_year > 2037) {
return ngx_snprintf((char *) buf, return ngx_snprintf((char *) buf,
sizeof("Mon, 28-Sep-1970 06:00:00 GMT"), sizeof("Mon, 28-Sep-1970 06:00:00 GMT"),
@ -264,6 +295,7 @@ size_t ngx_http_cookie_time(u_char *buf, time_t t)
tm.ngx_tm_min, tm.ngx_tm_min,
tm.ngx_tm_sec); tm.ngx_tm_sec);
} }
#endif
} }

View File

@ -14,8 +14,8 @@
void ngx_time_init(); void ngx_time_init();
void ngx_time_update(time_t s); void ngx_time_update(time_t s);
size_t ngx_http_time(u_char *buf, time_t t); u_char *ngx_http_time(u_char *buf, time_t t);
size_t ngx_http_cookie_time(u_char *buf, time_t t); 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);
#if (NGX_THREADS) #if (NGX_THREADS)

View File

@ -173,7 +173,7 @@ static int ngx_epoll_init(ngx_cycle_t *cycle)
#else #else
ngx_event_flags = NGX_USE_LEVEL_EVENT ngx_event_flags = NGX_USE_LEVEL_EVENT
#endif #endif
|NGX_HAVE_GREEDY_EVENT |NGX_USE_GREEDY_EVENT
|NGX_USE_EPOLL_EVENT; |NGX_USE_EPOLL_EVENT;
return NGX_OK; return NGX_OK;

View File

@ -194,10 +194,10 @@ static ngx_int_t ngx_kqueue_init(ngx_cycle_t *cycle)
#else #else
|NGX_USE_LEVEL_EVENT |NGX_USE_LEVEL_EVENT
#endif #endif
#if (HAVE_LOWAT_EVENT) #if (NGX_HAVE_LOWAT_EVENT)
|NGX_HAVE_LOWAT_EVENT |NGX_USE_LOWAT_EVENT
#endif #endif
|NGX_HAVE_KQUEUE_EVENT; |NGX_USE_KQUEUE_EVENT;
return NGX_OK; return NGX_OK;
} }
@ -245,6 +245,8 @@ static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
return NGX_ERROR; return NGX_ERROR;
} }
#if 1
if (nchanges > 0 if (nchanges > 0
&& ev->index < (u_int) nchanges && ev->index < (u_int) nchanges
&& ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1) && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
@ -262,7 +264,8 @@ static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
ngx_event_ident(ev->data), event); ngx_event_ident(ev->data), event);
if (ev->index < (u_int) --nchanges) { if (ev->index < (u_int) --nchanges) {
e = (ngx_event_t *) change_list[nchanges].udata; e = (ngx_event_t *)
((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1);
change_list[ev->index] = change_list[nchanges]; change_list[ev->index] = change_list[nchanges];
e->index = ev->index; e->index = ev->index;
} }
@ -282,6 +285,8 @@ static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
return NGX_ERROR; return NGX_ERROR;
} }
#endif
rc = ngx_kqueue_set_event(ev, event, EV_ADD|EV_ENABLE|flags); rc = ngx_kqueue_set_event(ev, event, EV_ADD|EV_ENABLE|flags);
ngx_mutex_unlock(list_mutex); ngx_mutex_unlock(list_mutex);
@ -302,6 +307,8 @@ static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
return NGX_ERROR; return NGX_ERROR;
} }
#if 1
if (nchanges > 0 if (nchanges > 0
&& ev->index < (u_int) nchanges && ev->index < (u_int) nchanges
&& ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1) && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
@ -314,7 +321,8 @@ static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
/* if the event is still not passed to a kernel we will not pass it */ /* if the event is still not passed to a kernel we will not pass it */
if (ev->index < (u_int) --nchanges) { if (ev->index < (u_int) --nchanges) {
e = (ngx_event_t *) change_list[nchanges].udata; e = (ngx_event_t *)
((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1);
change_list[ev->index] = change_list[nchanges]; change_list[ev->index] = change_list[nchanges];
e->index = ev->index; e->index = ev->index;
} }
@ -324,6 +332,8 @@ static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
return NGX_OK; return NGX_OK;
} }
#endif
/* /*
* when the file descriptor is closed the kqueue automatically deletes * when the file descriptor is closed the kqueue automatically deletes
* its filters so we do not need to delete explicity the event * its filters so we do not need to delete explicity the event
@ -393,7 +403,7 @@ static ngx_int_t ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
kev->data = 0; kev->data = 0;
} else { } else {
#if (HAVE_LOWAT_EVENT) #if (NGX_HAVE_LOWAT_EVENT)
if (flags & NGX_LOWAT_EVENT) { if (flags & NGX_LOWAT_EVENT) {
kev->fflags = NOTE_LOWAT; kev->fflags = NOTE_LOWAT;
kev->data = ev->available; kev->data = ev->available;

View File

@ -158,7 +158,7 @@ static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle)
ngx_event_actions = ngx_rtsig_module_ctx.actions; ngx_event_actions = ngx_rtsig_module_ctx.actions;
ngx_event_flags = NGX_USE_RTSIG_EVENT|NGX_HAVE_GREEDY_EVENT; ngx_event_flags = NGX_USE_RTSIG_EVENT|NGX_USE_GREEDY_EVENT;
return NGX_OK; return NGX_OK;
} }

View File

@ -465,9 +465,9 @@ ngx_int_t ngx_send_lowat(ngx_connection_t *c, size_t lowat)
{ {
int sndlowat; int sndlowat;
#if (HAVE_LOWAT_EVENT) #if (NGX_HAVE_LOWAT_EVENT)
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
c->write->available = lowat; c->write->available = lowat;
return NGX_OK; return NGX_OK;
} }

View File

@ -240,19 +240,19 @@ extern ngx_event_actions_t ngx_event_actions;
* The event filter has kqueue features - the eof flag, errno, * The event filter has kqueue features - the eof flag, errno,
* available data, etc. * available data, etc.
*/ */
#define NGX_HAVE_KQUEUE_EVENT 0x00000008 #define NGX_USE_KQUEUE_EVENT 0x00000008
/* /*
* The event filter supports low water mark - kqueue's NOTE_LOWAT. * The event filter supports low water mark - kqueue's NOTE_LOWAT.
* kqueue in FreeBSD 4.1-4.2 has no NOTE_LOWAT so we need a separate flag. * kqueue in FreeBSD 4.1-4.2 has no NOTE_LOWAT so we need a separate flag.
*/ */
#define NGX_HAVE_LOWAT_EVENT 0x00000010 #define NGX_USE_LOWAT_EVENT 0x00000010
/* /*
* The event filter requires to do i/o operation until EAGAIN - * The event filter requires to do i/o operation until EAGAIN -
* epoll, rt signals. * epoll, rt signals.
*/ */
#define NGX_HAVE_GREEDY_EVENT 0x00000020 #define NGX_USE_GREEDY_EVENT 0x00000020
/* /*
* The event filter is epoll, * The event filter is epoll,
@ -571,7 +571,7 @@ ngx_inline static int ngx_handle_write_event(ngx_event_t *wev, size_t lowat)
ngx_connection_t *c; ngx_connection_t *c;
if (lowat) { if (lowat) {
c = wev->data; c = (ngx_connection_t *) wev->data;
if (ngx_send_lowat(c, lowat) == NGX_ERROR) { if (ngx_send_lowat(c, lowat) == NGX_ERROR) {
return NGX_ERROR; return NGX_ERROR;

View File

@ -39,7 +39,7 @@ void ngx_event_accept(ngx_event_t *ev)
if (ngx_event_flags & NGX_USE_RTSIG_EVENT) { if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
ev->available = 1; ev->available = 1;
} else if (!(ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)) { } else if (!(ngx_event_flags & NGX_USE_KQUEUE_EVENT)) {
ev->available = ecf->multi_accept; ev->available = ecf->multi_accept;
} }
@ -118,7 +118,7 @@ void ngx_event_accept(ngx_event_t *ev)
ls->listening->addr_text.data); ls->listening->addr_text.data);
if (err == NGX_ECONNABORTED) { if (err == NGX_ECONNABORTED) {
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ev->available--; ev->available--;
} }
@ -342,7 +342,7 @@ void ngx_event_accept(ngx_event_t *ev)
ls->listening->handler(c); ls->listening->handler(c);
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ev->available--; ev->available--;
} }

View File

@ -296,6 +296,9 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
if (ngx_event_flags & NGX_USE_AIO_EVENT) { if (ngx_event_flags & NGX_USE_AIO_EVENT) {
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, ngx_socket_errno,
"connect(): %d", rc);
/* aio, iocp */ /* aio, iocp */
if (ngx_blocking(s) == -1) { if (ngx_blocking(s) == -1) {
@ -311,8 +314,7 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
} }
/* /*
* aio allows to post operation on non-connected socket * FreeBSD aio allows to post operation on non-connected socket.
* at least in FreeBSD.
* NT does not support it. * NT does not support it.
* *
* TODO: check in Win32, etc. As workaround we can use NGX_ONESHOT_EVENT * TODO: check in Win32, etc. As workaround we can use NGX_ONESHOT_EVENT

View File

@ -86,6 +86,7 @@ ngx_int_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size)
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", sslerr); ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", sslerr);
if (sslerr == SSL_ERROR_WANT_READ) { if (sslerr == SSL_ERROR_WANT_READ) {
c->read->ready = 0;
return NGX_AGAIN; return NGX_AGAIN;
} }

View File

@ -12,7 +12,7 @@
typedef struct { typedef struct {
char **tables; char **tables;
ngx_str_t name; ngx_str_t name;
unsigned server; ngx_uint_t server; /* unsigned server:1; */
} ngx_http_charset_t; } ngx_http_charset_t;
@ -45,7 +45,7 @@ typedef struct {
} ngx_http_charset_ctx_t; } ngx_http_charset_ctx_t;
static void 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);
@ -232,16 +232,33 @@ static ngx_int_t ngx_http_charset_body_filter(ngx_http_request_t *r,
} }
static void 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, c; u_char *p;
ngx_uint_t change;
change = 0;
for (p = b->pos; p < b->last; p++) { for (p = b->pos; p < b->last; p++) {
c = *p; if (*p != table[*p]) {
*p = table[c]; change = 1;
break;
} }
} }
if (change) {
while (p < b->last) {
*p = table[*p];
p++;
}
b->in_file = 0;
}
return change;
}
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)
@ -419,7 +436,9 @@ static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
return NGX_ERROR; return NGX_ERROR;
} }
c->tables = NULL;
c->name = *name; c->name = *name;
c->server = 0;
return i; return i;
} }

View File

@ -63,7 +63,7 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
ngx_chain_t *in) ngx_chain_t *in)
{ {
u_char *chunk; u_char *chunk;
size_t size, len; size_t size;
ngx_buf_t *b; ngx_buf_t *b;
ngx_chain_t out, tail, *cl, *tl, **ll; ngx_chain_t out, tail, *cl, *tl, **ll;
@ -98,6 +98,20 @@ 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))) {
return NGX_ERROR;
}
if (!(chunk = ngx_palloc(r->pool, 11))) {
return NGX_ERROR;
}
b->temporary = 1;
b->pos = chunk;
b->last = ngx_sprintf(chunk, "%uxS" CRLF, size);
out.buf = b;
#if 0
ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR); ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR);
len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size); len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size);
@ -107,6 +121,7 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
b->last = chunk + len; b->last = chunk + len;
out.buf = b; out.buf = b;
#endif
} }
if (cl->buf->last_buf) { if (cl->buf->last_buf) {

View File

@ -837,26 +837,30 @@ static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf,
return buf + 1; return buf + 1;
} }
#if 0
return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 4, "%.2f",
(float) ctx->zin / ctx->zout);
#endif
/* we prefer do not use the FPU */ /* we prefer do not use the FPU */
zint = (ngx_uint_t) (ctx->zin / ctx->zout); zint = (ngx_uint_t) (ctx->zin / ctx->zout);
zfrac = (ngx_uint_t) ((ctx->zin * 100 / ctx->zout) % 100); zfrac = (ngx_uint_t) ((ctx->zin * 100 / ctx->zout) % 100);
if ((ctx->zin * 1000 / ctx->zout) % 10 > 4) { if ((ctx->zin * 1000 / ctx->zout) % 10 > 4) {
if (++zfrac > 99) {
/* the rounding, e.g., 2.125 to 2.13 */
zfrac++;
if (zfrac > 99) {
zint++; zint++;
zfrac = 0; zfrac = 0;
} }
} }
return ngx_sprintf(buf, "%ui.%02ui", zint, zfrac);
#if 0
return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 4, return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 4,
"%" NGX_UINT_T_FMT ".%02" NGX_UINT_T_FMT, "%" NGX_UINT_T_FMT ".%02" NGX_UINT_T_FMT,
zint, zfrac); zint, zfrac);
#endif
} }

View File

@ -134,10 +134,16 @@ static ngx_int_t ngx_http_headers_filter(ngx_http_request_t *r)
return NGX_ERROR; return NGX_ERROR;
} }
cc->value.len = ngx_sprintf(cc->value.data, "max-age=%T",
conf->expires)
- cc->value.data;
#if 0
cc->value.len = ngx_snprintf((char *) cc->value.data, cc->value.len = ngx_snprintf((char *) cc->value.data,
sizeof("max-age=") + TIME_T_LEN, sizeof("max-age=") + TIME_T_LEN,
"max-age=" TIME_T_FMT, "max-age=" TIME_T_FMT,
conf->expires); conf->expires);
#endif
} }
} }
} }

View File

@ -264,9 +264,14 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
} }
r->headers_out.content_range->value.len = r->headers_out.content_range->value.len =
ngx_sprintf(r->headers_out.content_range->value.data,
"bytes */%O", r->headers_out.content_length_n)
- r->headers_out.content_range->value.data;
#if 0
ngx_snprintf((char *) r->headers_out.content_range->value.data, ngx_snprintf((char *) r->headers_out.content_range->value.data,
8 + 20 + 1, "bytes */" OFF_T_FMT, 8 + 20 + 1, "bytes */" OFF_T_FMT,
r->headers_out.content_length_n); r->headers_out.content_length_n);
#endif
r->headers_out.content_length_n = -1; r->headers_out.content_length_n = -1;
if (r->headers_out.content_length) { if (r->headers_out.content_length) {
@ -297,12 +302,20 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
/* "Content-Range: bytes SSSS-EEEE/TTTT" header */ /* "Content-Range: bytes SSSS-EEEE/TTTT" header */
r->headers_out.content_range->value.len = r->headers_out.content_range->value.len =
ngx_sprintf(r->headers_out.content_range->value.data,
"bytes %O-%O/%O",
range->start, range->end - 1,
r->headers_out.content_length_n)
- r->headers_out.content_range->value.data;
#if 0
ngx_snprintf((char *) ngx_snprintf((char *)
r->headers_out.content_range->value.data, r->headers_out.content_range->value.data,
6 + 20 + 1 + 20 + 1 + 20 + 1, 6 + 20 + 1 + 20 + 1 + 20 + 1,
"bytes " OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT, "bytes " OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT,
range->start, range->end - 1, range->start, range->end - 1,
r->headers_out.content_length_n); r->headers_out.content_length_n);
#endif
r->headers_out.content_length_n = range->end - range->start; r->headers_out.content_length_n = range->end - range->start;
@ -343,6 +356,15 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
if (r->headers_out.charset.len) { if (r->headers_out.charset.len) {
ctx->boundary_header.len = ctx->boundary_header.len =
ngx_sprintf(ctx->boundary_header.data,
CRLF "--%010ui" CRLF
"Content-Type: %s; charset=%s" CRLF
"Content-Range: bytes ",
boundary,
r->headers_out.content_type->value.data,
r->headers_out.charset.data)
- ctx->boundary_header.data;
#if 0
ngx_snprintf((char *) ctx->boundary_header.data, len, ngx_snprintf((char *) ctx->boundary_header.data, len,
CRLF "--%010" NGX_UINT_T_FMT CRLF CRLF "--%010" NGX_UINT_T_FMT CRLF
"Content-Type: %s; charset=%s" CRLF "Content-Type: %s; charset=%s" CRLF
@ -350,17 +372,29 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
boundary, boundary,
r->headers_out.content_type->value.data, r->headers_out.content_type->value.data,
r->headers_out.charset.data); r->headers_out.charset.data);
#endif
r->headers_out.charset.len = 0; r->headers_out.charset.len = 0;
} else { } else {
ctx->boundary_header.len = ctx->boundary_header.len =
ngx_sprintf(ctx->boundary_header.data,
CRLF "--%010ui" CRLF
"Content-Type: %s" CRLF
"Content-Range: bytes ",
boundary,
r->headers_out.content_type->value.data)
- ctx->boundary_header.data;
#if 0
ngx_snprintf((char *) ctx->boundary_header.data, len, ngx_snprintf((char *) ctx->boundary_header.data, len,
CRLF "--%010" NGX_UINT_T_FMT CRLF CRLF "--%010" NGX_UINT_T_FMT CRLF
"Content-Type: %s" CRLF "Content-Type: %s" CRLF
"Content-Range: bytes ", "Content-Range: bytes ",
boundary, boundary,
r->headers_out.content_type->value.data); r->headers_out.content_type->value.data);
#endif
} }
ngx_test_null(r->headers_out.content_type->value.data, ngx_test_null(r->headers_out.content_type->value.data,
@ -370,12 +404,18 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
/* "Content-Type: multipart/byteranges; boundary=0123456789" */ /* "Content-Type: multipart/byteranges; boundary=0123456789" */
r->headers_out.content_type->value.len = r->headers_out.content_type->value.len =
ngx_sprintf(r->headers_out.content_type->value.data,
"multipart/byteranges; boundary=%010ui",
boundary)
- r->headers_out.content_type->value.data;
#if 0
ngx_snprintf((char *) ngx_snprintf((char *)
r->headers_out.content_type->value.data, r->headers_out.content_type->value.data,
31 + 10 + 1, 31 + 10 + 1,
"multipart/byteranges; boundary=%010" "multipart/byteranges; boundary=%010"
NGX_UINT_T_FMT, NGX_UINT_T_FMT,
boundary); boundary);
#endif
/* the size of the last boundary CRLF "--0123456789--" CRLF */ /* the size of the last boundary CRLF "--0123456789--" CRLF */
len = 4 + 10 + 4; len = 4 + 10 + 4;
@ -389,11 +429,18 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
/* the size of the range: "SSSS-EEEE/TTTT" CRLF CRLF */ /* the size of the range: "SSSS-EEEE/TTTT" CRLF CRLF */
range[i].content_range.len = range[i].content_range.len =
ngx_sprintf(range[i].content_range.data,
"%O-%O/%O" CRLF CRLF,
range[i].start, range[i].end - 1,
r->headers_out.content_length_n)
- range[i].content_range.data;
#if 0
ngx_snprintf((char *) range[i].content_range.data, ngx_snprintf((char *) range[i].content_range.data,
20 + 1 + 20 + 1 + 20 + 5, 20 + 1 + 20 + 1 + 20 + 5,
OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT CRLF CRLF, OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT CRLF CRLF,
range[i].start, range[i].end - 1, range[i].start, range[i].end - 1,
r->headers_out.content_length_n); r->headers_out.content_length_n);
#endif
len += ctx->boundary_header.len + range[i].content_range.len len += ctx->boundary_header.len + range[i].content_range.len
+ (size_t) (range[i].end - range[i].start); + (size_t) (range[i].end - range[i].start);

View File

@ -159,6 +159,9 @@ static ngx_int_t ngx_http_status(ngx_http_status_ctx_t *ctx)
+ 1 + (r->server_name ? cmcf->max_server_name_len : 1) + 1 + (r->server_name ? cmcf->max_server_name_len : 1)
+ 2; /* "\r\n" */ + 2; /* "\r\n" */
/* BUG: cmcf->max_server_name_len and "*.domain.tld" */
if (r->request_line.len) { if (r->request_line.len) {
len += 1 + 1 + r->request_line.len + 1; len += 1 + 1 + r->request_line.len + 1;
} }

View File

@ -367,7 +367,7 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
} else if (conf->expires) { } else if (conf->expires) {
p = ngx_cpymem(p, expires, sizeof("; expires=") - 1); p = ngx_cpymem(p, expires, sizeof("; expires=") - 1);
p += ngx_http_cookie_time(p, ngx_time() + conf->expires); p = ngx_http_cookie_time(p, ngx_time() + conf->expires);
} }
if (conf->domain.len > 1) { if (conf->domain.len > 1) {

View File

@ -289,6 +289,8 @@ ngx_http_header_t ngx_http_proxy_headers_in[] = {
offsetof(ngx_http_proxy_headers_in_t, content_type) }, offsetof(ngx_http_proxy_headers_in_t, content_type) },
{ ngx_string("Content-Length"), { ngx_string("Content-Length"),
offsetof(ngx_http_proxy_headers_in_t, content_length) }, offsetof(ngx_http_proxy_headers_in_t, content_length) },
{ ngx_string("Content-Encoding"),
offsetof(ngx_http_proxy_headers_in_t, content_encoding) },
{ ngx_string("Last-Modified"), { ngx_string("Last-Modified"),
offsetof(ngx_http_proxy_headers_in_t, last_modified) }, offsetof(ngx_http_proxy_headers_in_t, last_modified) },
{ ngx_string("Location"), { ngx_string("Location"),
@ -400,7 +402,7 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *ev)
#if (HAVE_KQUEUE) #if (HAVE_KQUEUE)
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (!ev->pending_eof) { if (!ev->pending_eof) {
return; return;
@ -1310,10 +1312,10 @@ static char *ngx_http_proxy_parse_upstream(ngx_str_t *url,
static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data)
{ {
#if __FreeBSD__
ssize_t *np = data; ssize_t *np = data;
#if (NGX_FREEBSD)
if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { if (*np >= ngx_freebsd_net_inet_tcp_sendspace) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"proxy_send_lowat\" must be less than %d " "\"proxy_send_lowat\" must be less than %d "
@ -1323,15 +1325,12 @@ static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data)
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
#elif !(HAVE_SO_SNDLOWAT)
#else
#if 0
ngx_conf_log_error(NGX_LOG_WARN, cf, 0, ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
"\"proxy_send_lowat\" is not supported, ignored"); "\"proxy_send_lowat\" is not supported, ignored");
*np = 0; *np = 0;
#endif
#endif #endif

View File

@ -130,6 +130,7 @@ typedef struct {
ngx_table_elt_t *connection; ngx_table_elt_t *connection;
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 *last_modified; ngx_table_elt_t *last_modified;
ngx_table_elt_t *location; ngx_table_elt_t *location;
ngx_table_elt_t *accept_ranges; ngx_table_elt_t *accept_ranges;

View File

@ -113,6 +113,11 @@ int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p,
continue; continue;
} }
if (&h[i] == headers_in->content_encoding) {
r->headers_out.content_encoding = ho;
continue;
}
if (&h[i] == headers_in->last_modified) { if (&h[i] == headers_in->last_modified) {
r->headers_out.last_modified = ho; r->headers_out.last_modified = ho;
/* TODO: update r->headers_out.last_modified_time */ /* TODO: update r->headers_out.last_modified_time */

View File

@ -692,12 +692,14 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
/* rc == NGX_OK */ /* rc == NGX_OK */
#if 1 /* test only, see below about "post aio operation" */ #if 0 /* test only, see below about "post aio operation" */
if (c->read->ready) { if (c->read->ready) {
/* post aio operation */ /* post aio operation */
ngx_http_proxy_process_upstream_status_line(c->read); ngx_http_proxy_process_upstream_status_line(c->read);
#if 0
return; return;
#endif
} }
#endif #endif
@ -718,7 +720,7 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p)
#if (HAVE_KQUEUE) #if (HAVE_KQUEUE)
if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT)
&& !p->request_sent && !p->request_sent
&& c->write->pending_eof) && c->write->pending_eof)
{ {
@ -776,7 +778,7 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p)
ngx_add_timer(c->read, p->lcf->read_timeout); ngx_add_timer(c->read, p->lcf->read_timeout);
#if 0 #if 1
if (c->read->ready) { if (c->read->ready) {
/* post aio operation */ /* post aio operation */

View File

@ -11,6 +11,14 @@
static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static ngx_int_t ngx_http_add_address(ngx_conf_t *cf,
ngx_http_in_port_t *in_port,
ngx_http_listen_t *lscf,
ngx_http_core_srv_conf_t *cscf);
static ngx_int_t ngx_http_add_names(ngx_conf_t *cf,
ngx_http_in_addr_t *in_addr,
ngx_http_core_srv_conf_t *cscf);
static char *ngx_http_merge_locations(ngx_conf_t *cf, static char *ngx_http_merge_locations(ngx_conf_t *cf,
ngx_array_t *locations, ngx_array_t *locations,
void **loc_conf, void **loc_conf,
@ -79,6 +87,11 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_iocp_conf_t *iocpcf; ngx_iocp_conf_t *iocpcf;
#endif #endif
#if (NGX_SUPPRESS_WARN)
/* MSVC thinks 'in_ports' may be used without having been initialized */
ngx_memzero(&in_ports, sizeof(ngx_array_t));
#endif
/* the main http context */ /* the main http context */
ngx_test_null(ctx, ngx_test_null(ctx,
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
@ -274,18 +287,23 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
/* /*
* create the lists of the ports, the addresses and the server names * create the lists of ports, addresses and server names
* to allow quickly find the server core module configuration at run-time * to quickly find the server core module configuration at run-time
*/ */
ngx_init_array(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_CONF_ERROR); == NGX_ERROR)
{
return NGX_CONF_ERROR;
}
/* "server" directives */ /* "server" directives */
cscfp = cmcf->servers.elts; cscfp = cmcf->servers.elts;
for (s = 0; s < cmcf->servers.nelts; s++) { for (s = 0; s < cmcf->servers.nelts; s++) {
/* "listen" directives */ /* "listen" directives */
lscf = cscfp[s]->listen.elts; lscf = cscfp[s]->listen.elts;
for (l = 0; l < cscfp[s]->listen.nelts; l++) { for (l = 0; l < cscfp[s]->listen.nelts; l++) {
@ -308,36 +326,24 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
if (lscf[l].addr == in_addr[a].addr) { if (lscf[l].addr == in_addr[a].addr) {
/* the address is already bound to this port */ /* the address is already in the address list */
/* "server_name" directives */ if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
s_name = cscfp[s]->server_names.elts; == NGX_ERROR)
for (n = 0; n < cscfp[s]->server_names.nelts; n++) { {
return NGX_CONF_ERROR;
/*
* add the server name and server core module
* configuration to the address:port
*/
/* TODO: duplicate names can be checked here */
ngx_test_null(name,
ngx_push_array(&in_addr[a].names),
NGX_CONF_ERROR);
name->name = s_name[n].name;
name->core_srv_conf = s_name[n].core_srv_conf;
} }
/* /*
* check duplicate "default" server that * check the duplicate "default" server
* serves this address:port * for this address:port
*/ */
if (lscf[l].default_server) { if (lscf[l].default_server) {
if (in_addr[a].default_server) { if (in_addr[a].default_server) {
ngx_log_error(NGX_LOG_ERR, cf->log, 0, ngx_log_error(NGX_LOG_ERR, cf->log, 0,
"duplicate default server in %s:%d", "the duplicate default server in %s:%d",
lscf[l].file_name.data, lscf[l].file_name.data,
lscf[l].line); lscf[l].line);
@ -354,31 +360,31 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
} else if (in_addr[a].addr == INADDR_ANY) { } else if (in_addr[a].addr == INADDR_ANY) {
/* /* the INADDR_ANY is always the last address */
* "*:port" must be the last resort so move it
* to the end of the address list and add
* the new address at its place
*/
ngx_test_null(inaddr, if (!(inaddr = ngx_array_push(&in_port[p].addrs))) {
ngx_push_array(&in_port[p].addrs), return NGX_CONF_ERROR;
NGX_CONF_ERROR); }
/*
* the INADDR_ANY must be the last resort
* so we move it to the end of the address list
* and put the new address in its place
*/
ngx_memcpy(inaddr, &in_addr[a], ngx_memcpy(inaddr, &in_addr[a],
sizeof(ngx_http_in_addr_t)); sizeof(ngx_http_in_addr_t));
in_addr[a].addr = lscf[l].addr; in_addr[a].addr = lscf[l].addr;
in_addr[a].names.elts = NULL;
in_addr[a].default_server = lscf[l].default_server; in_addr[a].default_server = lscf[l].default_server;
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])
* create the empty list of the server names that == NGX_ERROR)
* can be served on this address:port {
*/ return NGX_CONF_ERROR;
}
ngx_init_array(inaddr->names, cf->pool, 10,
sizeof(ngx_http_server_name_t),
NGX_CONF_ERROR);
addr_found = 1; addr_found = 1;
@ -393,22 +399,11 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
* bound to this port * bound to this port
*/ */
ngx_test_null(inaddr, if (ngx_http_add_address(cf, &in_port[p], &lscf[l],
ngx_push_array(&in_port[p].addrs), cscfp[s]) == NGX_ERROR)
NGX_CONF_ERROR); {
return NGX_CONF_ERROR;
inaddr->addr = lscf[l].addr; }
inaddr->default_server = lscf[l].default_server;
inaddr->core_srv_conf = cscfp[s];
/*
* create the empty list of the server names that
* can be served on this address:port
*/
ngx_init_array(inaddr->names, cf->pool, 10,
sizeof(ngx_http_server_name_t),
NGX_CONF_ERROR);
} }
} }
} }
@ -417,54 +412,42 @@ static char *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 */
ngx_test_null(in_port, if (!(in_port = ngx_array_push(&in_ports))) {
ngx_push_array(&in_ports), return NGX_CONF_ERROR;
NGX_CONF_ERROR); }
in_port->port = lscf[l].port; in_port->port = lscf[l].port;
in_port->addrs.elts = NULL;
ngx_test_null(in_port->port_text.data, ngx_palloc(cf->pool, 7), if (!(in_port->port_text.data = ngx_palloc(cf->pool, 7))) {
NGX_CONF_ERROR); return NGX_CONF_ERROR;
in_port->port_text.len = ngx_snprintf((char *) }
in_port->port_text.data,
7, ":%d",
in_port->port);
/* create list of the addresses that bound to this port ... */ in_port->port_text.len = ngx_sprintf(in_port->port_text.data,
":%d", in_port->port)
- in_port->port_text.data;
ngx_init_array(in_port->addrs, cf->pool, 10, if (ngx_http_add_address(cf, in_port, &lscf[l], cscfp[s])
sizeof(ngx_http_in_addr_t), == NGX_ERROR)
NGX_CONF_ERROR); {
return NGX_CONF_ERROR;
ngx_test_null(inaddr, ngx_push_array(&in_port->addrs), }
NGX_CONF_ERROR);
/* ... and add the address to this list */
inaddr->addr = lscf[l].addr;
inaddr->default_server = lscf[l].default_server;
inaddr->core_srv_conf = cscfp[s];
/*
* create the empty list of the server names that
* can be served on this address:port
*/
ngx_init_array(inaddr->names, cf->pool, 10,
sizeof(ngx_http_server_name_t),
NGX_CONF_ERROR);
} }
} }
} }
/* optimize the lists of the ports, the addresses and the server names */
/* optimize the lists of ports, addresses and server names */
/* AF_INET only */ /* AF_INET only */
in_port = in_ports.elts; in_port = in_ports.elts;
for (p = 0; p < in_ports.nelts; p++) { for (p = 0; p < in_ports.nelts; p++) {
/* check whether the all server names point to the same server */ /*
* check whether all name-based servers have the same configuraiton
* as the default server, or some servers restrict the host names
*/
in_addr = in_port[p].addrs.elts; in_addr = in_port[p].addrs.elts;
for (a = 0; a < in_port[p].addrs.nelts; a++) { for (a = 0; a < in_port[p].addrs.nelts; a++) {
@ -473,15 +456,19 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
name = in_addr[a].names.elts; name = in_addr[a].names.elts;
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
!= NGX_HTTP_RESTRICT_HOST_OFF)
{
virtual_names = 1; virtual_names = 1;
break; break;
} }
} }
/* /*
* if the all server names point to the same server * if all name-based servers have the same configuration
* then we do not need to check them at run-time * as the default server, and no servers restrict the host names
* then we do not need to check them at run-time at all
*/ */
if (!virtual_names) { if (!virtual_names) {
@ -588,30 +575,117 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
} }
#if (NGX_DEBUG) #if (NGX_DEBUG)
{
u_char address[20];
ngx_uint_t p, a, n;
in_port = in_ports.elts; in_port = in_ports.elts;
for (p = 0; p < in_ports.nelts; p++) { for (p = 0; p < in_ports.nelts; p++) {
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
"port: %d %08x", in_port[p].port, &in_port[p]); "port: %d %08x", in_port[p].port, &in_port[p]);
in_addr = in_port[p].addrs.elts; in_addr = in_port[p].addrs.elts;
for (a = 0; a < in_port[p].addrs.nelts; a++) { for (a = 0; a < in_port[p].addrs.nelts; a++) {
u_char ip[20]; ngx_inet_ntop(AF_INET, &in_addr[a].addr, address, 20);
ngx_inet_ntop(AF_INET, &in_addr[a].addr, ip, 20); ngx_log_debug3(NGX_LOG_DEBUG_HTTP, cf->log, 0,
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, "%s:%d %08x",
"%s %08x", ip, in_addr[a].core_srv_conf); address, in_port[p].port, in_addr[a].core_srv_conf);
s_name = in_addr[a].names.elts; s_name = in_addr[a].names.elts;
for (n = 0; n < in_addr[a].names.nelts; n++) { for (n = 0; n < in_addr[a].names.nelts; n++) {
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, ngx_log_debug4(NGX_LOG_DEBUG_HTTP, cf->log, 0,
"%s %08x", s_name[n].name.data, "%s:%d %s %08x",
address, in_port[p].port, s_name[n].name.data,
s_name[n].core_srv_conf); s_name[n].core_srv_conf);
} }
} }
} }
}
#endif #endif
return NGX_CONF_OK; return NGX_CONF_OK;
} }
/*
* add the server address, the server names and the server core module
* configurations to the port (in_port)
*/
static ngx_int_t ngx_http_add_address(ngx_conf_t *cf,
ngx_http_in_port_t *in_port,
ngx_http_listen_t *lscf,
ngx_http_core_srv_conf_t *cscf)
{
ngx_http_in_addr_t *in_addr;
if (in_port->addrs.elts == NULL) {
if (ngx_array_init(&in_port->addrs, cf->pool, 10,
sizeof(ngx_http_in_addr_t)) == NGX_ERROR)
{
return NGX_ERROR;
}
}
if (!(in_addr = ngx_array_push(&in_port->addrs))) {
return NGX_ERROR;
}
in_addr->addr = lscf->addr;
in_addr->names.elts = NULL;
in_addr->default_server = lscf->default_server;
in_addr->core_srv_conf = cscf;
#if (NGX_DEBUG)
{
u_char text[20];
ngx_inet_ntop(AF_INET, &in_addr->addr, text, 20);
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, "address: %s:%d",
text, in_port->port);
}
#endif
return ngx_http_add_names(cf, in_addr, cscf);
}
/*
* add the server names and the server core module
* configurations to the address:port (in_addr)
*/
static ngx_int_t ngx_http_add_names(ngx_conf_t *cf,
ngx_http_in_addr_t *in_addr,
ngx_http_core_srv_conf_t *cscf)
{
ngx_uint_t i;
ngx_http_server_name_t *server_names, *name;
if (in_addr->names.elts == NULL) {
if (ngx_array_init(&in_addr->names, cf->pool, 10,
sizeof(ngx_http_server_name_t)) == NGX_ERROR)
{
return NGX_ERROR;
}
}
server_names = cscf->server_names.elts;
for (i = 0; i < cscf->server_names.nelts; i++) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0,
"name: %s", server_names[i].name.data);
/* TODO: duplicate names can be checked here */
if (!(name = ngx_array_push(&in_addr->names))) {
return NGX_ERROR;
}
*name = server_names[i];
}
return NGX_OK;
}
static char *ngx_http_merge_locations(ngx_conf_t *cf, static char *ngx_http_merge_locations(ngx_conf_t *cf,
ngx_array_t *locations, ngx_array_t *locations,
void **loc_conf, void **loc_conf,

View File

@ -36,7 +36,7 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd,
void *dummy); void *dummy);
static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf); static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_http_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf); void *conf);
static char *ngx_set_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_set_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@ -126,9 +126,9 @@ static ngx_command_t ngx_http_core_commands[] = {
#if 0 #if 0
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
#else #else
NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, NGX_HTTP_SRV_CONF|NGX_CONF_TAKE12,
#endif #endif
ngx_set_listen, ngx_http_listen,
NGX_HTTP_SRV_CONF_OFFSET, NGX_HTTP_SRV_CONF_OFFSET,
0, 0,
NULL }, NULL },
@ -576,7 +576,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
clcfp = locations->elts; clcfp = locations->elts;
for (i = 0; i < locations->nelts; i++) { for (i = 0; i < locations->nelts; i++) {
#if (HAVE_PCRE) #if (NGX_PCRE)
if (clcfp[i]->regex) { if (clcfp[i]->regex) {
break; break;
} }
@ -638,7 +638,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
} }
} }
#if (HAVE_PCRE) #if (NGX_PCRE)
/* regex matches */ /* regex matches */
@ -673,7 +673,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
return NGX_HTTP_LOCATION_REGEX; return NGX_HTTP_LOCATION_REGEX;
} }
#endif /* HAVE_PCRE */ #endif /* NGX_PCRE */
return NGX_OK; return NGX_OK;
} }
@ -991,7 +991,7 @@ static int ngx_cmp_locations(const void *one, const void *two)
first = *(ngx_http_core_loc_conf_t **) one; first = *(ngx_http_core_loc_conf_t **) one;
second = *(ngx_http_core_loc_conf_t **) two; second = *(ngx_http_core_loc_conf_t **) two;
#if (HAVE_PCRE) #if (NGX_PCRE)
if (first->regex && !second->regex) { if (first->regex && !second->regex) {
/* shift the regex matches to the end */ /* shift the regex matches to the end */
@ -1026,7 +1026,7 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
ngx_http_conf_ctx_t *ctx, *pctx; ngx_http_conf_ctx_t *ctx, *pctx;
ngx_http_core_srv_conf_t *cscf; ngx_http_core_srv_conf_t *cscf;
ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp; ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp;
#if (HAVE_PCRE) #if (NGX_PCRE)
ngx_str_t err; ngx_str_t err;
u_char errstr[NGX_MAX_CONF_ERRSTR]; u_char errstr[NGX_MAX_CONF_ERRSTR];
#endif #endif
@ -1076,7 +1076,7 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
&& value[1].data[0] == '~' && value[1].data[0] == '~'
&& value[1].data[1] == '*')) && value[1].data[1] == '*'))
{ {
#if (HAVE_PCRE) #if (NGX_PCRE)
err.len = NGX_MAX_CONF_ERRSTR; err.len = NGX_MAX_CONF_ERRSTR;
err.data = errstr; err.data = errstr;
@ -1129,7 +1129,7 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
#if (HAVE_PCRE) #if (NGX_PCRE)
if (clcf->regex == NULL if (clcf->regex == NULL
&& ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len) && ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len)
!= 0) != 0)
@ -1323,12 +1323,8 @@ static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf,
n->name.len = ngx_strlen(n->name.data); n->name.len = ngx_strlen(n->name.data);
n->core_srv_conf = conf; n->core_srv_conf = conf;
n->wildcard = 0;
#if 0
ctx = (ngx_http_conf_ctx_t *)
cf->cycle->conf_ctx[ngx_http_module.index];
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
#endif
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->max_server_name_len < n->name.len) { if (cmcf->max_server_name_len < n->name.len) {
@ -1512,7 +1508,7 @@ static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
} }
static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) static char *ngx_http_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{ {
ngx_http_core_srv_conf_t *scf = conf; ngx_http_core_srv_conf_t *scf = conf;
@ -1607,13 +1603,8 @@ static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_http_server_name_t *sn; ngx_http_server_name_t *sn;
ngx_http_core_main_conf_t *cmcf; ngx_http_core_main_conf_t *cmcf;
/* TODO: several names */
/* TODO: warn about duplicate 'server_name' directives */ /* TODO: warn about duplicate 'server_name' directives */
#if 0
ctx = (ngx_http_conf_ctx_t *) cf->cycle->conf_ctx[ngx_http_module.index];
cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
#endif
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);
value = cf->args->elts; value = cf->args->elts;
@ -1627,12 +1618,23 @@ static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR); if (!(sn = ngx_array_push(&scf->server_names))) {
return NGX_CONF_ERROR;
}
sn->name.len = value[i].len; sn->name.len = value[i].len;
sn->name.data = value[i].data; sn->name.data = value[i].data;
sn->core_srv_conf = scf; sn->core_srv_conf = scf;
if (sn->name.data[0] == '*') {
sn->name.len--;
sn->name.data++;
sn->wildcard = 1;
} else {
sn->wildcard = 0;
}
if (cmcf->max_server_name_len < sn->name.len) { if (cmcf->max_server_name_len < sn->name.len) {
cmcf->max_server_name_len = sn->name.len; cmcf->max_server_name_len = sn->name.len;
} }
@ -1806,7 +1808,7 @@ static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data)
{ {
ssize_t *np = data; ssize_t *np = data;
#if __FreeBSD__ #if (NGX_FREEBSD)
if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { if (*np >= ngx_freebsd_net_inet_tcp_sendspace) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,

View File

@ -96,13 +96,15 @@ typedef struct {
ngx_http_core_srv_conf_t *core_srv_conf; /* default server conf ngx_http_core_srv_conf_t *core_srv_conf; /* default server conf
for this address:port */ for this address:port */
unsigned default_server:1; ngx_uint_t default_server; /* unsigned default_server:1; */
} ngx_http_in_addr_t; } ngx_http_in_addr_t;
typedef struct { typedef struct {
ngx_str_t name; ngx_str_t name;
ngx_http_core_srv_conf_t *core_srv_conf; /* virtual name server conf */ ngx_http_core_srv_conf_t *core_srv_conf; /* virtual name server conf */
ngx_uint_t wildcard; /*unsigned wildcard:1; */
} ngx_http_server_name_t; } ngx_http_server_name_t;
@ -135,7 +137,7 @@ typedef struct ngx_http_core_loc_conf_s ngx_http_core_loc_conf_t;
struct ngx_http_core_loc_conf_s { struct ngx_http_core_loc_conf_s {
ngx_str_t name; /* location name */ ngx_str_t name; /* location name */
#if (HAVE_PCRE) #if (NGX_PCRE)
ngx_regex_t *regex; ngx_regex_t *regex;
#endif #endif

View File

@ -317,10 +317,15 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
if (r->headers_out.content_length == NULL) { if (r->headers_out.content_length == NULL) {
if (r->headers_out.content_length_n >= 0) { if (r->headers_out.content_length_n >= 0) {
b->last = ngx_sprintf(b->last, "Content-Length: %O" CRLF,
r->headers_out.content_length_n);
#if 0
b->last += ngx_snprintf((char *) b->last, b->last += ngx_snprintf((char *) b->last,
sizeof("Content-Length: ") + NGX_OFF_T_LEN + 2, sizeof("Content-Length: ") + NGX_OFF_T_LEN + 2,
"Content-Length: " OFF_T_FMT CRLF, "Content-Length: " OFF_T_FMT CRLF,
r->headers_out.content_length_n); r->headers_out.content_length_n);
#endif
} }
} }
@ -372,7 +377,7 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
{ {
b->last = ngx_cpymem(b->last, "Last-Modified: ", b->last = ngx_cpymem(b->last, "Last-Modified: ",
sizeof("Last-Modified: ") - 1); sizeof("Last-Modified: ") - 1);
b->last += ngx_http_time(b->last, r->headers_out.last_modified_time); b->last = ngx_http_time(b->last, r->headers_out.last_modified_time);
*(b->last++) = CR; *(b->last++) = LF; *(b->last++) = CR; *(b->last++) = LF;
} }
@ -389,10 +394,14 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
if (clcf->keepalive_header if (clcf->keepalive_header
&& (r->headers_in.gecko || r->headers_in.konqueror)) && (r->headers_in.gecko || r->headers_in.konqueror))
{ {
b->last = ngx_sprintf(b->last, "Keep-Alive: timeout=%T" CRLF,
clcf->keepalive_header);
#if 0
b->last += ngx_snprintf((char *) b->last, b->last += ngx_snprintf((char *) b->last,
sizeof("Keep-Alive: timeout=") + TIME_T_LEN + 2, sizeof("Keep-Alive: timeout=") + TIME_T_LEN + 2,
"Keep-Alive: timeout=" TIME_T_FMT CRLF, "Keep-Alive: timeout=" TIME_T_FMT CRLF,
clcf->keepalive_header); clcf->keepalive_header);
#endif
} }
} else { } else {

View File

@ -210,9 +210,13 @@ static u_char *ngx_http_log_addr(ngx_http_request_t *r, u_char *buf,
static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf,
uintptr_t data) uintptr_t data)
{ {
return ngx_sprintf(buf, "%ui", r->connection->number);
#if 0
return buf + ngx_snprintf((char *) buf, NGX_INT_T_LEN + 1, return buf + ngx_snprintf((char *) buf, NGX_INT_T_LEN + 1,
"%" NGX_UINT_T_FMT, "%" NGX_UINT_T_FMT,
r->connection->number); r->connection->number);
#endif
} }
@ -244,8 +248,12 @@ static u_char *ngx_http_log_msec(ngx_http_request_t *r, u_char *buf,
ngx_gettimeofday(&tv); ngx_gettimeofday(&tv);
return ngx_sprintf(buf, "%l.%03l", tv.tv_sec, tv.tv_usec / 1000);
#if 0
return buf + ngx_snprintf((char *) buf, TIME_T_LEN + 5, "%ld.%03ld", return buf + ngx_snprintf((char *) buf, TIME_T_LEN + 5, "%ld.%03ld",
tv.tv_sec, tv.tv_usec / 1000); tv.tv_sec, tv.tv_usec / 1000);
#endif
} }
@ -264,24 +272,36 @@ static u_char *ngx_http_log_request(ngx_http_request_t *r, u_char *buf,
static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf, static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf,
uintptr_t data) uintptr_t data)
{ {
return ngx_sprintf(buf, "%ui",
r->err_status ? r->err_status : r->headers_out.status);
#if 0
return buf + ngx_snprintf((char *) buf, 4, "%" NGX_UINT_T_FMT, return buf + ngx_snprintf((char *) buf, 4, "%" NGX_UINT_T_FMT,
r->err_status ? r->err_status : r->headers_out.status); r->err_status ? r->err_status : r->headers_out.status);
#endif
} }
static u_char *ngx_http_log_length(ngx_http_request_t *r, u_char *buf, static u_char *ngx_http_log_length(ngx_http_request_t *r, u_char *buf,
uintptr_t data) uintptr_t data)
{ {
return ngx_sprintf(buf, "%O", r->connection->sent);
#if 0
return buf + ngx_snprintf((char *) buf, NGX_OFF_T_LEN + 1, OFF_T_FMT, return buf + ngx_snprintf((char *) buf, NGX_OFF_T_LEN + 1, OFF_T_FMT,
r->connection->sent); r->connection->sent);
#endif
} }
static u_char *ngx_http_log_apache_length(ngx_http_request_t *r, u_char *buf, static u_char *ngx_http_log_apache_length(ngx_http_request_t *r, u_char *buf,
uintptr_t data) uintptr_t data)
{ {
return ngx_sprintf(buf, "%O", r->connection->sent - r->header_size);
#if 0
return buf + ngx_snprintf((char *) buf, NGX_OFF_T_LEN + 1, OFF_T_FMT, return buf + ngx_snprintf((char *) buf, NGX_OFF_T_LEN + 1, OFF_T_FMT,
r->connection->sent - r->header_size); r->connection->sent - r->header_size);
#endif
} }
@ -467,8 +487,7 @@ static u_char *ngx_http_log_header_out(ngx_http_request_t *r, u_char *buf,
return (u_char *) return (u_char *)
sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1; sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1;
} }
return buf + ngx_http_time(buf, return ngx_http_time(buf, r->headers_out.last_modified_time);
r->headers_out.last_modified_time);
} }
if (buf) { if (buf) {

View File

@ -1091,28 +1091,48 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
name = r->virtual_names->elts; name = r->virtual_names->elts;
for (i = 0; i < r->virtual_names->nelts; i++) { for (i = 0; i < r->virtual_names->nelts; i++) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"server name: %s", name[i].name.data);
if (name[i].wildcard) {
if (r->headers_in.host_name_len <= name[i].name.len) {
continue;
}
if (ngx_rstrncasecmp(r->headers_in.host->value.data,
name[i].name.data,
name[i].name.len) == 0)
{
continue;
}
} else {
if (r->headers_in.host_name_len != name[i].name.len) { if (r->headers_in.host_name_len != name[i].name.len) {
continue; continue;
} }
if (ngx_strncasecmp(r->headers_in.host->value.data, if (ngx_strncasecmp(r->headers_in.host->value.data,
name[i].name.data, name[i].name.data,
r->headers_in.host_name_len) == 0) name[i].name.len) != 0)
{ {
continue;
}
}
r->srv_conf = name[i].core_srv_conf->ctx->srv_conf; r->srv_conf = name[i].core_srv_conf->ctx->srv_conf;
r->loc_conf = name[i].core_srv_conf->ctx->loc_conf; r->loc_conf = name[i].core_srv_conf->ctx->loc_conf;
r->server_name = &name[i].name; r->server_name = &name[i].name;
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
r->connection->log->file = clcf->err_log->file; r->connection->log->file = clcf->err_log->file;
if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION))
{ if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
r->connection->log->log_level = clcf->err_log->log_level; r->connection->log->log_level = clcf->err_log->log_level;
} }
break; break;
} }
}
if (i == r->virtual_names->nelts) { if (i == r->virtual_names->nelts) {
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
@ -1562,7 +1582,13 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
if (b != c->buffer) { if (b != c->buffer) {
/* move the large header buffers to the free list */ /*
* If the large header buffers were allocated while the previous
* request processing then we do not use c->buffer for
* the pipelined request (see ngx_http_init_request()).
*
* Now we would move the large header buffers to the free list.
*/
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
@ -1614,6 +1640,14 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
hc->pipeline = 0; hc->pipeline = 0;
/*
* To keep a memory footprint as small as possible for an idle
* keepalive connection we try to free the ngx_http_request_t and
* c->buffer's memory if they were allocated outside the c->pool.
* The large header buffers are always allocated outside the c->pool and
* are freed too.
*/
if (ngx_pfree(c->pool, r) == NGX_OK) { if (ngx_pfree(c->pool, r) == NGX_OK) {
hc->request = NULL; hc->request = NULL;
} }
@ -1621,6 +1655,12 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
b = c->buffer; b = c->buffer;
if (ngx_pfree(c->pool, b->start) == NGX_OK) { if (ngx_pfree(c->pool, b->start) == NGX_OK) {
/*
* the special note for ngx_http_keepalive_handler() that
* c->buffer's memory was freed
*/
b->pos = NULL; b->pos = NULL;
} else { } else {
@ -1655,7 +1695,7 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
rev->event_handler = ngx_http_keepalive_handler; rev->event_handler = ngx_http_keepalive_handler;
if (wev->active) { if (wev->active) {
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT) if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
== NGX_ERROR) == NGX_ERROR)
{ {
@ -1702,7 +1742,7 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
} }
#if 0 #if 0
/* if "keepalive_buffers off" then we need some other place */ /* if ngx_http_request_t was freed then we need some other place */
r->http_state = NGX_HTTP_KEEPALIVE_STATE; r->http_state = NGX_HTTP_KEEPALIVE_STATE;
#endif #endif
@ -1734,7 +1774,7 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
#if (HAVE_KQUEUE) #if (HAVE_KQUEUE)
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (rev->pending_eof) { if (rev->pending_eof) {
ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno, ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
"kevent() reported that client %s closed " "kevent() reported that client %s closed "
@ -1751,6 +1791,13 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
size = b->end - b->start; size = b->end - b->start;
if (b->pos == NULL) { if (b->pos == NULL) {
/*
* The c->buffer's memory was freed by ngx_http_set_keepalive().
* However, the c->buffer->start and c->buffer->end were not changed
* to keep the buffer size.
*/
if (!(b->pos = ngx_palloc(c->pool, size))) { if (!(b->pos = ngx_palloc(c->pool, size))) {
ngx_http_close_connection(c); ngx_http_close_connection(c);
return; return;
@ -1824,7 +1871,7 @@ static void ngx_http_set_lingering_close(ngx_http_request_t *r)
wev->event_handler = ngx_http_empty_handler; wev->event_handler = ngx_http_empty_handler;
if (wev->active) { if (wev->active) {
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT) if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
== NGX_ERROR) == NGX_ERROR)
{ {

View File

@ -38,11 +38,11 @@
#define NGX_HTTP_PARSE_HEADER_ERROR 14 #define NGX_HTTP_PARSE_HEADER_ERROR 14
#define NGX_HTTP_PARSE_INVALID_HEADER 14 #define NGX_HTTP_PARSE_INVALID_HEADER 14
#define NGX_HTTP_PARSE_TOO_LONG_HEADER 15 #define NGX_HTTP_PARSE_TOO_LONG_HEADER 15
#define NGX_HTTP_PARSE_NO_HOST_HEADER 17 #define NGX_HTTP_PARSE_NO_HOST_HEADER 16
#define NGX_HTTP_PARSE_INVALID_CL_HEADER 18 #define NGX_HTTP_PARSE_INVALID_CL_HEADER 17
#define NGX_HTTP_PARSE_POST_WO_CL_HEADER 19 #define NGX_HTTP_PARSE_POST_WO_CL_HEADER 18
#define NGX_HTTP_PARSE_HTTP_TO_HTTPS 20 #define NGX_HTTP_PARSE_HTTP_TO_HTTPS 19
#define NGX_HTTP_PARSE_INVALID_HOST 21 #define NGX_HTTP_PARSE_INVALID_HOST 20
#define NGX_HTTP_OK 200 #define NGX_HTTP_OK 200

View File

@ -125,6 +125,7 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
if (!last) { if (!last) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"the http output chain is empty"); "the http output chain is empty");
return NGX_ERROR;
} }
return NGX_OK; return NGX_OK;
} }

View File

@ -210,59 +210,3 @@ int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
return NGX_OK; return NGX_OK;
} }
#if 0
ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset)
{
if (!file->read->ready) {
ngx_memzero(&file->iocb, sizeof(iocb));
file->iocb.aio_fildes = file->fd;
file->iocb.aio_buf = buf;
file->iocb.aio_nbytes = size;
file->iocb.aio_offset = offset;
#if (USE_AIO_KQUEUE)
file->iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
file->iocb.aio_sigevent.sigev_notify_kqueue = tid->kq;
file->iocb.aio_sigevent.sigev_value = (union sigval) file;
#endif
#if (USE_AIO_SIGNAL)
file->iocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
file->iocb.aio_sigevent.sigev_signo = NGX_SIGAIO;
#ifndef __FreeBSD__
file->iocb.aio_sigevent.sigev_value.sival_ptr = file;
#endif
#endif
if (aio_read(&file->iocb) == -1) {
ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
"aio_read() failed");
return NGX_ERROR;
n = aio_error(&file->iocb);
if (n == EINPROGRESS)
return NGX_AGAIN;
if (n == -1) {
ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
"aio_read() failed");
return NGX_ERROR;
}
}
ngx_assert(file->iocb.aio_buf == buf), return NGX_ERROR,
"ngx_aio_read_file: another buffer is passed");
n = aio_return(&file->iocb);
if (n == -1) {
ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
"aio_read() failed");
return NGX_ERROR;
}
return n;
}
#endif

View File

@ -99,7 +99,7 @@ int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
#define ngx_de_name(dir) (dir)->de->d_name #define ngx_de_name(dir) (dir)->de->d_name
#ifdef __FreeBSD__ #if (NGX_FREEBSD)
#define ngx_de_namelen(dir) (dir)->de->d_namlen #define ngx_de_namelen(dir) (dir)->de->d_namlen
#else #else
#define ngx_de_namelen(dir) ngx_strlen((dir)->de->d_name) #define ngx_de_namelen(dir) ngx_strlen((dir)->de->d_name)

View File

@ -22,8 +22,8 @@
#include <grp.h> #include <grp.h>
#include <dirent.h> #include <dirent.h>
#include <sys/uio.h>
#include <sys/filio.h> /* FIONBIO */ #include <sys/filio.h> /* FIONBIO */
#include <sys/uio.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
@ -41,12 +41,11 @@
#include <libutil.h> /* setproctitle() before 4.1 */ #include <libutil.h> /* setproctitle() before 4.1 */
#include <osreldate.h> #include <osreldate.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <sys/param.h> /* ALIGN() */
#if __FreeBSD_version < 400017 #if __FreeBSD_version < 400017
#include <sys/param.h> /* ALIGN() */
/* FreeBSD 3.x has no CMSG_SPACE() at all and has the broken CMSG_DATA() */ /* FreeBSD 3.x has no CMSG_SPACE() at all and has the broken CMSG_DATA() */
#undef CMSG_SPACE #undef CMSG_SPACE

View File

@ -57,7 +57,7 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
#if (HAVE_KQUEUE) #if (HAVE_KQUEUE)
if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && wev->pending_eof) { if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno, ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
"kevent() reported about an closed connection"); "kevent() reported about an closed connection");
@ -131,7 +131,6 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
send += size; send += size;
} }
/* get the file buf */
if (cl && cl->buf->in_file && send < limit) { if (cl && cl->buf->in_file && send < limit) {
file = cl->buf; file = cl->buf;
@ -164,17 +163,18 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
&& fprev == cl->buf->file_pos); && fprev == cl->buf->file_pos);
} }
if (file) { if (file) {
/* create the tailer iovec and coalesce the neighbouring bufs */ /* create the tailer iovec and coalesce the neighbouring bufs */
prev = NULL; prev = NULL;
iov = NULL; iov = NULL;
for (/* void */; while (cl && header.nelts < IOV_MAX && send < limit) {
cl && header.nelts < IOV_MAX && send < limit;
cl = cl->next)
{
if (ngx_buf_special(cl->buf)) { if (ngx_buf_special(cl->buf)) {
cl = cl->next;
continue; continue;
} }
@ -202,6 +202,7 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
prev = cl->buf->pos + size; prev = cl->buf->pos + size;
send += size; send += size;
cl = cl->next;
} }
} }
@ -210,7 +211,6 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
if (ngx_freebsd_use_tcp_nopush if (ngx_freebsd_use_tcp_nopush
&& c->tcp_nopush == NGX_TCP_NOPUSH_UNSET) && c->tcp_nopush == NGX_TCP_NOPUSH_UNSET)
{ {
if (ngx_tcp_nopush(c->fd) == NGX_ERROR) { if (ngx_tcp_nopush(c->fd) == NGX_ERROR) {
err = ngx_errno; err = ngx_errno;
@ -275,6 +275,20 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
} }
} }
if (rc == 0 && sent == 0) {
/*
* rc and sent are equals to zero when someone has truncated
* the file, so the offset became beyond the end of the file
*/
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
"sendfile() reported that \"%s\" was truncated",
file->file->name.data);
return NGX_CHAIN_ERROR;
}
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
"sendfile: %d, @" OFF_T_FMT " " OFF_T_FMT ":%d", "sendfile: %d, @" OFF_T_FMT " " OFF_T_FMT ":%d",
rc, file->file_pos, sent, fsize + hsize); rc, file->file_pos, sent, fsize + hsize);

View File

@ -8,11 +8,11 @@
#define _NGX_LINUX_CONFIG_H_INCLUDED_ #define _NGX_LINUX_CONFIG_H_INCLUDED_
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* pread(), pwrite(), gethostname() */ #define _GNU_SOURCE /* pread(), pwrite(), gethostname() */
#endif
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#define _LARGEFILE_SOURCE
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
@ -51,11 +51,11 @@
#include <ngx_auto_config.h> #include <ngx_auto_config.h>
#if (HAVE_PRCTL) #if (NGX_HAVE_SYS_PRCTL_H)
#include <sys/prctl.h> #include <sys/prctl.h>
#endif #endif
#if (HAVE_SENDFILE64) #if (NGX_HAVE_SENDFILE64)
#include <sys/sendfile.h> #include <sys/sendfile.h>
#else #else
extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size); extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);

View File

@ -37,7 +37,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
ngx_event_t *wev; ngx_event_t *wev;
ngx_chain_t *cl; ngx_chain_t *cl;
struct iovec *iov, headers[NGX_HEADERS]; struct iovec *iov, headers[NGX_HEADERS];
#if (HAVE_SENDFILE64) #if (NGX_HAVE_SENDFILE64)
off_t offset; off_t offset;
#else #else
int32_t offset; int32_t offset;
@ -167,7 +167,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
} }
if (file) { if (file) {
#if (HAVE_SENDFILE64) #if (NGX_HAVE_SENDFILE64)
offset = file->file_pos; offset = file->file_pos;
#else #else
offset = (int32_t) file->file_pos; offset = (int32_t) file->file_pos;

View File

@ -66,17 +66,15 @@ extern ngx_int_t ngx_inherited_nonblocking;
#define ngx_stderr_fileno STDERR_FILENO #define ngx_stderr_fileno STDERR_FILENO
#ifdef __FreeBSD__ #if (NGX_FREEBSD)
#include <ngx_freebsd.h> #include <ngx_freebsd.h>
#endif
#ifdef __linux__ #elif (NGX_LINUX)
#include <ngx_linux.h> #include <ngx_linux.h>
#endif
#ifdef SOLARIS #elif (NGX_SOLARIS)
#include <ngx_solaris.h> #include <ngx_solaris.h>
#endif #endif

View File

@ -8,9 +8,20 @@
#define _NGX_POSIX_CONFIG_H_INCLUDED_ #define _NGX_POSIX_CONFIG_H_INCLUDED_
#if 0
#define _XOPEN_SOURCE
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#if (NGX_HAVE_UNISTD_H)
#include <unistd.h> #include <unistd.h>
#endif
#if (NGX_HAVE_INTTYPES_H)
#include <inttypes.h>
#endif
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> /* offsetof() */ #include <stddef.h> /* offsetof() */
#include <stdio.h> #include <stdio.h>
@ -22,8 +33,12 @@
#include <grp.h> #include <grp.h>
#include <dirent.h> #include <dirent.h>
#include <sys/uio.h> #if (NGX_HAVE_SYS_FILIO_H)
#include <sys/filio.h> /* FIONBIO */ #include <sys/filio.h> /* FIONBIO */
#endif
#include <sys/ioctl.h> /* FIONBIO */
#include <sys/uio.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
@ -34,9 +49,19 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> /* TCP_NODELAY */
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#if (NGX_HAVE_LIMITS_H)
#include <limits.h> /* IOV_MAX */
#endif
#ifndef IOV_MAX
#define IOV_MAX 16
#endif
#include <ngx_auto_config.h> #include <ngx_auto_config.h>
@ -53,6 +78,32 @@
#endif #endif
#if (HAVE_KQUEUE)
#include <sys/event.h>
#endif
#if (HAVE_DEVPOLL)
#include <sys/ioctl.h>
#include <sys/devpoll.h>
#endif
#if (__FreeBSD__) && (__FreeBSD_version < 400017)
#include <sys/param.h> /* ALIGN() */
/* FreeBSD 3.x has no CMSG_SPACE() at all and has the broken CMSG_DATA() */
#undef CMSG_SPACE
#define CMSG_SPACE(l) (ALIGN(sizeof(struct cmsghdr)) + ALIGN(l))
#undef CMSG_DATA
#define CMSG_DATA(cmsg) ((u_char *)(cmsg) + ALIGN(sizeof(struct cmsghdr)))
#endif
#define ngx_setproctitle(title) #define ngx_setproctitle(title)

View File

@ -33,6 +33,12 @@ int ngx_os_init(ngx_log_t *log)
} }
void ngx_os_status(ngx_log_t *log)
{
ngx_posix_status(log);
}
#endif #endif

View File

@ -236,7 +236,7 @@ void ngx_process_get_status()
return; return;
} }
#if (SOLARIS) #if (NGX_SOLARIS)
/* /*
* Solaris always calls the signal handler for each exited process * Solaris always calls the signal handler for each exited process

View File

@ -54,7 +54,13 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx); ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
void ngx_process_get_status(void); void ngx_process_get_status(void);
#if (NGX_HAVE_SCHED_YIELD)
#define ngx_sched_yield() sched_yield() #define ngx_sched_yield() sched_yield()
#else
#define ngx_sched_yield() usleep(1)
#endif
extern int ngx_argc; extern int ngx_argc;
extern char **ngx_argv; extern char **ngx_argv;

View File

@ -175,12 +175,15 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle)
if (ngx_timer) { if (ngx_timer) {
ngx_timer = 0; ngx_timer = 0;
if (!ngx_noaccepting) {
ngx_start_worker_processes(cycle, ccf->worker_processes, ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_JUST_RESPAWN); NGX_PROCESS_JUST_RESPAWN);
live = 1; live = 1;
ngx_signal_worker_processes(cycle, ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
} }
}
if (ngx_reconfigure) { if (ngx_reconfigure) {
ngx_reconfigure = 0; ngx_reconfigure = 0;
@ -578,16 +581,14 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
if (ccf->group != (gid_t) NGX_CONF_UNSET) { if (geteuid() == 0) {
if (setgid(ccf->group) == -1) { if (setgid(ccf->group) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"setgid(%d) failed", ccf->group); "setgid(%d) failed", ccf->group);
/* fatal */ /* fatal */
exit(2); exit(2);
} }
}
if (ccf->user != (uid_t) NGX_CONF_UNSET) {
if (setuid(ccf->user) == -1) { if (setuid(ccf->user) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"setuid(%d) failed", ccf->user); "setuid(%d) failed", ccf->user);
@ -596,7 +597,7 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
} }
} }
#if (HAVE_PR_SET_DUMPABLE) #if (NGX_HAVE_PR_SET_DUMPABLE)
/* allow coredump after setuid() in Linux 2.4.x */ /* allow coredump after setuid() in Linux 2.4.x */

View File

@ -22,7 +22,7 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
rev = c->read; rev = c->read;
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
"readv: eof:%d, avail:%d, err:%d", "readv: eof:%d, avail:%d, err:%d",
rev->pending_eof, rev->available, rev->kq_errno); rev->pending_eof, rev->available, rev->kq_errno);
@ -81,7 +81,7 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
n = readv(c->fd, (struct iovec *) io.elts, io.nelts); n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
if (n >= 0) { if (n >= 0) {
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
rev->available -= n; rev->available -= n;
/* /*
@ -186,7 +186,7 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
} else if (n > 0) { } else if (n > 0) {
if (n < size && !(ngx_event_flags & NGX_HAVE_GREEDY_EVENT)) { if (n < size && !(ngx_event_flags & NGX_USE_GREEDY_EVENT)) {
rev->ready = 0; rev->ready = 0;
} }

View File

@ -19,7 +19,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
rev = c->read; rev = c->read;
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
"recv: eof:%d, avail:%d, err:%d", "recv: eof:%d, avail:%d, err:%d",
rev->pending_eof, rev->available, rev->kq_errno); rev->pending_eof, rev->available, rev->kq_errno);
@ -60,7 +60,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
"recv: fd:%d %d of %d", c->fd, n, size); "recv: fd:%d %d of %d", c->fd, n, size);
if (n >= 0) { if (n >= 0) {
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
rev->available -= n; rev->available -= n;
/* /*
@ -139,7 +139,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
} else if (n > 0) { } else if (n > 0) {
if ((size_t) n < size if ((size_t) n < size
&& !(ngx_event_flags & NGX_HAVE_GREEDY_EVENT)) && !(ngx_event_flags & NGX_USE_GREEDY_EVENT))
{ {
rev->ready = 0; rev->ready = 0;
} }

View File

@ -19,7 +19,7 @@ ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size)
#if (HAVE_KQUEUE) #if (HAVE_KQUEUE)
if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && wev->pending_eof) { if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno, ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
"kevent() reported about an closed connection"); "kevent() reported about an closed connection");

View File

@ -76,7 +76,7 @@ void ngx_setproctitle(char *title)
{ {
u_char *p; u_char *p;
#if (SOLARIS) #if (NGX_SOLARIS)
ngx_int_t i; ngx_int_t i;
size_t size; size_t size;
@ -90,7 +90,7 @@ void ngx_setproctitle(char *title)
p = ngx_cpystrn(p, (u_char *) title, ngx_os_argv_last - (char *) p); p = ngx_cpystrn(p, (u_char *) title, ngx_os_argv_last - (char *) p);
#if (SOLARIS) #if (NGX_SOLARIS)
size = 0; size = 0;

View File

@ -44,7 +44,7 @@ int ngx_blocking(ngx_socket_t s)
#endif #endif
#ifdef __FreeBSD__ #if (NGX_FREEBSD)
int ngx_tcp_nopush(ngx_socket_t s) int ngx_tcp_nopush(ngx_socket_t s)
{ {
@ -67,7 +67,7 @@ int ngx_tcp_push(ngx_socket_t s)
(const void *) &tcp_nopush, sizeof(int)); (const void *) &tcp_nopush, sizeof(int));
} }
#elif __linux__ #elif (NGX_LINUX)
int ngx_tcp_nopush(ngx_socket_t s) int ngx_tcp_nopush(ngx_socket_t s)
{ {

View File

@ -37,7 +37,7 @@ int ngx_blocking(ngx_socket_t s);
int ngx_tcp_nopush(ngx_socket_t s); int ngx_tcp_nopush(ngx_socket_t s);
int ngx_tcp_push(ngx_socket_t s); int ngx_tcp_push(ngx_socket_t s);
#ifdef __linux__ #if (NGX_LINUX)
#define ngx_tcp_nopush_n "setsockopt(TCP_CORK)" #define ngx_tcp_nopush_n "setsockopt(TCP_CORK)"
#define ngx_tcp_push_n "setsockopt(!TCP_CORK)" #define ngx_tcp_push_n "setsockopt(!TCP_CORK)"

Some files were not shown because too many files have changed in this diff Show More