Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-10-27 19:46:13 +0400
committerIgor Sysoev <igor@sysoev.ru>2005-10-27 19:46:13 +0400
commit697d1aea0c7b1525beed2911f9f32426280df8f4 (patch)
tree3c59875442d9a8114785a04003fcc3b7b059dc55 /src/core
parent968b2a868ba7950b7c11c81905eeb5ed87b889f2 (diff)
nginx-0.3.7-RELEASE importrelease-0.3.7
*) Feature: the "access_log" supports the "buffer=" parameter. *) Bugfix: nginx could not be built on platforms different from i386, amd64, sparc, and ppc; the bug had appeared in 0.3.2.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/core/ngx_conf_file.c37
-rw-r--r--src/core/ngx_conf_file.h12
-rw-r--r--src/core/ngx_cycle.c6
-rw-r--r--src/core/ngx_log.c38
5 files changed, 56 insertions, 39 deletions
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 5a3593d35..78ae2a78a 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_
-#define NGINX_VER "nginx/0.3.6"
+#define NGINX_VER "nginx/0.3.7"
#define NGINX_VAR "NGINX"
#define NGX_OLDPID_EXT ".oldbin"
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 78e61f8c1..acec1308f 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -11,6 +11,7 @@
static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static void ngx_conf_flush_files(ngx_cycle_t *cycle);
static ngx_command_t ngx_conf_commands[] = {
@@ -36,7 +37,7 @@ ngx_module_t ngx_conf_module = {
NULL, /* init process */
NULL, /* init thread */
NULL, /* exit thread */
- NULL, /* exit process */
+ ngx_conf_flush_files, /* exit process */
NULL, /* exit master */
NGX_MODULE_V1_PADDING
};
@@ -742,10 +743,44 @@ ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
file->name.data = NULL;
}
+ file->buffer = NULL;
+
return file;
}
+static void
+ngx_conf_flush_files(ngx_cycle_t *cycle)
+{
+ ngx_uint_t i;
+ ngx_list_part_t *part;
+ ngx_open_file_t *file;
+
+ ngx_log_debug0(NGX_LOG_DEBUG_CORE, cycle->log, 0, "flush files");
+
+ part = &cycle->open_files.part;
+ file = part->elts;
+
+ for (i = 0; /* void */ ; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+ part = part->next;
+ file = part->elts;
+ i = 0;
+ }
+
+ if (file[i].buffer == NULL || file[i].pos - file[i].buffer == 0) {
+ continue;
+ }
+
+ ngx_write_fd(file[i].fd, file[i].buffer, file[i].pos - file[i].buffer);
+ }
+}
+
+
void ngx_cdecl
ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
char *fmt, ...)
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 9f344e64c..b09d8cc6a 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -34,6 +34,7 @@
#define NGX_CONF_TAKE23 (NGX_CONF_TAKE2|NGX_CONF_TAKE3)
+#define NGX_CONF_TAKE123 (NGX_CONF_TAKE1|NGX_CONF_TAKE2|NGX_CONF_TAKE3)
#define NGX_CONF_TAKE1234 (NGX_CONF_TAKE1|NGX_CONF_TAKE2|NGX_CONF_TAKE3 \
|NGX_CONF_TAKE4)
@@ -87,6 +88,11 @@ struct ngx_command_s {
struct ngx_open_file_s {
ngx_fd_t fd;
ngx_str_t name;
+
+ u_char *buffer;
+ u_char *pos;
+ u_char *last;
+
#if 0
/* e.g. append mode, error_log */
ngx_uint_t flags;
@@ -121,10 +127,10 @@ struct ngx_module_s {
ngx_int_t (*init_process)(ngx_cycle_t *cycle);
ngx_int_t (*init_thread)(ngx_cycle_t *cycle);
- ngx_int_t (*exit_thread)(ngx_cycle_t *cycle);
- ngx_int_t (*exit_process)(ngx_cycle_t *cycle);
+ void (*exit_thread)(ngx_cycle_t *cycle);
+ void (*exit_process)(ngx_cycle_t *cycle);
- ngx_int_t (*exit_master)(ngx_cycle_t *cycle);
+ void (*exit_master)(ngx_cycle_t *cycle);
uintptr_t spare_hook0;
uintptr_t spare_hook1;
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 58679ed28..ab196112c 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -724,6 +724,12 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
continue;
}
+ if (file[i].buffer && file[i].pos - file[i].buffer != 0) {
+ ngx_write_fd(file[i].fd, file[i].buffer,
+ file[i].pos - file[i].buffer);
+ file[i].pos = file[i].buffer;
+ }
+
fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 905c8a165..444e943c5 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -8,7 +8,6 @@
#include <ngx_core.h>
-static void ngx_log_write(ngx_log_t *log, u_char *errstr, size_t len);
static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@@ -152,42 +151,13 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
p = log->handler(log, p, last - p);
}
- ngx_log_write(log, errstr, p - errstr);
-}
-
-
-static void
-ngx_log_write(ngx_log_t *log, u_char *errstr, size_t len)
-{
-#if (NGX_WIN32)
- u_long written;
-
- if (len >= NGX_MAX_ERROR_STR - 1) {
- len = NGX_MAX_ERROR_STR - 2;
+ if (p > last - NGX_LINEFEED_SIZE) {
+ p = last - NGX_LINEFEED_SIZE;
}
- errstr[len++] = CR;
- errstr[len++] = LF;
-
- WriteFile(log->file->fd, errstr, len, &written, NULL);
+ ngx_linefeed(p);
-#if 0
- if (WriteFile(log->file->fd, errstr, len, &written, NULL) == 0) {
- ngx_message_box("nginx", MB_OK, ngx_errno, "WriteFile() failed");
- }
-#endif
-
-#else
-
- if (len == NGX_MAX_ERROR_STR) {
- len--;
- }
-
- errstr[len++] = LF;
-
- (void) write(log->file->fd, errstr, len);
-
-#endif
+ ngx_write_fd(log->file->fd, errstr, p - errstr);
}