nginx-0.1.8-RELEASE import

*) Bugfix: in the ngx_http_autoindex_module if the long file names were
       in the listing.

    *) Feature: the "^~" modifier in the location directive.

    *) Feature: the proxy_max_temp_file_size directive.
This commit is contained in:
Igor Sysoev 2004-11-20 19:52:20 +00:00
parent 13376e1538
commit d43bee8ee9
57 changed files with 890 additions and 600 deletions

View File

@ -52,11 +52,12 @@ else
. auto/cc/icc
;;
# ccc)
ccc)
# # Compaq C V6.5-207
#
# . auto/cc/ccc
# ;;
ngx_include_opt="-I "
;;
# acc)
# # aCC: HP ANSI C++ B3910B A.03.55.02
@ -95,7 +96,7 @@ if [ "$PLATFORM" != win32 ]; then
if test -n "$NGX_LD_OPT"; then
ngx_feature=--with-ld-opt=\"$NGX_LD_OPT\"
ngx_feature_name=DUMMY
ngx_feature_name="DUMMY"
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_libs=
@ -110,7 +111,7 @@ if [ "$PLATFORM" != win32 ]; then
fi
ngx_feature="gcc variadic macros"
ngx_feature_name=HAVE_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)"
@ -122,7 +123,7 @@ if [ "$PLATFORM" != win32 ]; then
ngx_feature="C99 variadic macros"
ngx_feature_name=HAVE_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__)"
@ -132,4 +133,16 @@ if [ "$PLATFORM" != win32 ]; then
if (buf[0] != '1') return 1"
. auto/feature
# ngx_feature="inline"
# ngx_feature_name="DUMMY"
# ngx_feature_run=no
# ngx_feature_incs="int inline f(void) { return 1 }"
# ngx_feature_libs=
# ngx_feature_test=
# . auto/feature
#
# if [ $ngx_found = yes ]; then
# fi
fi

View File

@ -3,7 +3,7 @@
# 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
# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4, 3.4.2
# Solaris 7's /usr/ccs/bin/as does not support "-pipe"

2
auto/configure vendored
View File

@ -11,6 +11,8 @@ test -d $OBJS || mkdir $OBJS
echo > $NGX_AUTO_HEADERS_H
echo > $NGX_AUTO_CONFIG_H
echo > $NGX_AUTOCONF_ERR
if [ $DEBUG = YES ]; then
have=NGX_DEBUG . auto/have

View File

@ -3,6 +3,7 @@
cat << END >> $MAKEFILE
install:
test -d $PREFIX || mkdir -p $PREFIX

View File

@ -2,35 +2,21 @@
# Copyright (C) Igor Sysoev
case "$CC" in
case "$NGX_CC_NAME" in
cl)
makefile=makefile.msvc
opt="CPU_OPT=$CPU_OPT LIBC=$LIBC MD5_ASM=$MD5_ASM"
msvc*)
ngx_makefile=makefile.msvc
ngx_opt="CPU_OPT=$CPU_OPT LIBC=$LIBC MD5_ASM=$MD5_ASM"
;;
wcl386)
makefile=makefile.owc
opt="CPU_OPT=$CPU_OPT"
owc*)
ngx_makefile=makefile.owc
ngx_opt="CPU_OPT=$CPU_OPT"
;;
bcc32)
makefile=makefile.bcc
opt="-DCPU_OPT=$CPU_OPT -DMD5_ASM=$MD5_ASM"
;;
esac
case $PLATFORM in
win32)
line=`echo $MD5/md5.lib: | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE
;;
*)
echo "$MD5/libmd5.a:" >> $MAKEFILE
bcc)
ngx_makefile=makefile.bcc
ngx_opt="-DCPU_OPT=$CPU_OPT -DMD5_ASM=$MD5_ASM"
;;
esac
@ -42,12 +28,16 @@ done=NO
case $PLATFORM in
win32)
md5=`echo $MD5 | sed -e "s/\//$ngx_regex_dirsep/g"`
cp auto/lib/md5/$ngx_makefile $MD5
cp auto/lib/md5/$makefile $MD5
echo " cd $md5" >> $MAKEFILE
echo " \$(MAKE) -f $makefile $opt" >> $MAKEFILE
echo " cd ..\\..\\.." >> $MAKEFILE
cat << END >> $NGX_MAKEFILE
`echo "$MD5/md5.lib: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
cd `echo $MD5 | sed -e "s/\//$ngx_regex_dirsep/g"`
\$(MAKE) -f $ngx_makefile $ngx_opt
cd ..\\..\\..
END
done=YES
;;
@ -55,13 +45,15 @@ case $PLATFORM in
SunOS:*:i86pc)
if [ $MD5_ASM = YES ]; then
MD5_OPT="CFLAGS=\"$MD5_OPT -DSOL -DMD5_ASM -DL_ENDIAN\""
cat << END >> $NGX_MAKEFILE
echo " cd $MD5 \\" >> $MAKEFILE
echo " && \$(MAKE) $MD5_OPT \\" >> $MAKEFILE
echo " MD5_ASM_OBJ=asm/mx86-sol.o \\" >> $MAKEFILE
echo " CC=\"\$(CC)\" CPP=\"\$(CPP)\" \\" >> $MAKEFILE
echo " libmd5.a" >> $MAKEFILE
$MD5/libmd5.a: $NGX_MAKEFILE
cd $MD5 \\
&& \$(MAKE) CFLAGS="$MD5_OPT -DSOL -DMD5_ASM -DL_ENDIAN" \\
CC="\$(CC)" CPP="\$(CPP)" \\
MD5_ASM_OBJ=asm/mx86-sol.o clean libmd5.a
END
done=YES
fi
@ -73,13 +65,15 @@ case $PLATFORM in
*:i386 | *:i686)
if [ $MD5_ASM = YES ]; then
MD5_OPT="CFLAGS=\"$MD5_OPT -DELF -DMD5_ASM -DL_ENDIAN\""
cat << END >> $NGX_MAKEFILE
echo " cd $MD5 \\" >> $MAKEFILE
echo " && \$(MAKE) $MD5_OPT \\" >> $MAKEFILE
echo " MD5_ASM_OBJ=asm/mx86-elf.o \\" >> $MAKEFILE
echo " CC=\"\$(CC)\" CPP=\"\$(CPP)\" \\" >> $MAKEFILE
echo " libmd5.a" >> $MAKEFILE
$MD5/libmd5.a: $NGX_MAKEFILE
cd $MD5 \\
&& \$(MAKE) CFLAGS="$MD5_OPT -DELF -DMD5_ASM -DL_ENDIAN" \\
CC="\$(CC)" CPP="\$(CPP)" \\
MD5_ASM_OBJ=asm/mx86-elf.o clean libmd5.a
END
done=YES
fi
@ -89,10 +83,14 @@ esac
if [ $done = NO ]; then
echo " cd $MD5 \\" >> $MAKEFILE
echo " && \$(MAKE) CFLAGS=\"$MD5_OPT\" \\" >> $MAKEFILE
echo " MD5_ASM_OBJ= CC=\"\$(CC)\" libmd5.a" >> $MAKEFILE
cat << END >> $NGX_MAKEFILE
$MD5/libmd5.a: $NGX_MAKEFILE
cd $MD5 \\
&& \$(MAKE) CFLAGS="$MD5_OPT" \\
CC="\$(CC)" MD5_ASM_OBJ= clean libmd5.a
END
fi
echo >> $MAKEFILE

View File

