nginx timer in log module

Maxim Dounin mdounin at mdounin.ru
Sat Sep 17 02:48:24 UTC 2016


Hello!

On Sat, Sep 17, 2016 at 08:25:54AM +0800, 洪志道 wrote:

[...]

> static void
> ngx_http_log_flush(ngx_open_file_t *file, ngx_log_t *log)
> {
>     ...
>     if (buffer->event && buffer->event->timer_set) {
>         ngx_del_timer(buffer->event);
>     }
> }
> 
> 
> I find there are two functions explicitly call event handler.
> 1. ngx_event_cancel_timers happened as long as worker process quits.
> 2. ngx_event_expire_timers in ngx_process_events_and_timers.
> 
> And they remove timer from timer rbtree, then set timer_set zero.
> After that they call event->handler.
> 
> So why we call ngx_del_timer in ngx_http_log_flush again?

The ngx_http_log_flush() function is also used as a flush handler 
for the log file, notably called while reopening logs.  In this 
case the timer can be set when ngx_http_log_flush() is called and 
should be deleted - and this is what the code in question does.

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx-devel mailing list