nginx-0.1.0-2004-09-27-20:03:21 import

This commit is contained in:
Igor Sysoev 2004-09-27 16:03:21 +00:00
parent 4bed6e3120
commit 6d2a14aa90
11 changed files with 215 additions and 148 deletions

1
auto/configure vendored
View File

@ -31,6 +31,7 @@ fi
. auto/make
. auto/lib/make
. auto/install
if [ "$PLATFORM" != win32 ]; then
. auto/unix

45
auto/install Normal file
View File

@ -0,0 +1,45 @@
cat << END >> $MAKEFILE
install:
test -d $PREFIX || mkdir -p $PREFIX
test -d `dirname $SBIN_PATH` || mkdir -p `dirname $SBIN_PATH`
cp nginx $SBIN_PATH
test -d `dirname $CONF_PATH` || mkdir -p `dirname $CONF_PATH`
cp conf/koi-win `dirname $CONF_PATH`
test -f `dirname $CONF_PATH`/mime.types || \
cp conf/mime.types `dirname $CONF_PATH`/mime.types
cp conf/mime.types `dirname $CONF_PATH`/mime.types.default
test -f $CONF_PATH || cp conf/nginx.conf $CONF_PATH
cp conf/nginx.conf `dirname $CONF_PATH`/nginx.conf.default
test -d `dirname $PID_PATH` || mkdir -p `dirname $PID_PATH`
test -d `dirname $ERROR_LOG_PATH` || mkdir -p `dirname $ERROR_LOG_PATH`
test -d `dirname $HTTP_LOG_PATH` || mkdir -p `dirname $HTTP_LOG_PATH`
test -d $PREFIX/html || cp -r html $PREFIX
#test -d $PREFIX/temp || mkdir -p $PREFIX/temp
END
if test ! -f Makefile; then
cat << END > Makefile
build:
\$(MAKE) -f $OBJS/Makefile
install:
\$(MAKE) -f $OBJS/Makefile install
clean:
rm -rf Makefile $OBJS
END
fi

View File

@ -33,10 +33,10 @@ HTTP=YES
HTTP_CHARSET=YES
HTTP_GZIP=YES
HTTP_SSL=NO
HTTP_SSI=YES
HTTP_SSI=NO
HTTP_ACCESS=YES
HTTP_USERID=YES
HTTP_STATUS=YES
HTTP_STATUS=NO
HTTP_REWRITE=YES
HTTP_PROXY=YES
@ -183,22 +183,72 @@ if [ ".$PREFIX" = "." ]; then
PREFIX=/usr/local/nginx
fi
if [ ".$SBIN_PATH" = "." ]; then
SBIN_PATH=$PREFIX/sbin/nginx
fi
if [ ".$CONF_PATH" = "." ]; then
CONF_PATH=$PREFIX/conf/nginx.conf
fi
case ".$SBIN_PATH" in
./*)
;;
if [ ".$PID_PATH" = "." ]; then
PID_PATH=$PREFIX/logs/nginx.pid
fi
.)
SBIN_PATH=$PREFIX/sbin/nginx
;;
if [ ".$ERROR_LOG_PATH" = "." ]; then
ERROR_LOG_PATH=$PREFIX/logs/error.log
fi
*)
SBIN_PATH=$PREFIX/$SBIN_PATH
;;
esac
if [ ".$HTTP_LOG_PATH" = "." ]; then
HTTP_LOG_PATH=$PREFIX/logs/access.log
fi
case ".$CONF_PATH" in
./*)
;;
.)
CONF_PATH=$PREFIX/conf/nginx.conf
;;
*)
CONF_PATH=$PREFIX/$CONF_PATH
;;
esac
case ".$PID_PATH" in
./*)
;;
.)
PID_PATH=$PREFIX/logs/nginx.pid
;;
*)
PID_PATH=$PREFIX/$PID_PATH
;;
esac
case ".$ERROR_LOG_PATH" in
./*)
;;
.)
ERROR_LOG_PATH=$PREFIX/logs/error.log
;;
*)
ERROR_LOG_PATH=$PREFIX/$ERROR_LOG_PATH
;;
esac
case ".$HTTP_LOG_PATH" in
./*)
;;
.)
HTTP_LOG_PATH=$PREFIX/logs/access.log
;;
*)
HTTP_LOG_PATH=$PREFIX/$HTTP_LOG_PATH
;;
esac

View File

@ -128,10 +128,6 @@ int main(int argc, char *const *argv)
ctx.argc = argc;
ctx.argv = argv;
if (ngx_getopt(&ctx, &init_cycle) == NGX_ERROR) {
return 1;
}
if (ngx_os_init(log) == NGX_ERROR) {
return 1;
}
@ -140,6 +136,10 @@ int main(int argc, char *const *argv)
return 1;
}
if (ngx_getopt(&ctx, &init_cycle) == NGX_ERROR) {
return 1;
}
if (ngx_add_inherited_sockets(&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 (!(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));
}
if (ngx_conf_full_name(cycle, &ccf->pid) == NGX_ERROR) {
return NGX_CONF_ERROR;
}
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),
NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT));
#endif
return NGX_CONF_OK;

View File

@ -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"

View File

@ -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;
}

View File

@ -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, ...);

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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
};

View File

@ -1416,6 +1416,10 @@ static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
ngx_conf_merge_str_value(conf->root, prev->root, "html");
if (ngx_conf_full_name(cf->cycle, &conf->root) == NGX_ERROR) {
return NGX_CONF_ERROR;
}
if (conf->types == NULL) {
if (prev->types) {
conf->types = prev->types;