@ -2,21 +2,21 @@
# Copyright (C) Igor Sysoev
case "$CC" in
case "$NGX_CC_NAME" in
cl)
makefile=makefile.msvc
opt="CPU_OPT=$CPU_OPT LIBC=$LIBC"
msvc*)
ngx_makefile=makefile.msvc
ngx_opt="CPU_OPT=$CPU_OPT LIBC=$LIBC"
;;
wcl386)
makefile=makefile.owc
opt="CPU_OPT=$CPU_OPT"
owc*)
ngx_makefile=makefile.owc
ngx_opt="CPU_OPT=$CPU_OPT"
;;
bcc32)
makefile=makefile.bcc
opt="-DCPU_OPT=$CPU_OPT"
bcc)
ngx_makefile=makefile.bcc
ngx_opt="-DCPU_OPT=$CPU_OPT"
;;
esac
@ -27,39 +27,45 @@ case $PLATFORM in
win32)
cp auto/lib/pcre/patch.pcre.in $PCRE
cp auto/lib/pcre/patch.config.in $PCRE
cp auto/lib/pcre/$makefile $PCRE
cp auto/lib/pcre/$ngx_makefile $PCRE
pcre=`echo $PCRE | sed -e "s/\//$ngx_regex_dirsep/g"`
line=`echo $PCRE/pcre.h: | sed -e "s/\//$ngx_regex_dirsep/g"`
ngx_pcre=`echo $PCRE | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE
echo " cd $pcre" >> $MAKEFILE
echo " \$(MAKE) -f $makefile pcre.h" >> $MAKEFILE
echo " cd ..\\..\\.." >> $MAKEFILE
echo >> $MAKEFILE
cat << END >> $NGX_MAKEFILE
line="$PCRE/pcre.lib: $PCRE/pcre.h"
line=`echo $line | sed -e "s/\//$ngx_regex_dirsep/g"`
`echo "$PCRE/pcre.h: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
cd $ngx_pcre
\$(MAKE) -f $ngx_makefile pcre.h
cd ..\\..\\..
`echo "$PCRE/pcre.lib: $PCRE/pcre.h" | sed -e "s/\//$ngx_regex_dirsep/g"`
cd $ngx_pcre
\$(MAKE) -f $ngx_makefile $ngx_opt
cd ..\\..\\..
END
echo "$line" >> $MAKEFILE
echo " cd $pcre" >> $MAKEFILE
echo " \$(MAKE) -f $makefile $opt" >> $MAKEFILE
echo " cd ..\\..\\.." >> $MAKEFILE
;;
*)
PCRE_OPT="CFLAGS=\"$PCRE_OPT\""
cat << END >> $NGX_MAKEFILE
$PCRE/pcre.h: $NGX_MAKEFILE
cd $PCRE \\
&& if [ -f Makefile ]; then \$(MAKE) distclean; fi
cd $PCRE \\
&& CC="\$(CC)" CFLAGS="$PCRE_OPT" \\
./configure --disable-shared
$PCRE/.libs/libpcre.a: $PCRE/pcre.h
cd $PCRE \\
&& \$(MAKE) libpcre.la
END
echo "$PCRE/pcre.h:" >> $MAKEFILE
echo " cd $PCRE \\" >> $MAKEFILE
echo " && CC=\"\$(CC)\" $PCRE_OPT \\" >> $MAKEFILE
echo " ./configure --disable-shared" >> $MAKEFILE
echo >> $MAKEFILE
echo "$PCRE/.libs/libpcre.a: $PCRE/pcre.h" >> $MAKEFILE
echo " cd $PCRE \\" >> $MAKEFILE
echo " && \$(MAKE) libpcre.la" >> $MAKEFILE
;;
esac
echo >> $MAKEFILE

View File

@ -2,36 +2,22 @@
# Copyright (C) Igor Sysoev
case "$CC" in
case "$NGX_CC_NAME" in
cl)
makefile=makefile.msvc
opt="CPU_OPT=$CPU_OPT LIBC=$LIBC"
msvc*)
ngx_makefile=makefile.msvc
ngx_opt="CPU_OPT=$CPU_OPT LIBC=$LIBC"
;;
wcl386)
makefile=makefile.owc
opt="CPU_OPT=$CPU_OPT"
owc*)
ngx_makefile=makefile.owc
ngx_opt="CPU_OPT=$CPU_OPT"
;;
bcc32)
makefile=makefile.bcc
opt="-DCPU_OPT=$CPU_OPT"
;;
esac
case $PLATFORM in
win32)
line=`echo $ZLIB/zlib.lib: | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE
;;
*)
echo "$ZLIB/libz.a:" >> $MAKEFILE
bcc)
ngx_makefile=makefile.bcc
ngx_opt="-DCPU_OPT=$CPU_OPT"
;;
esac
@ -43,12 +29,16 @@ done=NO
case $PLATFORM in
win32)
zlib=`echo $ZLIB | sed -e "s/\//$ngx_regex_dirsep/g"`
cp auto/lib/zlib/$ngx_makefile $ZLIB
cp auto/lib/zlib/$makefile $ZLIB
echo " cd $zlib" >> $MAKEFILE
echo " \$(MAKE) -f $makefile $opt" >> $MAKEFILE
echo " cd ..\\..\\.." >> $MAKEFILE
cat << END >> $NGX_MAKEFILE
`echo "$ZLIB/zlib.lib: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"`
cd `echo $ZLIB | sed -e "s/\//$ngx_regex_dirsep/g"`
\$(MAKE) -f $ngx_makefile $ngx_opt
cd ..\\..\\..
END
done=YES
;;
@ -59,23 +49,35 @@ case $PLATFORM in
*:i386 | *:i686)
case $ZLIB_ASM in
pentium)
echo " cd $ZLIB \\" >> $MAKEFILE
echo " && cp contrib/asm586/match.S . \\" >> $MAKEFILE
echo " && CFLAGS=\"$ZLIB_OPT -DASMV\" \\" >> $MAKEFILE
echo " CC=\"\$(CC)\" \\" >> $MAKEFILE
echo " ./configure \\" >> $MAKEFILE
echo " && \$(MAKE) OBJA=match.o libz.a" >> $MAKEFILE
cat << END >> $NGX_MAKEFILE
$ZLIB/libz.a: $NGX_MAKEFILE
cd $ZLIB \\
&& make clean \\
&& cp contrib/asm586/match.S . \\
&& CFLAGS="$ZLIB_OPT -DASMV" CC="\$(CC)" \\
./configure \\
&& \$(MAKE) OBJA=match.o libz.a
END
done=YES
;;
pentiumpro)
echo " cd $ZLIB \\" >> $MAKEFILE
echo " && cp contrib/asm686/match.S . \\" >> $MAKEFILE
echo " && CFLAGS=\"$ZLIB_OPT -DASMV\" \\" >> $MAKEFILE
echo " CC=\"\$(CC)\" \\" >> $MAKEFILE
echo " ./configure \\" >> $MAKEFILE
echo " && \$(MAKE) OBJA=match.o libz.a" >> $MAKEFILE
cat << END >> $NGX_MAKEFILE
$ZLIB/libz.a: $NGX_MAKEFILE
cd $ZLIB \\
&& make clean \\
&& cp contrib/asm686/match.S . \\
&& CFLAGS="$ZLIB_OPT -DASMV" CC="\$(CC)" \\
./configure \\
&& \$(MAKE) OBJA=match.o libz.a
END
done=YES
;;
@ -97,11 +99,16 @@ esac
if [ $done = NO ]; then
echo " cd $ZLIB \\" >> $MAKEFILE
echo " && CFLAGS=\"$ZLIB_OPT\" CC=\"\$(CC)\" \\" >> $MAKEFILE
echo " ./configure \\" >> $MAKEFILE
echo " && \$(MAKE) libz.a" >> $MAKEFILE
cat << END >> $NGX_MAKEFILE
$ZLIB/libz.a: $NGX_MAKEFILE
cd $ZLIB \\
&& make clean \\
&& CFLAGS="$ZLIB_OPT" CC="\$(CC)" \\
./configure \\
&& \$(MAKE) libz.a
END
fi
echo >> $MAKEFILE

View File

@ -12,7 +12,7 @@ ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
ngx_use_pch=`echo $NGX_USE_PCH | sed -e "s/\//$ngx_regex_dirsep/g"`
cat << END >> $NGX_MAKEFILE
cat << END > $NGX_MAKEFILE
CC = $CC
CFLAGS = $CFLAGS
@ -49,7 +49,7 @@ ngx_all_srcs="$CORE_SRCS"
# the core dependences and include pathes
ngx_deps=`echo $CORE_DEPS $NGX_PCH \
ngx_deps=`echo $CORE_DEPS $NGX_AUTO_CONFIG_H $NGX_PCH \
| sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
-e "s/\//$ngx_regex_dirsep/g"`

View File

@ -7,6 +7,7 @@ if [ $EVENT_SELECT = NO -a $EVENT_FOUND = NO ]; then
fi
if [ $EVENT_SELECT = YES ]; then
have=HAVE_SELECT . auto/have
CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
fi
@ -17,6 +18,7 @@ if [ $EVENT_POLL = NO -a $EVENT_FOUND = NO ]; then
fi
if [ $EVENT_POLL = YES ]; then
have=HAVE_POLL . auto/have
CORE_SRCS="$CORE_SRCS $POLL_SRCS"
EVENT_MODULES="$EVENT_MODULES $POLL_MODULE"
fi

View File

@ -52,6 +52,8 @@ HTTP_PROXY=YES
IMAP=NO
MODULES=
USE_PCRE=NO
PCRE=NONE
PCRE_OPT=
@ -118,6 +120,8 @@ do
--with-imap) IMAP=YES ;;
--with-module=*) NGX_MODULES="$NGX_MODULES $values" ;;
--with-cc=*) CC="$value" ;;
--with-cpp=*) CPP="$value" ;;
--with-cc-opt=*) NGX_CC_OPT="$value" ;;

View File

