summaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c15
-rw-r--r--src/core/ngx_array.c6
-rw-r--r--src/core/ngx_conf_file.c25
-rw-r--r--src/core/ngx_config.h2
-rw-r--r--src/core/ngx_connection.h9
-rw-r--r--src/core/ngx_core.h11
-rw-r--r--src/core/ngx_file.c6
-rw-r--r--src/core/ngx_file.h1
-rw-r--r--src/core/ngx_log.c52
-rw-r--r--src/core/ngx_log.h7
-rw-r--r--src/core/ngx_modules.c12
-rw-r--r--src/core/ngx_os_init.h26
12 files changed, 142 insertions, 30 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 6fbc33bfd..70ff149cf 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -6,13 +6,6 @@
#include <ngx_core.h>
#include <ngx_connection.h>
#include <ngx_os_init.h>
-#include <ngx_string.h>
-#include <ngx_errno.h>
-#include <ngx_time.h>
-#include <ngx_log.h>
-#include <ngx_alloc.h>
-#include <ngx_array.h>
-#include <ngx_socket.h>
#include <ngx_server.h>
#include <ngx_listen.h>
#include <ngx_conf_file.h>
@@ -55,8 +48,12 @@ int main(int argc, char *const *argv)
ngx_str_t conf_file;
ngx_conf_t conf;
- /* STUB */
- ngx_log.log_level = NGX_LOG_DEBUG;
+ ngx_max_sockets = -1;
+
+ ngx_log.fd = STDERR_FILENO;
+ ngx_log.log_level = NGX_LOG_INFO;
+
+ /* STUB */ ngx_log.log_level = NGX_LOG_DEBUG;
if (ngx_os_init(&ngx_log) == NGX_ERROR) {
return 1;
diff --git a/src/core/ngx_array.c b/src/core/ngx_array.c
index 0043929e9..dd91141c2 100644
--- a/src/core/ngx_array.c
+++ b/src/core/ngx_array.c
@@ -29,7 +29,7 @@ void ngx_destroy_array(ngx_array_t *a)
p = a->pool;
- if (a->elts + a->size * a->nalloc == p->last) {
+ if ((char *) a->elts + a->size * a->nalloc == p->last) {
p->last -= a->size * a->nalloc;
}
@@ -49,7 +49,7 @@ void *ngx_push_array(ngx_array_t *a)
p = a->pool;
/* array allocation is the last in the pool */
- if (a->elts + a->size * a->nelts == p->last
+ if ((char *) a->elts + a->size * a->nelts == p->last
&& (unsigned) (p->end - p->last) >= a->size)
{
p->last += a->size;
@@ -65,7 +65,7 @@ void *ngx_push_array(ngx_array_t *a)
}
}
- elt = a->elts + a->size * a->nelts;
+ elt = (char *) a->elts + a->size * a->nelts;
a->nelts++;
return elt;
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 99af0afbd..28068d4fe 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -435,6 +435,10 @@ char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
int flag;
ngx_str_t *value;
+ if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
+ return "is duplicate";
+ }
+
value = (ngx_str_t *) cf->args->elts;
if (ngx_strcasecmp(value[1].data, "on") == 0) {
@@ -458,6 +462,11 @@ char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
ngx_str_t *field, *value;
field = (ngx_str_t *) (conf + cmd->offset);
+
+ if (field->len > 0) {
+ return "is duplicate";
+ }
+
value = (ngx_str_t *) cf->args->elts;
field->len = value[1].len;
@@ -472,6 +481,10 @@ char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
int num, len;
ngx_str_t *value;
+ if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
+ return "is duplicate";
+ }
+
value = (ngx_str_t *) cf->args->elts;
len = value[1].len;
@@ -493,6 +506,10 @@ char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
char last;
ngx_str_t *value;
+ if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
+ return "is duplicate";
+ }
+
value = (ngx_str_t *) cf->args->elts;
len = value[1].len;
@@ -535,6 +552,10 @@ char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
char last, *start;
ngx_str_t *value;
+ if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
+ return "is duplicate";
+ }
+
value = (ngx_str_t *) cf->args->elts;
start = value[1].data;
len = 0;
@@ -626,6 +647,10 @@ char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
char last, *start;
ngx_str_t *value;
+ if (*(int *) (conf + cmd->offset) != NGX_CONF_UNSET) {
+ return "is duplicate";
+ }
+
value = (ngx_str_t *) cf->args->elts;
start = value[1].data;
len = 0;
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h
index e039cd6a5..690cb32f5 100644
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -104,7 +104,7 @@
#endif
-#if (HAVE_DEVPOLL)
+#if (HAVE_DEVPOLL) && !(TEST_DEVPOLL)
#include <sys/ioctl.h>
#include <sys/devpoll.h> /* Solaris, HP/UX */
#endif
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index 8ad48c8d1..a8b8804f4 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -1,15 +1,22 @@
#ifndef _NGX_CONNECTION_H_INCLUDED_
#define _NGX_CONNECTION_H_INCLUDED_
+#include <ngx_core.h>
+
+#if 0
#include <ngx_socket.h>
#include <ngx_log.h>
#include <ngx_alloc.h>
#include <ngx_hunk.h>
#include <ngx_array.h>
#include <ngx_string.h>
+#endif
+
#include <ngx_server.h>
+#if 0
typedef struct ngx_connection_s ngx_connection_t;
+#endif
#ifdef NGX_EVENT
#include <ngx_event.h>
@@ -81,12 +88,14 @@ EV_VNODE should notify by some signal if diretory tree is changed
#endif
+#if 0
typedef struct {
ssize_t (*recv)(ngx_connection_t *c, char *buf, size_t size);
void *dummy_recv_chain;
void *dummy_send;
ngx_chain_t *(*send_chain)(ngx_connection_t *c, ngx_chain_t *in);
} ngx_os_io_t;
+#endif
extern ngx_os_io_t ngx_io;
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index acb7fa430..76003fb37 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -6,6 +6,11 @@
#include <ngx_time.h>
#include <ngx_socket.h>
#include <ngx_files.h>
+#include <ngx_errno.h>
+#include <ngx_process.h>
+
+typedef struct ngx_connection_s ngx_connection_t;
+typedef struct ngx_event_s ngx_event_t;
#include <ngx_log.h>
#include <ngx_alloc.h>
@@ -14,8 +19,8 @@
#include <ngx_string.h>
#include <ngx_file.h>
#include <ngx_conf_file.h>
-#include <ngx_connection.h>
#include <ngx_os_init.h>
+#include <ngx_connection.h>
@@ -38,4 +43,8 @@
*/
+/* STUB */
+extern ngx_log_t ngx_log;
+
+
#endif /* _NGX_CORE_H_INCLUDED_ */
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index b8f15e17d..d70004b2f 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -14,7 +14,7 @@ static int ngx_random;
int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
ngx_pool_t *pool, int persistent)
{
- int i, num;
+ int num;
ngx_err_t err;
file->name.len = path->name.len + 1 + path->len + 10;
@@ -33,8 +33,8 @@ int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
num = ngx_next_temp_number(0);
for ( ;; ) {
- snprintf(file->name.data + path->name.len + 1 + path->len, 11,
- "%010u", num);
+ ngx_snprintf(file->name.data + path->name.len + 1 + path->len, 11,
+ "%010u", num);
ngx_create_hashed_filename(file, path);
diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h
index 2cd2f762c..442f843b6 100644
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -2,7 +2,6 @@
#define _NGX_FILE_H_INCLUDED_
-#include <ngx_file.h>
#include <ngx_log.h>
#include <ngx_alloc.h>
#include <ngx_string.h>
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 4057d7a81..fee60187c 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -11,15 +11,12 @@
*/
#include <ngx_config.h>
-#include <ngx_errno.h>
-#include <ngx_time.h>
-#include <ngx_process.h>
-#include <ngx_string.h>
-#include <ngx_log.h>
+#include <ngx_core.h>
static const char *err_levels[] = {
- "emerg", "alert", "crit", "error", "warn", "notice", "info", "debug"
+ "stderr", "emerg", "alert", "crit", "error",
+ "warn", "notice", "info", "debug"
};
#if (HAVE_VARIADIC_MACROS)
@@ -30,11 +27,11 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
const char *fmt, va_list args)
#endif
{
- char errstr[MAX_ERROR_STR];
- ngx_tm_t tm;
- size_t len;
+ char errstr[MAX_ERROR_STR];
+ ngx_tm_t tm;
+ size_t len;
#if (HAVE_VARIADIC_MACROS)
- va_list args;
+ va_list args;
#endif
ngx_localtime(&tm);
@@ -93,7 +90,7 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
#endif
errstr[len++] = '\n';
- write(2, errstr, len);
+ write(log->fd, errstr, len);
#if 0
errstr[len] = '\0';
@@ -102,6 +99,7 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
#endif
}
+
#if !(HAVE_VARIADIC_MACROS)
void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err,
@@ -116,6 +114,7 @@ void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err,
}
}
+
void ngx_log_debug_core(ngx_log_t *log, const char *fmt, ...)
{
va_list args;
@@ -125,6 +124,7 @@ void ngx_log_debug_core(ngx_log_t *log, const char *fmt, ...)
va_end(args);
}
+
void ngx_assert_core(ngx_log_t *log, const char *fmt, ...)
{
va_list args;
@@ -135,3 +135,33 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...)
}
#endif
+
+
+void ngx_log_stderr(ngx_event_t *ev)
+{
+ char errstr[MAX_ERROR_STR];
+ ssize_t n;
+ ngx_err_t err;
+
+ for ( ;; ) {
+ n = read((ngx_fd_t) ev->data, errstr, sizeof(errstr - 1));
+
+ if (n == -1) {
+ err = ngx_errno;
+ if (err == NGX_EAGAIN) {
+ return;
+ }
+
+ ngx_log_error(NGX_LOG_ALERT, &ngx_log, err, "read() failed");
+ return;
+ }
+
+ if (n == 0) {
+ ngx_log_error(NGX_LOG_ALERT, &ngx_log, 0, "stderr clolsed");
+ return;
+ }
+
+ errstr[n] = '\0';
+ ngx_log_error(NGX_LOG_STDERR, &ngx_log, 0, "%s", errstr);
+ }
+}
diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
index c7b780fdd..b549d80d9 100644
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -6,7 +6,8 @@
#include <ngx_errno.h>
typedef enum {
- NGX_LOG_EMERG = 0,
+ NGX_LOG_STDERR = 0,
+ NGX_LOG_EMERG,
NGX_LOG_ALERT,
NGX_LOG_CRIT,
NGX_LOG_ERR,
@@ -16,6 +17,7 @@ typedef enum {
NGX_LOG_DEBUG
} ngx_log_e;
+
/*
"[%time] [%level] %pid#%tid: %message:(%errno)%errstr, while %action"
" %peer and while processing %context"
@@ -59,6 +61,7 @@ typedef enum {
"... while reading client command for 'john_doe'"
*/
+
typedef struct {
int log_level;
ngx_fd_t fd;
@@ -100,6 +103,7 @@ typedef struct {
void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
const char *fmt, ...);
+
#elif (HAVE_C99_VARIADIC_MACROS)
#define HAVE_VARIADIC_MACROS 1
@@ -125,6 +129,7 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
const char *fmt, ...);
+
#else /* NO VARIADIC MACROS */
#include <stdarg.h>
diff --git a/src/core/ngx_modules.c b/src/core/ngx_modules.c
index db6cf7351..5e5f5a8bd 100644
--- a/src/core/ngx_modules.c
+++ b/src/core/ngx_modules.c
@@ -8,9 +8,15 @@ extern ngx_module_t ngx_events_module;
extern ngx_module_t ngx_event_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
extern ngx_module_t ngx_http_module;
@@ -32,9 +38,15 @@ ngx_module_t *ngx_modules[] = {
&ngx_event_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
/* http */
diff --git a/src/core/ngx_os_init.h b/src/core/ngx_os_init.h
new file mode 100644
index 000000000..b65932def
--- /dev/null
+++ b/src/core/ngx_os_init.h
@@ -0,0 +1,26 @@
+#ifndef _NGX_OS_INIT_H_INCLUDED_
+#define _NGX_OS_INIT_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#if 0
+#include <ngx_connection.h>
+#endif
+
+
+typedef struct {
+ ssize_t (*recv)(ngx_connection_t *c, char *buf, size_t size);
+ void *dummy_recv_chain;
+ void *dummy_send;
+ ngx_chain_t *(*send_chain)(ngx_connection_t *c, ngx_chain_t *in);
+} ngx_os_io_t;
+
+
+int ngx_os_init(ngx_log_t *log);
+
+extern ngx_os_io_t ngx_os_io;
+extern int ngx_max_sockets;
+
+
+#endif /* _NGX_OS_INIT_H_INCLUDED_ */