changeset 248:e885208c518b

nginx-0.0.2-2004-02-03-00:19:52 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 02 Feb 2004 21:19:52 +0000
parents 008276b9e061
children 2a0540287298
files auto/configure auto/have auto/lib/md5/conf auto/make auto/modules auto/options auto/os/conf auto/os/freebsd auto/os/linux auto/os/solaris auto/sources src/core/nginx.c src/core/nginx.h src/core/ngx_config.h src/event/modules/ngx_kqueue_module.c src/event/modules/ngx_poll_module.c src/event/modules/ngx_select_module.c src/event/ngx_event.c src/event/ngx_event.h src/event/ngx_event_accept.c src/os/unix/ngx_aio_write_chain.c src/os/unix/ngx_errno.h src/os/unix/ngx_linux_config.h src/os/unix/ngx_process.c src/os/unix/ngx_process.h
diffstat 25 files changed, 237 insertions(+), 157 deletions(-) [+]
line wrap: on
line diff
--- a/auto/configure
+++ b/auto/configure
@@ -3,15 +3,17 @@
 . auto/init
 . auto/sources
 
+echo > $NGX_AUTO_CONFIG_H
+
 . auto/os/conf
+. auto/modules
 
 . auto/cc
 . auto/lib/conf
+
 . auto/make
 . auto/lib/make
 
-echo > $NGX_AUTO_CONFIG_H
-
 if [ "$PLATFORM" != win32 ]; then
     . auto/unix
 fi
new file mode 100644
--- /dev/null
+++ b/auto/have
@@ -0,0 +1,8 @@
+
+cat << END >> $NGX_AUTO_CONFIG_H
+
+#ifndef $have
+#define $have  1
+#endif
+
+END
--- a/auto/lib/md5/conf
+++ b/auto/lib/md5/conf
@@ -4,7 +4,7 @@ if [ $MD5 != NO ]; then
     if grep MD5_Init $MD5/md5.h >/dev/null; then
         # OpenSSL md5
         OPENSSL_MD5=YES
-        CFLAGS="$CFLAGS -D HAVE_OPENSSL_MD5"
+        have=HAVE_OPENSSL_MD5 . auto/have
     else
         # rsaref md5
         OPENSSL_MD5=NO
@@ -60,7 +60,7 @@ ngx_lib_inc="#include <sys/types.h>
 
 
     if [ $ngx_found = yes ]; then
-        CFLAGS="$CFLAGS -D HAVE_OPENSSL_MD5"
+        have=HAVE_OPENSSL_MD5 . auto/have
         CORE_LIBS="$CORE_LIBS $ngx_libs"
         MD5=YES
     fi
--- a/auto/make
+++ b/auto/make
@@ -4,35 +4,6 @@ mkdir -p $OBJS/src/core $OBJS/src/event 
          $OBJS/src/http $OBJS/src/http/modules $OBJS/src/http/modules/proxy
 
 
-HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES \
-                     $HTTP_CHUNKED_FILTER_MODULE \
-                     $HTTP_RANGE_FILTER_MODULE \
-                     $HTTP_CHARSET_FILTER_MODULE"
-
-HTTP_MODULES="$HTTP_MODULES $HTTP_STATIC_MODULE $HTTP_INDEX_MODULE"
-
-if [ $HTTP_REWRITE = YES ]; then
-    HTTP_MODULES="$HTTP_MODULES $HTTP_REWRITE_MODULE"
-    HTTP_SRCS="$HTTP_SRCS $HTTP_REWRITE_SRCS"
-fi
-
-if [ $HTTP_GZIP = YES ]; then
-    HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_GZIP_FILTER_MODULE"
-    HTTP_SRCS="$HTTP_SRCS $HTTP_GZIP_SRCS"
-fi
-
-if [ $HTTP_SSI = YES ]; then
-    HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_SSI_FILTER_MODULE"
-    HTTP_SRCS="$HTTP_SRCS $HTTP_SSI_SRCS"
-fi
-
-if [ $HTTP_PROXY = YES ]; then
-    HTTP_MODULES="$HTTP_MODULES $HTTP_PROXY_MODULE"
-    HTTP_INCS="$HTTP_INCS $HTTP_PROXY_INCS"
-    HTTP_DEPS="$HTTP_DEPS $HTTP_PROXY_DEPS"
-    HTTP_SRCS="$HTTP_SRCS $HTTP_PROXY_SRCS"
-fi
-
 modules="$CORE_MODULES $EVENT_MODULES $HTTP_MODULES \
          $HTTP_FILTER_MODULES $HTTP_NOT_MODIFIED_FILTER_MODULE"
 
