nginx-0.0.2-2004-02-09-23:47:18 import

This commit is contained in:
Igor Sysoev 2004-02-09 20:47:18 +00:00
parent f14d69e4cc
commit e9b2cb1b9d
11 changed files with 196 additions and 56 deletions

2
auto/configure vendored
View File

@ -3,7 +3,7 @@
. auto/init
. auto/sources
test $OBJ || mkdir $OBJ
test -d $OBJ || mkdir $OBJ
echo > $NGX_AUTO_CONFIG_H
if [ "$PLATFORM" != win32 ]; then

View File

@ -1,19 +1,6 @@
if [ $PCRE != NO ]; then
CORE_INCS="$CORE_INCS -I $PCRE"
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
if [ "$PLATFORM" = "win32" ]; then
CFLAGS="$CFLAGS -D PCRE_STATIC -D HAVE_PCRE=1"
CORE_LIBS="$CORE_LIBS pcre.lib"
CORE_LINK="$CORE_LINK -libpath:$PCRE"
else
CFLAGS="$CFLAGS -D HAVE_PCRE=1"
CORE_DEPS="$CORE_DEPS $PCRE/.libs/libpcre.a"
CORE_LIBS="$CORE_LIBS -L $PCRE/.libs -lpcre"
fi
if [ $USE_PCRE = YES ]; then
. auto/lib/pcre/conf
fi

38
auto/lib/pcre/conf Normal file
View File

@ -0,0 +1,38 @@
if [ $PCRE != NONE ]; then
CORE_INCS="$CORE_INCS -I $PCRE"
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
if [ "$PLATFORM" = "win32" ]; then
#CFLAGS="$CFLAGS -D PCRE_STATIC -D HAVE_PCRE=1"
have=HAVE_PCRE . auto/have
have=PCRE_STATIC . auto/have
CORE_LIBS="$CORE_LIBS pcre.lib"
CORE_LINK="$CORE_LINK -libpath:$PCRE"
else
#CFLAGS="$CFLAGS -D HAVE_PCRE=1"
have=HAVE_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/.libs/libpcre.a"
CORE_LIBS="$CORE_LIBS -L $PCRE/.libs -lpcre"
fi
else
ngx_lib_inc="#include <pcre.h>"
ngx_lib="PCRE"
ngx_lib_test="pcre *re; pcre_compile(re, 0, NULL, 0, NULL)"
ngx_libs=-lpcre
. auto/lib/test
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_libs"
PCRE=YES
else
PCRE=NO
fi
fi

View File

@ -1,4 +1,43 @@
if [ $EVENT_SELECT = NO -a $EVENT_FOUND = NO ]; then
EVENT_SELECT=YES
fi
if [ $EVENT_SELECT = YES ]; then
CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
fi
if [ $EVENT_POLL = NO -a $EVENT_FOUND = NO ]; then
EVENT_POLL=YES
fi
if [ $EVENT_POLL = YES ]; then
CORE_SRCS="$CORE_SRCS $POLL_SRCS"
EVENT_MODULES="$EVENT_MODULES $POLL_MODULE"
fi
if [ $TEST_BUILD_DEVPOLL = YES ]; then
CFLAGS="$CFLAGS -D HAVE_DEVPOLL=1 -D TEST_BUILD_DEVPOLL=1"
EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
fi
if [ $TEST_BUILD_EPOLL = YES ]; then
CFLAGS="$CFLAGS -D HAVE_EPOLL=1 -D TEST_BUILD_EPOLL=1"
EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
fi
if [ $TEST_BUILD_SIGIO = YES ]; then
CFLAGS="$CFLAGS -D HAVE_SIGIO=1 -D TEST_BUILD_SIGIO=1"
EVENT_MODULES="$EVENT_MODULES $SIGIO_MODULE"
CORE_SRCS="$CORE_SRCS $SIGIO_SRCS"
fi
HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES \
$HTTP_CHUNKED_FILTER_MODULE \
$HTTP_RANGE_FILTER_MODULE \

