Mercurial > hg > nginx
diff src/core/nginx.c @ 98:c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 30 May 2003 14:27:59 +0000 |
parents | 70d2345a903f |
children | 7ebc8b7fb816 |
line wrap: on
line diff
--- a/src/core/nginx.c Thu May 29 13:02:09 2003 +0000 +++ b/src/core/nginx.c Fri May 30 14:27:59 2003 +0000 @@ -1,30 +1,16 @@ + + +#include <ngx_config.h> +#include <ngx_core.h> + +#include <ngx_listen.h> #include <nginx.h> -#include <ngx_config.h> - -#include <ngx_core.h> -#include <ngx_connection.h> -#include <ngx_os_init.h> -#include <ngx_server.h> -#include <ngx_listen.h> -#include <ngx_conf_file.h> - -/* STUB */ -#include <ngx_http.h> -/* */ -static void ngx_set_signals(ngx_log_t *log); -static void ngx_open_listening_sockets(ngx_log_t *log); - +static int ngx_open_listening_sockets(ngx_log_t *log); -/* STUB */ -int ngx_max_conn = 512; -u_int ngx_sendfile_flags; - -ngx_server_t ngx_server; -/* */ ngx_log_t ngx_log; ngx_pool_t *ngx_pool; @@ -34,8 +20,8 @@ ngx_os_io_t ngx_io; -int ngx_max_module; -void *ctx_conf; +int ngx_max_module; +void *ctx_conf; int ngx_connection_counter; @@ -109,7 +95,9 @@ } } - ngx_open_listening_sockets(&ngx_log); + if (ngx_open_listening_sockets(&ngx_log) == NGX_ERROR) { + return 1; + } /* TODO: daemon, once only */ @@ -127,7 +115,7 @@ } -static void ngx_open_listening_sockets(ngx_log_t *log) +static int ngx_open_listening_sockets(ngx_log_t *log) { int times, failed, reuseaddr, i; ngx_err_t err; @@ -161,7 +149,7 @@ if (s == -1) { ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, ngx_socket_n " %s falied", ls[i].addr_text.data); - exit(1); + return NGX_ERROR; } if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, @@ -169,7 +157,7 @@ ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, "setsockopt(SO_REUSEADDR) %s failed", ls[i].addr_text.data); - exit(1); + return NGX_ERROR; } /* TODO: close on exit */ @@ -179,7 +167,7 @@ ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, ngx_nonblocking_n " %s failed", ls[i].addr_text.data); - exit(1); + return NGX_ERROR; } } @@ -189,7 +177,7 @@ "bind() to %s failed", ls[i].addr_text.data); if (err != NGX_EADDRINUSE) - exit(1); + return NGX_ERROR; if (ngx_close_socket(s) == -1) ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, @@ -203,7 +191,7 @@ if (listen(s, ls[i].backlog) == -1) { ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, "listen() to %s failed", ls[i].addr_text.data); - exit(1); + return NGX_ERROR; } /* TODO: deferred accept */ @@ -222,6 +210,8 @@ if (failed) { ngx_log_error(NGX_LOG_EMERG, log, 0, "can not bind(), exiting"); - exit(1); + return NGX_ERROR; } + + return NGX_OK; }