@ -97,9 +97,20 @@ fi
if [ $EVENT_AIO = YES ]; then
have=HAVE_AIO . auto/have
EVENT_MODULES="$EVENT_MODULES $AIO_MODULE"
CORE_SRCS="$CORE_SRCS $AIO_SRCS"
else
have=HAVE_AIO . auto/nohave
if [ \( $version -lt 500000 -a $version -ge 430000 \) \
-o $version -ge 500014 ]
then
have=HAVE_AIO . auto/have
EVENT_MODULES="$EVENT_MODULES $AIO_MODULE"
CORE_SRCS="$CORE_SRCS $AIO_SRCS"
else
cat << END
$0: error: the kqueue does not support AIO on this FreeBSD version
END
exit 1
fi
fi

View File

@ -48,7 +48,7 @@ fi
ngx_feature="epoll"
ngx_feature_name="epoll"
ngx_feature_run=yes
ngx_feature_run=no
ngx_feature_incs="#include <sys/epoll.h>"
ngx_feature_libs=
ngx_feature_test="int efd = 0, fd = 1, n;

View File

@ -73,6 +73,15 @@ ngx_param=TIME_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
# syscalls, libc calls and some features
ngx_feature="setproctitle()"
ngx_feature_name="HAVE_SETPROCTITLE"
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_libs=
ngx_feature_test="setproctitle(\"test\");"
. auto/feature
ngx_feature="pread()"
ngx_feature_name="pread"
ngx_feature_run=no

View File

@ -6,18 +6,50 @@
title="nginx">
<changes ver="0.1.8" date="20.11.2004">
<change type="bugfix">
<para lang="ru">
ÏÛÉÂËÁ × ÍÏÄÕÌÅ ngx_http_autoindex_module ÐÒÉ ÐÏËÁÚÅ ÄÌÉÎÎÙÈ ÉͣΠÆÁÊÌÏ×.
</para>
<para lang="en">
in the ngx_http_autoindex_module if the long file names were in the listing.
</para>
</change>
<change type="feature">
<para lang="ru">
ÍÏÄÉÆÉËÁÔÏÒ "^~" × ÄÉÒÅËÔÉ×Å location.
</para>
<para lang="en">
the "^~" modifier in the location directive.
</para>
</change>
<change type="feature">
<para lang="ru">
ÄÉÒÅËÔÉ×Á proxy_max_temp_file_size.
</para>
<para lang="en">
the proxy_max_temp_file_size directive.
</para>
</change>
</changes>
<changes ver="0.1.7" date="12.11.2004">
<change type="bugfix">
<para lang="ru">
ÐÒÉ ÉÓÐÏÌØÚÏ×ÁÎÉÉ sendfile, ÅÓÌÉ ÐÅÒÅÄÁ×ÁÅÍÙÊ ÆÁÊÌ ÍÅÎÑÌÓÑ, ÔÏ ÍÏÇ
ÐÒÏÉÚÏÊÔÉ segmentation fault ÎÁ FreeBSD;
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.2.
ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.5.
</para>
<para lang="en">
on FreeBSD the segmentation fault may occure if the size of the transferred
file was changed;
bug appeared in 0.1.2.
bug appeared in 0.1.5.
</para>
</change>

View File

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

View File

@ -26,7 +26,7 @@ void ngx_destroy_array(ngx_array_t *a);
void *ngx_push_array(ngx_array_t *a);
ngx_inline static ngx_int_t ngx_array_init(ngx_array_t *array, ngx_pool_t *pool,
static ngx_inline ngx_int_t ngx_array_init(ngx_array_t *array, ngx_pool_t *pool,
ngx_uint_t n, size_t size)
{
if (!(array->elts = ngx_palloc(pool, n * size))) {

View File

@ -109,7 +109,7 @@ typedef long ngx_flag_t;
/* TODO: auto_conf: ngx_inline inline __inline __inline__ */
#ifndef ngx_inline
#define ngx_inline inline
#define ngx_inline __inline
#endif
#define NGX_ACCEPT_THRESHOLD 100

View File

@ -299,7 +299,7 @@ void ngx_close_listening_sockets(ngx_cycle_t *cycle)
}
}
if (ngx_close_socket(ls[i].fd) == -1) {
if (ngx_close_socket(fd) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
ngx_close_socket_n " %V failed", &ls[i].addr_text);
}

View File

@ -10,7 +10,7 @@
/* 32-bit crc16 */
ngx_inline static uint32_t ngx_crc(char *data, size_t len)
static ngx_inline uint32_t ngx_crc(char *data, size_t len)
{
uint32_t sum;

View File

@ -49,6 +49,8 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
ngx_list_part_t *part;
ngx_open_file_t *file;
ngx_listening_t *ls, *nls;
ngx_core_conf_t *ccf;
ngx_event_conf_t *ecf;
ngx_core_module_t *module;
log = old_cycle->log;
@ -203,6 +205,16 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
#endif
if (!failed) {
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
ngx_core_module);
if (ngx_create_pathes(cycle, ccf->user) == NGX_ERROR) {
failed = 1;
}
}
if (!failed) {
/* open the new files */
@ -421,6 +433,13 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
}
}
ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
"using the \"%s\" event method", ecf->name);
/* close and delete stuff that lefts from an old cycle */
/* close the unneeded listening sockets */
@ -697,16 +716,6 @@ void ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
}
#else
if (user != (ngx_uid_t) -1) {
if (chown((const char *) file[i].name.data, user, -1) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"chown \"%s\" failed", file[i].name.data);
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
ngx_close_file_n " \"%s\" failed",
file[i].name.data);
}
}
if (ngx_file_info((const char *) file[i].name.data, &fi) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
@ -720,14 +729,27 @@ void ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
}
}
if (fi.st_uid != user) {
if (chown((const char *) file[i].name.data, user, -1) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"chown(\"%s\", %d) failed",
file[i].name.data, user);
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
ngx_close_file_n " \"%s\" failed",
file[i].name.data);
}
}
}
if ((fi.st_mode & (S_IRUSR|S_IWUSR)) != (S_IRUSR|S_IWUSR)) {
fi.st_mode |= (S_IRUSR|S_IWUSR);
if (chmod((const char *) file[i].name.data, fi.st_mode) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"chmod \"%s\" failed",
file[i].name.data);
"chmod() \"%s\" failed", file[i].name.data);
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,

View File

