diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2004-02-11 17:08:49 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2004-02-11 17:08:49 +0000 |
| commit | 54498db7a2a2e7e74fba61ec073b248da05e999e (patch) | |
| tree | 7e5bda151896efa349f2220fc122ba9792ce5dfb /src/core | |
| parent | c7a2f6860669f45f5abe342163de5bc68e344816 (diff) | |
| download | nginx-54498db7a2a2e7e74fba61ec073b248da05e999e.tar.gz nginx-54498db7a2a2e7e74fba61ec073b248da05e999e.tar.bz2 | |
nginx-0.0.2-2004-02-11-20:08:49 import
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/ngx_alloc.c | 26 | ||||
| -rw-r--r-- | src/core/ngx_conf_file.c | 2 | ||||
| -rw-r--r-- | src/core/ngx_conf_file.h | 2 | ||||
| -rw-r--r-- | src/core/ngx_connection.c | 3 | ||||
| -rw-r--r-- | src/core/ngx_cycle.c | 12 | ||||
| -rw-r--r-- | src/core/ngx_file.c | 11 | ||||
| -rw-r--r-- | src/core/ngx_garbage_collector.c | 19 | ||||
| -rw-r--r-- | src/core/ngx_log.c | 12 | ||||
| -rw-r--r-- | src/core/ngx_log.h | 53 | ||||
| -rw-r--r-- | src/core/ngx_output_chain.c | 6 |
10 files changed, 53 insertions, 93 deletions
diff --git a/src/core/ngx_alloc.c b/src/core/ngx_alloc.c index dff05936e..ae96564fc 100644 --- a/src/core/ngx_alloc.c +++ b/src/core/ngx_alloc.c @@ -12,9 +12,7 @@ void *ngx_alloc(size_t size, ngx_log_t *log) "malloc() %d bytes failed", size); } -#if (NGX_DEBUG_ALLOC) - ngx_log_debug(log, "malloc: %08x:%d" _ p _ size); -#endif + ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0, "malloc: %08x:%d", p, size); return p; } @@ -57,27 +55,30 @@ void ngx_destroy_pool(ngx_pool_t *pool) ngx_pool_large_t *l; for (l = pool->large; l; l = l->next) { -#if (NGX_DEBUG_ALLOC) - ngx_log_debug(pool->log, "free: %08x" _ l->alloc); -#endif + + ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, + "free: %08x", l->alloc); + if (l->alloc) { free(l->alloc); } } +#if (NGX_DEBUG) + /* - * we could allocate pool->log from this pool - * so we can not use this log while free()ing the pool + * we could allocate the pool->log from this pool + * so we can not use this log while the free()ing the pool */ -#if (NGX_DEBUG_ALLOC) for (p = pool, n = pool->next; /* void */; p = n, n = n->next) { - ngx_log_debug(pool->log, "free: %08x" _ p); + ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, "free: %08x", p); if (n == NULL) { break; } } + #endif for (p = pool, n = pool->next; /* void */; p = n, n = n->next) { @@ -177,9 +178,8 @@ void ngx_pfree(ngx_pool_t *pool, void *p) for (l = pool->large; l; l = l->next) { if (p == l->alloc) { -#if (NGX_DEBUG_ALLOC) - ngx_log_debug(pool->log, "free: %08x" _ l->alloc); -#endif + ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, + "free: %08x", l->alloc); free(l->alloc); l->alloc = NULL; } diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 704365c6a..f8e7f7b62 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -540,7 +540,7 @@ ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name) } -void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err, +void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err, char *fmt, ...) { int len; diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h index e1c4e33ce..6e81f2b67 100644 --- a/src/core/ngx_conf_file.h +++ b/src/core/ngx_conf_file.h @@ -238,7 +238,7 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename); ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name); -void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err, +void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err, char *fmt, ...); diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 115748432..989a0de1f 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -240,7 +240,7 @@ void ngx_close_listening_sockets(ngx_cycle_t *cycle) ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text) { - ngx_int_t level; + ngx_uint_t level; if (err == NGX_ECONNRESET && c->log_error == NGX_ERROR_IGNORE_ECONNRESET) @@ -252,6 +252,7 @@ ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text) switch (c->log_error) { + case NGX_ERROR_IGNORE_ECONNRESET: case NGX_ERROR_INFO: level = NGX_LOG_INFO; break; diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index f80271d24..017db87f1 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -464,7 +464,7 @@ static void ngx_clean_old_cycles(ngx_event_t *ev) log = ngx_cycle->log; ngx_temp_pool->log = log; - ngx_log_debug(log, "clean old cycles"); + ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycles"); live = 0; @@ -480,7 +480,9 @@ static void ngx_clean_old_cycles(ngx_event_t *ev) for (n = 0; n < cycle[i]->connection_n; n++) { if (cycle[i]->connections[n].fd != -1) { found = 1; - ngx_log_debug(log, "live fd: %d" _ n); + + ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "live fd:%d", n); + break; } } @@ -490,15 +492,15 @@ static void ngx_clean_old_cycles(ngx_event_t *ev) continue; } - ngx_log_debug(log, "clean old cycle: %d" _ i); + ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycle: %d", i); + ngx_destroy_pool(cycle[i]->pool); cycle[i] = NULL; } - ngx_log_debug(log, "old cycles status: %d" _ live); + ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "old cycles status: %d", live); if (live) { - ngx_log_debug(log, "TIMER"); ngx_add_timer(ev, 30000); } else { diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c index 3b29bec07..72d7ba750 100644 --- a/src/core/ngx_file.c +++ b/src/core/ngx_file.c @@ -75,7 +75,8 @@ int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, #endif file->fd = ngx_open_tempfile(file->name.data, 1); -ngx_log_debug(file->log, "temp fd: %d" _ file->fd); + ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0, + "temp fd:%d", file->fd); if (file->fd != NGX_INVALID_FILE) { return NGX_OK; @@ -123,15 +124,14 @@ void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path) break; } - ngx_log_debug(file->log, "hashed path: %s" _ file->name.data); - name -= level; file->name.data[pos - 1] = '/'; ngx_memcpy(&file->name.data[pos], &file->name.data[name], level); pos += level + 1; } - ngx_log_debug(file->log, "hashed path: %s" _ file->name.data); + ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0, + "hashed path: %s", file->name.data); } @@ -151,7 +151,8 @@ int ngx_create_path(ngx_file_t *file, ngx_path_t *path) file->name.data[pos] = '\0'; - ngx_log_debug(file->log, "temp: %s" _ file->name.data); + ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0, + "temp file: \"%s\"", file->name.data); if (ngx_create_dir(file->name.data) == NGX_FILE_ERROR) { err = ngx_errno; diff --git a/src/core/ngx_garbage_collector.c b/src/core/ngx_garbage_collector.c index f60fae927..35a060ba3 100644 --- a/src/core/ngx_garbage_collector.c +++ b/src/core/ngx_garbage_collector.c @@ -79,7 +79,8 @@ static int ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level) buf.len = 0; -ngx_log_debug(ctx->log, "dir '%s':%d" _ dname->data _ dname->len); + ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0, + "gc dir \"%s\":%d", dname->data, dname->len); if (ngx_open_dir(dname, &dir) == NGX_ERROR) { ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, @@ -106,7 +107,8 @@ ngx_log_debug(ctx->log, "dir '%s':%d" _ dname->data _ dname->len); len = ngx_de_namelen(&dir); -ngx_log_debug(ctx->log, "name '%s':%d" _ ngx_de_name(&dir) _ len); + ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0, + "gc name \"%s\":%d", ngx_de_name(&dir), len); if (len == 1 && ngx_de_name(&dir)[0] == '.') { continue; @@ -139,7 +141,8 @@ ngx_log_debug(ctx->log, "name '%s':%d" _ ngx_de_name(&dir) _ len); ngx_memcpy(last, ngx_de_name(&dir), len + 1); fname.data = buf.data; -ngx_log_debug(ctx->log, "path %s" _ fname.data); + ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, + "gc path: \"%s\"", fname.data); if (!dir.info_valid) { if (ngx_de_info(fname.data, &dir) == NGX_FILE_ERROR) { @@ -151,7 +154,8 @@ ngx_log_debug(ctx->log, "path %s" _ fname.data); if (ngx_de_is_dir(&dir)) { -ngx_log_debug(ctx->log, "enter %s" _ fname.data); + ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, + "gc enter dir \"%s\"", fname.data); if (level == -1 /* there can not be directory on the last level */ @@ -187,7 +191,8 @@ ngx_log_debug(ctx->log, "enter %s" _ fname.data); } else if (ngx_de_is_file(&dir)) { -ngx_log_debug(ctx->log, "file %s" _ fname.data); + ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, + "gc file \"%s\"", fname.data); if (level == -1 || (level < NGX_MAX_PATH_LEVEL && ctx->path->level[level] != 0)) @@ -239,10 +244,10 @@ int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, ngx_dir_t *dir) { /* - * we use mtime only and do not use atime because: + * We use mtime only and do not use atime because: * on NTFS access time has a resolution of 1 hour, * on NT FAT access time has a resolution of 1 day, - * Unices have mount option "noatime" + * Unices have the mount option "noatime". */ if (ngx_cached_time - ngx_de_mtime(dir) < 3600) { diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index a902f1e31..7fdd8984c 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -42,7 +42,7 @@ static const char *err_levels[] = { }; static const char *debug_levels[] = { - "debug", "debug_core", "debug_alloc", "debug_event", "debug_http" + "debug_core", "debug_alloc", "debug_event", "debug_http" }; @@ -81,9 +81,9 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, len += ngx_snprintf(errstr + len, max - len, PID_T_FMT "#%d: ", ngx_pid, /* STUB */ 0); - if (log->data) { + if (log->data && *(int *) log->data != -1) { len += ngx_snprintf(errstr + len, max - len, - "*%u ", * (u_int *) log->data); + "*%u ", *(u_int *) log->data); } #if (HAVE_VARIADIC_MACROS) @@ -332,7 +332,7 @@ char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log) for (i = 2; i < cf->args->nelts; i++) { - for (n = 1; n < NGX_LOG_DEBUG; n++) { + for (n = 1; n <= NGX_LOG_DEBUG; n++) { if (ngx_strcmp(value[i].data, err_levels[n]) == 0) { if (log->log_level != 0) { @@ -368,5 +368,9 @@ char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log) } } + if (log->log_level == NGX_LOG_DEBUG) { + log->log_level = NGX_LOG_DEBUG_ALL; + } + return NGX_CONF_OK; } diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h index 15498e14f..46fbf12ce 100644 --- a/src/core/ngx_log.h +++ b/src/core/ngx_log.h @@ -21,9 +21,9 @@ #define NGX_LOG_DEBUG_EVENT 0x40 #define NGX_LOG_DEBUG_HTTP 0x80 -#define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG +#define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG_CORE #define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_HTTP -#define NGX_LOG_DEBUG_ALL 0xfffffff8 +#define NGX_LOG_DEBUG_ALL 0xfffffff0 /* @@ -74,7 +74,7 @@ typedef size_t (*ngx_log_handler_pt) (void *ctx, char *buf, size_t len); struct ngx_log_s { - int log_level; + ngx_uint_t log_level; ngx_open_file_t *file; void *data; ngx_log_handler_pt handler; @@ -82,8 +82,6 @@ struct ngx_log_s { #define MAX_ERROR_STR 2048 -#define _ , - /*********************************/ @@ -94,21 +92,6 @@ struct ngx_log_s { #define ngx_log_error(level, log, args...) \ if (log->log_level >= level) ngx_log_error_core(level, log, args) -#if (NGX_DEBUG) -#define ngx_log_debug(log, args...) \ - if (log->log_level & NGX_LOG_DEBUG) \ - ngx_log_error_core(NGX_LOG_DEBUG, log, 0, args) -#else -#define ngx_log_debug(log, args...) -#endif - -#define ngx_assert(assert, fallback, log, args...) \ - if (!(assert)) { \ - if (log->log_level >= NGX_LOG_ALERT) \ - ngx_log_error_core(NGX_LOG_ALERT, log, 0, args); \ - fallback; \ - } - void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, const char *fmt, ...); @@ -121,21 +104,6 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, #define ngx_log_error(level, log, ...) \ if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__) -#if (NGX_DEBUG) -#define ngx_log_debug(log, ...) \ - if (log->log_level == NGX_LOG_DEBUG) \ - ngx_log_error_core(NGX_LOG_DEBUG, log, 0, __VA_ARGS__) -#else -#define ngx_log_debug(log, ...) -#endif - -#define ngx_assert(assert, fallback, log, ...) \ - if (!(assert)) { \ - if (log->log_level >= NGX_LOG_ALERT) \ - ngx_log_error_core(NGX_LOG_ALERT, log, 0, __VA_ARGS__); \ - fallback; \ - } - void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, const char *fmt, ...); @@ -145,21 +113,6 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, #define HAVE_VARIADIC_MACROS 0 -#if (NGX_DEBUG) -#define ngx_log_debug(log, text) \ - if (log->log_level == NGX_LOG_DEBUG) \ - ngx_log_debug_core(log, 0, text) -#else -#define ngx_log_debug(log, text) -#endif - -#define ngx_assert(assert, fallback, log, text) \ - if (!(assert)) { \ - if (log->log_level >= NGX_LOG_ALERT) \ - ngx_assert_core(log, text); \ - fallback; \ - } - void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err, const char *fmt, ...); void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c index 46deab446..10326bcf7 100644 --- a/src/core/ngx_output_chain.c +++ b/src/core/ngx_output_chain.c @@ -217,12 +217,6 @@ static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src, } else { n = ngx_read_file(src->file, dst->pos, size, src->file_pos); -if (n == 0) { -ngx_log_debug(src->file->log, "READ: %qd:%qd %X:%X %X:%X" _ - src->file_pos _ src->file_last _ - dst->pos _ dst->last _ dst->start _ dst->end); -} - if (n == NGX_ERROR) { return n; } |
