nginx-0.0.2-2004-02-10-19:23:38 import
diff --git a/auto/configure b/auto/configure
index 162a697..f9ad319 100755
--- a/auto/configure
+++ b/auto/configure
@@ -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
diff --git a/auto/unix b/auto/unix
index 3aa1883..d6fc373 100755
--- a/auto/unix
+++ b/auto/unix
@@ -98,6 +98,12 @@
. 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)"
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 34f204f..005417c 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -203,6 +203,15 @@
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 @@
}
}
- 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 @@
/* set by pcalloc()
*
* ccf->pid = NULL;
+ * ccf->newpid = NULL;
*/
ccf->daemon = NGX_CONF_UNSET;
ccf->master = NGX_CONF_UNSET;
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 99423d3..eb7fe93 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -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_ */
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index e0b24fa..1157484 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -243,14 +243,14 @@
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;
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index 6f87fd2..835f5e1 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -52,6 +52,14 @@
} 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 @@
ngx_int_t number;
+ unsigned log_error:2; /* ngx_connection_log_error_e */
+
unsigned pipeline:1;
unsigned unexpected_eof:1;
signed tcp_nopush:2;
diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c
index 3f46a83..111432b 100644
--- a/src/event/modules/ngx_epoll_module.c
+++ b/src/event/modules/ngx_epoll_module.c
@@ -132,12 +132,15 @@
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,
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index 68d9f81..a2c1e9c 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -20,14 +20,6 @@
#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 @@
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;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 8d20a31..ff53a7b 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -79,10 +79,10 @@
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 @@
* 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;
diff --git a/src/os/unix/ngx_errno.c b/src/os/unix/ngx_errno.c
index c50da82..410cfde 100644
--- a/src/os/unix/ngx_errno.c
+++ b/src/os/unix/ngx_errno.c
@@ -25,4 +25,34 @@
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
diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h
index 208faa2..7ead602 100644
--- a/src/os/unix/ngx_errno.h
+++ b/src/os/unix/ngx_errno.h
@@ -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 @@
#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);
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
index 2e14831..3d53d20 100644
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -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>
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index fca68f6..76b0dd0 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -13,10 +13,11 @@
#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>
diff --git a/src/os/unix/ngx_recv.c b/src/os/unix/ngx_recv.c
index 60e2d09..3c454e9 100644
--- a/src/os/unix/ngx_recv.c
+++ b/src/os/unix/ngx_recv.c
@@ -32,7 +32,7 @@
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;
}
diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h
index 920aaf9..f4f8df2 100644
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -14,9 +14,10 @@
#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>