-p and --prefix=

This commit is contained in:
Igor Sysoev 2009-04-27 11:32:33 +00:00
parent df585ef949
commit 5ef370df40
13 changed files with 296 additions and 190 deletions

37
auto/configure vendored
View File

@ -52,20 +52,26 @@ fi
. auto/modules . auto/modules
. auto/lib/conf . auto/lib/conf
. auto/make case ".$NGX_PREFIX" in
. auto/lib/make .)
. auto/install NGX_PREFIX=${NGX_PREFIX:-/usr/local/nginx}
have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
;;
if [ "$NGX_PLATFORM" != win32 ]; then .!)
. auto/unix NGX_PREFIX=
;;
*)
have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
;;
esac
if [ ".$NGX_CONF_PREFIX" != "." ]; then
have=NGX_CONF_PREFIX value="\"$NGX_CONF_PREFIX/\"" . auto/define
fi fi
# STUB
. auto/stubs
have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
have=NGX_SBIN_PATH value="\"$NGX_SBIN_PATH\"" . auto/define have=NGX_SBIN_PATH value="\"$NGX_SBIN_PATH\"" . auto/define
have=NGX_CONF_PREFIX value="\"$NGX_CONF_PREFIX/\"" . auto/define
have=NGX_CONF_PATH value="\"$NGX_CONF_PATH\"" . auto/define have=NGX_CONF_PATH value="\"$NGX_CONF_PATH\"" . auto/define
have=NGX_PID_PATH value="\"$NGX_PID_PATH\"" . auto/define have=NGX_PID_PATH value="\"$NGX_PID_PATH\"" . auto/define
have=NGX_LOCK_PATH value="\"$NGX_LOCK_PATH\"" . auto/define have=NGX_LOCK_PATH value="\"$NGX_LOCK_PATH\"" . auto/define
@ -79,6 +85,17 @@ have=NGX_HTTP_PROXY_TEMP_PATH value="\"$NGX_HTTP_PROXY_TEMP_PATH\""
have=NGX_HTTP_FASTCGI_TEMP_PATH value="\"$NGX_HTTP_FASTCGI_TEMP_PATH\"" have=NGX_HTTP_FASTCGI_TEMP_PATH value="\"$NGX_HTTP_FASTCGI_TEMP_PATH\""
. auto/define . auto/define
. auto/make
. auto/lib/make
. auto/install
if [ "$NGX_PLATFORM" != win32 ]; then
. auto/unix
fi
# STUB
. auto/stubs
have=NGX_USER value="\"$NGX_USER\"" . auto/define have=NGX_USER value="\"$NGX_USER\"" . auto/define
have=NGX_GROUP value="\"$NGX_GROUP\"" . auto/define have=NGX_GROUP value="\"$NGX_GROUP\"" . auto/define

View File