@ -12,9 +12,9 @@ static ngx_uint_t ngx_temp_number;
static ngx_uint_t ngx_random;
int ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
ssize_t ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
{
int rc;
ngx_int_t rc;
if (tf->file.fd == NGX_INVALID_FILE) {
rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool,
@ -33,16 +33,17 @@ int ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
}
int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
ngx_pool_t *pool, int persistent)
ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
ngx_pool_t *pool, int persistent)
{
int num;
ngx_err_t err;
ngx_err_t err;
uint32_t num;
file->name.len = path->name.len + 1 + path->len + 10;
ngx_test_null(file->name.data, ngx_palloc(pool, file->name.len + 1),
NGX_ERROR);
if (!(file->name.data = ngx_palloc(pool, file->name.len + 1))) {
return NGX_ERROR;
}
#if 0
for (i = 0; i < file->name.len; i++) {
@ -52,11 +53,11 @@ int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
ngx_memcpy(file->name.data, path->name.data, path->name.len);
num = ngx_next_temp_number(0);
num = (uint32_t) ngx_next_temp_number(0);
for ( ;; ) {
ngx_sprintf(file->name.data + path->name.len + 1 + path->len,
"%010ud%Z", num);
"%010ui%Z", num);
ngx_create_hashed_filename(file, path);
@ -85,7 +86,8 @@ int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
#if (NGX_WIN32)
&& err != NGX_ENOTDIR
#endif
)) {
))
{
ngx_log_error(NGX_LOG_CRIT, file->log, err,
ngx_open_tempfile_n " \"%s\" failed",
file->name.data);
@ -101,8 +103,7 @@ int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path)
{
int i, name, pos;
size_t level;
ngx_uint_t i, name, pos, level;
name = file->name.len;
pos = path->name.len + 1;
@ -127,7 +128,7 @@ void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path)
}
int ngx_create_path(ngx_file_t *file, ngx_path_t *path)
ngx_int_t ngx_create_path(ngx_file_t *file, ngx_path_t *path)
{
int i, pos;
ngx_err_t err;
@ -189,32 +190,28 @@ char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *p = conf;
ngx_int_t level;
ssize_t level;
ngx_uint_t i, n;
ngx_str_t *value;
ngx_path_t *path, **pp;
ngx_path_t *path, **pp, **slot;
pp = (ngx_path_t **) (p + cmd->offset);
slot = (ngx_path_t **) (p + cmd->offset);
if (*pp) {
if (*slot) {
return "is duplicate";
}
/* TODO: check duplicate in cf->cycle->pathes */
if (!(path = ngx_pcalloc(cf->pool, sizeof(ngx_path_t)))) {
return NGX_CONF_ERROR;
}
ngx_test_null(path, ngx_pcalloc(cf->pool, sizeof(ngx_path_t)),
NGX_CONF_ERROR);
*pp = path;
ngx_test_null(pp, ngx_push_array(&cf->cycle->pathes), NGX_CONF_ERROR);
*pp = path;
value = (ngx_str_t *) cf->args->elts;
value = cf->args->elts;
path->name = value[1];
path->len = 0;
path->gc_handler = (ngx_gc_handler_pt) cmd->post;
path->conf_file = cf->conf_file->file.name.data;
path->line = cf->conf_file->line;
for (i = 0, n = 2; n < cf->args->nelts; i++, n++) {
level = ngx_atoi(value[n].data, value[n].len);
@ -230,7 +227,102 @@ char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
path->level[i++] = 0;
}
path->gc_handler = (ngx_gc_handler_pt) cmd->post;
pp = cf->cycle->pathes.elts;
for (i = 0; i < cf->cycle->pathes.nelts; i++) {
if (pp[i]->name.len == path->name.len
&& ngx_strcmp(pp[i]->name.data, path->name.data) == 0)
{
for (n = 0; n < 3; n++) {
if (pp[i]->level[n] != path->level[n]) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"the same \"%V\" path name in %s:%ui "
"has the different levels than",
&pp[i]->name, pp[i]->conf_file, pp[i]->line);
return NGX_CONF_ERROR;
}
if (pp[i]->level[n] == 0) {
break;
}
}
*slot = pp[i];
return NGX_CONF_OK;
}
}
*slot = path;
if (!(pp = ngx_array_push(&cf->cycle->pathes))) {
return NGX_CONF_ERROR;
}
*pp = path;
return NGX_CONF_OK;
}
ngx_int_t ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user)
{
ngx_err_t err;
ngx_uint_t i;
ngx_path_t **path;
#if !(NGX_WIN32)
ngx_file_info_t fi;
#endif
path = cycle->pathes.elts;
for (i = 0; i < cycle->pathes.nelts; i++) {
if (ngx_create_dir(path[i]->name.data) == NGX_FILE_ERROR) {
err = ngx_errno;
if (err != NGX_EEXIST) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, err,
ngx_create_dir_n " \"%s\" failed",
path[i]->name.data);
return NGX_ERROR;
}
}
if (user == (ngx_uid_t) -1) {
continue;
}
#if !(NGX_WIN32)
if (ngx_file_info((const char *) path[i]->name.data, &fi) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
ngx_file_info_n " \"%s\" failed", path[i]->name.data);
return NGX_ERROR;
}
if (fi.st_uid != user) {
if (chown((const char *) path[i]->name.data, user, -1) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"chown(\"%s\", %d) failed",
path[i]->name.data, user);
return NGX_ERROR;
}
}
if ((fi.st_mode & (S_IRUSR|S_IWUSR|S_IXUSR))
!= (S_IRUSR|S_IWUSR|S_IXUSR))
{
fi.st_mode |= (S_IRUSR|S_IWUSR|S_IXUSR);
if (chmod((const char *) path[i]->name.data, fi.st_mode) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"chmod() \"%s\" failed", path[i]->name.data);
return NGX_ERROR;
}
}
#endif
}
return NGX_OK;
}

View File

@ -17,44 +17,48 @@ typedef struct ngx_path_s ngx_path_t;
struct ngx_file_s {
ngx_fd_t fd;
ngx_str_t name;
ngx_file_info_t info;
ngx_fd_t fd;
ngx_str_t name;
ngx_file_info_t info;
off_t offset;
off_t sys_offset;
off_t offset;
off_t sys_offset;
ngx_log_t *log;
ngx_log_t *log;
ngx_uint_t valid_info:1; /* unsigned valid_info:1; */
ngx_uint_t valid_info:1; /* unsigned valid_info:1; */
};
#define NGX_MAX_PATH_LEVEL 3
struct ngx_path_s {
ngx_str_t name;
u_int len;
u_int level[3];
ngx_uint_t len;
ngx_uint_t level[3];
ngx_gc_handler_pt gc_handler;
u_char *conf_file;
ngx_uint_t line;
};
typedef struct {
ngx_file_t file;
off_t offset;
ngx_path_t *path;
ngx_pool_t *pool;
char *warn;
ngx_file_t file;
off_t offset;
ngx_path_t *path;
ngx_pool_t *pool;
char *warn;
unsigned persistent:1;
unsigned persistent:1;
} ngx_temp_file_t;
int ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain);
int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
ngx_pool_t *pool, int persistent);
ssize_t ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain);
ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
ngx_pool_t *pool, int persistent);
void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path);
int ngx_create_path(ngx_file_t *file, ngx_path_t *path);
ngx_int_t ngx_create_path(ngx_file_t *file, ngx_path_t *path);
ngx_int_t ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user);
void ngx_init_temp_number();
ngx_uint_t ngx_next_temp_number(ngx_uint_t collision);

View File

