]> git.kaiwu.me - nginx.git/commitdiff
nginx-0.0.2-2004-02-10-19:23:38 import
authorIgor Sysoev <igor@sysoev.ru>
Tue, 10 Feb 2004 16:23:38 +0000 (16:23 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 10 Feb 2004 16:23:38 +0000 (16:23 +0000)
15 files changed:
auto/configure
auto/unix
src/core/nginx.c
src/core/nginx.h
src/core/ngx_connection.c
src/core/ngx_connection.h
src/event/modules/ngx_epoll_module.c
src/event/ngx_event.h
src/http/ngx_http_request.c
src/os/unix/ngx_errno.c
src/os/unix/ngx_errno.h
src/os/unix/ngx_freebsd_config.h
src/os/unix/ngx_linux_config.h
src/os/unix/ngx_recv.c
src/os/unix/ngx_solaris_config.h

index 162a6974615c87881cda0922982520500d6219a4..f9ad3191c4bafe8e4a262acb3ead9a5eb8219e64 100755 (executable)
@@ -3,7 +3,7 @@
 . auto/init
 . auto/sources
 
-test -d $OBJ || mkdir $OBJ
+test -d $OBJS || mkdir $OBJS
 echo > $NGX_AUTO_CONFIG_H
 
 if [ "$PLATFORM" != win32 ]; then
index 3aa188303f8cc96d764b2a63b3e701f595559ba4..d6fc3730eabd9a23e0b17e6a168d92ce32ff7d55 100755 (executable)
--- a/auto/unix
+++ b/auto/unix
@@ -98,6 +98,12 @@ ngx_func_test="char buf[20]; int n; n = strerror_r(1, buf, 20)"
 . auto/func
 
 
+ngx_func="gnu_strerror_r()"
+ngx_func_inc="#include <string.h>"
+ngx_func_test="char buf[20], *str; str = strerror_r(1, buf, 20)"
+. auto/func
+
+
 ngx_func="localtime_r()"
 ngx_func_inc="#include <time.h>"
 ngx_func_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
index 34f204f43afb28bae876a5350faea3cf5d8a0694..005417ced649cf172fe9a3a21e24f0ae30ef758a 100644 (file)
@@ -203,6 +203,15 @@ int main(int argc, char *const *argv, char **envp)
         ccf->pid.data = NGINX_PID;
         ccf->newpid.len = sizeof(NGINX_NEW_PID) - 1;
         ccf->newpid.data = NGINX_NEW_PID;
+
+    } else {
+        ccf->newpid.len = ccf->pid.len + sizeof(NGINX_NEW_PID_EXT);
+        if (!(ccf->newpid.data = ngx_alloc(ccf->newpid.len, cycle->log))) {
+            return 1;
+        }
+
+        ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len),
+                   NGINX_NEW_PID_EXT, sizeof(NGINX_NEW_PID_EXT));
     }
 
     len = ngx_snprintf(pid, /* STUB */ 10, PID_T_FMT, ngx_getpid());
@@ -785,7 +794,7 @@ static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle)
         }
     }
 
-    if (cycle->conf_file.len == NULL) {
+    if (cycle->conf_file.data == NULL) {
         cycle->conf_file.len = sizeof(NGINX_CONF) - 1;
         cycle->conf_file.data = NGINX_CONF;
     }
@@ -814,6 +823,7 @@ static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle)
     /* set by pcalloc()
      *
      * ccf->pid = NULL;
+     * ccf->newpid = NULL;
      */
     ccf->daemon = NGX_CONF_UNSET;
     ccf->master = NGX_CONF_UNSET;
index 99423d32a969219b239fc0b6bb2777f6e9c80f7a..eb7fe93addccb61e00acdd50c010a1f863a0d81c 100644 (file)
@@ -2,19 +2,20 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER      "nginx/0.0.2"
-#define NGINX_CONF     "nginx.conf"
-#define NGINX_PID      "nginx.pid"
-#define NGINX_NEW_PID  NGINX_PID ".newbin"
+#define NGINX_VER          "nginx/0.0.2"
+#define NGINX_CONF         "nginx.conf"
+#define NGINX_PID          "nginx.pid"
+#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="
+#define NGINX_VAR_LEN      (sizeof(NGINX_VAR) - 1)
 
