nginx-0.0.3-2004-05-19-00:28:54 import

This commit is contained in:
Igor Sysoev 2004-05-18 20:28:54 +00:00
parent ab517d5827
commit 090849dc6f
9 changed files with 102 additions and 70 deletions

7
auto/configure vendored
View File

@ -38,4 +38,11 @@ fi
have=NGX_SMP . auto/have
have=NGX_PREFIX value="\"$PREFIX/\"" . auto/define
have=NGX_SBIN_PATH value="\"$SBIN_PATH\"" . auto/define
have=NGX_CONF_PATH value="\"$CONF_PATH\"" . auto/define
have=NGX_PID_PATH value="\"$PID_PATH\"" . auto/define
have=NGX_ERROR_LOG_PATH value="\"$ERROR_LOG_PATH\"" . auto/define
have=NGX_HTTP_LOG_PATH value="\"$HTTP_LOG_PATH\"" . auto/define
. auto/summary

8
auto/define Normal file
View File

@ -0,0 +1,8 @@
cat << END >> $NGX_AUTO_CONFIG_H
#ifndef $have
#define $have $value
#endif
END

View File

@ -1,6 +1,13 @@
help=no
PREFIX=
SBIN_PATH=
CONF_PATH=
HTTP_LOG_PATH=
ERROR_LOG_PATH=
PID_PATH=
CC=gcc
CPP=
OBJS=objs
@ -52,6 +59,13 @@ do
case "$option" in
--help) help=yes ;;
--prefix=*) PREFIX="$value" ;;
--sbin-path=*) SBIN_PATH="$value" ;;
--conf-path=*) CONF_PATH="$value" ;;
--http-log-path=*) HTTP_LOG_PATH="$value" ;;
--error-log-path=*) ERROR_LOG_PATH="$value" ;;
--pid-path=*) PID_PATH="$value" ;;
--crossbuild=*) PLATFORM="$value" ;;
--builddir=*) OBJS="$value" ;;
@ -129,3 +143,28 @@ if [ ".$PLATFORM" = ".win32" -a $EVENT_POLL = YES ]; then
EVENT_POLL=NO
echo "$0: warning: --with-poll_module option is ignored for win32"
fi
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
if [ ".$PID_PATH" = "." ]; then
PID_PATH=$PREFIX/logs/nginx.pid
fi
if [ ".$ERROR_LOG_PATH" = "." ]; then
ERROR_LOG_PATH=$PREFIX/logs/error.log
fi
if [ ".$HTTP_LOG_PATH" = "." ]; then
HTTP_LOG_PATH=$PREFIX/logs/access.log
fi

View File

@ -2,6 +2,7 @@
echo
echo "Configuration summary"
if [ $USE_PCRE = DISABLED ]; then
echo " + PCRE library is disabled"
@ -55,3 +56,12 @@ if [ $HTTP_GZIP = YES ]; then
exit 1
fi
fi
echo " nginx path prefix: $PREFIX"
echo " nginx binary file: $SBIN_PATH"
echo " nginx configuration file: $CONF_PATH"
echo " nginx pid file: $PID_PATH"
echo " nginx error log file: $ERROR_LOG_PATH"
echo " nginx http access log file: $HTTP_LOG_PATH"
echo

View File

@ -315,8 +315,8 @@ static ngx_int_t ngx_getopt(ngx_master_ctx_t *ctx, ngx_cycle_t *cycle)
}
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 @@ static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
/* 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

View File

@ -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_ */

View File

@ -546,6 +546,10 @@ static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
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;

View File

@ -24,7 +24,6 @@ static ngx_connection_t dumb;
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_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
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 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
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_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
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 @@ ngx_int_t ngx_create_pidfile(ngx_cycle_t *cycle, ngx_cycle_t *old_cycle)
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 @@ ngx_int_t ngx_create_pidfile(ngx_cycle_t *cycle, ngx_cycle_t *old_cycle)
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 @@ ngx_int_t ngx_create_pidfile(ngx_cycle_t *cycle, ngx_cycle_t *old_cycle)
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) {

View File

@ -59,15 +59,14 @@ static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
u_char *chunk;
size_t size, len;
ngx_hunk_t *h;
ngx_chain_t *out, *cl, *tl, **ll;
ngx_chain_t out, tail, *cl, *tl, **ll;
if (in == NULL || !r->chunked) {
return ngx_http_next_body_filter(r, in);
}
ngx_test_null(out, ngx_alloc_chain_link(r->pool), NGX_ERROR);
out->hunk = NULL;
ll = &out->next;
out.hunk = NULL;
ll = &out.next;
size = 0;
cl = in;
@ -99,11 +98,10 @@ static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
h->pos = chunk;
h->last = chunk + len;
out->hunk = h;
out.hunk = h;
}
if (cl->hunk->type & NGX_HUNK_LAST) {
ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY|NGX_HUNK_LAST;
h->pos = (u_char *) CRLF "0" CRLF CRLF;
@ -112,16 +110,17 @@ static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
cl->hunk->type &= ~NGX_HUNK_LAST;
if (size == 0) {
out->hunk = h;
out->next = NULL;
h->pos += 2;
out.hunk = h;
out.next = NULL;
return ngx_http_next_body_filter(r, out);
return ngx_http_next_body_filter(r, &out);
}
} else {
if (size == 0) {
*ll = NULL;
return ngx_http_next_body_filter(r, out->next);
return ngx_http_next_body_filter(r, out.next);
}
ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
@ -130,10 +129,11 @@ static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
h->last = h->pos + 2;
}
ngx_alloc_link_and_set_hunk(tl, h, r->pool, NGX_ERROR);
*ll = tl;
tail.hunk = h;
tail.next = NULL;
*ll = &tail;
return ngx_http_next_body_filter(r, out);
return ngx_http_next_body_filter(r, &out);
}