Mercurial > hg > nginx
changeset 196:11fbd0fc041d
nginx-0.0.1-2003-11-26-18:42:18 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 26 Nov 2003 15:42:18 +0000 |
parents | 8dee38ea9117 |
children | 0b81c7a0b133 |
files | auto/fmt/fmt auto/fmt/xfmt auto/func auto/inc auto/init auto/os/conf auto/os/linux auto/os/solaris auto/sources auto/types/sizeof auto/types/typedef auto/types/uintptr_t auto/unix src/event/modules/ngx_kqueue_module.c src/os/unix/ngx_files.c src/os/unix/ngx_freebsd_config.h src/os/unix/ngx_freebsd_init.c src/os/unix/ngx_linux.h src/os/unix/ngx_linux_config.h src/os/unix/ngx_linux_init.c src/os/unix/ngx_linux_sendfile_chain.c src/os/unix/ngx_os.h src/os/unix/ngx_solaris_config.h src/os/unix/ngx_solaris_init.c |
diffstat | 24 files changed, 167 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/auto/fmt/fmt Tue Nov 25 20:44:56 2003 +0000 +++ b/auto/fmt/fmt Wed Nov 26 15:42:18 2003 +0000 @@ -5,8 +5,12 @@ for FMT in $NGX_FORMATS do - echo "#include <stdio.h>" >> autotest.c + echo "#include <stdio.h>" > autotest.c echo "#include <sys/types.h>" >> autotest.c + echo "#include <sys/time.h>" >> autotest.c + echo "#include <sys/resource.h>" >> autotest.c + echo "$NGX_INTTYPES_H" >> autotest.c + echo "$NGX_AUTO_CONFIG" >> autotest.c echo "int main() {" >> autotest.c echo "printf(\"${FMT}\", ($NGX_TYPE) $NGX_MAX_SIZE);" >> autotest.c echo "return 0; }" >> autotest.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/auto/fmt/xfmt Wed Nov 26 15:42:18 2003 +0000 @@ -0,0 +1,6 @@ + +echo "#ifndef $NGX_FMT_NAME" >> $NGX_AUTO_CONFIG_H +echo "#define $NGX_FMT_NAME \"$NGX_FMT\"" | sed -e 's/d"$/x"/' \ + >> $NGX_AUTO_CONFIG_H +echo "#endif" >> $NGX_AUTO_CONFIG_H +echo >> $NGX_AUTO_CONFIG_H
--- a/auto/func Tue Nov 25 20:44:56 2003 +0000 +++ b/auto/func Wed Nov 26 15:42:18 2003 +0000 @@ -1,19 +1,21 @@ echo "checking for $NGX_FUNC" +func=`echo $NGX_FUNC | sed -e 's/()$//' | tr '[a-z]' '[A-Z]'` + echo "$NGX_UNISTD_H" > autotest.c echo "$NGX_FUNC_INC" >> autotest.c echo "int main() { $NGX_FUNC_TEST; return 0; }" >> autotest.c -eval "${CC} -o autotest autotest.c > /dev/null 2>&1" +eval "$CC $CC_TEST_FLAGS -o autotest autotest.c > /dev/null 2>&1" if [ -x autotest ]; then echo " + $NGX_FUNC found" - echo "#ifndef $NGX_HAVE" >> $NGX_AUTO_CONFIG_H - echo "#define $NGX_HAVE 1" >> $NGX_AUTO_CONFIG_H - echo "#endif" >> $NGX_AUTO_CONFIG_H - echo >> $NGX_AUTO_CONFIG_H + echo "#ifndef HAVE_$func" >> $NGX_AUTO_CONFIG_H + echo "#define HAVE_$func 1" >> $NGX_AUTO_CONFIG_H + echo "#endif" >> $NGX_AUTO_CONFIG_H + echo >> $NGX_AUTO_CONFIG_H else echo " + $NGX_FUNC not found" fi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/auto/inc Wed Nov 26 15:42:18 2003 +0000 @@ -0,0 +1,25 @@ + +echo "checking for $NGX_INC" + +inc=`echo $NGX_INC | sed -e 's/\./_/' | tr '[a-z]' '[A-Z]'` + +echo "#include <$NGX_INC>" > autotest.c +echo "int main() { return 0; }" >> autotest.c + +eval "${CC} -o autotest autotest.c > /dev/null 2>&1" + +if [ -x autotest ]; then + echo " + $NGX_INC found" + + echo "#ifndef HAVE_$inc" >> $NGX_AUTO_CONFIG_H + echo "#define HAVE_$inc 1" >> $NGX_AUTO_CONFIG_H + echo "#endif" >> $NGX_AUTO_CONFIG_H + echo >> $NGX_AUTO_CONFIG_H + + eval "NGX_$inc='#include <$NGX_INC>'" + +else + echo " + $NGX_INC not found" +fi + +rm autotest*
--- a/auto/init Tue Nov 25 20:44:56 2003 +0000 +++ b/auto/init Wed Nov 26 15:42:18 2003 +0000 @@ -4,6 +4,4 @@ NGX_AUTO_CONFIG_H=$OBJS/ngx_auto_config.h NGX_MODULES_C=$OBJS/ngx_modules.c - -NGX_UNISTD_H="#include <unistd.h>" -NGX_INTTYPES_H="#include <inttypes.h>" +NGX_ERR=autoconf.err
--- a/auto/os/conf Tue Nov 25 20:44:56 2003 +0000 +++ b/auto/os/conf Wed Nov 26 15:42:18 2003 +0000 @@ -19,13 +19,12 @@ . auto/os/freebsd ;; - Solaris:*) - CC_TEST_FLAGS="-D_FILE_OFFSET_BITS=64" - CORE_LIBS="$CORE_LIBS -lsocket -lnsl" + Linux:*) + . auto/os/linux ;; - Linux:*) - CC_TEST_FLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" + SunOS:*) + . auto/os/solaris ;; win32)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/auto/os/linux Wed Nov 26 15:42:18 2003 +0000 @@ -0,0 +1,16 @@ + +CORE_INCS="$UNIX_INCS" +CORE_DEPS="$UNIX_DEPS $LINUX_DEPS" +CORE_SRCS="$UNIX_SRCS $LINUX_SRCS $SELECT_SRCS $POLL_SRCS" +EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE $POLL_MODULE" + +ZLIB_LIB="-lz" + + +# TODO check sendfile64() + +#CC_TEST_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" +CC_TEST_FLAGS="-D_GNU_SOURCE" + +# STUB +CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/auto/os/solaris Wed Nov 26 15:42:18 2003 +0000 @@ -0,0 +1,18 @@ + +CORE_INCS="$UNIX_INCS" +CORE_DEPS="$UNIX_DEPS $SOLARIS_DEPS" +CORE_SRCS="$UNIX_SRCS $SOLARIS_SRCS $SELECT_SRCS $POLL_SRCS" +EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE $POLL_MODULE" + +MD5_LIB="-lmd5" +ZLIB_LIB="-lz" + +CC_TEST_FLAGS="-D_FILE_OFFSET_BITS=64" + +CORE_LIBS="$CORE_LIBS -lsocket -lnsl" + +# STUB +CFLAGS="$CFLAGS -D HAVE_DEVPOLL=1" +EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE" +CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS" +#CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS"
--- a/auto/sources Tue Nov 25 20:44:56 2003 +0000 +++ b/auto/sources Wed Nov 26 15:42:18 2003 +0000 @@ -95,14 +95,21 @@ src/os/unix/ngx_process.c \ src/os/unix/ngx_daemon.c" - -LINUX_SENDFILE_SRCS=src/os/unix/ngx_linux_sendfile_chain.c - FREEBSD_DEPS=src/os/unix/ngx_freebsd_config.h FREEBSD_SRCS=src/os/unix/ngx_freebsd_init.c FREEBSD_SENDFILE_SRCS=src/os/unix/ngx_freebsd_sendfile_chain.c +LINUX_DEPS=src/os/unix/ngx_linux_config.h +LINUX_SRCS=src/os/unix/ngx_linux_init.c +LINUX_SENDFILE_SRCS=src/os/unix/ngx_linux_sendfile_chain.c + + +SOLARIS_DEPS=src/os/unix/ngx_solaris_config.h +SOLARIS_SRCS=src/os/unix/ngx_solaris_init.c +SOLARIS_SENDFILE_SRCS=src/os/unix/ngx_solaris_sendfilev_chain.c + + WIN32_INCS="$CORE_INCS $EVENT_INCS -I src/os/win32" WIN32_DEPS="$CORE_DEPS $EVENT_DEPS \
--- a/auto/types/sizeof Tue Nov 25 20:44:56 2003 +0000 +++ b/auto/types/sizeof Wed Nov 26 15:42:18 2003 +0000 @@ -4,6 +4,10 @@ NGX_BYTES= echo "#include <sys/types.h>" > autotest.c +echo "#include <sys/time.h>" >> autotest.c +echo "#include <sys/resource.h>" >> autotest.c +echo "$NGX_INTTYPES_H" >> autotest.c +echo "$NGX_AUTO_CONFIG" >> autotest.c echo "int main() {" >> autotest.c echo "printf(\"%d\", sizeof($NGX_TYPE));" >> autotest.c echo "return 0; }" >> autotest.c
--- a/auto/types/typedef Tue Nov 25 20:44:56 2003 +0000 +++ b/auto/types/typedef Wed Nov 26 15:42:18 2003 +0000 @@ -7,10 +7,13 @@ do echo "#include <sys/types.h>" > autotest.c echo "#include <sys/socket.h>" >> autotest.c + echo "#include <sys/time.h>" >> autotest.c + echo "#include <sys/resource.h>" >> autotest.c + echo "#include <netinet/in.h>" >> autotest.c echo "$NGX_INTTYPES_H" >> autotest.c echo "int main() { $TYPE i = 0; return 0; }" >> autotest.c - eval "$CC -o autotest autotest.c > /dev/null 2>&1" + eval "$CC -o autotest autotest.c > $NGX_ERR 2>&1" if [ -x autotest ]; then if [ $TYPE = $NGX_TYPE ]; then
--- a/auto/types/uintptr_t Tue Nov 25 20:44:56 2003 +0000 +++ b/auto/types/uintptr_t Wed Nov 26 15:42:18 2003 +0000 @@ -4,6 +4,7 @@ FOUND=NO echo "#include <sys/types.h>" > autotest.c +echo "$NGX_INTTYPES_H" >> autotest.c echo "int main() { uintptr_t i = 0; return 0; }" >> autotest.c eval "$CC -o autotest autotest.c > /dev/null 2>&1"
--- a/auto/unix Tue Nov 25 20:44:56 2003 +0000 +++ b/auto/unix Wed Nov 26 15:42:18 2003 +0000 @@ -2,6 +2,8 @@ CC_WARN=$CC NGX_FMT_COLLECT=YES +# C types + NGX_TYPE="int"; . auto/types/sizeof; NGX_FORMATS="%d"; . auto/fmt/fmt @@ -14,6 +16,32 @@ NGX_TYPE="void *"; . auto/types/sizeof; NGX_PTR_BYTES=$NGX_BYTES +# headers + +NGX_INC="unistd.h"; . auto/inc +NGX_INC="inttypes.h"; . auto/inc + +#POSIX types + +NGX_AUTO_CONFIG="#include \"$NGX_AUTO_CONFIG_H\"" + +NGX_TYPE="uint64_t" +NGX_TYPES="u_int64_t"; . auto/types/typedef + +NGX_TYPE="socklen_t" +NGX_TYPES="uint32_t"; . auto/types/typedef + +NGX_TYPE="in_addr_t" +NGX_TYPES="uint32_t"; . auto/types/typedef + +NGX_TYPE="rlim_t" +NGX_TYPES="int"; . auto/types/typedef + +. auto/types/uintptr_t + + +# printf() formats + CC_WARN=$CC_STRONG NGX_FMT_COLLECT=NO @@ -40,31 +68,22 @@ eval NGX_FORMATS=\${NGX_${NGX_BYTES}_FMT}; . auto/fmt/fmt -CC_WARN=$CC - -NGX_TYPE="uint64_t" -NGX_TYPES="u_int64_t"; . auto/types/typedef - -NGX_TYPE="socklen_t" -NGX_TYPES="u_int32_t"; . auto/types/typedef - -. auto/types/uintptr_t - +# syscalls and libc calls NGX_FUNC_INC= NGX_FUNC_TEST="int fd = 0; char buf[1]; size_t size = 1; ssize_t n; off_t offset = 0; n = pread(fd, buf, size, offset)" -NGX_HAVE=HAVE_PREAD; NGX_FUNC="pread()"; . auto/func +NGX_FUNC="pread()"; . auto/func NGX_FUNC_INC= NGX_FUNC_TEST="int fd = 1; char buf[1]; size_t size = 1; ssize_t n; off_t offset = 0; n = pwrite(fd, buf, size, offset)" -NGX_HAVE=HAVE_PWRITE; NGX_FUNC="pwrite()"; . auto/func +NGX_FUNC="pwrite()"; . auto/func NGX_FUNC_INC="#include <time.h>" NGX_FUNC_TEST="struct tm t; time_t c=0; localtime_r(&c, &t)" -NGX_HAVE=HAVE_LOCALTIME_R; NGX_FUNC="localtime_r()"; . auto/func +NGX_FUNC="localtime_r()"; . auto/func
--- a/src/event/modules/ngx_kqueue_module.c Tue Nov 25 20:44:56 2003 +0000 +++ b/src/event/modules/ngx_kqueue_module.c Wed Nov 26 15:42:18 2003 +0000 @@ -311,7 +311,12 @@ if (filter == EVFILT_VNODE) { change_list[nchanges].fflags = NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND - |NOTE_ATTRIB|NOTE_RENAME|NOTE_REVOKE; + |NOTE_ATTRIB|NOTE_RENAME +#if (__FreeBSD__ == 4 && __FreeBSD_version >= 430000) \ + || __FreeBSD_version >= 500018 + |NOTE_REVOKE +#endif + ; change_list[nchanges].data = 0; } else {
--- a/src/os/unix/ngx_files.c Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_files.c Wed Nov 26 15:42:18 2003 +0000 @@ -11,7 +11,7 @@ { ssize_t n; - ngx_log_debug(file->log, "read: %d, %x, %d, %qd" _ + ngx_log_debug(file->log, "read: %d, %x, %d, " OFF_T_FMT _ file->fd _ buf _ size _ offset); #if (HAVE_PREAD)
--- a/src/os/unix/ngx_freebsd_config.h Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_freebsd_config.h Wed Nov 26 15:42:18 2003 +0000 @@ -79,4 +79,5 @@ #define HAVE_LITTLE_ENDIAN 1 + #endif /* _NGX_FREEBSD_CONFIG_H_INCLUDED_ */
--- a/src/os/unix/ngx_freebsd_init.c Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_freebsd_init.c Wed Nov 26 15:42:18 2003 +0000 @@ -22,7 +22,7 @@ NULL, #if (HAVE_SENDFILE) ngx_freebsd_sendfile_chain, - NGX_HAVE_SENDFILE + NGX_IO_SENDFILE #else ngx_writev_chain, 0
--- a/src/os/unix/ngx_linux.h Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_linux.h Wed Nov 26 15:42:18 2003 +0000 @@ -2,7 +2,7 @@ #define _NGX_LINUX_H_INCLUDED_ -ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in) +ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in); #endif /* _NGX_LINUX_H_INCLUDED_ */
--- a/src/os/unix/ngx_linux_config.h Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_linux_config.h Wed Nov 26 15:42:18 2003 +0000 @@ -4,8 +4,10 @@ #define _GNU_SOURCE /* pread(), pwrite(), gethostname() */ +#if 0 #define _FILE_OFFSET_BITS 64 #define _LARGEFILE_SOURCE +#endif #include <unistd.h> @@ -24,8 +26,11 @@ #include <sys/ioctl.h> #include <sys/resource.h> #include <sys/sysctl.h> +#include <sys/wait.h> #include <sys/socket.h> +#include <sys/sendfile.h> #include <netinet/in.h> +#include <netinet/tcp.h> /* TCP_CORK */ #include <arpa/inet.h> #include <dirent.h> #include <netdb.h>
--- a/src/os/unix/ngx_linux_init.c Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_linux_init.c Wed Nov 26 15:42:18 2003 +0000 @@ -11,8 +11,8 @@ ngx_unix_recv, NULL, NULL, - ngx_writev_chain, - NGX_HAVE_ZEROCOPY + ngx_linux_sendfile_chain, + NGX_IO_SENDFILE };
--- a/src/os/unix/ngx_linux_sendfile_chain.c Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_linux_sendfile_chain.c Wed Nov 26 15:42:18 2003 +0000 @@ -8,7 +8,7 @@ { int rc; char *prev; - off_t fprev; + off_t offset; size_t size, fsize, sent; ngx_int_t use_cork, eintr; struct iovec *iov; @@ -16,7 +16,7 @@ ngx_hunk_t *file; ngx_array_t header; ngx_event_t *wev; - ngx_chain_t *cl; + ngx_chain_t *cl, *tail; wev = c->write; @@ -24,8 +24,6 @@ return in; } - cork = 0; - do { file = NULL; fsize = 0; @@ -84,20 +82,20 @@ file = cl->hunk; fsize = (size_t) (file->file_last - file->file_pos); - fprev = file->file_last; + offset = file->file_last; cl = cl->next; /* coalesce the neighbouring file hunks */ while (cl && (cl->hunk->type & NGX_HUNK_FILE)) { if (file->file->fd != cl->hunk->file->fd - || fprev != cl->hunk->file_pos) + || offset != cl->hunk->file_pos) { break; } fsize += (size_t) (cl->hunk->file_last - cl->hunk->file_pos); - fprev = cl->hunk->file_last; + offset = cl->hunk->file_last; cl = cl->next; } } @@ -110,7 +108,8 @@ tail = cl; if (fsize) { - rc = sendfile(c->fd, file->file->fd, file->file_pos, fsize); + offset = file->file_pos; + rc = sendfile(c->fd, file->file->fd, &offset, fsize); if (rc == -1) { err = ngx_errno;
--- a/src/os/unix/ngx_os.h Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_os.h Wed Nov 26 15:42:18 2003 +0000 @@ -57,4 +57,9 @@ #endif +#ifdef __linux__ +#include <ngx_linux.h> +#endif + + #endif /* _NGX_OS_H_INCLUDED_ */
--- a/src/os/unix/ngx_solaris_config.h Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_solaris_config.h Wed Nov 26 15:42:18 2003 +0000 @@ -17,8 +17,9 @@ #include <fcntl.h> #include <signal.h> #include <strings.h> - #include <sys/types.h> +#include <sys/stat.h> +#include <sys/wait.h> #include <sys/filio.h> /* FIONBIO */ #include <sys/stropts.h> /* INFTIM */ #include <sys/socket.h> @@ -26,16 +27,7 @@ #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> - - -#if 0 -#define OFF_FMT "%lld" -#define SIZE_FMT "%d" -#define SIZEX_FMT "%x" -#define TIME_FMT "%ld" -#define PID_FMT "%ld" -#define RLIM_FMT "%lu" -#endif +#include <dirent.h> #ifndef HAVE_SELECT
--- a/src/os/unix/ngx_solaris_init.c Tue Nov 25 20:44:56 2003 +0000 +++ b/src/os/unix/ngx_solaris_init.c Wed Nov 26 15:42:18 2003 +0000 @@ -13,7 +13,7 @@ NULL, NULL, ngx_writev_chain, - NGX_HAVE_ZEROCOPY + 0 }; @@ -40,7 +40,7 @@ return NGX_ERROR; } - ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %s %s" + ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %s %s", ngx_solaris_sysname, ngx_solaris_release); ngx_log_error(NGX_LOG_INFO, log, 0, "version: %s",