aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-02-03 16:43:54 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-02-03 16:43:54 +0000
commit25b36fedf72139617dc172dbca887888b258698d (patch)
treea2279a6ecdbac2779e206eb5da2640bb95f95c99
parenta4b16df728abe1e989a8311e901ba5d9ae30328e (diff)
downloadnginx-25b36fedf72139617dc172dbca887888b258698d.tar.gz
nginx-25b36fedf72139617dc172dbca887888b258698d.zip
nginx-0.0.2-2004-02-03-19:43:54 import
-rw-r--r--auto/lib/make13
-rw-r--r--auto/os/linux4
-rw-r--r--auto/os/solaris4
-rw-r--r--src/core/nginx.c8
-rw-r--r--src/core/ngx_config.h5
-rw-r--r--src/core/ngx_cycle.c15
-rw-r--r--src/core/ngx_log.c2
-rw-r--r--src/event/ngx_event.c9
-rw-r--r--src/os/unix/ngx_daemon.c2
-rw-r--r--src/os/unix/ngx_freebsd_config.h2
-rw-r--r--src/os/unix/ngx_linux_config.h15
-rw-r--r--src/os/unix/ngx_process.c1
-rw-r--r--src/os/unix/ngx_process.h1
-rw-r--r--src/os/unix/ngx_solaris_config.h2
14 files changed, 60 insertions, 23 deletions
diff --git a/auto/lib/make b/auto/lib/make
index 6055e3fd1..d4cba34f5 100644
--- a/auto/lib/make
+++ b/auto/lib/make
@@ -12,7 +12,18 @@ if [ "$PLATFORM" != "win32" ]; then
if [ $MD5 != NO ]; then
echo "$MD5/libmd5.a:" >> $MAKEFILE
- echo " cd $MD5 && \$(MAKE) x86-elf" >> $MAKEFILE
+
+ case $PLATFORM in
+
+ SunOS:*)
+ echo " cd $MD5 && \$(MAKE) x86-solaris" >> $MAKEFILE
+ ;;
+
+ *)
+ echo " cd $MD5 && \$(MAKE) x86-elf" >> $MAKEFILE
+ ;;
+ esac
+
echo >> $MAKEFILE
fi
diff --git a/auto/os/linux b/auto/os/linux
index effb4723f..3a020e944 100644
--- a/auto/os/linux
+++ b/auto/os/linux
@@ -1,8 +1,8 @@
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"
+CORE_SRCS="$UNIX_SRCS $LINUX_SRCS"
+EVENT_MODULES="$EVENT_MODULES"
ZLIB_LIB="-lz"
diff --git a/auto/os/solaris b/auto/os/solaris
index 2fd479f17..363ac1d2d 100644
--- a/auto/os/solaris
+++ b/auto/os/solaris
@@ -1,8 +1,8 @@
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"
+CORE_SRCS="$UNIX_SRCS $SOLARIS_SRCS "
+EVENT_MODULES="$EVENT_MODULES"
MD5_LIB="-lmd5"
ZLIB_LIB="-lz"
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 61cc53e48..21a22d0ba 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -82,6 +82,7 @@ ngx_int_t ngx_max_module;
ngx_uint_t ngx_connection_counter;
ngx_int_t ngx_process;
+ngx_pid_t ngx_pid;
ngx_pid_t ngx_new_binary;
ngx_int_t ngx_inherited;
@@ -122,6 +123,7 @@ int main(int argc, char *const *argv, char **envp)
#endif
log = ngx_log_init_errlog();
+ ngx_pid = ngx_getpid();
/* init_cycle->log is required for signal handlers */
@@ -179,12 +181,6 @@ int main(int argc, char *const *argv, char **envp)
}
}
- if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
- ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
- "dup2(STDERR) failed");
- return 1;
- }
-
if (ccf->pid.len == 0) {
ccf->pid.len = sizeof(NGINX_PID) - 1;
ccf->pid.data = NGINX_PID;
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h
index 796d7a20b..b691c3ca9 100644
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -2,9 +2,6 @@
#define _NGX_CONFIG_H_INCLUDED_
-#include <ngx_auto_config.h>
-
-
#if 1
/* STUB to allocate a big ngx_connections */
#undef FD_SETSIZE
@@ -36,6 +33,8 @@
#else /* posix */
+#include <ngx_auto_config.h>
+
#endif
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index dcae4a0c5..845099814 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -228,6 +228,14 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
}
}
+ /* TODO: Win32 DuplicateHandle ? */
+ if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ "dup2(STDERR) failed");
+ failed = 1;
+ }
+
+
if (failed) {
/* rollback the new cycle configuration */
@@ -262,6 +270,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
return NULL;
}
+
/* commit the new cycle configuration */
pool->log = cycle->log;
@@ -438,6 +447,12 @@ void ngx_reopen_files(ngx_cycle_t *cycle, uid_t user)
file[i].fd = fd;
}
+
+ /* TODO: Win32 DuplicateHandle ? */
+ if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
+ "dup2(STDERR) failed");
+ }
}
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 1f7bb11a9..a902f1e31 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -79,7 +79,7 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
/* pid#tid */
len += ngx_snprintf(errstr + len, max - len,
- PID_T_FMT "#%d: ", ngx_getpid(), /* STUB */ 0);
+ PID_T_FMT "#%d: ", ngx_pid, /* STUB */ 0);
if (log->data) {
len += ngx_snprintf(errstr + len, max - len,
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index 482310b3d..3ca1067b4 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -16,6 +16,7 @@ extern ngx_event_module_t ngx_select_module_ctx;
#if (HAVE_DEVPOLL)
extern ngx_module_t ngx_devpoll_module;
+extern ngx_event_module_t ngx_devpoll_module_ctx;
#endif
#if (HAVE_AIO)
@@ -386,6 +387,7 @@ static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
old_ecf = NULL;
}
+
for (m = 0; ngx_modules[m]; m++) {
if (ngx_modules[m]->type != NGX_EVENT_MODULE) {
continue;
@@ -397,14 +399,19 @@ static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ecf->use = ngx_modules[m]->ctx_index;
ecf->name = module->name->data;
- if (old_ecf && old_ecf->use != ecf->use) {
+ if (ngx_process == NGX_PROCESS_SINGLE
+ && old_ecf
+ && old_ecf->use != ecf->use)
+ {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "when the server runs without a master process "
"the \"%s\" event type must be the same as "
"in previous configuration - \"%s\" "
"and it can not be changed on the fly, "
"to change it you need to stop server "
"and start it again",
value[1].data, old_ecf->name);
+
return NGX_CONF_ERROR;
}
diff --git a/src/os/unix/ngx_daemon.c b/src/os/unix/ngx_daemon.c
index b2a37c100..8bad5444a 100644
--- a/src/os/unix/ngx_daemon.c
+++ b/src/os/unix/ngx_daemon.c
@@ -19,6 +19,8 @@ int ngx_daemon(ngx_log_t *log)
exit(0);
}
+ ngx_pid = ngx_getpid();
+
if (setsid() == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "setsid() failed");
return NGX_ERROR;
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
index 6a4397999..2e14831ea 100644
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -28,6 +28,8 @@
#include <dirent.h>
#include <osreldate.h>
+#include <ngx_auto_config.h>
+
#ifndef HAVE_SELECT
#define HAVE_SELECT 1
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index e43a6caa7..f6b84569f 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -26,13 +26,6 @@
#include <sys/sysctl.h>
#include <sys/wait.h>
#include <sys/socket.h>
-
-#if (HAVE_SENDFILE64)
-#include <sys/sendfile.h>
-#else
-extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);
-#endif
-
#include <netinet/in.h>
#include <netinet/tcp.h> /* TCP_CORK */
#include <arpa/inet.h>
@@ -41,6 +34,14 @@ extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);
#include <netdb.h>
#include <dirent.h>
+#include <ngx_auto_config.h>
+
+#if (HAVE_SENDFILE64)
+#include <sys/sendfile.h>
+#else
+extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);
+#endif
+
#ifndef HAVE_SELECT
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 68bdaed7b..a8c9610b2 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -46,6 +46,7 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
return NGX_ERROR;
case 0:
+ ngx_pid = ngx_getpid();
proc(cycle, data);
break;
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index a1aa74bd7..66b9d7d45 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -49,6 +49,7 @@ ngx_pid_t ngx_exec(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
void ngx_respawn_processes(ngx_cycle_t *cycle);
void ngx_process_get_status(void);
+extern ngx_pid_t ngx_pid;
extern ngx_uint_t ngx_last_process;
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h
index 43068f20e..920aaf904 100644
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -32,6 +32,8 @@
#include <netdb.h>
#include <dirent.h>
+#include <ngx_auto_config.h>
+
#ifndef HAVE_SELECT
#define HAVE_SELECT 1