@ -15,6 +15,63 @@ END
fi fi
case ".$NGX_SBIN_PATH" in
./*)
;;
.)
NGX_SBIN_PATH=$NGX_PREFIX/sbin/nginx
;;
*)
NGX_SBIN_PATH=$NGX_PREFIX/$NGX_SBIN_PATH
;;
esac
case ".$NGX_CONF_PATH" in
./*)
;;
*)
NGX_CONF_PATH=$NGX_PREFIX/$NGX_CONF_PATH
;;
esac
NGX_CONF_PREFIX=`dirname $NGX_CONF_PATH`
case ".$NGX_PID_PATH" in
./*)
;;
*)
NGX_PID_PATH=$NGX_PREFIX/$NGX_PID_PATH
;;
esac
case ".$NGX_ERROR_LOG_PATH" in
./*)
;;
*)
NGX_ERROR_LOG_PATH=$NGX_PREFIX/$NGX_ERROR_LOG_PATH
;;
esac
case ".$NGX_HTTP_LOG_PATH" in
./*)
;;
*)
NGX_HTTP_LOG_PATH=$NGX_PREFIX/$NGX_HTTP_LOG_PATH
;;
esac
cat << END >> $NGX_MAKEFILE cat << END >> $NGX_MAKEFILE
install: $NGX_OBJS${ngx_dirsep}nginx${ngx_binext} \ install: $NGX_OBJS${ngx_dirsep}nginx${ngx_binext} \

View File

@ -143,6 +143,7 @@ do
case "$option" in case "$option" in
--help) help=yes ;; --help) help=yes ;;
--prefix=) NGX_PREFIX="!" ;;
--prefix=*) NGX_PREFIX="$value" ;; --prefix=*) NGX_PREFIX="$value" ;;
--sbin-path=*) NGX_SBIN_PATH="$value" ;; --sbin-path=*) NGX_SBIN_PATH="$value" ;;
--conf-path=*) NGX_CONF_PATH="$value" ;; --conf-path=*) NGX_CONF_PATH="$value" ;;
@ -415,141 +416,21 @@ if [ ".$NGX_PLATFORM" = ".win32" ]; then
fi fi
NGX_PREFIX=${NGX_PREFIX:-/usr/local/nginx} NGX_CONF_PATH=${NGX_CONF_PATH:-conf/nginx.conf}
case ".$NGX_SBIN_PATH" in
./*)
;;
.)
NGX_SBIN_PATH=$NGX_PREFIX/sbin/nginx
;;
*)
NGX_SBIN_PATH=$NGX_PREFIX/$NGX_SBIN_PATH
;;
esac
case ".$NGX_CONF_PATH" in
./*)
;;
.)
NGX_CONF_PATH=$NGX_PREFIX/conf/nginx.conf
;;
*)
NGX_CONF_PATH=$NGX_PREFIX/$NGX_CONF_PATH
;;
esac
NGX_CONF_PREFIX=`dirname $NGX_CONF_PATH` NGX_CONF_PREFIX=`dirname $NGX_CONF_PATH`
NGX_PID_PATH=${NGX_PID_PATH:-logs/nginx.pid}
NGX_LOCK_PATH=${NGX_LOCK_PATH:-logs/nginx.lock}
if [ ".$NGX_ERROR_LOG_PATH" = ".stderr" ]; then
case ".$NGX_PID_PATH" in
./*)
;;
.)
NGX_PID_PATH=$NGX_PREFIX/logs/nginx.pid
;;
*)
NGX_PID_PATH=$NGX_PREFIX/$NGX_PID_PATH
;;
esac
case ".$NGX_LOCK_PATH" in
./*)
;;
.)
NGX_LOCK_PATH=$NGX_PREFIX/logs/nginx.lock
;;
*)
NGX_LOCK_PATH=$NGX_PREFIX/$NGX_LOCK_PATH
;;
esac
case ".$NGX_ERROR_LOG_PATH" in
./*)
;;
.)
NGX_ERROR_LOG_PATH=$NGX_PREFIX/logs/error.log
;;
.stderr)
NGX_ERROR_LOG_PATH= NGX_ERROR_LOG_PATH=
;; else
NGX_ERROR_LOG_PATH=${NGX_ERROR_LOG_PATH:-logs/error.log}
*) fi
NGX_ERROR_LOG_PATH=$NGX_PREFIX/$NGX_ERROR_LOG_PATH
;;
esac
case ".$NGX_HTTP_LOG_PATH" in
./*)
;;
.)
NGX_HTTP_LOG_PATH=$NGX_PREFIX/logs/access.log
;;
*)
NGX_HTTP_LOG_PATH=$NGX_PREFIX/$NGX_HTTP_LOG_PATH
;;
esac
case ".$NGX_HTTP_CLIENT_TEMP_PATH" in
./*)
;;
.)
NGX_HTTP_CLIENT_TEMP_PATH=$NGX_PREFIX/client_body_temp
;;
*)
NGX_HTTP_CLIENT_TEMP_PATH=$NGX_PREFIX/$NGX_HTTP_CLIENT_TEMP_PATH
;;
esac
case ".$NGX_HTTP_PROXY_TEMP_PATH" in
./*)
;;
.)
NGX_HTTP_PROXY_TEMP_PATH=$NGX_PREFIX/proxy_temp
;;
*)
NGX_HTTP_PROXY_TEMP_PATH=$NGX_PREFIX/$NGX_HTTP_PROXY_TEMP_PATH
;;
esac
case ".$NGX_HTTP_FASTCGI_TEMP_PATH" in
./*)
;;
.)
NGX_HTTP_FASTCGI_TEMP_PATH=$NGX_PREFIX/fastcgi_temp
;;
*)
NGX_HTTP_FASTCGI_TEMP_PATH=$NGX_PREFIX/$NGX_HTTP_FASTCGI_TEMP_PATH
;;
esac
NGX_HTTP_LOG_PATH=${NGX_HTTP_LOG_PATH:-logs/access.log}
NGX_HTTP_CLIENT_TEMP_PATH=${NGX_HTTP_CLIENT_TEMP_PATH:-client_body_temp}
NGX_HTTP_PROXY_TEMP_PATH=${NGX_HTTP_PROXY_TEMP_PATH:-proxy_temp}
NGX_HTTP_FASTCGI_TEMP_PATH=${NGX_HTTP_FASTCGI_TEMP_PATH:-fastcgi_temp}
case ".$NGX_PERL_MODULES" in case ".$NGX_PERL_MODULES" in
./*) ./*)

View File

@ -11,7 +11,7 @@
static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle); static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle);
static ngx_int_t ngx_get_options(int argc, char *const *argv); static ngx_int_t ngx_get_options(int argc, char *const *argv);
static void ngx_process_options(ngx_cycle_t *cycle); static ngx_int_t ngx_process_options(ngx_cycle_t *cycle);
static ngx_int_t ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv); static ngx_int_t ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv);
static void *ngx_core_module_create_conf(ngx_cycle_t *cycle); static void *ngx_core_module_create_conf(ngx_cycle_t *cycle);
static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf); static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf);
@ -186,6 +186,7 @@ ngx_uint_t ngx_max_module;
static ngx_uint_t ngx_show_help; static ngx_uint_t ngx_show_help;
static ngx_uint_t ngx_show_version; static ngx_uint_t ngx_show_version;
static ngx_uint_t ngx_show_configure; static ngx_uint_t ngx_show_configure;
static u_char *ngx_prefix;
static u_char *ngx_conf_file; static u_char *ngx_conf_file;
static u_char *ngx_conf_params; static u_char *ngx_conf_params;
static char *ngx_signal; static char *ngx_signal;
@ -221,6 +222,12 @@ main(int argc, char *const *argv)
" -t : test configuration and exit" CRLF " -t : test configuration and exit" CRLF
" -s signal : send signal to a master process: " " -s signal : send signal to a master process: "
"stop, quit, reopen, reload" CRLF "stop, quit, reopen, reload" CRLF
#ifdef NGX_PREFIX
" -p prefix : set prefix path (default: "
NGX_PREFIX ")" CRLF
#else
" -p prefix : set prefix path (default: NONE)" CRLF
#endif
" -c filename : set configuration file (default: " " -c filename : set configuration file (default: "
NGX_CONF_PATH ")" CRLF NGX_CONF_PATH ")" CRLF
" -g directives : set global directives out of configuration " " -g directives : set global directives out of configuration "
@ -254,7 +261,7 @@ main(int argc, char *const *argv)
ngx_pid = ngx_getpid(); ngx_pid = ngx_getpid();
log = ngx_log_init(); log = ngx_log_init(ngx_prefix);
if (log == NULL) { if (log == NULL) {
return 1; return 1;
} }
@ -282,7 +289,9 @@ main(int argc, char *const *argv)
return 1; return 1;
} }
ngx_process_options(&init_cycle); if (ngx_process_options(&init_cycle) != NGX_OK) {
return 1;
}
if (ngx_os_init(log) != NGX_OK) { if (ngx_os_init(log) != NGX_OK) {
return 1; return 1;
@ -662,6 +671,20 @@ ngx_get_options(int argc, char *const *argv)
ngx_test_config = 1; ngx_test_config = 1;
break; break;
case 'p':
if (*p) {
ngx_prefix = p;
goto next;
}
if (argv[++i]) {
ngx_prefix = (u_char *) argv[i];
goto next;
}
ngx_log_stderr(0, "option \"-p\" requires directory name");
return NGX_ERROR;
case 'c': case 'c':
if (*p) { if (*p) {
ngx_conf_file = p; ngx_conf_file = p;
@ -771,9 +794,69 @@ ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv)
} }
static void static ngx_int_t
ngx_process_options(ngx_cycle_t *cycle) ngx_process_options(ngx_cycle_t *cycle)
{ {
u_char *p;
size_t len;
if (ngx_prefix) {
len = ngx_strlen(ngx_prefix);
p = ngx_prefix;
if (!ngx_path_separator(*p)) {
p = ngx_pnalloc(cycle->pool, len + 1);
if (p == NULL) {
return NGX_ERROR;
}
ngx_memcpy(p, ngx_prefix, len);
p[len++] = '/';
}
cycle->conf_prefix.len = len;
cycle->conf_prefix.data = p;
cycle->prefix.len = len;
cycle->prefix.data = p;
} else {
#ifndef NGX_PREFIX
p = ngx_pnalloc(cycle->pool, NGX_MAX_PATH);
if (p == NULL) {
return NGX_ERROR;
}
if (ngx_getcwd(p, NGX_MAX_PATH) == 0) {
ngx_log_stderr(ngx_errno, "[emerg]: " ngx_getcwd_n " failed");
return NGX_ERROR;
}
len = ngx_strlen(p);
p[len++] = '/';
cycle->conf_prefix.len = len;
cycle->conf_prefix.data = p;
cycle->prefix.len = len;
cycle->prefix.data = p;
#else
#ifdef NGX_CONF_PREFIX
cycle->conf_prefix.len = sizeof(NGX_CONF_PREFIX) - 1;
cycle->conf_prefix.data = (u_char *) NGX_CONF_PREFIX;
#else
cycle->conf_prefix.len = sizeof(NGX_PREFIX) - 1;
cycle->conf_prefix.data = (u_char *) NGX_PREFIX;
#endif
cycle->prefix.len = sizeof(NGX_PREFIX) - 1;
cycle->prefix.data = (u_char *) NGX_PREFIX;
#endif
}
if (ngx_conf_file) { if (ngx_conf_file) {
cycle->conf_file.len = ngx_strlen(ngx_conf_file); cycle->conf_file.len = ngx_strlen(ngx_conf_file);
cycle->conf_file.data = ngx_conf_file; cycle->conf_file.data = ngx_conf_file;
@ -783,6 +866,21 @@ ngx_process_options(ngx_cycle_t *cycle)
cycle->conf_file.data = (u_char *) NGX_CONF_PATH; cycle->conf_file.data = (u_char *) NGX_CONF_PATH;
} }
if (ngx_conf_full_name(cycle, &cycle->conf_file, 0) != NGX_OK) {
return NGX_ERROR;
}
for (p = cycle->conf_file.data + cycle->conf_file.len - 1;
p > cycle->conf_file.data;
p--)
{
if (ngx_path_separator(*p)) {
cycle->conf_prefix.len = p - ngx_cycle->conf_file.data + 1;
cycle->conf_prefix.data = ngx_cycle->conf_file.data;
break;
}
}
if (ngx_conf_params) { if (ngx_conf_params) {
cycle->conf_param.len = ngx_strlen(ngx_conf_params); cycle->conf_param.len = ngx_strlen(ngx_conf_params);
cycle->conf_param.data = ngx_conf_params; cycle->conf_param.data = ngx_conf_params;
@ -791,6 +889,8 @@ ngx_process_options(ngx_cycle_t *cycle)
if (ngx_test_config) { if (ngx_test_config) {
cycle->log->log_level = NGX_LOG_INFO; cycle->log->log_level = NGX_LOG_INFO;
} }
return NGX_OK;
} }

View File

@ -798,10 +798,6 @@ ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
u_char *p, *prefix; u_char *p, *prefix;
ngx_str_t old; ngx_str_t old;
if (name->data[0] == '/') {
return NGX_OK;
}
#if (NGX_WIN32) #if (NGX_WIN32)
if (name->len > 2 if (name->len > 2
@ -812,17 +808,23 @@ ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
return NGX_OK; return NGX_OK;
} }
#else
if (name->data[0] == '/') {
return NGX_OK;
}
#endif #endif
old = *name; old = *name;
if (conf_prefix) { if (conf_prefix) {
len = sizeof(NGX_CONF_PREFIX) - 1; len = cycle->conf_prefix.len;
prefix = (u_char *) NGX_CONF_PREFIX; prefix = cycle->conf_prefix.data;
} else { } else {
len = cycle->root.len; len = cycle->prefix.len;
prefix = cycle->root.data; prefix = cycle->prefix.data;
} }
name->len = len + old.len; name->len = len + old.len;
@ -851,7 +853,7 @@ ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
full.data = NULL; full.data = NULL;
#endif #endif
if (name) { if (name && name->len) {
full = *name; full = *name;
if (ngx_conf_full_name(cycle, &full, 0) != NGX_OK) { if (ngx_conf_full_name(cycle, &full, 0) != NGX_OK) {
@ -887,7 +889,7 @@ ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
return NULL; return NULL;
} }
if (name) { if (name && name->len) {
file->fd = NGX_INVALID_FILE; file->fd = NGX_INVALID_FILE;
file->name = full; file->name = full;

View File

@ -34,11 +34,7 @@ ngx_tls_key_t ngx_core_tls_key;
static ngx_connection_t dumb; static ngx_connection_t dumb;
/* STUB */ /* STUB */
#ifdef NGX_ERROR_LOG_PATH
static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH); static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH);
#else
static ngx_str_t error_log = ngx_null_string;
#endif
ngx_cycle_t * ngx_cycle_t *
@ -87,9 +83,20 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
cycle->pool = pool; cycle->pool = pool;
cycle->log = log; cycle->log = log;
cycle->old_cycle = old_cycle; cycle->old_cycle = old_cycle;
cycle->root.len = sizeof(NGX_PREFIX) - 1;
cycle->root.data = (u_char *) NGX_PREFIX;
cycle->conf_prefix.len = old_cycle->conf_prefix.len;
cycle->conf_prefix.data = ngx_pstrdup(pool, &old_cycle->conf_prefix);
if (cycle->conf_prefix.data == NULL) {
ngx_destroy_pool(pool);
return NULL;
}
cycle->prefix.len = old_cycle->prefix.len;
cycle->prefix.data = ngx_pstrdup(pool, &old_cycle->prefix);
if (cycle->prefix.data == NULL) {
ngx_destroy_pool(pool);
return NULL;
}
cycle->conf_file.len = old_cycle->conf_file.len; cycle->conf_file.len = old_cycle->conf_file.len;
cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1); cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1);
@ -100,15 +107,12 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
ngx_cpystrn(cycle->conf_file.data, old_cycle->conf_file.data, ngx_cpystrn(cycle->conf_file.data, old_cycle->conf_file.data,
old_cycle->conf_file.len + 1); old_cycle->conf_file.len + 1);
cycle->conf_param.len = old_cycle->conf_param.len; cycle->conf_param.len = old_cycle->conf_param.len;
cycle->conf_param.data = ngx_pnalloc(pool, old_cycle->conf_param.len); cycle->conf_param.data = ngx_pstrdup(pool, &old_cycle->conf_param);
if (cycle->conf_param.data == NULL) { if (cycle->conf_param.data == NULL) {
ngx_destroy_pool(pool); ngx_destroy_pool(pool);
return NULL; return NULL;
} }
ngx_memcpy(cycle->conf_param.data, old_cycle->conf_param.data,
old_cycle->conf_param.len);
n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10; n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
@ -162,14 +166,12 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
} }
cycle->new_log = ngx_log_create_errlog(cycle, NULL); cycle->new_log = ngx_log_create_errlog(cycle, &error_log);
if (cycle->new_log == NULL) { if (cycle->new_log == NULL) {
ngx_destroy_pool(pool); ngx_destroy_pool(pool);
return NULL; return NULL;
} }
cycle->new_log->file->name = error_log;
n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10; n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10;
@ -350,7 +352,7 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
i = 0; i = 0;
} }
if (file[i].name.data == NULL) { if (file[i].name.len == 0) {
continue; continue;
} }
@ -1083,7 +1085,7 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
i = 0; i = 0;
} }
if (file[i].name.data == NULL) { if (file[i].name.len == 0) {
continue; continue;
} }

