diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2003-05-20 15:37:55 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2003-05-20 15:37:55 +0000 |
| commit | 1c13c662f0ae8066d1d4849b4158d7459a4c7822 (patch) | |
| tree | a8e517c0d41e922b1d3744d869edc60ed540b2d9 /src/os | |
| parent | a98301160de4c12f455cca8f78509f2e04626c0b (diff) | |
| download | nginx-1c13c662f0ae8066d1d4849b4158d7459a4c7822.tar.gz nginx-1c13c662f0ae8066d1d4849b4158d7459a4c7822.tar.bz2 | |
nginx-0.0.1-2003-05-20-19:37:55 import
Diffstat (limited to 'src/os')
| -rw-r--r-- | src/os/unix/ngx_daemon.c | 16 | ||||
| -rw-r--r-- | src/os/unix/ngx_freebsd_init.h | 2 | ||||
| -rw-r--r-- | src/os/unix/ngx_os_init.h | 16 | ||||
| -rw-r--r-- | src/os/unix/ngx_unix_init.c | 32 | ||||
| -rw-r--r-- | src/os/win32/ngx_files.h | 3 | ||||
| -rw-r--r-- | src/os/win32/ngx_init.c | 24 |
6 files changed, 61 insertions, 32 deletions
diff --git a/src/os/unix/ngx_daemon.c b/src/os/unix/ngx_daemon.c index 6faf85b06..93d3571b0 100644 --- a/src/os/unix/ngx_daemon.c +++ b/src/os/unix/ngx_daemon.c @@ -11,7 +11,7 @@ int ngx_daemon(ngx_log_t *log) switch (fork()) { case -1: - ngx_log_error(NGX_LOG_ALERT, log, errno, "fork() failed"); + ngx_log_error(NGX_LOG_EMERG, log, errno, "fork() failed"); return NGX_ERROR; case 0: @@ -22,7 +22,7 @@ int ngx_daemon(ngx_log_t *log) } if (setsid() == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "setsid() failed"); + ngx_log_error(NGX_LOG_EMERG, log, errno, "setsid() failed"); return NGX_ERROR; } @@ -32,7 +32,7 @@ int ngx_daemon(ngx_log_t *log) switch (fork()) { case -1: - ngx_log_error(NGX_LOG_ALERT, log, errno, "fork() failed"); + ngx_log_error(NGX_LOG_EMERG, log, errno, "fork() failed"); return NGX_ERROR; case 0: @@ -49,28 +49,28 @@ int ngx_daemon(ngx_log_t *log) #if 0 fd = open("/dev/null", O_RDWR); if (fd == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "open(\"/dev/null\") failed"); + ngx_log_error(NGX_LOG_EMERG, log, errno, "open(\"/dev/null\") failed"); return NGX_ERROR; } if (dup2(fd, STDIN_FILENO) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "dup2(STDIN) failed"); + ngx_log_error(NGX_LOG_EMERG, log, errno, "dup2(STDIN) failed"); return NGX_ERROR; } if (dup2(fd, STDOUT_FILENO) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "dup2(STDOUT) failed"); + ngx_log_error(NGX_LOG_EMERG, log, errno, "dup2(STDOUT) failed"); return NGX_ERROR; } if (dup2(fd, STDERR_FILENO) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "dup2(STDERR) failed"); + ngx_log_error(NGX_LOG_EMERG, log, errno, "dup2(STDERR) failed"); return NGX_ERROR; } if (fd > STDERR_FILENO) { if (close(fd) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "close() failed"); + ngx_log_error(NGX_LOG_EMERG, log, errno, "close() failed"); return NGX_ERROR; } } diff --git a/src/os/unix/ngx_freebsd_init.h b/src/os/unix/ngx_freebsd_init.h index d0d2c5b87..6f5862599 100644 --- a/src/os/unix/ngx_freebsd_init.h +++ b/src/os/unix/ngx_freebsd_init.h @@ -4,8 +4,6 @@ #include <ngx_config.h> #include <ngx_core.h> -#include <ngx_log.h> -#include <ngx_os_init.h> #include <sys/sysctl.h> diff --git a/src/os/unix/ngx_os_init.h b/src/os/unix/ngx_os_init.h deleted file mode 100644 index 25e0b6a7a..000000000 --- a/src/os/unix/ngx_os_init.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _NGX_OS_INIT_H_INCLUDED_ -#define _NGX_OS_INIT_H_INCLUDED_ - - -#include <ngx_config.h> -#include <ngx_log.h> -#include <ngx_hunk.h> -#include <ngx_connection.h> - - -int ngx_os_init(ngx_log_t *log); - -extern ngx_os_io_t ngx_os_io; - - -#endif /* _NGX_OS_INIT_H_INCLUDED_ */ diff --git a/src/os/unix/ngx_unix_init.c b/src/os/unix/ngx_unix_init.c index 2916c9e44..7b38bb18e 100644 --- a/src/os/unix/ngx_unix_init.c +++ b/src/os/unix/ngx_unix_init.c @@ -3,6 +3,9 @@ #include <ngx_core.h> +int ngx_max_sockets; + + int ngx_unix_init(ngx_log_t *log) { struct sigaction sa; @@ -29,11 +32,32 @@ int ngx_unix_init(ngx_log_t *log) "getrlimit(RLIMIT_NOFILE): %qd:%qd", rlmt.rlim_cur, rlmt.rlim_max); + ngx_max_sockets = rlmt.rlim_cur; + + return NGX_OK; +} + + +int ngx_unix_post_conf_init(ngx_log_t *log) +{ + ngx_fd_t pp[2]; -#if 0 - RLIM_INFINITY - max_connections =< rlmt.rlim_cur; -#endif + if (pipe(pp) == -1) { + ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "pipe() failed"); + return NGX_ERROR; + } + + if (dup2(pp[1], STDERR_FILENO) == -1) { + ngx_log_error(NGX_LOG_EMERG, log, errno, "dup2(STDERR) failed"); + return NGX_ERROR; + } + + if (pp[1] > STDERR_FILENO) { + if (close(pp[1]) == -1) { + ngx_log_error(NGX_LOG_EMERG, log, errno, "close() failed"); + return NGX_ERROR; + } + } return NGX_OK; } diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h index 1cf981089..382136fe2 100644 --- a/src/os/win32/ngx_files.h +++ b/src/os/win32/ngx_files.h @@ -36,6 +36,9 @@ FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE, \ NULL); +#define ngx_open_tempfile_n "CreateFile()" + + #define ngx_open_file_n "CreateFile()" diff --git a/src/os/win32/ngx_init.c b/src/os/win32/ngx_init.c index cc4f25e62..8c3511fe7 100644 --- a/src/os/win32/ngx_init.c +++ b/src/os/win32/ngx_init.c @@ -1,9 +1,29 @@ -#include <ngx_os_init.h> +#include <ngx_config.h> +#include <ngx_core.h> + + +int ngx_max_sockets; + + +ngx_os_io_t ngx_os_io = { +#if 0 + ngx_unix_recv, + NULL, + NULL, + ngx_freebsd_write_chain +#else + NULL, + NULL, + NULL, + NULL +#endif +}; + int ngx_os_init(ngx_log_t *log) { - if (ngx_init_sockets(&ngx_log) == NGX_ERROR) { + if (ngx_init_sockets(log) == NGX_ERROR) { return NGX_ERROR; } |