-extern ngx_module_t    ngx_core_module;
+extern ngx_module_t        ngx_core_module;
 
-extern ngx_uint_t      ngx_connection_counter;
+extern ngx_uint_t          ngx_connection_counter;
 
-extern ngx_int_t       ngx_process;
+extern ngx_int_t           ngx_process;
 
 
 #endif /* _NGINX_H_INCLUDED_ */
index e0b24fa63a2726da71f04425004fd0edfedf5307..11574843222c7d6ec13fcc04973e91a471fd4275 100644 (file)
@@ -243,14 +243,14 @@ ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text)
     ngx_int_t  level;
 
     if (err == NGX_ECONNRESET
-        && c->read->log_error == NGX_ERROR_IGNORE_ECONNRESET)
+        && c->log_error == NGX_ERROR_IGNORE_ECONNRESET)
     {
         return 0;
     }
 
     if (err == NGX_ECONNRESET || err == NGX_EPIPE || err == NGX_ENOTCONN) {
 
-        switch (c->read->log_error) {
+        switch (c->log_error) {
 
         case NGX_ERROR_INFO:
             level = NGX_LOG_INFO;
index 6f87fd2d81770ee12d49f9a7285651095ae61f48..835f5e1cbd946e014f439c1287356d934698c00e 100644 (file)
@@ -52,6 +52,14 @@ typedef struct {
 } ngx_listening_t;
 
 
+typedef enum {
+     NGX_ERROR_CRIT = 0,
+     NGX_ERROR_ERR,
+     NGX_ERROR_INFO,
+     NGX_ERROR_IGNORE_ECONNRESET
+} ngx_connection_log_error_e;
+
+
 struct ngx_connection_s {
     void             *data;
     ngx_event_t      *read;
@@ -84,6 +92,8 @@ struct ngx_connection_s {
 
     ngx_int_t         number;
 
+    unsigned          log_error:2;  /* ngx_connection_log_error_e */
+
     unsigned          pipeline:1;
     unsigned          unexpected_eof:1;
     signed            tcp_nopush:2;
index 3f46a83ad68f3abc047eb99c669815bbd091440b..111432b91573d78b9c9a4b255708916b380052d9 100644 (file)
@@ -132,12 +132,15 @@ ngx_module_t  ngx_epoll_module = {
 static int ngx_epoll_init(ngx_cycle_t *cycle)
 {
     size_t             n;
+    ngx_event_conf_t  *ecf;
     ngx_epoll_conf_t  *epcf;
 
+    ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
+
     epcf = ngx_event_get_conf(cycle->conf_ctx, ngx_epoll_module);
 
     if (ep == -1) {
-        ep = epoll_create(/* STUB: open_files / 2 */ 512);
+        ep = epoll_create(ecf->connections / 2);
 
         if (ep == -1) {
             ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
index 68d9f819934aa6d212c50694bf4ed78ee54822a7..a2c1e9cb6ad4fb9a50ea0b08210618790788f6a5 100644 (file)
@@ -20,14 +20,6 @@ typedef struct {
 #endif
 
 
-typedef enum {
-     NGX_ERROR_CRIT = 0,
-     NGX_ERROR_ERR,
-     NGX_ERROR_INFO,
-     NGX_ERROR_IGNORE_ECONNRESET
-} ngx_event_log_error_e;
-
-
 struct ngx_event_s {
     void            *data;
     /* TODO rename to handler */
@@ -88,7 +80,6 @@ struct ngx_event_s {
 
     unsigned short   read_discarded:1;
 
-    unsigned short   log_error:2;  /* ngx_event_log_error_e */
     unsigned short   unexpected_eof:1;
 
     unsigned short   deferred_accept:1;
index 8d20a31d501e77bdb049cfa1a204fb13d2f6d380..ff53a7ba6220876e527e727725838aa414f17bf3 100644 (file)
@@ -79,10 +79,10 @@ void ngx_http_init_connection(ngx_connection_t *c)
     ctx->action = "reading client request line";
     c->log->data = ctx;
     c->log->handler = ngx_http_log_error;
+    c->log_error = NGX_ERROR_INFO;
 
     rev = c->read;
     rev->event_handler = ngx_http_init_request;
-    rev->log_error = NGX_ERROR_INFO;
 
     /* STUB: epoll */ c->write->event_handler = ngx_http_empty_handler;
 
@@ -1272,10 +1272,10 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
      * so we ignore ECONNRESET here.
      */
 
-    rev->log_error = NGX_ERROR_IGNORE_ECONNRESET;
+    c->log_error = NGX_ERROR_IGNORE_ECONNRESET;
     ngx_set_socket_errno(0);
     n = ngx_recv(c, c->buffer->last, c->buffer->end - c->buffer->last);
-    rev->log_error = NGX_ERROR_INFO;
+    c->log_error = NGX_ERROR_INFO;
 
     if (n == NGX_AGAIN) {
         return;
index c50da825154bde1a2232f5039e2440fefd4df002..410cfde5cee79da38eb805339e8a8720e56fd2d5 100644 (file)
@@ -25,4 +25,34 @@ ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
     return len;
 }
 
+#elif (HAVE_GNU_STRERROR_R)
+
+/* Linux strerror_r() */
+
+ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size)
+{
+    char    *str;
+    size_t   len;
+
+    if (size == 0) {
+        return 0;
+    }
+
+    errstr[0] = '\0';
+
+    str = strerror_r(err, errstr, size);
+
+    if (str != errstr) {
+        return ngx_cpystrn(errstr, str, size) - errstr;
+    }
+
+    for (len = 0; len < size; len++) {
+        if (errstr[len] == '\0') {
+            break;
+        }
+    }
+
+    return len;
+}
+
 #endif
index 208faa244f0db3f70e15f1c24ee8bab98906c4fe..7ead602f715eb4caff7e8bc8ee2fc84a97ec8222 100644 (file)
@@ -2,8 +2,8 @@
 #define _NGX_ERRNO_H_INCLUDED_
 
 
-#include <errno.h>
-#include <string.h>
+#include <ngx_config.h>
+#include <ngx_core.h>
 
 
 typedef int               ngx_err_t;
@@ -34,7 +34,7 @@ typedef int               ngx_err_t;
 #define ngx_set_socket_errno(err)  errno = err
 
 
-#if (HAVE_STRERROR_R)
+#if (HAVE_STRERROR_R || HAVE_GNU_STRERROR_R)
 
 ngx_int_t ngx_strerror_r(int err, char *errstr, size_t size);
 
index 2e14831eac96762f8c77643556de8d4b08a20d7b..3d53d2026927bfadc7b6cd5ced6ed5b1a19aa3c5 100644 (file)
@@ -7,7 +7,9 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <errno.h>
 #include <fcntl.h>
+#include <string.h>
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/stat.h>
index fca68f62263e6eeac623dd6bee75f107141523c4..76b0dd04c1b2c2b2d7fff26ca204242c1604a6b3 100644 (file)
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <errno.h>
 #include <fcntl.h>
+#include <string.h>
 #include <signal.h>
 #include <time.h>
-#include <string.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/select.h>
index 60e2d099f548fe2944f67ad82d90bbde1b5a8e4c..3c454e98c5d84963c556492432ef1dd7c5daf92a 100644 (file)
@@ -32,7 +32,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, char *buf, size_t size)
                     ngx_set_socket_errno(rev->kq_errno);
 
                     if (rev->kq_errno == NGX_ECONNRESET
-                        && rev->log_error == NGX_ERROR_IGNORE_ECONNRESET)
+                        && c->log_error == NGX_ERROR_IGNORE_ECONNRESET)
                     {
                         return 0;
                     }
index 920aaf9040bfe4e914d5111fdf23d56d9644aed9..f4f8df2afd5d3695cdd365cb14109a6b11be3f9c 100644 (file)
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <errno.h>
 #include <fcntl.h>
+#include <string.h>
 #include <signal.h>
-#include <strings.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/wait.h>