View File

@ -60,7 +60,8 @@ struct ngx_cycle_s {
ngx_str_t conf_file; ngx_str_t conf_file;
ngx_str_t conf_param; ngx_str_t conf_param;
ngx_str_t root; ngx_str_t conf_prefix;
ngx_str_t prefix;
ngx_str_t lock_file; ngx_str_t lock_file;
ngx_str_t hostname; ngx_str_t hostname;
}; };

View File

@ -273,38 +273,84 @@ ngx_log_stderr(ngx_err_t err, const char *fmt, ...)
ngx_log_t * ngx_log_t *
ngx_log_init(void) ngx_log_init(u_char *prefix)
{ {
u_char *p, *name;
size_t nlen, plen;
ngx_log.file = &ngx_log_file; ngx_log.file = &ngx_log_file;
ngx_log.log_level = NGX_LOG_NOTICE; ngx_log.log_level = NGX_LOG_NOTICE;
name = (u_char *) NGX_ERROR_LOG_PATH;
/* /*
* we use ngx_strlen() here since BCC warns about * we use ngx_strlen() here since BCC warns about
* condition is always false and unreachable code * condition is always false and unreachable code
*/ */
if (ngx_strlen(NGX_ERROR_LOG_PATH) == 0) { nlen = ngx_strlen(name);
if (nlen == 0) {
ngx_log_file.fd = ngx_stderr; ngx_log_file.fd = ngx_stderr;
return &ngx_log; return &ngx_log;
} }
ngx_log_file.fd = ngx_open_file((u_char *) NGX_ERROR_LOG_PATH, p = NULL;
NGX_FILE_APPEND,
#if (NGX_WIN32)
if (name[1] != ':') {
#else
if (name[0] != '/') {
#endif
plen = 0;
if (prefix) {
plen = ngx_strlen(prefix);
#ifdef NGX_PREFIX
} else {
prefix = (u_char *) NGX_PREFIX;
plen = ngx_strlen(prefix);
#endif
}
if (plen) {
name = malloc(plen + nlen + 2);
if (name == NULL) {
return NULL;
}
p = ngx_cpymem(name, prefix, plen);
if (!ngx_path_separator(*(p - 1))) {
*p++ = '/';
}
ngx_cpystrn(p, (u_char *) NGX_ERROR_LOG_PATH, nlen + 1);
p = name;
}
}
ngx_log_file.fd = ngx_open_file(name, NGX_FILE_APPEND,
NGX_FILE_CREATE_OR_OPEN, NGX_FILE_CREATE_OR_OPEN,
NGX_FILE_DEFAULT_ACCESS); NGX_FILE_DEFAULT_ACCESS);
if (ngx_log_file.fd == NGX_INVALID_FILE) { if (ngx_log_file.fd == NGX_INVALID_FILE) {
ngx_log_stderr(ngx_errno, ngx_log_stderr(ngx_errno,
"[emerg]: could not open error log file: " "[alert]: could not open error log file: "
ngx_open_file_n " \"" NGX_ERROR_LOG_PATH "\" failed"); ngx_open_file_n " \"%s\" failed", name);
#if (NGX_WIN32) #if (NGX_WIN32)
ngx_event_log(ngx_errno, ngx_event_log(ngx_errno,
"could not open error log file: " "could not open error log file: "
ngx_open_file_n " \"" NGX_ERROR_LOG_PATH "\" failed"); ngx_open_file_n " \"%s\" failed", name);
#endif #endif
return NULL; ngx_log_file.fd = ngx_stderr;
}
if (p) {
ngx_free(p);
} }
return &ngx_log; return &ngx_log;

View File

@ -195,7 +195,7 @@ void ngx_cdecl ngx_log_debug_core(ngx_log_t *log, ngx_err_t err,
/*********************************/ /*********************************/
ngx_log_t *ngx_log_init(void); ngx_log_t *ngx_log_init(u_char *prefix);
ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_str_t *name); ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_str_t *name);
char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log); char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log);
void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...); void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...);