new file mode 100644
--- /dev/null
+++ b/auto/modules
@@ -0,0 +1,32 @@
+
+HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES \
+                     $HTTP_CHUNKED_FILTER_MODULE \
+                     $HTTP_RANGE_FILTER_MODULE \
+                     $HTTP_CHARSET_FILTER_MODULE"
+
+HTTP_MODULES="$HTTP_MODULES $HTTP_STATIC_MODULE $HTTP_INDEX_MODULE"
+
+if [ $HTTP_REWRITE = YES ]; then
+    USE_PCRE=YES
+    HTTP_MODULES="$HTTP_MODULES $HTTP_REWRITE_MODULE"
+    HTTP_SRCS="$HTTP_SRCS $HTTP_REWRITE_SRCS"
+fi
+
+if [ $HTTP_GZIP = YES ]; then
+    USE_ZLIB=YES
+    HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_GZIP_FILTER_MODULE"
+    HTTP_SRCS="$HTTP_SRCS $HTTP_GZIP_SRCS"
+fi
+
+if [ $HTTP_SSI = YES ]; then
+    HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_SSI_FILTER_MODULE"
+    HTTP_SRCS="$HTTP_SRCS $HTTP_SSI_SRCS"
+fi
+
+if [ $HTTP_PROXY = YES ]; then
+    USE_MD5=YES
+    HTTP_MODULES="$HTTP_MODULES $HTTP_PROXY_MODULE"
+    HTTP_INCS="$HTTP_INCS $HTTP_PROXY_INCS"
+    HTTP_DEPS="$HTTP_DEPS $HTTP_PROXY_DEPS"
+    HTTP_SRCS="$HTTP_SRCS $HTTP_PROXY_SRCS"
+fi
--- a/auto/options
+++ b/auto/options
@@ -8,8 +8,11 @@ TEST_BUILD_DEVPOLL=NO
 TEST_BUILD_EPOLL=NO
 TEST_BUILD_SIGIO=NO
 
-SELECT=YES
-POLL=YES
+EVENT_FOUND=NO
+
+EVENT_SELECT=NO
+EVENT_POLL=NO
+EVENT_AIO=NO
 
 HTTP_REWRITE=YES
 HTTP_GZIP=YES
@@ -18,11 +21,11 @@ HTTP_PROXY=YES
 
 PCRE=NO
 
-USE_MD5=YES
+USE_MD5=NO
 MD5=NO
 MD5_LIB=NO
 
-USE_ZLIB=YES
+USE_ZLIB=NO
 ZLIB=NO
 ZLIB_LIB=NO
 
@@ -41,8 +44,9 @@ do
 
         --builddir=*)                    OBJS="$value"              ;;
 
-        --without-select_module)         SELECT=NO                  ;;
-        --without-poll_module)           POLL=NO                    ;;
+        --with-select_module)            EVENT_SELECT=YES           ;;
+        --with-poll_module)              EVENT_POLL=YES             ;;
+        --with-aio_module)               EVENT_AIO=YES              ;;
 
         --without-http_rewrite_module)   HTTP_REWRITE=NO            ;;
         --without-http_ssi_module)       HTTP_SSI=NO                ;;
--- a/auto/os/conf
+++ b/auto/os/conf
@@ -43,6 +43,18 @@ case $PLATFORM in
 esac
 
 
+if [ $EVENT_SELECT = YES -o $EVENT_FOUND = NO ]; then
+    CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
+    EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
+fi
+
+
+if [ $EVENT_POLL = YES -o $EVENT_FOUND = NO ]; then
+    CORE_SRCS="$CORE_SRCS $POLL_SRCS"
+    EVENT_MODULES="$EVENT_MODULES $POLL_MODULE"
+fi
+
+
 if [ $TEST_BUILD_DEVPOLL = YES ]; then
     CFLAGS="$CFLAGS -D HAVE_DEVPOLL=1 -D TEST_BUILD_DEVPOLL=1"
     EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
--- a/auto/os/freebsd
+++ b/auto/os/freebsd
@@ -7,16 +7,6 @@ CORE_SRCS="$UNIX_SRCS $FREEBSD_SRCS"
 MD5_LIB="-lmd"
 ZLIB_LIB="-lz"
 
