nginx-0.0.3-2004-05-19-00:28:54 import
diff --git a/src/core/nginx.c b/src/core/nginx.c
index be95637..cef3434 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -315,8 +315,8 @@
}
if (cycle->conf_file.data == NULL) {
- cycle->conf_file.len = sizeof(NGINX_CONF) - 1;
- cycle->conf_file.data = NGINX_CONF;
+ cycle->conf_file.len = sizeof(NGX_CONF_PATH) - 1;
+ cycle->conf_file.data = (u_char *) NGX_CONF_PATH;
}
return NGX_OK;
@@ -358,20 +358,20 @@
/* TODO: default "nobody" user */
if (ccf->pid.len == 0) {
- ccf->pid.len = sizeof(NGINX_PID) - 1;
- ccf->pid.data = NGINX_PID;
- ccf->newpid.len = sizeof(NGINX_NEWPID) - 1;
- ccf->newpid.data = NGINX_NEWPID;
+ ccf->pid.len = sizeof(NGX_PID_PATH) - 1;
+ ccf->pid.data = NGX_PID_PATH;
+ ccf->newpid.len = sizeof(NGX_PID_PATH NGX_NEWPID_EXT) - 1;
+ ccf->newpid.data = NGX_PID_PATH NGX_NEWPID_EXT;
} else {
- ccf->newpid.len = ccf->pid.len + sizeof(NGINX_NEWPID_EXT);
+ ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT);
if (!(ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len))) {
return NGX_CONF_ERROR;
}
ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len),
- NGINX_NEWPID_EXT, sizeof(NGINX_NEWPID_EXT));
+ NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT));
}
#endif
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 7d75537..ba59c12 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -3,14 +3,9 @@
#define NGINX_VER "nginx/0.0.3"
-#define NGINX_CONF (u_char *) "nginx.conf"
-#define NGINX_PID "nginx.pid"
-#define NGINX_NEWPID_EXT ".newbin"
-#define NGINX_NEWPID NGINX_PID NGINX_NEWPID_EXT
#define NGINX_VAR "NGINX"
-
-extern ngx_module_t ngx_core_module;
+#define NGX_NEWPID_EXT ".newbin"
#endif /* _NGINX_H_INCLUDED_ */
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index bb05b72..1a29eb0 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -546,6 +546,10 @@
value = cf->args->elts;
+ if (value[1].data[0] == '/') {
+ return ngx_conf_parse(cf, &value[1]);
+ }
+
file.len = cf->cycle->root.len + value[1].len;
if (!(file.data = ngx_palloc(cf->pool, file.len + 1))) {
return NGX_CONF_ERROR;
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 989973a..5a19f30 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -24,7 +24,6 @@
ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
{
void *rv;
- u_char *root;
ngx_uint_t i, n, failed;
ngx_log_t *log;
ngx_conf_t conf;
@@ -34,7 +33,6 @@
ngx_open_file_t *file;
ngx_listening_t *ls, *nls;
ngx_core_module_t *module;
- char cwd[NGX_MAX_PATH + 1];
log = old_cycle->log;
@@ -51,42 +49,8 @@
cycle->log = log;
cycle->old_cycle = old_cycle;
cycle->conf_file = old_cycle->conf_file;
-
-
- for (i = cycle->conf_file.len; i > 0; i--) {
- if (cycle->conf_file.data[i] == '/') {
- break;
- }
- }
-
- if (i == 0 && cycle->conf_file.data[i] != '/') {
- if (ngx_getcwd(cwd, NGX_MAX_PATH) == 0) {
- ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
- ngx_getcwd_n " failed");
- ngx_destroy_pool(pool);
- return NULL;
- }
-
- for ( /* void */; i < NGX_MAX_PATH && cwd[i]; i++) /* void */;
- cwd[i] = '/';
- cwd[i + 1] = '\0';
-
- root = (u_char *) cwd;
-
- } else {
- root = cycle->conf_file.data;
- }
-
- cycle->root.len = ++i;
- cycle->root.data = ngx_palloc(pool, ++i);
- if (cycle->root.data == NULL) {
- ngx_destroy_pool(pool);
- return NULL;
- }
-
- ngx_cpystrn(cycle->root.data, root, i);
-
- ngx_log_error(NGX_LOG_INFO, log, 0, "root: %s", cycle->root.data);
+ cycle->root.len = sizeof(NGX_PREFIX) - 1;
+ cycle->root.data = (u_char *) NGX_PREFIX;
n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
@@ -472,12 +436,13 @@
ngx_int_t ngx_create_pidfile(ngx_cycle_t *cycle, ngx_cycle_t *old_cycle)
{
+ ngx_uint_t trunc;
size_t len;
u_char *name, pid[NGX_INT64_LEN + 1];
ngx_file_t file;
ngx_core_conf_t *ccf, *old_ccf;
- if (old_cycle && old_cycle->conf_ctx == NULL) {
+ if (!ngx_test_config && old_cycle && old_cycle->conf_ctx == NULL) {
/*
* do not create the pid file in the first ngx_init_cycle() call
@@ -489,7 +454,7 @@
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
- if (old_cycle) {
+ if (!ngx_test_config && old_cycle) {
old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx,
ngx_core_module);
@@ -506,8 +471,10 @@
file.name = (ngx_inherited && getppid() > 1) ? ccf->newpid : ccf->pid;
file.log = cycle->log;
+ trunc = ngx_test_config ? 0: NGX_FILE_TRUNCATE;
+
file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR,
- NGX_FILE_CREATE_OR_OPEN|NGX_FILE_TRUNCATE);
+ NGX_FILE_CREATE_OR_OPEN|trunc);
if (file.fd == NGX_INVALID_FILE) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
@@ -515,8 +482,10 @@
return NGX_ERROR;
}
- if (ngx_write_file(&file, pid, len, 0) == NGX_ERROR) {
- return NGX_ERROR;
+ if (!ngx_test_config) {
+ if (ngx_write_file(&file, pid, len, 0) == NGX_ERROR) {
+ return NGX_ERROR;
+ }
}
if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {