From fc5a10aedcdd8cf261ecc164941562bc52fe415d Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Tue, 9 Mar 2004 19:47:07 +0000 Subject: [PATCH] nginx-0.0.2-2004-03-09-22:47:07 import --- auto/cc | 48 ++++++++++--- auto/init | 3 + auto/lib/make | 26 +++----- auto/lib/md5/conf | 26 ++++++-- auto/lib/md5/make | 44 ++++++++++-- auto/lib/md5/makefile.msvc | 8 +-- auto/lib/md5/makefile.owc | 12 ++++ auto/lib/pcre/conf | 63 ++++++++++------- auto/lib/pcre/make | 50 ++++++++++++-- auto/lib/pcre/makefile.msvc | 14 ++-- auto/lib/pcre/makefile.owc | 14 ++++ auto/lib/pcre/patch.config | 11 +++ auto/lib/pcre/patch.pcre | 15 +++++ auto/lib/zlib/conf | 26 ++++++-- auto/lib/zlib/make | 55 ++++++++++++--- auto/lib/zlib/makefile.msvc | 8 +++ auto/lib/zlib/makefile.owc | 6 ++ auto/make | 63 +++++++++++++++-- auto/os/conf | 4 +- auto/sources | 2 + auto/summary | 1 + src/core/nginx.c | 89 +++++++++++++------------ src/core/nginx.h | 3 +- src/core/ngx_connection.c | 2 +- src/core/ngx_cycle.c | 4 ++ src/event/modules/ngx_iocp_module.c | 2 +- src/http/modules/ngx_http_gzip_filter.c | 2 +- src/http/ngx_http_core_module.c | 5 +- src/http/ngx_http_log_handler.c | 3 - src/os/win32/ngx_process_cycle.c | 18 +++++ src/os/win32/ngx_socket.h | 56 ++++++++++++++++ src/os/win32/ngx_win32_config.h | 15 ++--- src/os/win32/ngx_win32_init.c | 35 ++++++---- src/os/win32/ngx_wsarecv.c | 2 +- 34 files changed, 554 insertions(+), 181 deletions(-) create mode 100644 auto/lib/md5/makefile.owc create mode 100644 auto/lib/pcre/makefile.owc create mode 100644 auto/lib/pcre/patch.config create mode 100644 auto/lib/pcre/patch.pcre create mode 100644 auto/lib/zlib/makefile.msvc create mode 100644 auto/lib/zlib/makefile.owc diff --git a/auto/cc b/auto/cc index 0fb96322e..4365ce6df 100644 --- a/auto/cc +++ b/auto/cc @@ -31,8 +31,10 @@ case $CC in have=HAVE_GCC_VARIADIC_MACROS . auto/have + LINK="\$(CC)" + OBJEXT=o - COMPILEONLY="-c " + COMPILEONLY="-c" OBJOUT="-o " BINOUT="-o " @@ -58,8 +60,10 @@ case $CC in have=HAVE_C99_VARIADIC_MACROS . auto/have + LINK="\$(CC)" + OBJEXT=o - COMPILEONLY="-c " + COMPILEONLY="-c" OBJOUT="-o " BINOUT="-o " @@ -100,11 +104,14 @@ case $CC in # disable logo CFLAGS="$CFLAGS -nologo" + LINK="\$(CC)" + # link flags CORE_LINK="$CORE_LINK -link" # msvcrt.dll CORE_LINK="$CORE_LINK -nodefaultlib:libcmt" + CORE_LIBS="$CORE_LIBS msvcrt.lib" # static libc #CORE_LINK="$CORE_LINK -nodefaultlib:msvcrt" @@ -115,16 +122,23 @@ case $CC in CFLAGS="$CFLAGS -Yd" CORE_LINK="$CORE_LINK -debug -debugtype:coff" + # precompiled headers + CORE_DEPS="$CORE_DEPS ngx_config.pch" + PCH="ngx_config.pch" + BUILDPCH="-Ycngx_config.h" + USEPCH="-Yungx_config.h" + OBJEXT=obj - COMPILEONLY="-c " + COMPILEONLY="-c" OBJOUT="-Fo" BINOUT="-Fe" + BINEXT=.exe CC_STRONG="$CC -W3 -WX" ;; - wcc386) + wcl386) # Open Watcom 1.0 # optimization @@ -139,16 +153,18 @@ case $CC in CFLAGS="$CFLAGS -oe" # disable stack checking calls CFLAGS="$CFLAGS -s" - # optimize for Pentium Pro - #CFLAGS="$CFLAGS -6r" - CFLAGS="$CFLAGS -6s" + # optimize for Pentium Pro, register-based arguments + OWC_OPT="-6r" + # optimize for Pentium Pro, stack-based arguments + #OWC_OPT="-6s" + CFLAGS="$CFLAGS $OWC_OPT" # warnings #CFLAGS="$CFLAGS -w3" CFLAGS="$CFLAGS -wx" # stop on warning - #CFLAGS="$CFLAGS -we" + CFLAGS="$CFLAGS -we" # built target is NT CFLAGS="$CFLAGS -bt=nt" @@ -162,13 +178,23 @@ case $CC in # quiet CFLAGS="$CFLAGS -zq" - # link traget is NT + # precompiled headers + CORE_DEPS="$CORE_DEPS $OBJS\\ngx_config.pch" + PCH="$OBJS\\ngx_config.pch" + BUILDPCH="-fhq=$OBJS\\ngx_config.pch" + USEPCH="-fh=$OBJS\\ngx_config.pch" + + LINK="\$(CC)" + + # link flags CORE_LINK="$CORE_LINK -l=nt" OBJEXT=obj - COMPILEONLY= + COMPILEONLY="-c" OBJOUT="-fo" - BINOUT="-fo" + BINOUT="-fe=" + BINEXT=.exe + INC_EQ=YES MAKE_BS=YES MAKE_SL=YES diff --git a/auto/init b/auto/init index 03e8a2b2d..2cc024abd 100644 --- a/auto/init +++ b/auto/init @@ -9,7 +9,10 @@ NGX_ERR=$OBJS/autoconf.err CC_WARN=$CC +PCH=NO +USEPCH= +BINEXT= INC_EQ=NO MAKE_BS=NO MAKE_SL=NO diff --git a/auto/lib/make b/auto/lib/make index 8bb32ca35..66568e6f5 100644 --- a/auto/lib/make +++ b/auto/lib/make @@ -1,18 +1,12 @@ -if [ "$PLATFORM" != "win32" ]; then - - if [ $PCRE != NO ]; then - . auto/lib/pcre/make - fi - - - if [ $MD5 != NO ]; then - . auto/lib/md5/make - fi - - - if [ $ZLIB != NO ]; then - . auto/lib/zlib/make - fi - +if [ $MD5 != NO ]; then + . auto/lib/md5/make +fi + +if [ $ZLIB != NO ]; then + . auto/lib/zlib/make +fi + +if [ $PCRE != NO ]; then + . auto/lib/pcre/make fi diff --git a/auto/lib/md5/conf b/auto/lib/md5/conf index 06006e456..3c7878382 100644 --- a/auto/lib/md5/conf +++ b/auto/lib/md5/conf @@ -12,13 +12,25 @@ if [ $MD5 != NONE ]; then CORE_INCS="$CORE_INCS -I $MD5" - if [ "$PLATFORM" = "win32" ]; then - CORE_LIBS="$CORE_LIBS md5.lib" - CORE_LINK="$CORE_LINK -libpath:$MD5" - else - LINK_DEPS="$LINK_DEPS $MD5/libmd5.a" - CORE_LIBS="$CORE_LIBS -L $MD5 -lmd5" - fi + case $CC in + + cl) + LINK_DEPS="$LINK_DEPS $MD5/md5.lib" + CORE_LIBS="$CORE_LIBS md5.lib" + CORE_LINK="$CORE_LINK -libpath:$MD5" + ;; + + wcl386) + LINK_DEPS="$LINK_DEPS $MD5/md5.lib" + CORE_LIBS="$CORE_LIBS $MD5/md5.lib" + ;; + + *) + LINK_DEPS="$LINK_DEPS $MD5/libmd5.a" + CORE_LIBS="$CORE_LIBS -L $MD5 -lmd5" + ;; + + esac else diff --git a/auto/lib/md5/make b/auto/lib/md5/make index 0b4d92773..43d35bf6a 100644 --- a/auto/lib/md5/make +++ b/auto/lib/md5/make @@ -1,24 +1,56 @@ -echo "$MD5/libmd5.a:" >> $MAKEFILE +case $CC in + + cl) + makefile=makefile.msvc + ;; + + wcl386) + makefile=makefile.owc + ;; + +esac + case $PLATFORM in + win32) + echo "$MD5/md5.lib:" >> $MAKEFILE + ;; + + *) + echo "$MD5/libmd5.a:" >> $MAKEFILE + ;; + +esac + + +case $PLATFORM in + + win32) + + cp auto/lib/md5/$makefile $MD5 + echo " cd $MD5" >> $MAKEFILE + echo " \$(MAKE) -f $makefile OWC_OPT=$OWC_OPT" >> $MAKEFILE + echo " cd ..\\..\\.." >> $MAKEFILE + ;; + SunOS:*:i386) - echo " cd $MD5 && \$(MAKE) x86-solaris" >> $MAKEFILE + echo " cd $MD5 && \$(MAKE) x86-solaris" >> $MAKEFILE ;; *:i386) - echo " cd $MD5 && \$(MAKE) x86-elf" >> $MAKEFILE + echo " cd $MD5 && \$(MAKE) x86-elf" >> $MAKEFILE ;; *) if [ $CC = gcc ]; then - echo " cd $MD5 && \$(MAKE) gcc" >> $MAKEFILE + echo " cd $MD5 && \$(MAKE) gcc" >> $MAKEFILE else - echo " cd $MD5 && \$(MAKE) cc" >> $MAKEFILE + echo " cd $MD5 && \$(MAKE) cc" >> $MAKEFILE fi ;; esac -echo >> $MAKEFILE +echo >> $MAKEFILE diff --git a/auto/lib/md5/makefile.msvc b/auto/lib/md5/makefile.msvc index a45fc52eb..3dbda09ee 100644 --- a/auto/lib/md5/makefile.msvc +++ b/auto/lib/md5/makefile.msvc @@ -1,6 +1,6 @@ -all: - cl -nologo -c -MT -O2 -Ob1 -Oi -Gs -D MD5_ASM -D L_ENDIAN \ - md5_dgst.c md5_one.c +CFLAGS = -nologo -c -MT -O2 -Ob1 -Oi -Gs -D MD5_ASM -D L_ENDIAN - link -lib -out:md5.lib md5_dgst.obj md5_one.obj asm/m-win32.obj +md5.lib: + cl $(CFLAGS) md5_dgst.c + link -lib -out:md5.lib md5_dgst.obj asm/m-win32.obj diff --git a/auto/lib/md5/makefile.owc b/auto/lib/md5/makefile.owc new file mode 100644 index 000000000..f3209409e --- /dev/null +++ b/auto/lib/md5/makefile.owc @@ -0,0 +1,12 @@ + +CFLAGS = -c -zq -bt=nt -ot -op -oi -oe -s $(OWC_OPT) + +md5.lib: + wcl386 $(CFLAGS) -bm -dL_ENDIAN md5_dgst.c + wlib -n md5.lib md5_dgst.obj + +#md5.lib: +asm: + wcl386 $(CFLAGS) -bm -dMD5_ASM -dL_ENDIAN md5_dgst.c + wcl386 $(CFLAGS) asm\m-win32.asm + wlib -n md5.lib md5_dgst.obj m-win32.obj diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf index 436bee2dd..6d4b53806 100644 --- a/auto/lib/pcre/conf +++ b/auto/lib/pcre/conf @@ -4,37 +4,54 @@ if [ $PCRE != NONE ]; then CORE_DEPS="$CORE_DEPS $REGEX_DEPS" CORE_SRCS="$CORE_SRCS $REGEX_SRCS" - if [ "$PLATFORM" = "win32" ]; then - have=HAVE_PCRE . auto/have - have=PCRE_STATIC . auto/have - CORE_LIBS="$CORE_LIBS pcre.lib" - CORE_LINK="$CORE_LINK -libpath:$PCRE" - else - have=HAVE_PCRE . auto/have - CORE_DEPS="$CORE_DEPS $PCRE/.libs/libpcre.a" - CORE_LIBS="$CORE_LIBS -L $PCRE/.libs -lpcre" - fi + case $CC in + + cl) + have=HAVE_PCRE . auto/have + have=PCRE_STATIC . auto/have + CORE_DEPS="$CORE_DEPS $PCRE/pcre.lib" + #CORE_DEPS="$PCRE/pcre.lib $CORE_DEPS" + CORE_LIBS="$CORE_LIBS pcre.lib" + CORE_LINK="$CORE_LINK -libpath:$PCRE" + ;; + + wcl386) + have=HAVE_PCRE . auto/have + have=PCRE_STATIC . auto/have + CORE_DEPS="$CORE_DEPS $PCRE/pcre.lib" + CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib" + ;; + + *) + have=HAVE_PCRE . auto/have + CORE_DEPS="$CORE_DEPS $PCRE/.libs/libpcre.a" + CORE_LIBS="$CORE_LIBS -L $PCRE/.libs -lpcre" + ;; + + esac else - ngx_lib_inc="#include " + if [ $PLATFORM != win32 ]; then + ngx_lib_inc="#include " - ngx_lib="PCRE" - ngx_lib_test="pcre *re; pcre_compile(re, 0, NULL, 0, NULL)" - ngx_libs=-lpcre - . auto/lib/test + ngx_lib="PCRE" + ngx_lib_test="pcre *re; pcre_compile(re, 0, NULL, 0, NULL)" + ngx_libs=-lpcre + . auto/lib/test - if [ $ngx_found = yes ]; then - have=HAVE_PCRE . auto/have + if [ $ngx_found = yes ]; then + have=HAVE_PCRE . auto/have - CORE_DEPS="$CORE_DEPS $REGEX_DEPS" - CORE_SRCS="$CORE_SRCS $REGEX_SRCS" - CORE_LIBS="$CORE_LIBS $ngx_libs" + CORE_DEPS="$CORE_DEPS $REGEX_DEPS" + CORE_SRCS="$CORE_SRCS $REGEX_SRCS" + CORE_LIBS="$CORE_LIBS $ngx_libs" - PCRE=YES - else - PCRE=NO + PCRE=YES + else + PCRE=NO + fi fi fi diff --git a/auto/lib/pcre/make b/auto/lib/pcre/make index 836668619..6ea086da6 100644 --- a/auto/lib/pcre/make +++ b/auto/lib/pcre/make @@ -1,7 +1,47 @@ -echo "$PCRE/.libs/libpcre.a:" >> $MAKEFILE -echo " cd $PCRE \\" >> $MAKEFILE -echo " && ./configure --disable-shared \\" >> $MAKEFILE -echo " && \$(MAKE)" >> $MAKEFILE -echo >> $MAKEFILE +case $CC in + cl) + makefile=makefile.msvc + ;; + + wcl386) + makefile=makefile.owc + ;; + +esac + + +case $PLATFORM in + + win32) + echo "$PCRE/pcre.lib:" >> $MAKEFILE + ;; + + *) + echo "$PCRE/.libs/libpcre.a:" >> $MAKEFILE + ;; + +esac + + +case $PLATFORM in + + win32) + cp auto/lib/pcre/patch.pcre $PCRE + cp auto/lib/pcre/patch.config $PCRE + cp auto/lib/pcre/$makefile $PCRE + echo " cd $PCRE" >> $MAKEFILE + echo " \$(MAKE) -f $makefile OWC_OPT=$OWC_OPT" >> $MAKEFILE + echo " cd ..\\..\\.." >> $MAKEFILE + ;; + + *) + echo " cd $PCRE \\" >> $MAKEFILE + echo " && ./configure --disable-shared \\" >> $MAKEFILE + echo " && \$(MAKE)" >> $MAKEFILE + ;; + +esac + +echo >> $MAKEFILE diff --git a/auto/lib/pcre/makefile.msvc b/auto/lib/pcre/makefile.msvc index e5c2aec29..0eeb310ab 100644 --- a/auto/lib/pcre/makefile.msvc +++ b/auto/lib/pcre/makefile.msvc @@ -1,18 +1,18 @@ -CC = cl CFLAGS = -O2 -Ob1 -Oi -Gs -MT -LINK = link - PCREFLAGS = -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 -all: - $(CC) -Fedftables dftables.c +pcre.lib: + patch -o pcre.h pcre.in patch.pcre + patch -o config.h config.in patch.config + + cl -Fedftables dftables.c dftables > chartables.c - $(CC) -nologo -c $(CFLAGS) $(PCREFLAGS) \ + cl -nologo -c $(CFLAGS) $(PCREFLAGS) \ maketables.c get.c study.c pcre.c - $(LINK) -lib -out:pcre.lib -verbose:lib \ + link -lib -out:pcre.lib -verbose:lib \ maketables.obj get.obj study.obj pcre.obj diff --git a/auto/lib/pcre/makefile.owc b/auto/lib/pcre/makefile.owc new file mode 100644 index 000000000..f4244a6c0 --- /dev/null +++ b/auto/lib/pcre/makefile.owc @@ -0,0 +1,14 @@ + +CFLAGS = -c -zq -bt=nt -ot -op -oi -oe -s -bm $(OWC_OPT) +PCREFLAGS = -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 + + +pcre.lib: + patch -o pcre.h pcre.in patch.pcre + patch -o config.h config.in patch.config + + wcl386 -zq -bt=nt -l=nt -fe=dftables dftables.c + dftables > chartables.c + + wcl386 $(CFLAGS) $(PCREFLAGS) maketables.c get.c study.c pcre.c + wlib -n pcre.lib maketables.obj get.obj study.obj pcre.obj diff --git a/auto/lib/pcre/patch.config b/auto/lib/pcre/patch.config new file mode 100644 index 000000000..f2c48c281 --- /dev/null +++ b/auto/lib/pcre/patch.config @@ -0,0 +1,11 @@ +--- config.in.orig Thu Aug 21 14:43:07 2003 ++++ config.in Sun Mar 7 02:37:24 2004 +@@ -28,7 +28,7 @@ + found. */ + + #define HAVE_STRERROR 0 +-#define HAVE_MEMMOVE 0 ++#define HAVE_MEMMOVE 1 + + /* There are some non-Unix systems that don't even have bcopy(). If this macro + is false, an emulation is used. If HAVE_MEMMOVE is set to 1, the value of diff --git a/auto/lib/pcre/patch.pcre b/auto/lib/pcre/patch.pcre new file mode 100644 index 000000000..3406548b5 --- /dev/null +++ b/auto/lib/pcre/patch.pcre @@ -0,0 +1,15 @@ +--- pcre.in.orig Thu Aug 21 14:43:07 2003 ++++ pcre.in Sun Mar 7 02:10:11 2004 +@@ -10,9 +10,9 @@ + /* The file pcre.h is build by "configure". Do not edit it; instead + make changes to pcre.in. */ + +-#define PCRE_MAJOR @PCRE_MAJOR@ +-#define PCRE_MINOR @PCRE_MINOR@ +-#define PCRE_DATE @PCRE_DATE@ ++#define PCRE_MAJOR 4 ++#define PCRE_MINOR 4 ++#define PCRE_DATE 21-August-2003 + + /* Win32 uses DLL by default */ + diff --git a/auto/lib/zlib/conf b/auto/lib/zlib/conf index 60fd8d880..a779b21b6 100644 --- a/auto/lib/zlib/conf +++ b/auto/lib/zlib/conf @@ -2,13 +2,25 @@ if [ $ZLIB != NONE ]; then CORE_INCS="$CORE_INCS -I $ZLIB" - if [ "$PLATFORM" = "win32" ]; then - CORE_LIBS="$CORE_LIBS zlib.lib" - CORE_LINK="$CORE_LINK -libpath:$ZLIB" - else - LINK_DEPS="$LINK_DEPS $ZLIB/libz.a" - CORE_LIBS="$CORE_LIBS -L $ZLIB -lz" - fi + case $CC in + + cl) + LINK_DEPS="$LINK_DEPS $ZLIB/zlib.lib" + CORE_LIBS="$CORE_LIBS zlib.lib" + CORE_LINK="$CORE_LINK -libpath:$ZLIB" + ;; + + wcl386) + LINK_DEPS="$LINK_DEPS $ZLIB/zlib.lib" + CORE_LIBS="$CORE_LIBS $ZLIB/zlib.lib" + ;; + + *) + LINK_DEPS="$LINK_DEPS $ZLIB/libz.a" + CORE_LIBS="$CORE_LIBS -L $ZLIB -lz" + ;; + + esac else diff --git a/auto/lib/zlib/make b/auto/lib/zlib/make index 78022c379..05b2e86fa 100644 --- a/auto/lib/zlib/make +++ b/auto/lib/zlib/make @@ -1,19 +1,52 @@ -echo "$ZLIB/libz.a:" >> $MAKEFILE +case $CC in -case $PLATFORM in - - *:i386) - echo " cd $ZLIB \\" >> $MAKEFILE - echo " && cp contrib/asm686/match.S . \\" >> $MAKEFILE - echo " && CFLAGS=\"-O3 -DASMV\" ./configure \\" >> $MAKEFILE - echo " && \$(MAKE) OBJA=match.o" >> $MAKEFILE + cl) + makefile=makefile.msvc ;; - *) - echo " cd $ZLIB && ./configure && \$(MAKE)" >> $MAKEFILE + wcl386) + makefile=makefile.owc ;; esac -echo >> $MAKEFILE + +case $PLATFORM in + + win32) + echo "$ZLIB/zlib.lib:" >> $MAKEFILE + ;; + + *) + echo "$ZLIB/libz.a:" >> $MAKEFILE + ;; + +esac + + +case $PLATFORM in + + win32) + + cp auto/lib/zlib/$makefile $ZLIB + echo " cd $ZLIB" >> $MAKEFILE + echo " \$(MAKE) -f $makefile OWC_OPT=$OWC_OPT" >> $MAKEFILE + echo " cd ..\\..\\.." >> $MAKEFILE + ;; + + + *:i386) + echo " cd $ZLIB \\" >> $MAKEFILE + echo " && cp contrib/asm686/match.S . \\" >> $MAKEFILE + echo " && CFLAGS=\"-O3 -DASMV\" ./configure \\" >> $MAKEFILE + echo " && \$(MAKE) OBJA=match.o" >> $MAKEFILE + ;; + + *) + echo " cd $ZLIB && ./configure && \$(MAKE)" >> $MAKEFILE + ;; + +esac + +echo >> $MAKEFILE diff --git a/auto/lib/zlib/makefile.msvc b/auto/lib/zlib/makefile.msvc new file mode 100644 index 000000000..69f0c1897 --- /dev/null +++ b/auto/lib/zlib/makefile.msvc @@ -0,0 +1,8 @@ + +CFLAGS = -nologo -c -MT -O2 -Ob1 -Oi -Gs + +zlib.lib: + cl $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c + + link -lib -out:zlib.lib adler32.obj crc32.obj deflate.obj \ + trees.obj zutil.obj diff --git a/auto/lib/zlib/makefile.owc b/auto/lib/zlib/makefile.owc new file mode 100644 index 000000000..3fa026040 --- /dev/null +++ b/auto/lib/zlib/makefile.owc @@ -0,0 +1,6 @@ + +CFLAGS = -c -zq -bt=nt -ot -op -oi -oe -s -bm $(OWC_OPT) + +zlib.lib: + wcl386 $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c + wlib -n zlib.lib adler32.obj crc32.obj deflate.obj trees.obj zutil.obj diff --git a/auto/make b/auto/make index 5a019db3d..c9e672f1b 100644 --- a/auto/make +++ b/auto/make @@ -5,10 +5,31 @@ mkdir -p $OBJS/src/core $OBJS/src/event $OBJS/src/event/modules \ echo "CC = $CC" > $MAKEFILE +echo "LINK = $LINK" >> $MAKEFILE +if [ $CC = wcl386 ]; then + echo MAKE = wmake >> $MAKEFILE +fi echo "CFLAGS = $CFLAGS" >> $MAKEFILE echo >> $MAKEFILE +if [ $MAKE_SL = YES ]; then + echo >> $MAKEFILE +fi + +all_inc="$CORE_INCS -I $OBJS $HTTP_INCS" +if [ $INC_EQ = YES ]; then + all_inc=`echo $all_inc | sed -e "s/-I /-i=/g"` +fi + +if [ $MAKE_BS = YES ]; then + all_inc=`echo $all_inc | sed -e "s/\//\\\\\\/g"` +fi + +echo "ALL_INCS = $all_inc" >> $MAKEFILE +echo >> $MAKEFILE + + # CORE_DEPS if [ $MAKE_SL = YES ]; then @@ -96,9 +117,9 @@ echo >> $MAKEFILE # nginx if [ $MAKE_SL = YES ]; then - echo $ngx_n "nginx: " $ngx_c >> $MAKEFILE + echo $ngx_n "nginx$BINEXT: " $ngx_c >> $MAKEFILE else - echo "nginx: \\" >> $MAKEFILE + echo "nginx$BINEXT: \\" >> $MAKEFILE fi @@ -140,9 +161,9 @@ echo >> $MAKEFILE # nginx build if [ $MAKE_SL = YES ]; then - echo $ngx_n " \$(CC) ${BINOUT}nginx" $ngx_c >> $MAKEFILE + echo $ngx_n " \$(LINK) ${BINOUT}nginx" $ngx_c >> $MAKEFILE else - echo " \$(CC) ${BINOUT}nginx \\" >> $MAKEFILE + echo " \$(LINK) ${BINOUT}nginx \\" >> $MAKEFILE fi @@ -190,7 +211,12 @@ fi # ngx_modules.c deps="\$(CORE_DEPS)" -args="\$(CFLAGS) \$(CORE_INCS)" + +if [ $PCH != NO ]; then + args="\$(CFLAGS) $USEPCH \$(ALL_INCS)" +else + args="\$(CFLAGS) $USEPCH \$(CORE_INCS)" +fi if [ $MAKE_SL = YES ]; then echo "$obj: $NGX_MODULES_C $deps" >> $MAKEFILE @@ -237,7 +263,12 @@ done # http sources deps="\$(CORE_DEPS) \$(HTTP_DEPS)" -args="\$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS)" + +if [ $PCH != NO ]; then + args="\$(CFLAGS) $USEPCH \$(ALL_INCS)" +else + args="\$(CFLAGS) $USEPCH \$(CORE_INCS) \$(HTTP_INCS)" +fi for src in $HTTP_SRCS do @@ -262,3 +293,23 @@ do echo >> $MAKEFILE fi done + + +# precompiled headers + +if [ $PCH != NO ]; then + echo "#include " > $OBJS/pch.c + + pch="$PCH: src/core/ngx_config.h $OS_CONFIG $OBJS/ngx_auto_config.h" + src="\$(CC) \$(CFLAGS) $BUILDPCH $COMPILEONLY \$(ALL_INCS)" + src="$src $OBJOUT$OBJS/pch.obj $OBJS/pch.c" + + if [ $MAKE_BS = YES ]; then + pch=`echo $pch | sed -e "s/\//\\\\\\/g"` + src=`echo $src | sed -e "s/\//\\\\\\/g"` + fi + + echo "$pch" >> $MAKEFILE + echo " $src" >> $MAKEFILE + echo >> $MAKEFILE +fi diff --git a/auto/os/conf b/auto/os/conf index 4ae08e856..2a6f99e8c 100644 --- a/auto/os/conf +++ b/auto/os/conf @@ -31,15 +31,13 @@ case $PLATFORM in CORE_INCS="$WIN32_INCS" CORE_DEPS="$WIN32_DEPS" CORE_SRCS="$WIN32_SRCS $SELECT_SRCS $IOCP_SRCS" + OS_CONFIG="$WIN32_CONFIG" EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE $IOCP_MODULE" EVENT_FOUND=YES have=HAVE_AIO . auto/have have=HAVE_IOCP . auto/have CORE_LIBS="$CORE_LIBS ws2_32.lib" - - # msvcrt.dll - CORE_LIBS="$CORE_LIBS msvcrt.lib" ;; esac diff --git a/auto/sources b/auto/sources index 026a5e0c5..f744ac537 100644 --- a/auto/sources +++ b/auto/sources @@ -148,6 +148,8 @@ WIN32_DEPS="$CORE_DEPS $EVENT_DEPS \ src/os/win32/ngx_os.h \ src/os/win32/ngx_process_cycle.h" +WIN32_CONFIG=src/os/win32/ngx_win32_config.h + WIN32_SRCS="$CORE_SRCS $EVENT_SRCS \ src/os/win32/ngx_errno.c \ src/os/win32/ngx_files.c \ diff --git a/auto/summary b/auto/summary index 5dacfc140..e0d8b2664 100644 --- a/auto/summary +++ b/auto/summary @@ -8,6 +8,7 @@ if [ $USE_PCRE = DISABLED ]; then else case $PCRE in YES) echo " + using system PCRE library" ;; + NONE) echo " + PCRE library is not used" ;; NO) echo " + PCRE library is not found" ;; *) echo " + using PCRE library: $PCRE" ;; esac diff --git a/src/core/nginx.c b/src/core/nginx.c index ef4ceca81..5515b906e 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -35,7 +35,7 @@ static int ngx_worker_thread_cycle(void *data); #endif -static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp); +static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle); static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle); static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle); static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); @@ -112,7 +112,7 @@ ngx_int_t ngx_reopen; ngx_int_t ngx_change_binary; -int main(int argc, char *const *argv, char **envp) +int main(int argc, char *const *argv) { ngx_int_t i; ngx_log_t *log; @@ -145,6 +145,10 @@ int main(int argc, char *const *argv, char **envp) init_cycle.log = log; ngx_cycle = &init_cycle; +#if 0 + /* STUB */ log->log_level = NGX_LOG_DEBUG_ALL; +#endif + ngx_memzero(&ctx, sizeof(ngx_master_ctx_t)); ctx.argc = argc; ctx.argv = argv; @@ -172,7 +176,7 @@ int main(int argc, char *const *argv, char **envp) return 1; } - if (ngx_add_inherited_sockets(&init_cycle, envp) == NGX_ERROR) { + if (ngx_add_inherited_sockets(&init_cycle) == NGX_ERROR) { return 1; } @@ -256,49 +260,48 @@ int main(int argc, char *const *argv, char **envp) } -static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp) +static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle) { - char *p, *v; + char *p, *v, *inherited; ngx_socket_t s; ngx_listening_t *ls; - for ( /* void */ ; *envp; envp++) { - if (ngx_strncmp(*envp, NGINX_VAR, NGINX_VAR_LEN) != 0) { - continue; - } + inherited = getenv(NGINX_VAR); - ngx_log_error(NGX_LOG_INFO, cycle->log, 0, - "using inherited sockets from \"%s\"", *envp); - - ngx_init_array(cycle->listening, cycle->pool, - 10, sizeof(ngx_listening_t), NGX_ERROR); - - for (p = *envp + NGINX_VAR_LEN, v = p; *p; p++) { - if (*p == ':' || *p == ';') { - s = ngx_atoi(v, p - v); - if (s == NGX_ERROR) { - ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, - "invalid socket number \"%s\" " - "in NGINX enviroment variable, " - "ignoring the rest of the variable", v); - break; - } - v = p + 1; - - if (!(ls = ngx_push_array(&cycle->listening))) { - return NGX_ERROR; - } - - ls->fd = s; - } - } - - ngx_inherited = 1; - - return ngx_set_inherited_sockets(cycle); + if (inherited == NULL) { + return NGX_OK; } - return NGX_OK; + ngx_log_error(NGX_LOG_INFO, cycle->log, 0, + "using inherited sockets from \"%s\"", inherited); + + ngx_init_array(cycle->listening, cycle->pool, + 10, sizeof(ngx_listening_t), NGX_ERROR); + + for (p = inherited, v = p; *p; p++) { + if (*p == ':' || *p == ';') { + s = ngx_atoi(v, p - v); + if (s == NGX_ERROR) { + ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, + "invalid socket number \"%s\" in " + NGINX_VAR " enviroment variable, " + "ignoring the rest of the variable", v); + break; + } + + v = p + 1; + + if (!(ls = ngx_push_array(&cycle->listening))) { + return NGX_ERROR; + } + + ls->fd = s; + } + } + + ngx_inherited = 1; + + return ngx_set_inherited_sockets(cycle); } @@ -314,17 +317,19 @@ ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv) ctx.name = "new binary process"; ctx.argv = argv; - var = ngx_alloc(NGINX_VAR_LEN - + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 1, + var = ngx_alloc(sizeof(NGINX_VAR) + + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2, cycle->log); - p = ngx_cpymem(var, NGINX_VAR, NGINX_VAR_LEN); + p = ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR)); ls = cycle->listening.elts; for (i = 0; i < cycle->listening.nelts; i++) { p += ngx_snprintf(p, NGX_INT32_LEN + 2, "%u;", ls[i].fd); } + ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, "inherited: %s", var); + env[0] = var; env[1] = NULL; ctx.envp = (char *const *) &env; diff --git a/src/core/nginx.h b/src/core/nginx.h index 6680de165..870368807 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,8 +8,7 @@ #define NGINX_NEW_PID_EXT ".newbin" #define NGINX_NEW_PID NGINX_PID NGINX_NEW_PID_EXT -#define NGINX_VAR "NGINX=" -#define NGINX_VAR_LEN (sizeof(NGINX_VAR) - 1) +#define NGINX_VAR "NGINX" extern ngx_module_t ngx_core_module; diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 8a858735e..54fd0f9f1 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -78,7 +78,7 @@ ngx_int_t ngx_open_listening_sockets(ngx_cycle_t *cycle) /* TODO: tries configurable */ - for (tries = 10; tries; tries--) { + for (tries = /* STUB */ 1; tries; tries--) { failed = 0; /* for each listening socket */ diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index 3827c0d4e..7fcc67908 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -227,9 +227,13 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) } #if (WIN32) +#if 0 /* TODO: TEST */ +fprintf(stderr, "BEFORE\n"); CloseHandle(GetStdHandle(STD_ERROR_HANDLE)); SetStdHandle(STD_ERROR_HANDLE, cycle->log->file->fd); +fprintf(stderr, "AFTER\n"); +#endif #else if (dup2(cycle->log->file->fd, STDERR_FILENO) == NGX_ERROR) { ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, diff --git a/src/event/modules/ngx_iocp_module.c b/src/event/modules/ngx_iocp_module.c index e0a042c9c..2056fd6dd 100644 --- a/src/event/modules/ngx_iocp_module.c +++ b/src/event/modules/ngx_iocp_module.c @@ -245,7 +245,7 @@ static ngx_int_t ngx_iocp_process_events(ngx_log_t *log) ev->available = bytes; ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, - "iocp event handler: %08x" PTR_FMT, ev->event_handler); + "iocp event handler: " PTR_FMT, ev->event_handler); ev->event_handler(ev); } diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index 9cf377e33..b68ca31b5 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -549,9 +549,9 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size) static void ngx_http_gzip_filter_free(void *opaque, void *address) { +#if 0 ngx_http_gzip_ctx_t *ctx = opaque; -#if 0 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0, "gzip free: %X", address); #endif diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 20c7a5594..e717a6ac7 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -844,13 +844,16 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) { char *rv; ngx_int_t m; - ngx_str_t *value, err; + ngx_str_t *value; ngx_http_module_t *module; ngx_conf_t pvcf; ngx_http_conf_ctx_t *ctx, *pvctx; ngx_http_core_srv_conf_t *cscf; ngx_http_core_loc_conf_t *clcf, **clcfp; +#if (HAVE_PCRE) + ngx_str_t err; char errstr[NGX_MAX_CONF_ERRSTR]; +#endif if (!(ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)))) { return NGX_CONF_ERROR; diff --git a/src/http/ngx_http_log_handler.c b/src/http/ngx_http_log_handler.c index b34bd1bf2..f2ac5a33b 100644 --- a/src/http/ngx_http_log_handler.c +++ b/src/http/ngx_http_log_handler.c @@ -95,9 +95,6 @@ ngx_module_t ngx_http_log_module = { static ngx_str_t http_access_log = ngx_string("access.log"); -static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - static ngx_str_t ngx_http_combined_fmt = ngx_string("%addr - - [%time] \"%request\" %status %apache_length " "\"%{Referer}i\" \"%{User-Agent}i\""); diff --git a/src/os/win32/ngx_process_cycle.c b/src/os/win32/ngx_process_cycle.c index 8ffef52dc..7b26d6b35 100644 --- a/src/os/win32/ngx_process_cycle.c +++ b/src/os/win32/ngx_process_cycle.c @@ -25,4 +25,22 @@ sig_atomic_t ngx_change_binary; void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx) { + ngx_int_t i; + + ngx_init_temp_number(); + + 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 ( ;; ) { + ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle"); + + ngx_process_events(cycle->log); + } } diff --git a/src/os/win32/ngx_socket.h b/src/os/win32/ngx_socket.h index 86231030f..ec519c31c 100644 --- a/src/os/win32/ngx_socket.h +++ b/src/os/win32/ngx_socket.h @@ -35,6 +35,62 @@ int ngx_blocking(ngx_socket_t s); #define ngx_close_socket_n "closesocket()" +#ifndef WSAID_ACCEPTEX + +typedef BOOL (PASCAL FAR * LPFN_ACCEPTEX)( + IN SOCKET sListenSocket, + IN SOCKET sAcceptSocket, + IN PVOID lpOutputBuffer, + IN DWORD dwReceiveDataLength, + IN DWORD dwLocalAddressLength, + IN DWORD dwRemoteAddressLength, + OUT LPDWORD lpdwBytesReceived, + IN LPOVERLAPPED lpOverlapped + ); + +#define WSAID_ACCEPTEX \ + {0xb5367df1,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} + +#endif + + +#ifndef WSAID_GETACCEPTEXSOCKADDRS + +typedef VOID (PASCAL FAR * LPFN_GETACCEPTEXSOCKADDRS)( + IN PVOID lpOutputBuffer, + IN DWORD dwReceiveDataLength, + IN DWORD dwLocalAddressLength, + IN DWORD dwRemoteAddressLength, + OUT struct sockaddr **LocalSockaddr, + OUT LPINT LocalSockaddrLength, + OUT struct sockaddr **RemoteSockaddr, + OUT LPINT RemoteSockaddrLength + ); + +#define WSAID_GETACCEPTEXSOCKADDRS \ + {0xb5367df2,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} + +#endif + + +#ifndef LPFN_TRANSMITFILE + +typedef BOOL (PASCAL FAR * LPFN_TRANSMITFILE)( + IN SOCKET hSocket, + IN HANDLE hFile, + IN DWORD nNumberOfBytesToWrite, + IN DWORD nNumberOfBytesPerSend, + IN LPOVERLAPPED lpOverlapped, + IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, + IN DWORD dwReserved + ); + +#define WSAID_TRANSMITFILE \ + {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} + +#endif + + extern LPFN_ACCEPTEX acceptex; extern LPFN_GETACCEPTEXSOCKADDRS getacceptexsockaddrs; extern LPFN_TRANSMITFILE transmitfile; diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h index b1d7d5781..38cca91e5 100644 --- a/src/os/win32/ngx_win32_config.h +++ b/src/os/win32/ngx_win32_config.h @@ -7,13 +7,9 @@ #define STRICT #define WIN32_LEAN_AND_MEAN -#ifdef __WATCOMC__ -#pragma disable_message(107) -#endif - /* * we need to include windows.h explicity before winsock2.h because - * warning 4201 is enabled in windows.h + * the warning 4201 is enabled in windows.h */ #include @@ -35,19 +31,16 @@ #pragma warning(disable:4100) /* STUB */ +#if 0 #pragma warning(disable:4127) #endif +#endif #ifdef __WATCOMC__ -#pragma enable_message(107) -#if 0 -/* Symbol 'ngx_rbtree_min' has been defined, but not referenced */ +/* disable "Symbol 'ngx_rbtree_min' has been defined, but not referenced" */ #pragma disable_message(202) #endif -/* No prototype found for 'stricmp' */ -#pragma disable_message(301) -#endif #include diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c index aaeca21b8..c4ffc1121 100644 --- a/src/os/win32/ngx_win32_init.c +++ b/src/os/win32/ngx_win32_init.c @@ -17,6 +17,13 @@ ngx_os_io_t ngx_os_io = { }; +typedef struct { + WORD wServicePackMinor; + WORD wSuiteMask; + BYTE wProductType; +} ngx_osviex_stub_t; + + /* Should these pointers be per protocol ? */ LPFN_ACCEPTEX acceptex; LPFN_GETACCEPTEXSOCKADDRS getacceptexsockaddrs; @@ -29,11 +36,12 @@ static GUID tf_guid = WSAID_TRANSMITFILE; int ngx_os_init(ngx_log_t *log) { - u_int osviex; - DWORD bytes; - SOCKET s; - WSADATA wsd; - OSVERSIONINFOEX osvi; + u_int osviex; + DWORD bytes; + SOCKET s; + WSADATA wsd; + OSVERSIONINFOEX osvi; + ngx_osviex_stub_t *osviex_stub; /* get Windows version */ @@ -75,17 +83,16 @@ int ngx_os_init(ngx_log_t *log) ngx_win32_version += osvi.wServicePackMajor * 10 + osvi.wServicePackMinor; - ngx_log_error(NGX_LOG_INFO, log, 0, - "OS: %u build:%u, \"%s\", suite:%x, type:%u", - ngx_win32_version, osvi.dwBuildNumber, osvi.szCSDVersion, - osvi.wReserved[0], osvi.wReserved[1]); + /* + * the MSVC 6.0 SP2 defines wSuiteMask and wProductType + * as WORD wReserved[2] + */ + osviex_stub = (ngx_osviex_stub_t *) &osvi.wServicePackMinor; -#if 0 ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %u build:%u, \"%s\", suite:%x, type:%u", ngx_win32_version, osvi.dwBuildNumber, osvi.szCSDVersion, - osvi.wSuiteMask, osvi.wProductType); -#endif + osviex_stub->wSuiteMask, osviex_stub->wProductType); } else { if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { @@ -123,6 +130,10 @@ int ngx_os_init(ngx_log_t *log) return NGX_ERROR; } + if (ngx_win32_version < NGX_WIN_NT) { + return NGX_OK; + } + /* get AcceptEx(), GetAcceptExSockAddrs() and TransmitFile() addresses */ s = ngx_socket(AF_INET, SOCK_STREAM, IPPROTO_IP, 0); diff --git a/src/os/win32/ngx_wsarecv.c b/src/os/win32/ngx_wsarecv.c index 2de1110c0..040adc4da 100644 --- a/src/os/win32/ngx_wsarecv.c +++ b/src/os/win32/ngx_wsarecv.c @@ -64,7 +64,7 @@ ssize_t ngx_overlapped_wsarecv(ngx_connection_t *c, char *buf, size_t size) rev = c->read; if (!rev->ready) { - ngx_log_error(NGX_LOG_ALERT, rev->log, 0, "second wsa post"); + ngx_log_error(NGX_LOG_ALERT, c->log, 0, "second wsa post"); return NGX_AGAIN; }