View File

@ -1213,7 +1213,7 @@ ngx_http_script_add_full_name_code(ngx_http_script_compile_t *sc)
} }
code->code = (ngx_http_script_code_pt) ngx_http_script_full_name_len_code; code->code = (ngx_http_script_code_pt) ngx_http_script_full_name_len_code;
code->prefix = sc->conf_prefix; code->conf_prefix = sc->conf_prefix;
code = ngx_http_script_add_code(*sc->values, code = ngx_http_script_add_code(*sc->values,
sizeof(ngx_http_script_full_name_code_t), sizeof(ngx_http_script_full_name_code_t),
@ -1223,7 +1223,7 @@ ngx_http_script_add_full_name_code(ngx_http_script_compile_t *sc)
} }
code->code = ngx_http_script_full_name_code; code->code = ngx_http_script_full_name_code;
code->prefix = sc->conf_prefix; code->conf_prefix = sc->conf_prefix;
return NGX_OK; return NGX_OK;
} }
@ -1238,7 +1238,8 @@ ngx_http_script_full_name_len_code(ngx_http_script_engine_t *e)
e->ip += sizeof(ngx_http_script_full_name_code_t); e->ip += sizeof(ngx_http_script_full_name_code_t);
return code->prefix ? sizeof(NGX_CONF_PREFIX) : ngx_cycle->root.len; return code->conf_prefix ? ngx_cycle->conf_prefix.len:
ngx_cycle->prefix.len;
} }
@ -1254,7 +1255,7 @@ ngx_http_script_full_name_code(ngx_http_script_engine_t *e)
value.data = e->buf.data; value.data = e->buf.data;
value.len = e->pos - e->buf.data; value.len = e->pos - e->buf.data;
if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &value, code->prefix) if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &value, code->conf_prefix)
!= NGX_OK) != NGX_OK)
{ {
e->ip = ngx_http_script_exit; e->ip = ngx_http_script_exit;

View File

@ -153,7 +153,7 @@ typedef struct {
typedef struct { typedef struct {
ngx_http_script_code_pt code; ngx_http_script_code_pt code;
uintptr_t prefix; uintptr_t conf_prefix;
} ngx_http_script_full_name_code_t; } ngx_http_script_full_name_code_t;

View File

@ -158,7 +158,7 @@ ngx_int_t ngx_set_file_time(u_char *name, ngx_fd_t fd, time_t s);
#define ngx_realpath(p, r) realpath((char *) p, (char *) r) #define ngx_realpath(p, r) realpath((char *) p, (char *) r)
#define ngx_realpath_n "realpath()" #define ngx_realpath_n "realpath()"
#define ngx_getcwd(buf, size) (getcwd(buf, size) != NULL) #define ngx_getcwd(buf, size) (getcwd((char *) buf, size) != NULL)
#define ngx_getcwd_n "getcwd()" #define ngx_getcwd_n "getcwd()"
#define ngx_path_separator(c) ((c) == '/') #define ngx_path_separator(c) ((c) == '/')

View File

@ -152,13 +152,12 @@ ngx_int_t ngx_file_info(u_char *filename, ngx_file_info_t *fi);
char *ngx_realpath(u_char *path, u_char *resolved); char *ngx_realpath(u_char *path, u_char *resolved);
#define ngx_realpath_n "" #define ngx_realpath_n ""
#define ngx_getcwd(buf, size) GetCurrentDirectory(size, buf) #define ngx_getcwd(buf, size) GetCurrentDirectory(size, (char *) buf)
#define ngx_getcwd_n "GetCurrentDirectory()" #define ngx_getcwd_n "GetCurrentDirectory()"
#define ngx_path_separator(c) ((c) == '/' || (c) == '\\') #define ngx_path_separator(c) ((c) == '/' || (c) == '\\')
#define NGX_MAX_PATH MAX_PATH #define NGX_MAX_PATH MAX_PATH
#define NGX_DIR_MASK (u_char *) "/*" #define NGX_DIR_MASK (u_char *) "/*"
#define NGX_DIR_MASK_LEN 2 #define NGX_DIR_MASK_LEN 2