diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/nginx.c | 2 | ||||
-rw-r--r-- | src/core/ngx_config.h | 3 | ||||
-rw-r--r-- | src/core/ngx_core.h | 1 | ||||
-rw-r--r-- | src/core/ngx_crc.h | 26 | ||||
-rw-r--r-- | src/core/ngx_log.c | 4 | ||||
-rw-r--r-- | src/core/ngx_log.h | 85 |
6 files changed, 97 insertions, 24 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index 77d1dc632..8c4716d68 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -134,7 +134,7 @@ int main(int argc, char *const *argv) /* life cycle */ for ( ;; ) { - /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG; + /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG|NGX_LOG_DEBUG_HTTP; #if 0 diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h index ccb653b98..b943960b2 100644 --- a/src/core/ngx_config.h +++ b/src/core/ngx_config.h @@ -38,6 +38,9 @@ typedef int ngx_int_t; typedef u_int ngx_uint_t; +/* STUB: autoconf */ +#define PTR_FMT "%X" + #include <ngx_auto_config.h> diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h index 8d096fa89..5b76d86c7 100644 --- a/src/core/ngx_core.h +++ b/src/core/ngx_core.h @@ -28,6 +28,7 @@ typedef struct ngx_connection_s ngx_connection_t; #include <ngx_types.h> #include <ngx_file.h> #include <ngx_files.h> +#include <ngx_crc.h> #include <ngx_regex.h> #include <ngx_times.h> #include <ngx_inet.h> diff --git a/src/core/ngx_crc.h b/src/core/ngx_crc.h new file mode 100644 index 000000000..df6488967 --- /dev/null +++ b/src/core/ngx_crc.h @@ -0,0 +1,26 @@ +#ifndef _NGX_CRC_H_INCLUDED_ +#define _NGX_CRC_H_INCLUDED_ + + +/* 32-bit crc16 */ + +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 + * into the single rol opcode. + * msvc 6.0sp2 compiles it into four opcodes. + */ + sum = sum >> 1 | sum << 31; + + sum += *data++; + } + + return sum; +} + + +#endif /* _NGX_CRC_H_INCLUDED_ */ diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index 627c507fc..e3e292ced 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -169,12 +169,12 @@ 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, ...) +void ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, const char *fmt, ...) { va_list args; va_start(args, fmt); - ngx_log_error_core(NGX_LOG_DEBUG, log, 0, fmt, args); + ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, args); va_end(args); } diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h index 290b11c46..59ca1f9c4 100644 --- a/src/core/ngx_log.h +++ b/src/core/ngx_log.h @@ -6,17 +6,17 @@ #include <ngx_core.h> -typedef enum { - NGX_LOG_STDERR = 0, - NGX_LOG_EMERG, - NGX_LOG_ALERT, - NGX_LOG_CRIT, - NGX_LOG_ERR, - NGX_LOG_WARN, - NGX_LOG_NOTICE, - NGX_LOG_INFO, - NGX_LOG_DEBUG -} ngx_log_e; +#define NGX_LOG_STDERR 0 +#define NGX_LOG_EMERG 1 +#define NGX_LOG_ALERT 2 +#define NGX_LOG_CRIT 3 +#define NGX_LOG_ERR 4 +#define NGX_LOG_WARN 5 +#define NGX_LOG_NOTICE 6 +#define NGX_LOG_INFO 7 +#define NGX_LOG_DEBUG 8 + +#define NGX_LOG_DEBUG_HTTP 0x80 /* @@ -71,13 +71,6 @@ struct ngx_log_s { ngx_open_file_t *file; void *data; ngx_log_handler_pt handler; - -#if 0 -/* STUB */ - char *action; - char *context; -/* */ -#endif }; #define MAX_ERROR_STR 2048 @@ -85,6 +78,8 @@ struct ngx_log_s { #define _ , +/*********************************/ + #if (HAVE_GCC_VARIADIC_MACROS) #define HAVE_VARIADIC_MACROS 1 @@ -94,7 +89,7 @@ struct ngx_log_s { #if (NGX_DEBUG) #define ngx_log_debug(log, args...) \ - if (log->log_level == NGX_LOG_DEBUG) \ + if (log->log_level & NGX_LOG_DEBUG) \ ngx_log_error_core(NGX_LOG_DEBUG, log, 0, args) #else #define ngx_log_debug(log, args...) @@ -110,6 +105,7 @@ struct ngx_log_s { void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, const char *fmt, ...); +/*********************************/ #elif (HAVE_C99_VARIADIC_MACROS) @@ -136,13 +132,16 @@ 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 */ +#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, text) + ngx_log_debug_core(log, 0, text) #else #define ngx_log_debug(log, text) #endif @@ -158,13 +157,57 @@ 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, const char *fmt, va_list args); -void ngx_log_debug_core(ngx_log_t *log, const char *fmt, ...); +void ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, const char *fmt, ...); void ngx_assert_core(ngx_log_t *log, const char *fmt, ...); #endif /* VARIADIC MACROS */ +/*********************************/ + +#if (HAVE_VARIADIC_MACROS) + +#if (NGX_DEBUG) +#define ngx_log_debug0(level, log, err, fmt) \ + if (log->log_level & level) \ + ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt) +#else +#define ngx_log_debug0(level, log, err, fmt) +#endif + +#if (NGX_DEBUG) +#define ngx_log_debug1(level, log, err, fmt, arg1) \ + if (log->log_level & level) \ + ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1) +#else +#define ngx_log_debug1(level, log, err, fmt, arg1) +#endif + +/*********************************/ + +#else /* NO VARIADIC MACROS */ + +#if (NGX_DEBUG) +#define ngx_log_debug0(level, log, err, fmt) \ + if (log->log_level & level) \ + ngx_log_debug_core(log, err, fmt) +#else +#define ngx_log_debug0(level, log, err, fmt) +#endif + +#if (NGX_DEBUG) +#define ngx_log_debug1(level, log, err, fmt, arg1) \ + if (log->log_level & level) \ + ngx_log_debug_core(log, err, fmt, arg1) +#else +#define ngx_log_debug1(level, log, err, fmt, arg1) +#endif +#endif + + +/*********************************/ + #define ngx_log_alloc_log(pool, log) ngx_palloc(pool, log, sizeof(ngx_log_t)) #define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t)) |