nginx-0.0.1-2002-12-19-10:08:55 import
diff --git a/src/core/nginx.c b/src/core/nginx.c
index e654e7e..3d1d11d 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -126,7 +126,7 @@
ls[i].flags);
if (s == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
- ngx_socket_n " %s falied", ls[i].addr_text);
+ ngx_socket_n " %s falied", ls[i].addr_text.data);
exit(1);
}
@@ -134,7 +134,7 @@
(const void *) &reuseaddr, sizeof(int)) == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
"setsockopt(SO_REUSEADDR) %s failed",
- ls[i].addr_text);
+ ls[i].addr_text.data);
exit(1);
}
@@ -144,7 +144,7 @@
if (ngx_nonblocking(s) == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
ngx_nonblocking_n " %s failed",
- ls[i].addr_text);
+ ls[i].addr_text.data);
exit(1);
}
}
@@ -152,7 +152,7 @@
if (bind(s, ls[i].sockaddr, ls[i].socklen) == -1) {
err = ngx_socket_errno;
ngx_log_error(NGX_LOG_EMERG, log, err,
- "bind() to %s failed", ls[i].addr_text);
+ "bind() to %s failed", ls[i].addr_text.data);
if (err != NGX_EADDRINUSE)
exit(1);
@@ -160,7 +160,7 @@
if (ngx_close_socket(s) == -1)
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
ngx_close_socket_n " %s failed",
- ls[i].addr_text);
+ ls[i].addr_text.data);
failed = 1;
continue;
@@ -168,7 +168,7 @@
if (listen(s, ls[i].backlog) == -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
- "listen() to %s failed", ls[i].addr_text);
+ "listen() to %s failed", ls[i].addr_text.data);
exit(1);
}
diff --git a/src/core/ngx_config_command.c b/src/core/ngx_config_command.c
deleted file mode 100644
index 26cd26b..0000000
--- a/src/core/ngx_config_command.c
+++ /dev/null
@@ -1,280 +0,0 @@
-
-#include <ngx_config.h>
-
-
-#if 0
-
-typedef struct ngx_conf_file_t {
- ngx_fd_t fd;
- char *name;
- int line;
- char *pos;
-};
-
-typedef struct ngx_conf_t {
- char *name;
- ngx_array_t *args;
-
- ngx_conf_file_t *file;
- ngx_log_t *log;
-
- void *context; # ngx_http_conf_t
-};
-
-static int argument_number[] = {
- NGX_CONF_NOARGS,
- NGX_CONF_TAKE1,
- NGX_CONF_TAKE2,
- NGX_CONF_TAKE3
-};
-
-
-ngx_conf_parse(cf, container, filename)
-{
- create cf;
-
- *conatiner(cf);
-
- if (filename) {
- open;
- }
-
- for ( ;; ) {
- rc = ngx_conf_read_token(cf);
-
-NGX_OK, NGX_ERROR, NGX_CONF_FILE_DONE, NGX_CONF_BLOCK_DONE
-
- if (rc != NGX_OK)
- return rc;
-
-"listen address:port;"
-"location /images/ {"
-
- cmd = ngx_conf_find_token(cf);
- if (cmd == NULL) {
- ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
- "unknown directive \"%s\" in %s:%d",
- cf->name, cf->file->name, cf->file->line);
- return NGX_ERROR;
- }
-
- if (cmd->type == NGX_CONF_CONTAINER) {
- ngx_conf_parse(cf, cmd->container, NULL);
-
- } else if (cmd->type == NGX_CONF_FLAG) {
-
- if (cf->args->nelts != 1) {
- ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
- "invalid number of arguments "
- "in directive \"%s\" in %s:%d",
- cf->name, cf->file->name, cf->file->line);
- return NGX_ERROR;
- }
-
- if (ngx_strcasecmp(cf->args->elts[0], "on") == 0) {
- flag = 1;
-
- } else if (ngx_strcasecmp(cf->args->elts[0], "off") == 0) {
- flag = 0;
-
- } else {
- ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
- "invalid flag in directive \"%s\" in %s:%d",
- cf->name, cf->file->name, cf->file->line);
- return NGX_ERROR;
- }
-
- rv = cmd->set(cf, cmd->offset, flag);
- if (rv) {
- ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
- "%s in directive \"%s\" in %s:%d",
- rv, cf->name, cf->file->name, cf->file->line);
- return NGX_ERROR;
- }
-
- } else if (cmd->type & argument_number[args->nelts]) {
- rv = cmd->set(cf, cmd->offset, cf->args);
- if (rv) {
- ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
- "%s in directive \"%s\" in %s:%d",
- rv, cf->name, cf->file->name, cf->file->line);
- return NGX_ERROR;
- }
-
- } else {
- ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
- "invalid number of arguments "
- "in directive \"%s\" in %s:%d",
- cf->name, cf->file->name, cf->file->line);
- return NGX_ERROR;
- }
- }
-
- if (filename) {
- close;
- }
-}
-
-int ngx_conf_read_token(ngx_conf_t *cf)
-{
-
- need_space = 0;
- last_space = 1;
- len = 0;
- quoted = s_quoted = d_quoted = 0;
-
- cf->args->nelts = 0;
-
- for (/* void */ ; cf->pos < cf->end; cf->pos++) {
-
- ch = *cf->pos;
-
- if (ch == LF)
- cf->line++;
-
- if (quoted) {
- quoted = 0;
- continue;
- }
-
- len++;
-
- if (ch = '\\') {
- quoted = 1;
- continue;
- }
-
- if (d_quoted) {
-
- if (ch == '"') {
- d_qouted = 0;
- need_space = 1;
- last_space = 1;
- continue;
- }
-
- } else if (s_quoted) {
-
- if (ch == '\'') {
- s_qouted = 0;
- need_space = 1;
- last_space = 1;
- continue;
- }
-
- } else {
-
- if (ch == ' ' || ch == '\t' || ch == CR || ch == LF) {
- ngx_test_null(word, ngx_push_array(cf->args), NGX_ERRROR);
- ngx_test_null(*word, ngx_palloc(cf->temp_pool, len + 1),
- NGX_ERROR);
-
- for (dst = *word, src = cf->start; src < cf->pos; /* void */) {
- if (*src == '\\')
- src++;
- *dst++ = *src++;
- }
- *dst = '\0';
-
- need_space = 0;
- last_space = 1;
- continue;
- }
-
- if (need_space) {
- return NGX_ERROR;
- }
-
- if (ch == ';')
- return NGX_OK;
-
- if (ch == '{')
- return NGX_OK;
-
- if (ch == '}')
- return NGX_BLOCK_DONE;
-
- if (last_space) {
- if (ch == '"') {
- d_qouted = 1;
- continue;
- }
-
- if (ch == '\'') {
- s_qouted = 1;
- continue;
- }
- }
-
- last_space = 0;
- }
- }
-}
-
-container
- server
- location
- module
- if
-
-http_conf current server
- current location
-
-
-ngx_conf_t *ngx_conf_open(char *filename, ngx_log_t *log)
-{
- ngx_cf->fd = ngx_open_file(config, NGX_FILE_RDONLY);
- if (ngx_conf->fd == -1) {
- ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
- "ngx_conf_open: "
- ngx_open_file_n " %s failed", filename);
-
- return NULL;
- }
-
- ngx_conf->name = filename;
- ngx_conf->log = log;
- return ngx_conf;
-}
-
-void ngx_conf_close(ngx_conf_t *cf)
-{
- if (ngx_close_file(cf->fd) == -1) {
- ngx_log_error(NGX_LOG_ERR, cf->log, ngx_errno,
- ngx_close_file_n " %s failed", cf->name);
- }
-
- cf->fd = -1;
-}
-
-
-
-
-
-
-#endif
-
-
-char *ngx_conf_set_size_slot(char *conf, int offset, char *value)
-{
- int size;
-
- size = atoi(value);
- if (size < 0)
- return "value must be greater or equal to zero";
-
- *(int *) (conf + offset) = size;
- return NULL;
-}
-
-char *ngx_conf_set_time_slot(char *conf, int offset, char *value)
-{
- int size;
-
- size = atoi(value);
- if (size < 0)
- return "value must be greater or equal to zero";
-
- *(int *) (conf + offset) = size;
- return NULL;
-}
diff --git a/src/core/ngx_config_command.h b/src/core/ngx_config_command.h
deleted file mode 100644
index e0ab956..0000000
--- a/src/core/ngx_config_command.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _NGX_HTTP_CONFIG_COMMAND_H_INCLUDED_
-#define _NGX_HTTP_CONFIG_COMMAND_H_INCLUDED_
-
-
-#define NGX_CONF_TAKE1 0
-#define NGX_CONF_ITERATE 0
-
-#define NGX_CONF_UNSET -1
-
-typedef struct {
- char *name;
- char *(*set)();
- int offset;
- int zone;
- int type;
- char *description;
-} ngx_command_t;
-
-char *ngx_conf_set_size_slot(char *conf, int offset, char *value);
-char *ngx_conf_set_time_slot(char *conf, int offset, char *value);
-
-
-#endif _NGX_HTTP_CONFIG_COMMAND_H_INCLUDED_
diff --git a/src/core/ngx_config_file.c b/src/core/ngx_config_file.c
new file mode 100644
index 0000000..b2b4b81
--- /dev/null
+++ b/src/core/ngx_config_file.c
@@ -0,0 +1,314 @@
+
+#include <ngx_config.h>
+
+#include <ngx_core.h>
+
+#include <ngx_config_file.h>
+
+
+static int argument_number[] = {
+ NGX_CONF_NOARGS,
+ NGX_CONF_TAKE1,
+ NGX_CONF_TAKE2
+};
+
+#if 0
+
+int ngx_conf_parse(ngx_conf_t *cf, char *filename)
+{
+ int rc;
+ char *error;
+ ngx_fd_t fd;
+ ngx_conf_file_t *prev;
+
+ if (filename) {
+
+ fd = ngx_open_file(filename, NGX_FILE_RDONLY);
+ if (fd == NGX_INVALID_FILE) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
+ "ngx_conf_open: "
+ ngx_open_file_n " %s failed", filename);
+ return NGX_ERROR;
+ }
+
+ prev = cf->file;
+ ngx_test_null(cf->file, ngx_palloc(cf->pool, sizeof(ngx_conf_file_t)),
+ NGX_ERROR);
+
+ cf->file->fd = fd;
+ cf->file->name = filename;
+ cf->file->line = 1;
+ cf->file->pos = 0;
+ }
+
+ for ( ;; ) {
+ rc = ngx_conf_read_token(cf);
+
+ /* ??? NGX_OK, NGX_ERROR, NGX_CONF_FILE_DONE, NGX_CONF_BLOCK_DONE */
+
+ if (rc != NGX_OK) {
+ return rc;
+ }
+
+ /* ????
+ "listen address:port;"
+ "location /images/ {" */
+
+ if (cf->handler) {
+
+ if (*(cf->handler)(cf) == NGX_ERROR) {
+ return NGX_ERROR;
+ }
+
+ continue;
+ }
+
+ cmd = ngx_conf_find_token(cf);
+ if (cmd == NULL) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "unknown directive \"%s\" in %s:%d",
+ cf->name, cf->file->name, cf->file->line);
+ return NGX_ERROR;
+ }
+
+ if (cmd->type & argument_number[cf->args->nelts]) {
+ error = cmd->set(cf, cmd->offset, cf->args);
+
+ if (error) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "%s in directive \"%s\" in %s:%d",
+ error, cf->name, cf->file->name, cf->file->line);
+ return NGX_ERROR;
+ }
+ }
+
+#if 0
+ if (cmd->type == NGX_CONF_CONTAINER) {
+ ngx_conf_parse(cf, cmd->container, NULL);
+
+ } else if (cmd->type == NGX_CONF_FLAG) {
+
+ if (cf->args->nelts != 1) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "invalid number of arguments "
+ "in directive \"%s\" in %s:%d",
+ cf->name, cf->file->name, cf->file->line);
+ return NGX_ERROR;
+ }
+
+ if (ngx_strcasecmp(cf->args->elts[0], "on") == 0) {
+ flag = 1;
+
+ } else if (ngx_strcasecmp(cf->args->elts[0], "off") == 0) {
+ flag = 0;
+
+ } else {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "invalid flag in directive \"%s\" in %s:%d",
+ cf->name, cf->file->name, cf->file->line);
+ return NGX_ERROR;
+ }
+
+ rv = cmd->set(cf, cmd->offset, flag);
+ if (rv) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "%s in directive \"%s\" in %s:%d",
+ rv, cf->name, cf->file->name, cf->file->line);
+ return NGX_ERROR;
+ }
+
+ } else if (cmd->type & argument_number[args->nelts]) {
+ rv = cmd->set(cf, cmd->offset, cf->args);
+ if (rv) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "%s in directive \"%s\" in %s:%d",
+ rv, cf->name, cf->file->name, cf->file->line);
+ return NGX_ERROR;
+ }
+
+ } else {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "invalid number of arguments "
+ "in directive \"%s\" in %s:%d",
+ cf->name, cf->file->name, cf->file->line);
+ return NGX_ERROR;
+ }
+ }
+#endif
+
+ if (filename) {
+ cf->file = prev;
+
+ if (ngx_close_file(fd) == NGX_FILE_ERROR) {
+ ngx_log_error(NGX_LOG_ERR, cf->log, ngx_errno,
+ ngx_close_file_n " %s failed", cf->name);
+ return NGX_ERROR;
+ }
+ }
+
+ return NGX_OK;
+}
+
+#endif
+
+#if 0
+
+int ngx_conf_read_token(ngx_conf_t *cf)
+{
+ char *start, ch, *src, *dst;
+ int n, need_space, last_space, len, quoted, s_quoted, d_quoted;
+ ngx_hunk_t *h;
+
+ need_space = 0;
+ last_space = 1;
+ len = 0;
+ quoted = s_quoted = d_quoted = 0;
+
+ cf->args->nelts = 0;
+ h = cf->conf_file->hunk;
+
+ for (start = h->pos.mem; /* end_of_file */ ; h->pos.mem++) {
+
+ if (h->pos.mem >= h->last.mem) {
+ if (h->pos.mem - start) {
+ ngx_memcpy(h->start, start, h->pos.mem - start);
+ }
+
+ n = ngx_read_file(cf->conf_file->file,
+ h->start + (h->pos.mem - start),
+ h->end - (h->start + (h->pos.mem - start)),
+ cf->conf_file->file.offset);
+
+ if (n == NGX_ERROR) {
+ return NGX_ERROR;
+ }
+
+ cf->conf_file.file.offset += n;
+ h->pos.mem = h->start + (h->pos.mem - start);
+ start = h->start;
+ h->last.mem = h->pos.mem + n;
+ }
+
+ ch = *h->pos.mem;
+
+ if (ch == LF) {
+ cf->conf_file->line++;
+ }
+
+ if (quoted) {
+ quoted = 0;
+ continue;
+ }
+
+ len++;
+
+ if (last_space) {
+ start = h->pos.mem;
+
+ if (ch == ' ' || ch == '\t' || ch == CR || ch == LF) {
+ start++;
+ continue;
+ }
+ }
+
+ if (ch = '\\') {
+ quoted = 1;
+ continue;
+ }
+
+ if (d_quoted) {
+
+ if (ch == '"') {
+ d_quoted = 0;
+ need_space = 1;
+ last_space = 1;
+ continue;
+ }
+
+ } else if (s_quoted) {
+
+ if (ch == '\'') {
+ s_quoted = 0;
+ need_space = 1;
+ last_space = 1;
+ continue;
+ }
+
+ } else {
+
+ if (ch == ' ' || ch == '\t' || ch == CR || ch == LF) {
+ ngx_test_null(word, ngx_push_array(cf->args), NGX_ERROR);
+ ngx_test_null(word->data, ngx_palloc(cf->temp_pool, len + 1),
+ NGX_ERROR);
+ word->len = len;
+
+ for (dst = word->data, src = start; src < h->pos; /* void */) {
+ if (*src == '\\')
+ src++;
+ *dst++ = *src++;
+ }
+ *dst = '\0';
+
+ need_space = 0;
+ last_space = 1;
+ continue;
+ }
+
+ if (need_space) {
+ return NGX_ERROR;
+ }
+
+ if (ch == ';') {
+ return NGX_OK;
+ }
+
+ if (ch == '{') {
+ return NGX_OK;
+ }
+
+ if (ch == '}') {
+ return NGX_BLOCK_DONE;
+ }
+
+ if (last_space) {
+ if (ch == '"') {
+ d_quoted = 1;
+ continue;
+ }
+
+ if (ch == '\'') {
+ s_quoted = 1;
+ continue;
+ }
+ }
+
+ last_space = 0;
+ }
+ }
+}
+
+#endif
+
+char *ngx_conf_set_size_slot(char *conf, int offset, char *value)
+{
+ int size;
+
+ size = atoi(value);
+ if (size < 0)
+ return "value must be greater or equal to zero";
+
+ *(int *) (conf + offset) = size;
+ return NULL;
+}
+
+char *ngx_conf_set_time_slot(char *conf, int offset, char *value)
+{
+ int size;
+
+ size = atoi(value);
+ if (size < 0)
+ return "value must be greater or equal to zero";
+
+ *(int *) (conf + offset) = size;
+ return NULL;
+}
diff --git a/src/core/ngx_config_file.h b/src/core/ngx_config_file.h
new file mode 100644
index 0000000..8b1d03e
--- /dev/null
+++ b/src/core/ngx_config_file.h
@@ -0,0 +1,56 @@
+#ifndef _NGX_HTTP_CONFIG_FILE_H_INCLUDED_
+#define _NGX_HTTP_CONFIG_FILE_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_files.h>
+#include <ngx_log.h>
+#include <ngx_file.h>
+#include <ngx_alloc.h>
+#include <ngx_hunk.h>
+#include <ngx_array.h>
+
+#define NGX_CONF_NOARGS 1
+#define NGX_CONF_TAKE1 2
+#define NGX_CONF_TAKE2 4
+
+#define NGX_CONF_ITERATE 0
+
+#define NGX_CONF_UNSET -1
+
+
+typedef struct {
+ ngx_file_t file;
+ ngx_hunk_t *hunk;
+ int line;
+} ngx_conf_file_t;
+
+typedef struct ngx_conf_s ngx_conf_t;
+struct ngx_conf_s {
+ char *name;
+ ngx_array_t *args;
+
+ ngx_pool_t *pool;
+ ngx_conf_file_t *conf_file;
+ ngx_log_t *log;
+
+ void *ctx;
+ int (*handler)(ngx_conf_t *cf);
+};
+
+
+
+typedef struct {
+ char *name;
+ char *(*set)();
+ int offset;
+ int zone;
+ int type;
+ char *description;
+} ngx_command_t;
+
+char *ngx_conf_set_size_slot(char *conf, int offset, char *value);
+char *ngx_conf_set_time_slot(char *conf, int offset, char *value);
+
+
+#endif _NGX_HTTP_CONFIG_FILE_H_INCLUDED_
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index 4e82162..e3c9e3a 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -27,8 +27,9 @@
int ngx_kqueue_init(int max_connections, ngx_log_t *log)
{
- int size = sizeof(struct kevent) * 512;
+ int size;
+ size = sizeof(struct kevent) * 512;
nchanges = 0;
nevents = 512;
@@ -68,8 +69,9 @@
{
ngx_event_t *e;
- if (ev->index < nchanges && change_list[ev->index].udata == ev) {
-
+ if (nchanges > 0 && ev->index < nchanges
+ && change_list[ev->index].udata == ev)
+ {
ngx_connection_t *cn = (ngx_connection_t *) ev->data;
ngx_log_debug(ev->log, "kqueue del event: %d: ft:%d" _
cn->fd _ event);
@@ -92,8 +94,10 @@
int ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
{
- struct timespec ts = { 0, 0 };
- ngx_connection_t *cn = (ngx_connection_t *) ev->data;
+ struct timespec ts;
+ ngx_connection_t *cn;
+
+ cn = (ngx_connection_t *) ev->data;
ngx_log_debug(ev->log, "kqueue set event: %d: ft:%d f:%08x" _
cn->fd _ filter _ flags);
@@ -102,6 +106,9 @@
ngx_log_error(NGX_LOG_WARN, ev->log, 0,
"kqueue change list is filled up");
+ ts.tv_sec = 0;
+ ts.tv_nsec = 0;
+
if (kevent(kq, change_list, nchanges, NULL, 0, &ts) == -1) {
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, "kevent failed");
return NGX_ERROR;
@@ -149,6 +156,7 @@
ngx_log_debug(log, "kevent timer: %d" _ timer);
events = kevent(kq, change_list, nchanges, event_list, nevents, tp);
+
if (events == -1) {
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "kevent failed");
return NGX_ERROR;
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index 763b8f8..8517e64 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -22,7 +22,7 @@
#if !(USE_KQUEUE)
-#if 1
+#if 0
ngx_event_type_e ngx_event_type = NGX_SELECT_EVENT;
#else
ngx_event_type_e ngx_event_type = NGX_KQUEUE_EVENT;
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index 1748e9a..6aa0166 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -135,7 +135,7 @@
#define ngx_init_events ngx_kqueue_init
#define ngx_process_events ngx_kqueue_process_events
#define ngx_add_event ngx_kqueue_add_event
-#define ngx_del_event ngx_kqueue_add_event
+#define ngx_del_event ngx_kqueue_del_event
#define ngx_add_timer ngx_kqueue_add_timer
#define ngx_event_recv ngx_event_recv_core
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index db3e3cc..d2084f0 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -4,7 +4,7 @@
#include <ngx_errno.h>
#include <ngx_string.h>
#include <ngx_files.h>
-#include <ngx_config_command.h>
+#include <ngx_config_file.h>
#include <ngx_http.h>
#include <ngx_http_config.h>
#include <ngx_http_index_handler.h>
diff --git a/src/http/modules/ngx_http_log_handler.c b/src/http/modules/ngx_http_log_handler.c
index 4937ed0..b2f0e0d 100644
--- a/src/http/modules/ngx_http_log_handler.c
+++ b/src/http/modules/ngx_http_log_handler.c
@@ -32,8 +32,6 @@
len += r->connection->addr_text.len;
len += r->request_line.len;
- ngx_log_debug(r->connection->log, "log handler: %d" _ len);
-
ngx_test_null(line, ngx_palloc(r->pool, len), NGX_ERROR);
p = line;
@@ -46,13 +44,8 @@
*p++ = ' ';
- *p = '\0';
- ngx_log_debug(r->connection->log, "log handler: %s" _ line);
-
ngx_localtime(&tm);
- ngx_log_debug(r->connection->log, "log handler: %s" _ line);
-
*p++ = '[';
p += ngx_snprintf(p, 21, "%02d/%s/%d:%02d:%02d:%02d",
tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1],
@@ -63,9 +56,6 @@
*p++ = ' ';
- *p = '\0';
- ngx_log_debug(r->connection->log, "log handler: %s" _ line);
-
*p++ = '"';
ngx_memcpy(p, r->request_line.data, r->request_line.len);
p += r->request_line.len;
@@ -79,19 +69,13 @@
p += ngx_snprintf(p, 21, QD_FMT, r->connection->sent);
- *p = '\0';
- ngx_log_debug(r->connection->log, "log handler: %s" _ line);
-
#if (WIN32)
*p++ = CR; *p++ = LF;
#else
*p++ = LF;
#endif
- *p = '\0';
- ngx_log_debug(r->connection->log, "log handler: %s" _ line);
-
- write(1, line, len);
+ write(1, line, p - line);
return NGX_OK;
}
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index ed7ca92..c3e0620 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -9,7 +9,7 @@
#include <ngx_hunk.h>
#include <ngx_files.h>
#include <ngx_connection.h>
-#include <ngx_config_command.h>
+#include <ngx_config_file.h>
#define NGX_HTTP_VERSION_10 1000
diff --git a/src/http/ngx_http_config.c b/src/http/ngx_http_config.c
index 2fb6410..f33fc62 100644
--- a/src/http/ngx_http_config.c
+++ b/src/http/ngx_http_config.c
@@ -1,7 +1,7 @@
#include <ngx_config.h>
#include <ngx_core.h>
-#include <ngx_config_command.h>
+#include <ngx_config_file.h>
#include <ngx_http.h>
#include <ngx_http_write_filter.h>
#include <ngx_http_output_filter.h>
@@ -17,7 +17,7 @@
void **ngx_loc_conf;
#if 0
-void *ngx_http_block(ngx_conf_t *cf)
+int ngx_http_block(ngx_conf_t *cf)
{
ngx_http_conf_ctx_t *ctx;
@@ -25,10 +25,12 @@
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
NGX_ERROR);
+#if 0
/* null server config */
ngx_test_null(ctx->srv_conf,
ngx_pcalloc(cf->pool, sizeof(void *) * ngx_max_module),
NGX_ERROR);
+#endif
/* null location config */
ngx_test_null(ctx->loc_conf,
@@ -36,10 +38,12 @@
NGX_ERROR);
for (i = 0; modules[i]; i++) {
+#if 0
if (modules[i]->create_srv_conf)
ngx_test_null(ctx->srv_conf[i],
modules[i]->create_srv_conf(cf->pool),
NGX_ERROR);
+#endif
if (modules[i]->create_loc_conf)
ngx_test_null(ctx->loc_conf[i],
@@ -51,10 +55,9 @@
return ngx_conf_parse(cf);
}
-void *ngx_server_block(ngx_conf_t *cf)
+int ngx_server_block(ngx_conf_t *cf)
{
- ngx_http_conf_ctx_t *ctx, *prev;
- ngx_http_core_loc_conf_t *loc_conf;
+ ngx_http_conf_ctx_t *ctx, *prev;
ngx_test_null(ctx,
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
@@ -88,31 +91,45 @@
rc = ngx_conf_parse(cf);
cf->ctx = prev;
- if (loc == NULL)
- return NULL;
+ if (loc == NGX_ERROR)
+ return NGX_ERROR;
for (i = 0; modules[i]; i++) {
+#if 0
if (modules[i]->merge_srv_conf)
if (modules[i]->merge_srv_conf(cf->pool,
prev->srv_conf, ctx->srv_conf)
== NGX_ERROR)
return NGX_ERROR;
+#endif
+
+ if (modules[i]->init_srv_conf)
+ if (modules[i]->init_srv_conf(cf->pool, ctx->srv_conf) == NGX_ERROR)
+ return NGX_ERROR;
if (modules[i]->merge_loc_conf)
if (modules[i]->merge_loc_conf(cf->pool,
prev->loc_conf, ctx->loc_conf)
== NGX_ERROR)
return NGX_ERROR;
+
+ for (array) {
+ if (modules[i]->merge_loc_conf(cf->pool,
+ ctx->loc_conf, loc->loc_conf)
+ == NGX_ERROR)
+ return NGX_ERROR;
+ }
+ }
}
- return (void *) 1;
+ return NGX_OK;
}
-void *ngx_location_block(ngx_conf_t *cf)
+int ngx_location_block(ngx_conf_t *cf)
{
+ ngx_http_conf_ctx_t *ctx, *prev;
- ngx_test_null(ctx,
- ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
+ ngx_test_null(ctx, ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
NGX_ERROR);
ctx->srv_conf = cf->ctx->srv_conf;
diff --git a/src/http/ngx_http_core.c b/src/http/ngx_http_core.c
index cb7bdc9..6d5d722 100644
--- a/src/http/ngx_http_core.c
+++ b/src/http/ngx_http_core.c
@@ -1,7 +1,7 @@
#include <ngx_config.h>
#include <ngx_core.h>
-#include <ngx_config_command.h>
+#include <ngx_config_file.h>
#include <ngx_http.h>
#include <ngx_http_core.h>
#include <ngx_http_config.h>
diff --git a/src/http/ngx_http_event.c b/src/http/ngx_http_event.c
index 60b3ca4..82e4a53 100644
--- a/src/http/ngx_http_event.c
+++ b/src/http/ngx_http_event.c
@@ -107,7 +107,7 @@
c->addr_text.len = ngx_inet_ntop(c->family,
(char *)c->sockaddr + c->addr,
c->addr_text.data, c->addr_text.len);
- if (c->addr_text.len = 0)
+ if (c->addr_text.len == 0)
return NGX_ERROR;
ngx_test_null(ctx, ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)),
diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c
index e8388dc..e16c1f7 100644
--- a/src/http/ngx_http_output_filter.c
+++ b/src/http/ngx_http_output_filter.c
@@ -3,7 +3,7 @@
#include <ngx_files.h>
#include <ngx_string.h>
#include <ngx_hunk.h>
-#include <ngx_config_command.h>
+#include <ngx_config_file.h>
#include <ngx_http.h>
#include <ngx_http_config.h>
#include <ngx_http_output_filter.h>