Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-09-27 20:03:21 +0400
committerIgor Sysoev <igor@sysoev.ru>2004-09-27 20:03:21 +0400
commit6d2a14aa906b1d576d5151b2410b59cfcab5edd4 (patch)
tree7d8d6d36783a29c4a9ec78e81bb9814155bb355f /src/core
parent4bed6e3120eeccc7f3ea97101decd382552a0ffc (diff)
nginx-0.1.0-2004-09-27-20:03:21 import
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c56
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/core/ngx_conf_file.c53
-rw-r--r--src/core/ngx_conf_file.h1
-rw-r--r--src/core/ngx_cycle.c3
-rw-r--r--src/core/ngx_log.c6
-rw-r--r--src/core/ngx_modules.c100
7 files changed, 94 insertions, 127 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 6d6103c0e..e9046fd95 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -128,15 +128,15 @@ int main(int argc, char *const *argv)
ctx.argc = argc;
ctx.argv = argv;
- if (ngx_getopt(&ctx, &init_cycle) == NGX_ERROR) {
+ if (ngx_os_init(log) == NGX_ERROR) {
return 1;
}
- if (ngx_os_init(log) == NGX_ERROR) {
+ if (!(init_cycle.pool = ngx_create_pool(1024, log))) {
return 1;
}
- if (!(init_cycle.pool = ngx_create_pool(1024, log))) {
+ if (ngx_getopt(&ctx, &init_cycle) == NGX_ERROR) {
return 1;
}
@@ -338,6 +338,10 @@ static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle)
cycle->conf_file.data = (u_char *) NGX_CONF_PATH;
}
+ if (ngx_conf_full_name(cycle, &cycle->conf_file) == NGX_ERROR) {
+ return NGX_ERROR;
+ }
+
return NGX_OK;
}
@@ -372,6 +376,11 @@ static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_core_conf_t *ccf = conf;
+#if !(WIN32)
+ struct passwd *pwd;
+ struct group *grp;
+#endif
+
ngx_conf_init_value(ccf->daemon, 1);
ngx_conf_init_value(ccf->master, 1);
ngx_conf_init_value(ccf->worker_processes, 1);
@@ -384,24 +393,45 @@ static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
#if !(WIN32)
- /* TODO: default "nobody" user */
+ if (ccf->user == (uid_t) NGX_CONF_UNSET) {
+
+ pwd = getpwnam("nobody");
+ if (pwd == NULL) {
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
+ "getpwnam(\"nobody\") failed");
+ return NGX_CONF_ERROR;
+ }
+
+ ccf->user = pwd->pw_uid;
+
+ grp = getgrnam("nobody");
+ if (grp == NULL) {
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
+ "getgrnam(\"nobody\") failed");
+ return NGX_CONF_ERROR;
+ }
+
+ ccf->group = grp->gr_gid;
+ }
if (ccf->pid.len == 0) {
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(NGX_NEWPID_EXT);
+ if (ngx_conf_full_name(cycle, &ccf->pid) == NGX_ERROR) {
+ return NGX_CONF_ERROR;
+ }
- if (!(ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len))) {
- return NGX_CONF_ERROR;
- }
+ ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT);
- ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len),
- NGX_NEWPID_EXT, 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),
+ NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT));
+
#endif
return NGX_CONF_OK;
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 9829873a2..769a9bf41 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -2,7 +2,7 @@
#define _NGINX_H_INCLUDED_
-#define NGINX_VER "nginx/0.0.12"
+#define NGINX_VER "nginx/0.1.0"
#define NGINX_VAR "NGINX"
#define NGX_NEWPID_EXT ".newbin"
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index e02b8c4b5..e0fec6fa0 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -549,33 +549,56 @@ static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_str_t *value, file;
value = cf->args->elts;
+ file = value[1];
- 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))) {
+ if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR){
return NGX_CONF_ERROR;
}
- ngx_cpystrn(ngx_cpymem(file.data, cf->cycle->root.data,
- cf->cycle->root.len),
- value[1].data, value[1].len + 1);
-
ngx_log_error(NGX_LOG_INFO, cf->log, 0, "include %s", file.data);
return ngx_conf_parse(cf, &file);
}
+ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name)
+{
+ u_char *p;
+ ngx_str_t old;
+
+ if (name->data[0] == '/') {
+ return NGX_OK;
+ }
+
+ old = *name;
+
+ name->len = cycle->root.len + old.len;
+
+ if (!(name->data = ngx_palloc(cycle->pool, name->len + 1))) {
+ return NGX_ERROR;
+ }
+
+ p = ngx_cpymem(name->data, cycle->root.data, cycle->root.len),
+ ngx_cpystrn(p, old.data, old.len + 1);
+
+ return NGX_OK;
+}
+
+
ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
{
+ ngx_str_t full;
ngx_uint_t i;
ngx_list_part_t *part;
ngx_open_file_t *file;
if (name) {
+ full = *name;
+
+ if (ngx_conf_full_name(cycle, &full) == NGX_ERROR) {
+ return NULL;
+ }
+
part = &cycle->open_files.part;
file = part->elts;
@@ -590,11 +613,11 @@ ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
i = 0;
}
- if (name->len != file[i].name.len) {
+ if (full.len != file[i].name.len) {
continue;
}
- if (ngx_strcmp(name->data, file[i].name.data) == 0) {
+ if (ngx_strcmp(full.data, file[i].name.data) == 0) {
return &file[i];
}
}
@@ -607,8 +630,12 @@ ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
file->fd = NGX_INVALID_FILE;
if (name) {
- file->name = *name;
+ file->name = full;
+
} else {
+
+ /* stderr */
+
file->name.len = 0;
file->name.data = NULL;
}
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 1bd135473..d2c76131a 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -265,6 +265,7 @@ char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data);
char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
+ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name);
ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name);
void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
char *fmt, ...);
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 9e5143ccb..e5b30b100 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -530,6 +530,9 @@ ngx_int_t ngx_create_pidfile(ngx_cycle_t *cycle, ngx_cycle_t *old_cycle)
if (ccf->pid.len == old_ccf->pid.len
&& ngx_strcmp(ccf->pid.data, old_ccf->pid.data) == 0)
{
+
+ /* pid file name is the same */
+
return NGX_OK;
}
}
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 05ee4dd1d..e542920d4 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -375,6 +375,12 @@ static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
} else {
cf->cycle->new_log->file->name = value[1];
+
+ if (ngx_conf_full_name(cf->cycle, &cf->cycle->new_log->file->name)
+ == NGX_ERROR)
+ {
+ return NGX_CONF_ERROR;
+ }
}
return ngx_set_error_log_levels(cf, cf->cycle->new_log);
diff --git a/src/core/ngx_modules.c b/src/core/ngx_modules.c
deleted file mode 100644
index 8948cdf24..000000000
--- a/src/core/ngx_modules.c
+++ /dev/null
@@ -1,100 +0,0 @@
-
-#include <ngx_config.h>
-#include <ngx_core.h>
-
-
-extern ngx_module_t ngx_core_module;
-extern ngx_module_t ngx_errlog_module;
-
-extern ngx_module_t ngx_events_module;
-extern ngx_module_t ngx_event_core_module;
-extern ngx_module_t ngx_select_module;
-#if (HAVE_POLL)
-extern ngx_module_t ngx_poll_module;
-#endif
-#if (HAVE_KQUEUE)
-extern ngx_module_t ngx_kqueue_module;
-#endif
-#if (HAVE_DEVPOLL)
-extern ngx_module_t ngx_devpoll_module;
-#endif
-#if (HAVE_IOCP)
-extern ngx_module_t ngx_iocp_module;
-#elif (HAVE_AIO)
-extern ngx_module_t ngx_aio_module;
-#endif
-
-
-extern ngx_module_t ngx_http_module;
-extern ngx_module_t ngx_http_core_module;
-extern ngx_module_t ngx_http_log_module;
-extern ngx_module_t ngx_http_cache_module;
-
-extern ngx_module_t ngx_http_write_filter_module;
-extern ngx_module_t ngx_http_output_filter_module;
-extern ngx_module_t ngx_http_header_filter_module;
-
-extern ngx_module_t ngx_http_chunked_filter_module;
-extern ngx_module_t ngx_http_gzip_filter_module;
-extern ngx_module_t ngx_http_not_modified_filter_module;
-extern ngx_module_t ngx_http_range_filter_module;
-extern ngx_module_t ngx_http_charset_filter_module;
-
-extern ngx_module_t ngx_http_static_module;
-extern ngx_module_t ngx_http_index_module;
-extern ngx_module_t ngx_http_proxy_module;
-
-
-ngx_module_t *ngx_modules[] = {
-
- /* core */
-
- &ngx_core_module,
- &ngx_errlog_module,
-
- /* events */
-
- &ngx_events_module,
- &ngx_event_core_module,
-
- &ngx_select_module,
-#if (HAVE_POLL)
- &ngx_poll_module,
-#endif
-#if (HAVE_KQUEUE)
- &ngx_kqueue_module,
-#endif
-#if (HAVE_DEVPOLL)
- &ngx_devpoll_module,
-#endif
-#if (HAVE_IOCP)
- &ngx_iocp_module,
-#elif (HAVE_AIO)
- &ngx_aio_module,
-#endif
-
- /* http */
-
- &ngx_http_module,
-
- &ngx_http_core_module,
- &ngx_http_log_module,
- &ngx_http_cache_module,
-
- &ngx_http_write_filter_module,
- &ngx_http_output_filter_module,
- &ngx_http_header_filter_module,
-
- &ngx_http_chunked_filter_module,
- &ngx_http_gzip_filter_module,
- &ngx_http_not_modified_filter_module,
- &ngx_http_range_filter_module,
- /* &ngx_http_ssi_filter_module, */
- &ngx_http_charset_filter_module,
-
- &ngx_http_static_module,
- &ngx_http_index_module,
- &ngx_http_proxy_module,
-
- NULL
-};