@ -9,71 +9,8 @@
#include <ngx_garbage_collector.h>
int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name,
ngx_dir_t *dir);
static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level);
#if 0
{
ngx_test_null(cycle->timer_events,
ngx_alloc(sizeof(ngx_event_t) * TIMERS, cycle->log),
NGX_ERROR);
ngx_event_timer_init(cycle);
}
void garbage_collector()
{
ngx_msec_t timer;
struct timeval tv;
ngx_epoch_msec_t delta;
for ( ;; ) {
timer = ngx_event_find_timer();
ngx_gettimeofday(&tv);
delta = tv.tv_sec * 1000 + tv.tv_usec / 1000;
msleep(timer);
ngx_gettimeofday(&tv);
ngx_cached_time = tv.tv_sec;
ngx_time_update();
delta = tv.tv_sec * 1000 + tv.tv_usec / 1000 - delta;
ngx_event_expire_timers((ngx_msec_t) delta);
}
}
#endif
void stub_init(ngx_cycle_t *cycle)
{
ngx_uint_t i;
ngx_gc_t ctx;
ngx_path_t **path;
path = cycle->pathes.elts;
for (i = 0; i < cycle->pathes.nelts; i++) {
ctx.path = path[i];
ctx.log = cycle->log;
ctx.handler = path[i]->gc_handler;
ngx_collect_garbage(&ctx, &path[i]->name, 0);
}
}
static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level)
ngx_int_t ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level)
{
int rc;
u_char *last;
@ -224,7 +161,8 @@ static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level)
} else {
ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno,
"\"%s\" has unknown file type, deleting", fname.data);
"the file \"%s\" has unknown type, deleting",
fname.data);
if (ngx_delete_file(fname.data) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno,
@ -249,8 +187,8 @@ static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level)
}
int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name,
ngx_dir_t *dir)
ngx_int_t ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name,
ngx_dir_t *dir)
{
/*
* We use mtime only and do not use atime because:
@ -264,7 +202,7 @@ int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name,
}
ngx_log_error(NGX_LOG_NOTICE, ctx->log, 0,
"delete stale temporary \"%s\"", name->data);
"delete the stale temporary file \"%s\"", name->data);
if (ngx_delete_file(name->data) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno,

View File

@ -23,8 +23,9 @@ struct ngx_gc_s {
};
int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name,
ngx_dir_t *dir);
ngx_int_t ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level);
ngx_int_t ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name,
ngx_dir_t *dir);
#endif /* _NGX_GARBAGE_COLLECTOR_H_INCLUDED_ */

View File

@ -20,7 +20,7 @@
*/
ngx_inline static size_t ngx_sprint_uchar(u_char *text, u_char c, size_t len)
static ngx_inline size_t ngx_sprint_uchar(u_char *text, u_char c, size_t len)
{
size_t n;
ngx_uint_t c1, c2;

View File

@ -30,7 +30,7 @@ typedef struct {
} ngx_list_t;
ngx_inline static ngx_int_t ngx_list_init(ngx_list_t *list, ngx_pool_t *pool,
static ngx_inline ngx_int_t ngx_list_init(ngx_list_t *list, ngx_pool_t *pool,
ngx_uint_t n, size_t size)
{
if (!(list->part.elts = ngx_palloc(pool, n * size))) {

View File

@ -155,8 +155,15 @@ static void ngx_log_write(ngx_log_t *log, u_char *errstr, size_t len)
errstr[len++] = CR;
errstr[len++] = LF;
WriteFile(log->file->fd, errstr, len, &written, NULL);
#if 0
if (WriteFile(log->file->fd, errstr, len, &written, NULL) == 0) {
ngx_message_box("nginx", MB_OK, ngx_errno, "WriteFile() failed");
}
#endif
#else
if (len == NGX_MAX_ERROR_STR) {
@ -164,6 +171,7 @@ static void ngx_log_write(ngx_log_t *log, u_char *errstr, size_t len)
}
errstr[len++] = LF;
write(log->file->fd, errstr, len);
#endif

View File

@ -12,7 +12,7 @@
#define NGX_NONE 1
ngx_inline static ngx_int_t
static ngx_inline ngx_int_t
ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf);
static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
ngx_uint_t sendfile);
@ -188,7 +188,7 @@ ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
}
ngx_inline static ngx_int_t
static ngx_inline ngx_int_t
ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf)
{
if (ngx_buf_special(buf)) {

View File

@ -20,12 +20,12 @@
#define ngx_rbt_copy_color(n1, n2) (n1->color = n2->color)
ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
ngx_rbtree_t *sentinel,
ngx_rbtree_t *node);
ngx_inline void ngx_rbtree_right_rotate(ngx_rbtree_t **root,
ngx_rbtree_t *sentinel,
ngx_rbtree_t *node);
static ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
ngx_rbtree_t *sentinel,
ngx_rbtree_t *node);
static ngx_inline void ngx_rbtree_right_rotate(ngx_rbtree_t **root,
ngx_rbtree_t *sentinel,
ngx_rbtree_t *node);
void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
@ -289,9 +289,9 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
}
ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
ngx_rbtree_t *sentinel,
ngx_rbtree_t *node)
static ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
ngx_rbtree_t *sentinel,
ngx_rbtree_t *node)
{
ngx_rbtree_t *temp;
@ -319,9 +319,9 @@ ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
}
ngx_inline void ngx_rbtree_right_rotate(ngx_rbtree_t **root,
ngx_rbtree_t *sentinel,
ngx_rbtree_t *node)
static ngx_inline void ngx_rbtree_right_rotate(ngx_rbtree_t **root,
ngx_rbtree_t *sentinel,
ngx_rbtree_t *node)
{
ngx_rbtree_t *temp;

View File

@ -29,7 +29,7 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
ngx_rbtree_t *node);
ngx_inline static ngx_rbtree_t *ngx_rbtree_min(ngx_rbtree_t *node,
static ngx_inline ngx_rbtree_t *ngx_rbtree_min(ngx_rbtree_t *node,
ngx_rbtree_t *sentinel)
{
while (node->left != sentinel) {

View File

@ -135,6 +135,11 @@ u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
fmt++;
continue;
case 'm':
width = NGX_INT_T_LEN;
fmt++;
continue;
case 'X':
hexadecimal = 2;
sign = 0;

View File

@ -12,31 +12,12 @@
#define DEFAULT_CONNECTIONS 512
extern ngx_module_t ngx_select_module;
extern ngx_event_module_t ngx_select_module_ctx;
#if (HAVE_KQUEUE)
#include <ngx_kqueue_module.h>
#endif
#if (HAVE_DEVPOLL)
extern ngx_module_t ngx_kqueue_module;
extern ngx_module_t ngx_devpoll_module;
extern ngx_event_module_t ngx_devpoll_module_ctx;
#endif
#if (HAVE_EPOLL)
extern ngx_module_t ngx_epoll_module;
extern ngx_event_module_t ngx_epoll_module_ctx;
#endif
#if (HAVE_RTSIG)
extern ngx_module_t ngx_rtsig_module;
extern ngx_event_module_t ngx_rtsig_module_ctx;
#endif
extern ngx_module_t ngx_select_module;
#if (HAVE_AIO)
#include <ngx_aio_module.h>
#endif
static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle);
static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle);
@ -631,13 +612,13 @@ static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
&& old_ecf->use != ecf->use)
{
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"when the server runs without a master process "
"the \"%V\" event type must be the same as "
"in previous configuration - \"%s\" "
"and it can not be changed on the fly, "
"to change it you need to stop server "
"and start it again",
&value[1], old_ecf->name);
"when the server runs without a master process "
"the \"%V\" event type must be the same as "
"in previous configuration - \"%s\" "
"and it can not be changed on the fly, "
"to change it you need to stop server "
"and start it again",
&value[1], old_ecf->name);
return NGX_CONF_ERROR;
}
@ -726,99 +707,122 @@ static void *ngx_event_create_conf(ngx_cycle_t *cycle)
static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_event_conf_t *ecf = conf;
int fd, rtsig;
ngx_int_t i, connections;
ngx_module_t *module;
ngx_core_conf_t *ccf;
ngx_event_module_t *event_module;
connections = NGX_CONF_UNSET_UINT;
module = NULL;
rtsig = 0;
fd = 0;
#if (HAVE_EPOLL) && !(TEST_BUILD_EPOLL)
fd = epoll_create(100);
if (fd != -1) {
close(fd);
connections = DEFAULT_CONNECTIONS;
module = &ngx_epoll_module;
} else if (ngx_errno != NGX_ENOSYS) {
connections = DEFAULT_CONNECTIONS;
module = &ngx_epoll_module;
}
#endif
#if (HAVE_RTSIG)
ngx_core_conf_t *ccf;
if (module == NULL) {
connections = DEFAULT_CONNECTIONS;
module = &ngx_rtsig_module;
rtsig = 1;
}
#endif
#if (HAVE_DEVPOLL)
connections = DEFAULT_CONNECTIONS;
module = &ngx_devpoll_module;
#endif
#if (HAVE_KQUEUE)
ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
ngx_conf_init_unsigned_value(ecf->use, ngx_kqueue_module.ctx_index);
ngx_conf_init_ptr_value(ecf->name, ngx_kqueue_module_ctx.name->data);
connections = DEFAULT_CONNECTIONS;
module = &ngx_kqueue_module;
#elif (HAVE_DEVPOLL)
ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
ngx_conf_init_unsigned_value(ecf->use, ngx_devpoll_module.ctx_index);
ngx_conf_init_ptr_value(ecf->name, ngx_devpoll_module_ctx.name->data);
#elif (HAVE_EPOLL)
ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
ngx_conf_init_unsigned_value(ecf->use, ngx_epoll_module.ctx_index);
ngx_conf_init_ptr_value(ecf->name, ngx_epoll_module_ctx.name->data);
#elif (HAVE_RTSIG)
ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
ngx_conf_init_unsigned_value(ecf->use, ngx_rtsig_module.ctx_index);
ngx_conf_init_ptr_value(ecf->name, ngx_rtsig_module_ctx.name->data);
#elif (HAVE_SELECT)
#if (NGX_WIN32)
ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
#else
ngx_conf_init_unsigned_value(ecf->connections,
FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE : DEFAULT_CONNECTIONS);
#endif
ngx_conf_init_unsigned_value(ecf->use, ngx_select_module.ctx_index);
ngx_conf_init_ptr_value(ecf->name, ngx_select_module_ctx.name->data);
#if (HAVE_SELECT)
if (module == NULL) {
#if (NGX_WIN32)
connections = DEFAULT_CONNECTIONS;
#else
connections = FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE:
DEFAULT_CONNECTIONS;
#endif
module = &ngx_select_module;
}
ngx_int_t i, m;
ngx_event_module_t *module;
#endif
m = -1;
module = NULL;
if (module == NULL) {
for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->type == NGX_EVENT_MODULE) {
event_module = ngx_modules[i]->ctx;
for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->type == NGX_EVENT_MODULE) {
module = ngx_modules[i]->ctx;
if (ngx_strcmp(event_module->name->data, event_core_name.data)
== 0)
{
continue;
}
if (ngx_strcmp(module->name->data, event_core_name.data) == 0) {
continue;
module = ngx_modules[i];
break;
}
m = ngx_modules[i]->ctx_index;
break;
}
}
if (m == -1) {
if (module == NULL) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no events module found");
return NGX_CONF_ERROR;
}
ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
ngx_conf_init_unsigned_value(ecf->use, m);
ngx_conf_init_ptr_value(ecf->name, module->name->data);
#endif
ngx_conf_init_unsigned_value(ecf->connections, connections);
cycle->connection_n = ecf->connections;
ngx_conf_init_unsigned_value(ecf->use, module->ctx_index);
event_module = module->ctx;
ngx_conf_init_ptr_value(ecf->name, event_module->name->data);
ngx_conf_init_value(ecf->multi_accept, 0);
ngx_conf_init_value(ecf->accept_mutex, 1);
ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500);
#if (HAVE_RTSIG)
if (ecf->use == ngx_rtsig_module.ctx_index && ecf->accept_mutex == 0) {
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
ngx_core_module);
if (ccf->worker_processes) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
"the \"rtsig\" method requires "
"\"accept_mutex\" to be on");
return NGX_CONF_ERROR;
}
}
#endif
return NGX_CONF_OK;
if (!rtsig || ecf->accept_mutex) {
return NGX_CONF_OK;
}
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
if (ccf->worker_processes == 0) {
return NGX_CONF_OK;
}
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
"the \"rtsig\" method requires \"accept_mutex\" to be on");
return NGX_CONF_ERROR;
}

View File

@ -496,7 +496,7 @@ ngx_int_t ngx_send_lowat(ngx_connection_t *c, size_t lowat);
ngx_inline static int ngx_handle_read_event(ngx_event_t *rev, u_int flags)
static ngx_inline ngx_int_t ngx_handle_read_event(ngx_event_t *rev, u_int flags)
{
if (ngx_event_flags & NGX_USE_CLEAR_EVENT) {
@ -540,7 +540,7 @@ ngx_inline static int ngx_handle_read_event(ngx_event_t *rev, u_int flags)
}
ngx_inline static int ngx_handle_level_read_event(ngx_event_t *rev)
static ngx_inline ngx_int_t ngx_handle_level_read_event(ngx_event_t *rev)
{
if (ngx_event_flags & NGX_USE_LEVEL_EVENT) {
if (!rev->active && !rev->ready) {
@ -566,7 +566,8 @@ ngx_inline static int ngx_handle_level_read_event(ngx_event_t *rev)
}
ngx_inline static int ngx_handle_write_event(ngx_event_t *wev, size_t lowat)
static ngx_inline ngx_int_t ngx_handle_write_event(ngx_event_t *wev,
size_t lowat)
{
ngx_connection_t *c;
@ -622,7 +623,7 @@ ngx_inline static int ngx_handle_write_event(ngx_event_t *wev, size_t lowat)
}
ngx_inline static int ngx_handle_level_write_event(ngx_event_t *wev)
static ngx_inline ngx_int_t ngx_handle_level_write_event(ngx_event_t *wev)
{
if (ngx_event_flags & NGX_USE_LEVEL_EVENT) {
if (!wev->active && !wev->ready) {

View File

@ -14,10 +14,10 @@ static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p);
static ngx_int_t ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p);
static ngx_int_t ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p);
ngx_inline static void ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf);
ngx_inline static void ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free,
static ngx_inline void ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf);
static ngx_inline void ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free,
ngx_buf_t *buf);
ngx_inline static void ngx_event_pipe_add_free_buf(ngx_chain_t **chain,
static ngx_inline void ngx_event_pipe_add_free_buf(ngx_chain_t **chain,
ngx_chain_t *cl);
static ngx_int_t ngx_event_pipe_drain_chains(ngx_event_pipe_t *p);
@ -676,7 +676,7 @@ ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
}
ngx_inline static void ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf)
static ngx_inline void ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf)
{
ngx_buf_t *b, *next;
@ -706,7 +706,7 @@ ngx_inline static void ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf)
}
ngx_inline static void ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free,
static ngx_inline void ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free,
ngx_buf_t *buf)
{
ngx_buf_t *s;
@ -735,7 +735,7 @@ ngx_inline static void ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free,
}
ngx_inline static void ngx_event_pipe_add_free_buf(ngx_chain_t **chain,
static ngx_inline void ngx_event_pipe_add_free_buf(ngx_chain_t **chain,
ngx_chain_t *cl)
{
if (*chain == NULL) {

View File

@ -42,7 +42,7 @@ extern ngx_thread_volatile ngx_rbtree_t *ngx_event_timer_rbtree;
extern ngx_rbtree_t ngx_event_timer_sentinel;
ngx_inline static void ngx_event_del_timer(ngx_event_t *ev)
static ngx_inline void ngx_event_del_timer(ngx_event_t *ev)
{
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"event timer del: %d: %d",
@ -68,7 +68,7 @@ ngx_inline static void ngx_event_del_timer(ngx_event_t *ev)
}
ngx_inline static void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer)
static ngx_inline void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer)
{
ngx_int_t key;

View File

@ -304,10 +304,9 @@ static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r)
+ 1 /* 1 is for "/" */
+ entry[i].name.len + entry[i].escape
+ sizeof("\">") - 1
+ NGX_HTTP_AUTOINDEX_NAME_LEN
+ NGX_HTTP_AUTOINDEX_NAME_LEN + sizeof("&gt;") - 2
+ sizeof("</a>") - 1
+ 1
+ sizeof("28-Sep-1970 12:00 ") - 1
+ sizeof(" 28-Sep-1970 12:00 ") - 1
+ sizeof("1023G") - 1
+ 2;
}

View File

@ -340,7 +340,7 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
return NGX_ERROR;
}
boundary = ngx_next_temp_number(0);
boundary = (uint32_t) ngx_next_temp_number(0);
/*
* The boundary header of the range:

View File

@ -165,6 +165,13 @@ static ngx_command_t ngx_http_proxy_commands[] = {
offsetof(ngx_http_proxy_loc_conf_t, temp_path),
(void *) ngx_garbage_collector_temp_handler },
{ ngx_string("proxy_max_temp_file_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_proxy_loc_conf_t, max_temp_file_size),
NULL },
{ ngx_string("proxy_temp_file_write_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot,
@ -954,12 +961,7 @@ static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
conf->read_timeout = NGX_CONF_UNSET_MSEC;
conf->busy_buffers_size = NGX_CONF_UNSET_SIZE;
/*
* "proxy_max_temp_file_size" is hardcoded to 1G for reverse proxy,
* it should be configurable in the generic proxy
*/
conf->max_temp_file_size = 1024 * 1024 * 1024;
conf->max_temp_file_size = NGX_CONF_UNSET_SIZE;
conf->temp_file_write_size = NGX_CONF_UNSET_SIZE;
/* "proxy_cyclic_temp_file" is disabled */
@ -1059,11 +1061,25 @@ static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf,
prev->max_temp_file_size, NGX_CONF_UNSET_SIZE);
if (conf->max_temp_file_size == NGX_CONF_UNSET_SIZE) {
conf->max_temp_file_size = 2 * size;
} else if (conf->max_temp_file_size < size) {
/*
* "proxy_max_temp_file_size" is set to 1G for reverse proxy,
* it should be much less in the generic proxy
*/
conf->max_temp_file_size = 1024 * 1024 * 1024;
#if 0
conf->max_temp_file_size = 2 * size;
#endif
} else if (conf->max_temp_file_size != 0
&& conf->max_temp_file_size < size)
{
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"proxy_max_temp_file_size\" must be equal or bigger than "
"\"proxy_max_temp_file_size\" must be equal to zero to disable "
"the temporary files usage or must be equal or bigger than "
"maximum of the value of \"proxy_header_buffer_size\" and "
"one of the \"proxy_buffers\"");

View File