-if [ $SELECT = YES ]; then
-    CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
-    EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
-fi
-
-if [ $POLL = YES ]; then
-    CORE_SRCS="$CORE_SRCS $POLL_SRCS"
-    EVENT_MODULES="$EVENT_MODULES $POLL_MODULE"
-fi
-
 version=`grep "#define __FreeBSD_version" /usr/include/osreldate.h \
          | sed -e 's/^.* \(.*\)$/\1/'`
 
@@ -24,7 +14,7 @@ version=`grep "#define __FreeBSD_version
 # sendfile
 
 if [ $version -gt 300007 ]; then
-    CFLAGS="$CFLAGS -D HAVE_SENDFILE=1"
+    have=HAVE_SENDFILE . auto/have
     CORE_SRCS="$CORE_SRCS $FREEBSD_SENDFILE_SRCS"
 fi
 
@@ -34,9 +24,11 @@ fi
 if [ \( $version -lt 500000 -a $version -ge 410000 \) \
      -o $version -ge 500011 ]
 then
-    CFLAGS="$CFLAGS -D HAVE_KQUEUE=1 -D HAVE_CLEAR_EVENT=1"
+    have=HAVE_KQUEUE . auto/have
+    have=HAVE_CLEAR_EVENT . auto/have
     CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
     EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
+    EVENT_FOUND=YES
 fi
 
 
@@ -45,5 +37,11 @@ fi
 if [ \( $version -lt 500000 -a $version -ge 430000 \) \
      -o $version -ge 500018 ]
 then
-    CFLAGS="$CFLAGS -D HAVE_LOWAT_EVENT=1"
+    have=HAVE_LOWAT_EVENT . auto/have
 fi
+
+
+if [ $EVENT_AIO = YES ]; then
+    CORE_SRCS="$CORE_SRCS $AIO_SRCS"
+    EVENT_MODULES="$EVENT_MODULES $AIO_MODULE"
+fi
--- a/auto/os/linux
+++ b/auto/os/linux
@@ -6,19 +6,49 @@ EVENT_MODULES="$EVENT_MODULES $SELECT_MO
 
 ZLIB_LIB="-lz"
 
+CC_TEST_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
 
-NGX_INC="sys/epoll.h"; . auto/inc
+
+# epoll, EPOLLET version
 
-if [ $NGX_FOUND=YES ]; then
+ngx_func="epoll";
+ngx_func_inc="#include <sys/epoll.h>"
+ngx_func_test="int fd = 1; int n;
+               struct epoll_event ee;
+               ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
+               ee.data.ptr = NULL;
+               n = epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)"
+. auto/func
+
+if [ $ngx_found = yes ]; then
     CFLAGS="$CFLAGS -D HAVE_EPOLL=1"
+    CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
     EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
-    CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
+    EVENT_FOUND=YES
 fi
 
 
-# TODO check sendfile64()
+# sendfile()
+
+CC_TEST_FLAGS="-D_GNU_SOURCE"
+ngx_func="sendfile()";
+ngx_func_inc="#include <sys/sendfile.h>"
+ngx_func_test="int s = 0, fd = 1;
+               ssize_t n; off_t off = 0;
+               n = sendfile(s, fd, &off, 1)"
+. auto/func
+
+if [ $ngx_found = yes ]; then
+    CFLAGS="$CFLAGS -D HAVE_SENDFILE=1"
+    CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS"
+fi
+
+
+# sendfile64()
 
 CC_TEST_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
+ngx_func="sendfile64()"; . auto/func
 
-# STUB
-CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS"
+if [ $ngx_found = yes ]; then
+    CFLAGS="$CFLAGS -D HAVE_SENDFILE64=1"
+fi
--- a/auto/os/solaris
+++ b/auto/os/solaris
@@ -6,29 +6,31 @@ EVENT_MODULES="$EVENT_MODULES $SELECT_MO
 
 MD5_LIB="-lmd5"
 ZLIB_LIB="-lz"
+CORE_LIBS="$CORE_LIBS -lsocket -lnsl"
 
 CC_TEST_FLAGS="-D_FILE_OFFSET_BITS=64"
 
-CORE_LIBS="$CORE_LIBS -lsocket -lnsl"
 
-
-NGX_INC="sys/devpoll.h"; . auto/inc
+ngx_inc="sys/devpoll.h"; . auto/inc
 
-if [ $NGX_FOUND=YES ]; then
+if [ $ngx_found = yes ]; then
     CFLAGS="$CFLAGS -D HAVE_DEVPOLL=1"
+    CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
     EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
-    CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
+    EVENT_FOUND=YES
 fi
 
 
-NGX_FUNC_INC="#include <sys/sendfile.h>"
-NGX_FUNC_LIBS="-lsendfile"
-NGX_FUNC_TEST="int fd = 1; sendfilevec_t vec[1];
+ngx_func="sendfilev()";
+ngx_func_inc="#include <sys/sendfile.h>"
+ngx_func_libs="-lsendfile"
+ngx_func_test="int fd = 1; sendfilevec_t vec[1];
                size_t sent = 1; ssize_t n;
                n = sendfilev(fd, vec, 1, &sent)"
-NGX_FUNC="sendfilev()"; . auto/func
+. auto/func
 
-if [ $NGX_FOUND=YES ]; then
+
+if [ $ngx_found = yes ]; then
     CFLAGS="$CFLAGS -D HAVE_SENDFILE=1"
     CORE_SRCS="$CORE_SRCS $SOLARIS_SENDFILEV_SRCS"
     CORE_LIBS="$CORE_LIBS -lsendfile"
--- a/auto/sources
+++ b/auto/sources
@@ -41,8 +41,8 @@ CORE_SRCS="src/core/nginx.c \
             src/core/ngx_garbage_collector.c"
 
 
-REGEX_DEPS="src/core/ngx_regex.h"
-REGEX_SRCS="src/core/ngx_regex.c"
+REGEX_DEPS=src/core/ngx_regex.h
+REGEX_SRCS=src/core/ngx_regex.c
 
 
 EVENT_MODULES="ngx_events_module ngx_event_core_module"
@@ -62,29 +62,33 @@ EVENT_SRCS="src/event/ngx_event.c \
             src/event/ngx_event_pipe.c"
 
 
-SELECT_MODULE="ngx_select_module"
+SELECT_MODULE=ngx_select_module
 SELECT_SRCS=src/event/modules/ngx_select_module.c
 
-POLL_MODULE="ngx_poll_module"
+POLL_MODULE=ngx_poll_module
 POLL_SRCS=src/event/modules/ngx_poll_module.c
 
-KQUEUE_MODULE="ngx_kqueue_module"
+KQUEUE_MODULE=ngx_kqueue_module
 KQUEUE_SRCS=src/event/modules/ngx_kqueue_module.c
 
-DEVPOLL_MODULE="ngx_devpoll_module"
+DEVPOLL_MODULE=ngx_devpoll_module
 DEVPOLL_SRCS=src/event/modules/ngx_devpoll_module.c
 
-EPOLL_MODULE="ngx_epoll_module"
+EPOLL_MODULE=ngx_epoll_module
 EPOLL_SRCS=src/event/modules/ngx_epoll_module.c
 
-SIGIO_MODULE="ngx_sigio_module"
+SIGIO_MODULE=ngx_sigio_module
 SIGIO_SRCS=src/event/modules/ngx_sigio_module.c
 
-IOCP_MODULE="ngx_iocp_module"
+IOCP_MODULE=ngx_iocp_module
 IOCP_SRCS=src/event/modules/ngx_iocp_module.c
 
-AIO_MODULE="ngx_aio_module"
-AIO_SRCS=src/event/modules/ngx_aio_module.c
+AIO_MODULE=ngx_aio_module
+AIO_SRCS="src/event/modules/ngx_aio_module.c \
+          src/os/unix/ngx_aio_read.c \
+          src/os/unix/ngx_aio_write.c \
+          src/os/unix/ngx_aio_read_chain.c \
+          src/os/unix/ngx_aio_write_chain.c"
 
 
 UNIX_INCS="$CORE_INCS $EVENT_INCS -I src/os/unix"
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -173,7 +173,7 @@ int main(int argc, char *const *argv, ch
 
 #else
 
-    if (ccf->daemon != 0) {
+    if (!ngx_inherited && ccf->daemon != 0) {
         if (ngx_daemon(cycle->log) == NGX_ERROR) {
             return 1;
         }
@@ -356,11 +356,10 @@ static void ngx_master_process_cycle(ngx
                     live = 0;
                     for (i = 0; i < ngx_last_process; i++) {
 
-                        ngx_log_debug6(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
+                        ngx_log_debug5(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
                                        "child: " PID_T_FMT
-                                       " s:%d e:%d t:%d d:%d r:%d",
+                                       " e:%d t:%d d:%d r:%d",
                                        ngx_processes[i].pid,
-                                       ngx_processes[i].signal,
                                        ngx_processes[i].exiting,
                                        ngx_processes[i].exited,
                                        ngx_processes[i].detached,
@@ -396,13 +395,10 @@ static void ngx_master_process_cycle(ngx
                                                ngx_processes[ngx_last_process];
                             }
 
-                        } else if (!ngx_processes[i].detached
-                                   && (ngx_terminate || ngx_quit))
+                        } else if (ngx_processes[i].exiting
+                                   || !ngx_processes[i].detached)
                         {
                             live = 1;
-
-                        } else if (ngx_processes[i].exiting) {
-                            live = 1;
                         }
                     }
                 }
@@ -470,44 +466,27 @@ static void ngx_master_process_cycle(ngx
                 if (signo) {
                     for (i = 0; i < ngx_last_process; i++) {
 
-                        if (!ngx_processes[i].detached) {
-                            ngx_processes[i].signal = signo;
-
-                            ngx_log_debug2(NGX_LOG_DEBUG_EVENT,
-                                           cycle->log, 0,
-                                           "signal " PID_T_FMT " %d",
-                                           ngx_processes[i].pid, signo);
+                        if (ngx_processes[i].detached) {
+                            continue;
                         }
-                    }
-                    signo = 0;
-                }
+
+                        ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
+                                       "kill (" PID_T_FMT ", %d)" ,
+                                       ngx_processes[i].pid, signo);
 
-                for (i = 0; i < ngx_last_process; i++) {
+                        if (kill(ngx_processes[i].pid, signo) == -1) {
+                            ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+                                          "kill(%d, %d) failed",
+                                          ngx_processes[i].pid, signo);
+                            continue;
+                        }
 
-                    if (ngx_processes[i].signal == 0) {
-                        continue;
+                        if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) {
+                            ngx_processes[i].exiting = 1;
+                        }
                     }
 
-                    ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
-                                   "kill (" PID_T_FMT ", %d)" ,
-                                   ngx_processes[i].pid,
-                                   ngx_processes[i].signal);
-
-                    if (kill(ngx_processes[i].pid, ngx_processes[i].signal)
-                                                                         == -1)
-                    {
-                        ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                                      "kill(%d, %d) failed",
-                                      ngx_processes[i].pid,
-                                      ngx_processes[i].signal);
-                        continue;
-                    }
-
-                    if (ngx_processes[i].signal
-                                        != ngx_signal_value(NGX_REOPEN_SIGNAL))
-                    {
-                        ngx_processes[i].exiting = 1;
-                    }
+                    signo = 0;
                 }
 
                 if (ngx_reopen || ngx_reconfigure || ngx_timer) {
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -2,7 +2,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER      "nginx/0.0.1"
+#define NGINX_VER      "nginx/0.0.2"
 #define NGINX_CONF     "nginx.conf"
 #define NGINX_PID      "nginx.pid"
 #define NGINX_NEW_PID  NGINX_PID ".newbin"
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -2,7 +2,10 @@
 #define _NGX_CONFIG_H_INCLUDED_
 
 
-#if 0
+#include <ngx_auto_config.h>
+
+
+#if 1
 /* STUB to allocate a big ngx_connections */
 #undef  FD_SETSIZE
 #define FD_SETSIZE  5000
@@ -53,9 +56,6 @@ typedef int    ngx_flag_t;
 #define PTR_FMT  "%08X"
 
 
-#include <ngx_auto_config.h>
-
-
 #ifndef NGX_SERVER_ROOT
 #define NGX_SERVER_ROOT   "./"
 #if 0
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -375,6 +375,8 @@ static int ngx_kqueue_process_events(ngx
     ngx_gettimeofday(&tv);
     ngx_time_update(tv.tv_sec);
 
+    ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "kevent events: %d", events);
+
     delta = ngx_elapsed_msec;
     ngx_elapsed_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000 - ngx_start_msec;
 
--- a/src/event/modules/ngx_poll_module.c
+++ b/src/event/modules/ngx_poll_module.c
@@ -320,12 +320,12 @@ static int ngx_poll_process_events(ngx_l
 
         found = 0;
 
-        if (event_list[i].revents & (POLLIN|POLLERR|POLLHUP)) {
+        if (event_list[i].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL)) {
             found = 1;
             ready_index[nready++] = c->read;
         }
 
-        if (event_list[i].revents & (POLLOUT|POLLERR|POLLHUP)) {
+        if (event_list[i].revents & (POLLOUT|POLLERR|POLLHUP|POLLNVAL)) {
             found = 1;
             ready_index[nready++] = c->write;
         }
--- a/src/event/modules/ngx_select_module.c
+++ b/src/event/modules/ngx_select_module.c
@@ -315,14 +315,15 @@ static int ngx_select_process_events(ngx
         deltas += delta;
         if (deltas > 1000) {
             ngx_gettimeofday(&tv);
+            ngx_time_update(tv.tv_sec);
             deltas = tv.tv_usec / 1000;
-            ngx_time_update(tv.tv_sec);
         }
 
         ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0,
                        "select timer: %d, delta: %d", timer, (int) delta);
 
     } else {
+        delta = 0;
         ngx_gettimeofday(&tv);
         ngx_time_update(tv.tv_sec);
 
@@ -438,8 +439,10 @@ static char *ngx_select_init_conf(ngx_cy
     /* disable warning: the default FD_SETSIZE is 1024U in FreeBSD 5.x */
 
     if ((unsigned) ecf->connections > FD_SETSIZE) {
-        return "maximum number of connections "
-               "supported by select() is " ngx_value(FD_SETSIZE);
+        ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
+                      "the maximum number of files "
+                      "supported by select() is " ngx_value(FD_SETSIZE));
+        return NGX_CONF_ERROR;
     }
 
     return NGX_CONF_OK;
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -84,6 +84,13 @@ static ngx_command_t  ngx_event_core_com
       0,
       NULL },
 
+    { ngx_string("multi_accept"),
+      NGX_EVENT_CONF|NGX_CONF_TAKE1,
+      ngx_conf_set_flag_slot,
+      0,
+      offsetof(ngx_event_conf_t, multi_accept),
+      NULL },
+
       ngx_null_command
 };
 
@@ -421,8 +428,8 @@ static void *ngx_event_create_conf(ngx_c
                   NGX_CONF_ERROR);
 
     ecf->connections = NGX_CONF_UNSET;
-    ecf->timer_queues = NGX_CONF_UNSET;
     ecf->use = NGX_CONF_UNSET;
+    ecf->multi_accept = NGX_CONF_UNSET;
     ecf->name = (void *) NGX_CONF_UNSET;
 
     return ecf;
@@ -457,7 +464,7 @@ static char *ngx_event_init_conf(ngx_cyc
 
     cycle->connection_n = ecf->connections;
 
-    ngx_conf_init_value(ecf->timer_queues, 10);
+    ngx_conf_init_value(ecf->multi_accept, 1);
 
     return NGX_CONF_OK;
 }
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -345,10 +345,10 @@ extern ngx_event_actions_t   ngx_event_a
 
 
 typedef struct {
-    int    connections;
-    int    timer_queues;
-    int    use;
-    char  *name;
+    int          connections;
+    int          use;
+    ngx_flag_t   multi_accept;
+    char       *name;
 } ngx_event_conf_t;
 
 
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -23,6 +23,13 @@ void ngx_event_accept(ngx_event_t *ev)
 
     ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module);
 
+    if (ngx_event_flags & (NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT)) {
+        ev->available = 1;
+
+    } else if (!(ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)) {
+        ev->available = ecf->multi_accept;
+    }
+
     ls = ev->data;
 
     ngx_log_debug(ev->log, "accept on %s ready: %d" _
@@ -31,26 +38,33 @@ void ngx_event_accept(ngx_event_t *ev)
 
     ev->ready = 0;
     accepted = 0;
+    pool = NULL;
 
     do {
 
-        /*
-         * Create the pool before accept() to avoid copy the sockaddr.
-         * Although accept() can fail it's an uncommon case
-         * and besides the pool can be got from the free pool list
-         */
+        if (pool == NULL) {
 
-        if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) {
-            return;
+            /*
+             * Create the pool before accept() to avoid copy the sockaddr.
+             * Although accept() can fail it's an uncommon case
+             * and besides the pool can be got from the free pool list
+             */
+
+            if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) {
+                return;
+            }
         }
 
         if (!(sa = ngx_palloc(pool, ls->listening->socklen))) {
+            ngx_destroy_pool(pool);
             return;
         }
 
         if (!(log = ngx_palloc(pool, sizeof(ngx_log_t)))) {
+            ngx_destroy_pool(pool);
             return;
         }
+
         ngx_memcpy(log, ls->log, sizeof(ngx_log_t));
         pool->log = log;
 
@@ -67,6 +81,8 @@ void ngx_event_accept(ngx_event_t *ev)
                 ngx_log_error(NGX_LOG_NOTICE, log, err,
                               "EAGAIN after %d accepted connection(s)",
                               accepted);
+
+                ngx_destroy_pool(pool);
                 return;
             }
 
@@ -74,6 +90,17 @@ void ngx_event_accept(ngx_event_t *ev)
                           "accept() on %s failed",
                           ls->listening->addr_text.data);
 
+            if (err == NGX_ECONNABORTED) {
+                if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+                    ev->available--;
+                }
+
+                if (ev->available) {
+                    /* reuse the previously allocated pool */
+                    continue;
+                }
+            }
+
             ngx_destroy_pool(pool);
             return;
         }
@@ -187,8 +214,10 @@ void ngx_event_accept(ngx_event_t *ev)
         wev->write = 1;
         wev->ready = 1;
 
-        if (ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_EDGE_EVENT)) {
-            /* aio, iocp, epoll */
+        if (ngx_event_flags
+            & (NGX_USE_AIO_EVENT|NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT))
+        {
+            /* aio, iocp, sigio, epoll */
             rev->ready = 1;
         }
 
@@ -229,6 +258,8 @@ void ngx_event_accept(ngx_event_t *ev)
             }
         }
 
+        pool = NULL;
+
         log->data = NULL;
         log->handler = NULL;
 
--- a/src/os/unix/ngx_aio_write_chain.c
+++ b/src/os/unix/ngx_aio_write_chain.c
@@ -58,7 +58,7 @@ ngx_chain_t *ngx_aio_write_chain(ngx_con
         }
 
 #if (NGX_DEBUG_WRITE_CHAIN)
-        ngx_log_debug(c->log, "aio_write sent: " OFF_FMT _ c->sent);
+        ngx_log_debug(c->log, "aio_write sent: " OFF_T_FMT _ c->sent);
 #endif
 
         for (cl = in; cl; cl = cl->next) {
--- a/src/os/unix/ngx_errno.h
+++ b/src/os/unix/ngx_errno.h
@@ -19,6 +19,7 @@ typedef int               ngx_err_t;
 #define NGX_EAGAIN        EWOULDBLOCK
 #define NGX_EINPROGRESS   EINPROGRESS
 #define NGX_EADDRINUSE    EADDRINUSE
+#define NGX_ECONNABORTED  ECONNABORTED
 #define NGX_ECONNRESET    ECONNRESET
 #define NGX_ENOTCONN      ENOTCONN
 #define NGX_ETIMEDOUT     ETIMEDOUT
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -55,6 +55,10 @@ extern ssize_t sendfile(int s, int fd, i
 #include <poll.h>
 #endif
 
+#if (HAVE_EPOLL)
+#include <sys/epoll.h>
+#endif /* HAVE_EPOLL */
+
 
 #if defined TCP_DEFER_ACCEPT && !defined HAVE_DEFERRED_ACCEPT
 #define HAVE_DEFERRED_ACCEPT  1
@@ -76,14 +80,6 @@ extern ssize_t sendfile(int s, int fd, i
 #endif
 
 
-/* 
- * SuSE 8.2 supports epoll's EPOLLET but misses it in <sys/epoll.h>
- */
-#ifndef EPOLLET  
-#define EPOLLET  0x80000000
-#endif
-
-
 #define ngx_setproctitle(title)
 
 
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -70,7 +70,6 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t 
                                       (respawn == NGX_PROCESS_RESPAWN) ? 1 : 0;
     ngx_processes[ngx_last_process].detached =
                                      (respawn == NGX_PROCESS_DETACHED) ? 1 : 0;
-    ngx_processes[ngx_last_process].signal = 0;
     ngx_processes[ngx_last_process].exited = 0;
     ngx_processes[ngx_last_process].exiting = 0;
     ngx_last_process++;
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -8,7 +8,6 @@ typedef void (*ngx_spawn_proc_pt) (ngx_c
 
 typedef struct {
     ngx_pid_t           pid;
-    int                 signal;
     int                 status;
 
     ngx_spawn_proc_pt   proc;