diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ngx_array.h | 4 | ||||
-rw-r--r-- | src/core/ngx_core.h | 1 | ||||
-rw-r--r-- | src/core/ngx_crc.h | 2 | ||||
-rw-r--r-- | src/core/ngx_file.c | 2 | ||||
-rw-r--r-- | src/core/ngx_garbage_collector.h | 2 | ||||
-rw-r--r-- | src/core/ngx_hunk.c | 2 | ||||
-rw-r--r-- | src/core/ngx_log.c | 61 | ||||
-rw-r--r-- | src/core/ngx_log.h | 10 | ||||
-rw-r--r-- | src/core/ngx_regex.c | 2 | ||||
-rw-r--r-- | src/core/ngx_times.c | 4 |
10 files changed, 69 insertions, 21 deletions
diff --git a/src/core/ngx_array.h b/src/core/ngx_array.h index d6443d6a7..9cef9f33a 100644 --- a/src/core/ngx_array.h +++ b/src/core/ngx_array.h @@ -6,13 +6,13 @@ #include <ngx_core.h> -typedef struct { +struct ngx_array_s { void *elts; int nelts; size_t size; int nalloc; ngx_pool_t *pool; -} ngx_array_t; +}; ngx_array_t *ngx_create_array(ngx_pool_t *p, int n, size_t size); diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h index 97819b6ff..b2c3d554d 100644 --- a/src/core/ngx_core.h +++ b/src/core/ngx_core.h @@ -6,6 +6,7 @@ typedef struct ngx_module_s ngx_module_t; typedef struct ngx_conf_s ngx_conf_t; typedef struct ngx_cycle_s ngx_cycle_t; typedef struct ngx_log_s ngx_log_t; +typedef struct ngx_array_s ngx_array_t; typedef struct ngx_open_file_s ngx_open_file_t; typedef struct ngx_command_s ngx_command_t; diff --git a/src/core/ngx_crc.h b/src/core/ngx_crc.h index df6488967..c6234c37a 100644 --- a/src/core/ngx_crc.h +++ b/src/core/ngx_crc.h @@ -7,7 +7,7 @@ ngx_inline static uint32_t ngx_crc(char *data, size_t len) { uint32_t sum; - + for (sum = 0; len; len--) { /* * gcc 2.95.2 x86 and icc 7.1.006 compile that operator diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c index 4cbd8fc2c..3b29bec07 100644 --- a/src/core/ngx_file.c +++ b/src/core/ngx_file.c @@ -14,7 +14,7 @@ int ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain) if (tf->file.fd == NGX_INVALID_FILE) { rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool, tf->persistent); - + if (rc == NGX_ERROR || rc == NGX_AGAIN) { return rc; } diff --git a/src/core/ngx_garbage_collector.h b/src/core/ngx_garbage_collector.h index 1164484b1..5bc8471dc 100644 --- a/src/core/ngx_garbage_collector.h +++ b/src/core/ngx_garbage_collector.h @@ -17,7 +17,7 @@ struct ngx_gc_s { }; -int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, +int ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name, ngx_dir_t *dir); diff --git a/src/core/ngx_hunk.c b/src/core/ngx_hunk.c index 2785c39d4..d6aa0a40e 100644 --- a/src/core/ngx_hunk.c +++ b/src/core/ngx_hunk.c @@ -108,7 +108,7 @@ void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy, if (te->next == NULL) { te->next = *out; break; - } + } } } diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index 3f578fc7f..b615c7ea2 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -22,7 +22,7 @@ static ngx_str_t errlog_name = ngx_string("errlog"); static ngx_command_t ngx_errlog_commands[] = { {ngx_string("error_log"), - NGX_MAIN_CONF|NGX_CONF_TAKE12, + NGX_MAIN_CONF|NGX_CONF_1MORE, ngx_set_error_log, 0, 0, @@ -51,6 +51,11 @@ static const char *err_levels[] = { "warn", "notice", "info", "debug" }; +static const char *debug_levels[] = { + "debug", "debug_alloc", "debug_event", "debug_http" +}; + + #if (HAVE_VARIADIC_MACROS) void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, const char *fmt, ...) @@ -262,9 +267,18 @@ ngx_log_t *ngx_log_init_errlog() } -ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_str_t *name) +ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args) { ngx_log_t *log; + ngx_str_t *value, *name; + + if (args) { + value = args->elts; + name = &value[1]; + + } else { + name = NULL; + } ngx_test_null(log, ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)), NULL); ngx_test_null(log->file, ngx_conf_open_file(cycle, name), NULL); @@ -279,7 +293,7 @@ ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_str_t *name) static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - ngx_int_t i; + ngx_int_t i, n, d; ngx_str_t *value; value = cf->args->elts; @@ -291,16 +305,43 @@ static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) cf->cycle->log->file->name = value[1]; } - if (cf->args->nelts == 3) { - for (i = 1; i <= /* STUB ??? */ NGX_LOG_DEBUG; i++) { - if (ngx_strcmp(value[2].data, err_levels[i]) == 0) { - cf->cycle->log->log_level = i; - break; + for (i = 2; i < cf->args->nelts; i++) { + + for (n = 1; n < NGX_LOG_DEBUG; n++) { + if (ngx_strcmp(value[i].data, err_levels[n]) == 0) { + + if (cf->cycle->log->log_level != 0) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid log level \"%s\"", + value[i].data); + return NGX_CONF_ERROR; + } + + cf->cycle->log->log_level = n; + continue; } } - if (i > NGX_LOG_DEBUG) { + + d = NGX_LOG_DEBUG_FIRST; + for (n = 0; n < /* STUB */ 3; n++) { + if (ngx_strcmp(value[i].data, debug_levels[n]) == 0) { + if (cf->cycle->log->log_level & ~NGX_LOG_DEBUG_ALL) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid log level \"%s\"", + value[i].data); + return NGX_CONF_ERROR; + } + + cf->cycle->log->log_level |= d; + d <<= 1; + continue; + } + } + + + if (cf->cycle->log->log_level == 0) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "invalid log level \"%s\"", value[2].data); + "invalid log level \"%s\"", value[i].data); return NGX_CONF_ERROR; } } diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h index 59ca1f9c4..71da9d524 100644 --- a/src/core/ngx_log.h +++ b/src/core/ngx_log.h @@ -16,7 +16,13 @@ #define NGX_LOG_INFO 7 #define NGX_LOG_DEBUG 8 -#define NGX_LOG_DEBUG_HTTP 0x80 +#define NGX_LOG_DEBUG_ALLOC 0x10 +#define NGX_LOG_DEBUG_EVENT 0x20 +#define NGX_LOG_DEBUG_HTTP 0x40 + +#define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG +#define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_HTTP +#define NGX_LOG_DEBUG_ALL 0xfffffff8 /* @@ -212,7 +218,7 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...); #define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t)) ngx_log_t *ngx_log_init_errlog(); -ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_str_t *name); +ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args); extern ngx_module_t ngx_errlog_module; diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c index 377f998de..a5d47d58c 100644 --- a/src/core/ngx_regex.c +++ b/src/core/ngx_regex.c @@ -30,7 +30,7 @@ ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options, re = pcre_compile(pattern->data, (int) options, &errstr, &erroff, NULL); if (re == NULL) { - if ((size_t) erroff == pattern->len) { + if ((size_t) erroff == pattern->len) { ngx_snprintf(err->data, err->len - 1, "pcre_compile() failed: %s in \"%s\"", errstr, pattern->data); diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index a1ffdceb5..bc0cb1684 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -116,11 +116,11 @@ void ngx_gmtime(time_t t, ngx_tm_t *tp) t %= 86400; hour = t / 3600; t %= 3600; - min = t / 60; + min = t / 60; sec = t % 60; /* the algorithm based on Gauss's formula */ - + days = days - (31 + 28) + 719527; year = days * 400 / (365 * 400 + 100 - 4 + 1); |