nginx-0.0.2-2004-02-09-23:47:18 import
diff --git a/auto/configure b/auto/configure
index a145a9e..162a697 100755
--- a/auto/configure
+++ b/auto/configure
@@ -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
diff --git a/auto/lib/conf b/auto/lib/conf
index 0739a72..60a824f 100644
--- a/auto/lib/conf
+++ b/auto/lib/conf
@@ -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
diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf
new file mode 100644
index 0000000..1fc3153
--- /dev/null
+++ b/auto/lib/pcre/conf
@@ -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
diff --git a/auto/modules b/auto/modules
index b254e34..dc3d1d3 100644
--- a/auto/modules
+++ b/auto/modules
@@ -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 \
diff --git a/auto/options b/auto/options
index 08d0468..76f0e36 100644
--- a/auto/options
+++ b/auto/options
@@ -19,6 +19,7 @@
HTTP_SSI=YES
HTTP_PROXY=YES
+USE_PCRE=NO
PCRE=NO
USE_MD5=NO
@@ -43,7 +44,9 @@
--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 @@
--with-cc=*) CC="$value" ;;
+ --without-pcre) PCRE=NONE ;;
--with-pcre=*) PCRE="$value" ;;
--with-md5=*) MD5="$value" ;;
--with-zlib=*) ZLIB="$value" ;;
diff --git a/auto/os/conf b/auto/os/conf
index 99de323..837e6d3 100644
--- a/auto/os/conf
+++ b/auto/os/conf
@@ -41,34 +41,3 @@
;;
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
diff --git a/auto/summary b/auto/summary
index 6546067..75ae609 100644
--- a/auto/summary
+++ b/auto/summary
@@ -24,3 +24,27 @@
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
diff --git a/src/core/nginx.c b/src/core/nginx.c
index fe78ab4..34f204f 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -19,6 +19,7 @@
typedef struct {
ngx_file_t pid;
char *name;
+ int argc;
char *const *argv;
} ngx_master_ctx_t;
@@ -28,6 +29,7 @@
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 @@
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 @@
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 @@
#endif
- ctx.argv = argv;
-
ngx_master_process_cycle(cycle, &ctx);
return 0;
@@ -745,6 +760,40 @@
}
+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;
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 8450998..f80271d 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -46,6 +46,7 @@
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 @@
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;
}
diff --git a/src/core/ngx_cycle.h b/src/core/ngx_cycle.h
index ef311a8..d9f1a60 100644
--- a/src/core/ngx_cycle.h
+++ b/src/core/ngx_cycle.h
@@ -21,7 +21,7 @@
ngx_cycle_t *old_cycle;
- unsigned one_process:1;
+ ngx_str_t conf_file;
};
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index 7044924..c2d24e5 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -369,7 +369,7 @@
{
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 @@
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 @@
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;