Opened 5 years ago

Closed 5 years ago

#1698 closed enhancement (invalid)

A minor optimization for ngx_log_debug

Reported by: chronolaw@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.15.x
Keywords: ngx_log_debug Cc:
uname -a:
nginx -V: nginx version: nginx/1.15.6

Description

In ngx_log_debug, it will compare log_level and level use '&',but if we compose multi levels it will case a compiler error (suggest parentheses around arithmetic in operand of ‘|’).

For example :
ngx_log_debug2(

NGX_LOG_DEBUG_HTTP|NGX_LOG_DEBUG_CONNECTION,...)

this code will be:

log->log_level & NGX_LOG_DEBUG_HTTP|NGX_LOG_DEBUG_CONNECTION

So I think we should add parentheses around 'level' in macro.
Please check the patch,Thanks all of you, nginx team.

(by the way, I can not config hg's emailbomb, please forgive my behavior)

Attachments (2)

ngx_log.c.patch (1.3 KB ) - added by chronolaw@… 5 years ago.
ngx_log.h.patch (1.3 KB ) - added by chronolaw@… 5 years ago.

Download all attachments as: .zip

Change History (4)

by chronolaw@…, 5 years ago

Attachment: ngx_log.c.patch added

by chronolaw@…, 5 years ago

Attachment: ngx_log.h.patch added

comment:1 by chronolaw@…, 5 years ago

sorry for the wrong patch filename ,I have uploaded the right 'ngx_log.h.patch', please ignore 'ngx_log.c.patch'.

comment:2 by Maxim Dounin, 5 years ago

Resolution: invalid
Status: newclosed

You are not expected to use more than one level in ngx_log_debugN() calls. In particular, the NGX_LOG_DEBUG_CONNECTION macro is to be used in the log->log_level to indicate that debug logging was requested via the debug_connection directive and should not be switched off by configuration-specific logging. Using it in a ngx_log_debugN(() call is clearly an error.

Note: See TracTickets for help on using tickets.