@ -13,7 +13,8 @@
#define NGX_HTTP_LOCATION_EXACT 1
#define NGX_HTTP_LOCATION_AUTO_REDIRECT 2
#define NGX_HTTP_LOCATION_REGEX 3
#define NGX_HTTP_LOCATION_NOREGEX 3
#define NGX_HTTP_LOCATION_REGEX 4
static void ngx_http_phase_event_handler(ngx_event_t *rev);
@ -564,12 +565,13 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
ngx_array_t *locations, size_t len)
{
ngx_int_t n, rc;
ngx_uint_t i, found;
ngx_uint_t i, found, noregex;
ngx_http_core_loc_conf_t *clcf, **clcfp;
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "find location");
found = 0;
noregex = 0;
clcfp = locations->elts;
for (i = 0; i < locations->nelts; i++) {
@ -619,6 +621,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
}
r->loc_conf = clcfp[i]->loc_conf;
noregex = clcfp[i]->noregex;
found = 1;
}
}
@ -637,6 +640,10 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
#if (NGX_PCRE)
if (noregex) {
return NGX_HTTP_LOCATION_NOREGEX;
}
/* regex matches */
for (/* void */; i < locations->nelts; i++) {
@ -1069,6 +1076,13 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
clcf->name = value[2];
clcf->exact_match = 1;
} else if (value[1].len == 2
&& value[1].data[0] == '^'
&& value[1].data[1] == '~')
{
clcf->name = value[2];
clcf->noregex = 1;
} else if ((value[1].len == 1 && value[1].data[0] == '~')
|| (value[1].len == 2
&& value[1].data[0] == '~'

View File

@ -142,6 +142,8 @@ struct ngx_http_core_loc_conf_s {
#endif
unsigned exact_match:1;
unsigned noregex:1;
unsigned auto_redirect:1;
unsigned alias:1;

View File

@ -34,6 +34,7 @@ typedef int ngx_err_t;
#define NGX_ETIMEDOUT ETIMEDOUT
#define NGX_ECONNREFUSED ECONNREFUSED
#define NGX_EHOSTUNREACH EHOSTUNREACH
#define NGX_ENOSYS ENOSYS
#define NGX_ECANCELED ECANCELED
#define NGX_ENOMOREFILES 0

View File

@ -109,7 +109,7 @@ ssize_t ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
}
int ngx_open_tempfile(u_char *name, ngx_uint_t persistent)
ngx_fd_t ngx_open_tempfile(u_char *name, ngx_uint_t persistent)
{
ngx_fd_t fd;
@ -216,7 +216,7 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl,
}
int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
{
dir->dir = opendir((const char *) name->data);

View File

@ -37,7 +37,7 @@
#define ngx_delete_file_n "unlink()"
int ngx_open_tempfile(u_char *name, ngx_uint_t persistent);
ngx_fd_t ngx_open_tempfile(u_char *name, ngx_uint_t persistent);
#define ngx_open_tempfile_n "open()"
@ -77,7 +77,7 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *ce,
#define NGX_DIR_MASK_LEN 0
int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
#define ngx_open_dir_n "opendir()"

View File

@ -60,41 +60,23 @@
#include <ngx_auto_config.h>
#ifndef HAVE_SELECT
#define HAVE_SELECT 1
#endif
#ifndef HAVE_POLL
#define HAVE_POLL 1
#endif
#if (HAVE_POLL)
#include <poll.h>
#endif
/* FreeBSD aio supported via kqueue */
#if (__FreeBSD__ == 4 && __FreeBSD_version >= 430000) \
|| __FreeBSD_version >= 500014
#ifndef HAVE_AIO
#define HAVE_AIO 1
#endif
#endif
#if (HAVE_AIO)
#include <aio.h>
#endif
#if defined SO_ACCEPTFILTER && !defined HAVE_DEFERRED_ACCEPT
#define HAVE_DEFERRED_ACCEPT 1
#if (HAVE_KQUEUE)
#include <sys/event.h>
#endif
#if (HAVE_KQUEUE)
#include <sys/event.h>
#if defined SO_ACCEPTFILTER && !defined HAVE_DEFERRED_ACCEPT
#define HAVE_DEFERRED_ACCEPT 1
#endif

View File

@ -63,19 +63,11 @@ extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);
#endif
#ifndef HAVE_SELECT
#define HAVE_SELECT 1
#endif
#ifndef HAVE_POLL
#define HAVE_POLL 1
#endif
#if (HAVE_POLL)
#include <poll.h>
#endif
#if (HAVE_EPOLL)
#include <sys/epoll.h>
#endif /* HAVE_EPOLL */

View File

@ -30,8 +30,9 @@ ngx_os_io_t ngx_os_io = {
ngx_int_t ngx_os_init(ngx_log_t *log)
{
int name[2];
size_t len;
int name[2];
size_t len;
ngx_err_t err;
name[0] = CTL_KERN;
name[1] = KERN_OSTYPE;
@ -58,10 +59,16 @@ ngx_int_t ngx_os_init(ngx_log_t *log)
name[1] = KERN_RTSIGMAX;
len = sizeof(ngx_linux_rtsig_max);
if (sysctl(name, sizeof(name), &ngx_linux_rtsig_max, &len, NULL, 0) == -1) {
ngx_log_error(NGX_LOG_INFO, log, ngx_errno,
"sysctl(KERN_RTSIGMAX) failed");
ngx_linux_rtsig_max = 0;
err = ngx_errno;
if (err != NGX_ENOTDIR) {
ngx_log_error(NGX_LOG_ALERT, log, err,
"sysctl(KERN_RTSIGMAX) failed");
return NGX_ERROR;
}
ngx_linux_rtsig_max = 0;
}
ngx_init_setproctitle(log);

View File

@ -14,6 +14,11 @@
#endif
#if 0
#define _REENTRANT
#endif
#include <sys/types.h>
#include <sys/time.h>
#if (NGX_HAVE_UNISTD_H)
@ -65,14 +70,6 @@
#include <ngx_auto_config.h>
#ifndef HAVE_SELECT
#define HAVE_SELECT 1
#endif
#ifndef HAVE_POLL
#define HAVE_POLL 1
#endif
#if (HAVE_POLL)
#include <poll.h>
#endif
@ -104,7 +101,11 @@
#endif
#if (NGX_HAVE_SETPROCTITLE)
#define ngx_setproctitle setproctitle
#else
#define ngx_setproctitle(title)
#endif
#define NGX_POSIX_IO 1

View File

@ -12,15 +12,18 @@
static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
ngx_int_t type);
static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type);
static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle);
static void ngx_master_exit(ngx_cycle_t *cycle);
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
static void ngx_worker_process_init(ngx_cycle_t *cycle);
static void ngx_channel_handler(ngx_event_t *ev);
#if (NGX_THREADS)
static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
static void *ngx_worker_thread_cycle(void *data);
#endif
static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data);
ngx_uint_t ngx_process;
@ -109,6 +112,7 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle)
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_RESPAWN);
ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
ngx_new_binary = 0;
delay = 0;
@ -179,6 +183,7 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle)
if (!ngx_noaccepting) {
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_JUST_RESPAWN);
ngx_start_garbage_collector(cycle, NGX_PROCESS_JUST_RESPAWN);
live = 1;
ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
@ -193,6 +198,7 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle)
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_RESPAWN);
ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
ngx_noaccepting = 0;
continue;
@ -211,6 +217,7 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle)
ngx_core_module);
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_JUST_RESPAWN);
ngx_start_garbage_collector(cycle, NGX_PROCESS_JUST_RESPAWN);
live = 1;
ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
@ -220,6 +227,7 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle)
ngx_restart = 0;
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_RESPAWN);
ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
live = 1;
}
@ -352,6 +360,47 @@ static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
}
static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
{
ngx_int_t i;
ngx_channel_t ch;
return;
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "start garbage collector");
ch.command = NGX_CMD_OPEN_CHANNEL;
ngx_spawn_process(cycle, ngx_garbage_collector_cycle, NULL,
"garbage collector", type);
ch.pid = ngx_processes[ngx_process_slot].pid;
ch.slot = ngx_process_slot;
ch.fd = ngx_processes[ngx_process_slot].channel[0];
for (i = 0; i < ngx_last_process; i++) {
if (i == ngx_process_slot
|| ngx_processes[i].pid == -1
|| ngx_processes[i].channel[0] == -1)
{
continue;
}
ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
"pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
ch.slot, ch.pid, ch.fd,
i, ngx_processes[i].pid,
ngx_processes[i].channel[0]);
/* TODO: NGX_AGAIN */
ngx_write_channel(ngx_processes[i].channel[0],
&ch, sizeof(ngx_channel_t), cycle->log);
}
}
static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
{
ngx_int_t i;
@ -558,116 +607,7 @@ static void ngx_master_exit(ngx_cycle_t *cycle)
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
{
sigset_t set;
ngx_err_t err;
ngx_int_t n;
ngx_uint_t i;
struct timeval tv;
ngx_listening_t *ls;
ngx_core_conf_t *ccf;
ngx_connection_t *c;
ngx_gettimeofday(&tv);
ngx_start_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000 + tv.tv_usec / 1000;
ngx_old_elapsed_msec = 0;
ngx_elapsed_msec = 0;
ngx_process = NGX_PROCESS_WORKER;
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
if (geteuid() == 0) {
if (setgid(ccf->group) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"setgid(%d) failed", ccf->group);
/* fatal */
exit(2);
}
if (setuid(ccf->user) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"setuid(%d) failed", ccf->user);
/* fatal */
exit(2);
}
}
#if (NGX_HAVE_PR_SET_DUMPABLE)
/* allow coredump after setuid() in Linux 2.4.x */
if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"prctl(PR_SET_DUMPABLE) failed");
}
#endif
sigemptyset(&set);
if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"sigprocmask() failed");
}
ngx_init_temp_number();
/*
* disable deleting previous events for the listening sockets because
* in the worker processes there are no events at all at this point
*/
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {
ls[i].remain = 0;
}
for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->init_process) {
if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
/* fatal */
exit(2);
}
}
}
for (n = 0; n < ngx_last_process; n++) {
if (ngx_processes[n].pid == -1) {
continue;
}
if (n == ngx_process_slot) {
continue;
}
if (ngx_processes[n].channel[1] == -1) {
continue;
}
if (close(ngx_processes[n].channel[1]) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"close() failed");
}
}
if (close(ngx_processes[ngx_process_slot].channel[0]) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"close() failed");
}
#if 0
ngx_last_process = 0;
#endif
if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT,
ngx_channel_handler) == NGX_ERROR)
{
/* fatal */
exit(2);
}
ngx_worker_process_init(cycle);
ngx_setproctitle("worker process");
@ -772,12 +712,129 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
}
static void ngx_worker_process_init(ngx_cycle_t *cycle)
{
sigset_t set;
ngx_int_t n;
ngx_uint_t i;
struct timeval tv;
ngx_core_conf_t *ccf;
ngx_listening_t *ls;
ngx_gettimeofday(&tv);
ngx_start_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000 + tv.tv_usec / 1000;
ngx_old_elapsed_msec = 0;
ngx_elapsed_msec = 0;
ngx_process = NGX_PROCESS_WORKER;
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
if (geteuid() == 0) {
if (setgid(ccf->group) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"setgid(%d) failed", ccf->group);
/* fatal */
exit(2);
}
if (setuid(ccf->user) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"setuid(%d) failed", ccf->user);
/* fatal */
exit(2);
}
}
#if (NGX_HAVE_PR_SET_DUMPABLE)
/* allow coredump after setuid() in Linux 2.4.x */
if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"prctl(PR_SET_DUMPABLE) failed");
}
#endif
sigemptyset(&set);
if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"sigprocmask() failed");
}
ngx_init_temp_number();
/*
* disable deleting previous events for the listening sockets because
* in the worker processes there are no events at all at this point
*/
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {
ls[i].remain = 0;
}
for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->init_process) {
if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
/* fatal */
exit(2);
}
}
}
for (n = 0; n < ngx_last_process; n++) {
if (ngx_processes[n].pid == -1) {
continue;
}
if (n == ngx_process_slot) {
continue;
}
if (ngx_processes[n].channel[1] == -1) {
continue;
}
if (close(ngx_processes[n].channel[1]) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"close() channel failed");
}
}
if (close(ngx_processes[ngx_process_slot].channel[0]) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"close() channel failed");
}
#if 0
ngx_last_process = 0;
#endif
if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT,
ngx_channel_handler) == NGX_ERROR)
{
/* fatal */
exit(2);
}
}
static void ngx_channel_handler(ngx_event_t *ev)
{
ngx_int_t n;
ngx_channel_t ch;
ngx_connection_t *c;
if (ev->timedout) {
ev->timedout = 0;
return;
}
c = ev->data;
ngx_log_debug0(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel handler");
@ -834,7 +891,8 @@ static void ngx_channel_handler(ngx_event_t *ev)
ngx_processes[ch.slot].channel[0]);
if (close(ngx_processes[ch.slot].channel[0]) == -1) {
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, "close() failed");
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
"close() channel failed");
}
ngx_processes[ch.slot].channel[0] = -1;
@ -896,7 +954,6 @@ static void *ngx_worker_thread_cycle(void *data)
ngx_err_t err;
ngx_core_tls_t *tls;
ngx_cycle_t *cycle;
struct timeval tv;
thr->cv->tid = ngx_thread_self();
@ -972,3 +1029,51 @@ static void *ngx_worker_thread_cycle(void *data)
}
#endif
static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
{
ngx_uint_t i;
ngx_gc_t ctx;
ngx_path_t **path;
ngx_event_t *ev;
ngx_worker_process_init(cycle);
ev = &cycle->read_events[ngx_channel];
ngx_accept_mutex = NULL;
ngx_setproctitle("garbage collector");
#if 0
ngx_add_timer(ev, 60 * 1000);
#endif
for ( ;; ) {
if (ngx_terminate || ngx_quit) {
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
exit(0);
}
if (ngx_reopen) {
ngx_reopen = 0;
ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs");
ngx_reopen_files(cycle, -1);
}
path = cycle->pathes.elts;
for (i = 0; i < cycle->pathes.nelts; i++) {
ctx.path = path[i];
ctx.log = cycle->log;
ctx.handler = path[i]->gc_handler;
ngx_collect_garbage(&ctx, &path[i]->name, 0);
}
ngx_add_timer(ev, 60 * 60 * 1000);
ngx_process_events(cycle);
}
}