View File

@ -19,6 +19,7 @@ HTTP_GZIP=YES
HTTP_SSI=YES
HTTP_PROXY=YES
USE_PCRE=NO
PCRE=NO
USE_MD5=NO
@ -43,7 +44,9 @@ do
--builddir=*) OBJS="$value" ;;
--with-select_module) EVENT_SELECT=YES ;;
--without-select_module) EVENT_SELECT=NONE ;;
--with-poll_module) EVENT_POLL=YES ;;
--without-poll_module) EVENT_POLL=NONE ;;
--with-aio_module) EVENT_AIO=YES ;;
--without-http_rewrite_module) HTTP_REWRITE=NO ;;
@ -53,6 +56,7 @@ do
--with-cc=*) CC="$value" ;;
--without-pcre) PCRE=NONE ;;
--with-pcre=*) PCRE="$value" ;;
--with-md5=*) MD5="$value" ;;
--with-zlib=*) ZLIB="$value" ;;

View File

@ -41,34 +41,3 @@ case $PLATFORM in
;;
esac
if [ $EVENT_SELECT = YES -o $EVENT_FOUND = NO ]; then
CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
fi
if [ $EVENT_POLL = YES -o $EVENT_FOUND = NO ]; then
CORE_SRCS="$CORE_SRCS $POLL_SRCS"
EVENT_MODULES="$EVENT_MODULES $POLL_MODULE"
fi
if [ $TEST_BUILD_DEVPOLL = YES ]; then
CFLAGS="$CFLAGS -D HAVE_DEVPOLL=1 -D TEST_BUILD_DEVPOLL=1"
EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
fi
if [ $TEST_BUILD_EPOLL = YES ]; then
CFLAGS="$CFLAGS -D HAVE_EPOLL=1 -D TEST_BUILD_EPOLL=1"
EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
fi
if [ $TEST_BUILD_SIGIO = YES ]; then
CFLAGS="$CFLAGS -D HAVE_SIGIO=1 -D TEST_BUILD_SIGIO=1"
EVENT_MODULES="$EVENT_MODULES $SIGIO_MODULE"
CORE_SRCS="$CORE_SRCS $SIGIO_SRCS"
fi

View File

@ -24,3 +24,27 @@ case $ZLIB in
esac
echo
if [ $HTTP_REWRITE = YES ]; then
if [ $PCRE = NONE -o $PCRE = NO ]; then
echo "$0: error: HTTP rewrite module requires PCRE library."
echo $ngx_n "You can disable the module by using" $ngx_c
echo "--without-http_rewrite_module option"
echo "or you have to enable PCRE support"
echo
exit 1
fi
fi
if [ $HTTP_GZIP = YES ]; then
if [ $ZLIB = NONE -o $ZLIB = NO ]; then
echo "$0: error: HTTP gzip module requires zlib library."
echo $ngx_n "You can disable the module by using" $ngx_c
echo "--without-http_gzip_module option"
echo "or you have to enable zlib support"
echo
exit 1
fi
fi

View File

