2003-05-21 21:28:21 +08:00
|
|
|
|
2004-09-28 16:34:51 +08:00
|
|
|
/*
|
2004-09-30 00:00:49 +08:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 16:34:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-05-21 21:28:21 +08:00
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
2005-09-07 00:09:32 +08:00
|
|
|
#include <nginx.h>
|
2003-05-21 21:28:21 +08:00
|
|
|
|
|
|
|
|
2004-12-03 02:40:46 +08:00
|
|
|
ngx_int_t ngx_ncpu;
|
|
|
|
ngx_int_t ngx_max_sockets;
|
|
|
|
ngx_uint_t ngx_inherited_nonblocking;
|
|
|
|
ngx_uint_t ngx_tcp_nodelay_and_tcp_nopush;
|
2004-10-04 04:02:06 +08:00
|
|
|
|
|
|
|
|
|
|
|
struct rlimit rlmt;
|
2003-05-21 21:28:21 +08:00
|
|
|
|
|
|
|
|
2004-06-16 01:47:16 +08:00
|
|
|
ngx_os_io_t ngx_os_io = {
|
|
|
|
ngx_unix_recv,
|
|
|
|
ngx_readv_chain,
|
2007-12-04 00:46:46 +08:00
|
|
|
ngx_udp_unix_recv,
|
2004-06-16 01:47:16 +08:00
|
|
|
NULL,
|
|
|
|
ngx_writev_chain,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-09-07 00:09:32 +08:00
|
|
|
ngx_int_t
|
|
|
|
ngx_os_init(ngx_log_t *log)
|
2004-10-21 23:34:38 +08:00
|
|
|
{
|
2006-11-20 16:51:45 +08:00
|
|
|
ngx_uint_t n;
|
|
|
|
|
2005-09-07 00:09:32 +08:00
|
|
|
#if (NGX_HAVE_OS_SPECIFIC_INIT)
|
|
|
|
if (ngx_os_specific_init(log) != NGX_OK) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2004-06-16 01:47:16 +08:00
|
|
|
#endif
|
|
|
|
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
ngx_init_setproctitle(log);
|
|
|
|
|
2004-06-07 03:49:18 +08:00
|
|
|
ngx_pagesize = getpagesize();
|
2005-12-16 23:07:08 +08:00
|
|
|
ngx_cacheline_size = NGX_CPU_CACHE_LINE;
|
2004-06-07 03:49:18 +08:00
|
|
|
|
2006-11-20 16:51:45 +08:00
|
|
|
n = ngx_pagesize;
|
|
|
|
|
|
|
|
for (n = ngx_pagesize; n >>= 1; ngx_pagesize_shift++) { /* void */ }
|
|
|
|
|
2004-06-30 23:30:41 +08:00
|
|
|
if (ngx_ncpu == 0) {
|
|
|
|
ngx_ncpu = 1;
|
|
|
|
}
|
|
|
|
|
2006-02-08 23:33:12 +08:00
|
|
|
ngx_cpuinfo();
|
|
|
|
|
2003-05-21 21:28:21 +08:00
|
|
|
if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, log, errno,
|
|
|
|
"getrlimit(RLIMIT_NOFILE) failed)");
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
2005-11-15 21:30:52 +08:00
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_max_sockets = (ngx_int_t) rlmt.rlim_cur;
|
2003-05-21 21:28:21 +08:00
|
|
|
|
2004-11-26 00:17:31 +08:00
|
|
|
#if (NGX_HAVE_INHERITED_NONBLOCK)
|
2003-05-21 21:28:21 +08:00
|
|
|
ngx_inherited_nonblocking = 1;
|
|
|
|
#else
|
|
|
|
ngx_inherited_nonblocking = 0;
|
|
|
|
#endif
|
|
|
|
|
2006-10-23 21:10:10 +08:00
|
|
|
srandom(ngx_time());
|
|
|
|
|
2003-05-21 21:28:21 +08:00
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-07 00:09:32 +08:00
|
|
|
void
|
|
|
|
ngx_os_status(ngx_log_t *log)
|
2004-10-04 04:02:06 +08:00
|
|
|
{
|
2005-09-08 22:36:09 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, log, 0, NGINX_VER);
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
#ifdef NGX_COMPILER
|
|
|
|
ngx_log_error(NGX_LOG_NOTICE, log, 0, "built by " NGX_COMPILER);
|
|
|
|
#endif
|
|
|
|
|
2005-09-07 00:09:32 +08:00
|
|
|
#if (NGX_HAVE_OS_SPECIFIC_INIT)
|
|
|
|
ngx_os_specific_status(log);
|
|
|
|
#endif
|
|
|
|
|
2005-07-25 17:41:38 +08:00
|
|
|
ngx_log_error(NGX_LOG_NOTICE, log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"getrlimit(RLIMIT_NOFILE): %r:%r",
|
2004-10-04 04:02:06 +08:00
|
|
|
rlmt.rlim_cur, rlmt.rlim_max);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-07 00:09:32 +08:00
|
|
|
ngx_int_t
|
|
|
|
ngx_posix_post_conf_init(ngx_log_t *log)
|
2003-05-21 21:28:21 +08:00
|
|
|
{
|
|
|
|
ngx_fd_t pp[2];
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|