View File

@ -36,7 +36,7 @@ void *ngx_create_shared_memory(size_t size, ngx_log_t *log)
if (fd == -1) {
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
"open(/dev/zero) failed");
"open(\"/dev/zero\") failed");
return NULL;
}
@ -49,7 +49,8 @@ void *ngx_create_shared_memory(size_t size, ngx_log_t *log)
}
if (close(fd) == -1) {
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed");
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
"close(\"/dev/zero\") failed");
}
return p;

View File

@ -49,14 +49,6 @@
#include <ngx_auto_config.h>
#ifndef HAVE_SELECT
#define HAVE_SELECT 1
#endif
#ifndef HAVE_POLL
#define HAVE_POLL 1
#endif
#if (HAVE_POLL)
#include <poll.h>
#endif

View File

@ -57,6 +57,7 @@ void ngx_localtime(ngx_tm_t *tm);
#define ngx_gettimeofday(tp) gettimeofday(tp, NULL);
#define ngx_msleep(ms) usleep(ms * 1000)
#define ngx_sleep(s) sleep(s)
#endif /* _NGX_TIME_H_INCLUDED_ */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 518 B

View File

@ -21,7 +21,10 @@ typedef DWORD ngx_err_t;
#define NGX_ENOENT ERROR_FILE_NOT_FOUND
#define NGX_EACCES ERROR_ACCESS_DENIED
#if 0
#define NGX_EEXIST ERROR_FILE_EXISTS
#endif
#define NGX_EEXIST ERROR_ALREADY_EXISTS
#define NGX_ENOTDIR ERROR_PATH_NOT_FOUND
#define NGX_EPIPE EPIPE
#define NGX_EAGAIN WSAEWOULDBLOCK

View File

@ -171,7 +171,8 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl,
}
int ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_pool_t *pool)
ngx_int_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to,
ngx_pool_t *pool)
{
int rc, collision;
u_int num;
@ -229,7 +230,7 @@ int ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_pool_t *pool)
#if 0
int ngx_file_info(char *file, ngx_file_info_t *sb)
ngx_int_t ngx_file_info(char *file, ngx_file_info_t *sb)
{
WIN32_FILE_ATTRIBUTE_DATA fa;
@ -252,7 +253,7 @@ int ngx_file_info(char *file, ngx_file_info_t *sb)
#endif
int ngx_file_info(u_char *file, ngx_file_info_t *sb)
ngx_int_t ngx_file_info(u_char *file, ngx_file_info_t *sb)
{
/* Win95 */
@ -266,7 +267,7 @@ int ngx_file_info(u_char *file, ngx_file_info_t *sb)
}
int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
{
ngx_cpystrn(name->data + name->len, NGX_DIR_MASK, NGX_DIR_MASK_LEN + 1);
@ -283,7 +284,7 @@ int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
}
int ngx_read_dir(ngx_dir_t *dir)
ngx_int_t ngx_read_dir(ngx_dir_t *dir)
{
if (dir->ready) {
dir->ready = 0;
@ -298,13 +299,25 @@ int ngx_read_dir(ngx_dir_t *dir)
}
int ngx_file_append_mode(ngx_fd_t fd)
ngx_int_t ngx_file_append_mode(ngx_fd_t fd)
{
#if 0
if (LockFile(fd, 0, 0, 0xffffffff, 0xffffffff) == 0) {
return NGX_ERROR;
}
#endif
if (SetFilePointer(fd, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER) {
if (ngx_errno != NO_ERROR) {
return NGX_ERROR;
}
}
#if 0
if (UnlockFile(fd, 0, 0, 0xffffffff, 0xffffffff) == 0) {
return NGX_ERROR;
}
#endif
return NGX_OK;
}

View File

@ -44,7 +44,7 @@
#define NGX_FILE_APPEND 0
int ngx_file_append_mode(ngx_fd_t fd);
ngx_int_t ngx_file_append_mode(ngx_fd_t fd);
#define ngx_file_append_mode_n "SetFilePointer()"
@ -71,10 +71,11 @@ int ngx_file_append_mode(ngx_fd_t fd);
#define ngx_rename_file MoveFile
#define ngx_rename_file_n "MoveFile()"
int ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to, ngx_pool_t *pool);
ngx_int_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to,
ngx_pool_t *pool);
int ngx_file_info(u_char *filename, ngx_file_info_t *fi);
ngx_int_t ngx_file_info(u_char *filename, ngx_file_info_t *fi);
#define ngx_file_info_n "GetFileAttributesEx()"
@ -109,11 +110,11 @@ int ngx_file_info(u_char *filename, ngx_file_info_t *fi);
#define NGX_DIR_MASK_LEN 2
int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
ngx_int_t ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
#define ngx_open_dir_n "FindFirstFile()"
int ngx_read_dir(ngx_dir_t *dir);
ngx_int_t ngx_read_dir(ngx_dir_t *dir);
#define ngx_read_dir_n "FindNextFile()"

View File

@ -98,7 +98,7 @@ extern LPFN_GETACCEPTEXSOCKADDRS getacceptexsockaddrs;
extern LPFN_TRANSMITFILE transmitfile;
ngx_inline static int ngx_tcp_push(ngx_socket_t s) {
static ngx_inline int ngx_tcp_push(ngx_socket_t s) {
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 198 B