@ -19,6 +19,7 @@ typedef struct {
typedef struct {
ngx_file_t pid;
char *name;
int argc;
char *const *argv;
} ngx_master_ctx_t;
@ -28,6 +29,7 @@ static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx);
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp);
static ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv);
static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle);
static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle);
static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@ -57,6 +59,13 @@ static ngx_command_t ngx_core_commands[] = {
offsetof(ngx_core_conf_t, master),
NULL },
{ ngx_string("pid"),
NGX_MAIN_CONF|NGX_CONF_TAKE1,
ngx_conf_set_core_str_slot,
0,
offsetof(ngx_core_conf_t, pid),
NULL },
{ ngx_string("worker_reopen"),
NGX_MAIN_CONF|NGX_CONF_TAKE1,
ngx_conf_set_core_flag_slot,
@ -125,12 +134,20 @@ int main(int argc, char *const *argv, char **envp)
log = ngx_log_init_errlog();
ngx_pid = ngx_getpid();
/* init_cycle->log is required for signal handlers */
/* init_cycle->log is required for signal handlers and ngx_getopt() */
ngx_memzero(&init_cycle, sizeof(ngx_cycle_t));
init_cycle.log = log;
ngx_cycle = &init_cycle;
ngx_memzero(&ctx, sizeof(ngx_master_ctx_t));
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;
}
@ -213,8 +230,6 @@ int main(int argc, char *const *argv, char **envp)
#endif
ctx.argv = argv;
ngx_master_process_cycle(cycle, &ctx);
return 0;
@ -745,6 +760,40 @@ static ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv)
}
static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle)
{
ngx_int_t i;
for (i = 1; i < ctx->argc; i++) {
if (ctx->argv[i][0] != '-') {
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
"invalid option: \"%s\"", ctx->argv[i]);
return NGX_ERROR;
}
switch (ctx->argv[i][1]) {
case 'c':
cycle->conf_file.data = ctx->argv[++i];
cycle->conf_file.len = ngx_strlen(cycle->conf_file.data);
break;
default:
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
"invalid option: \"%s\"", ctx->argv[i]);
return NGX_ERROR;
}
}
if (cycle->conf_file.len == NULL) {
cycle->conf_file.len = sizeof(NGINX_CONF) - 1;
cycle->conf_file.data = NGINX_CONF;
}
return NGX_OK;
}
static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle)
{
ngx_core_conf_t *ccf;

View File

@ -46,6 +46,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
cycle->pool = pool;
cycle->old_cycle = old_cycle;
cycle->conf_file = old_cycle->conf_file;
n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
@ -117,10 +118,8 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
conf.module_type = NGX_CORE_MODULE;
conf.cmd_type = NGX_MAIN_CONF;
conf_file.len = sizeof(NGINX_CONF) - 1;
conf_file.data = NGINX_CONF;
if (ngx_conf_parse(&conf, &conf_file) != NGX_CONF_OK) {
if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) {
ngx_destroy_pool(pool);
return NULL;
}

View File

@ -21,7 +21,7 @@ struct ngx_cycle_s {
ngx_cycle_t *old_cycle;
unsigned one_process:1;
ngx_str_t conf_file;
};

View File

@ -369,7 +369,7 @@ static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_event_conf_t *ecf = conf;
int m;
ngx_int_t m;
ngx_str_t *value;
ngx_event_conf_t *old_ecf;
ngx_event_module_t *module;
@ -465,7 +465,7 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
ngx_conf_init_value(ecf->use, ngx_epoll_module.ctx_index);
ngx_conf_init_ptr_value(ecf->name, ngx_epoll_module_ctx.name->data);
#else /* HAVE_SELECT */
#elif (HAVE_SELECT)
ngx_conf_init_value(ecf->connections,
FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE : DEFAULT_CONNECTIONS);
@ -473,6 +473,37 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
ngx_conf_init_value(ecf->use, ngx_select_module.ctx_index);
ngx_conf_init_ptr_value(ecf->name, ngx_select_module_ctx.name->data);
#else
ngx_int_t i, m;
ngx_event_module_t *module;
m = -1;
module = NULL;
for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->type == NGX_EVENT_MODULE) {
module = ngx_modules[i]->ctx;
if (ngx_strcmp(module->name->data, event_core_name.data) == 0) {
continue;
}
m = ngx_modules[i]->ctx_index;
break;
}
}
if (m == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no events module found");
return NGX_CONF_ERROR;
}
ngx_conf_init_value(ecf->connections, DEFAULT_CONNECTIONS);
ngx_conf_init_value(ecf->use, m);
ngx_conf_init_ptr_value(ecf->name, module->name->data);
#endif
cycle->connection_n = ecf->connections;