Thank you for your reply, I get it now. In other case such as I showed above, it seems we needn't do like the following ?
if (ev->timer_set) { ngx_del_timer(ev); } 2016-09-17 10:48 GMT+08:00 Maxim Dounin <mdou...@mdounin.ru>: > 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/ > > _______________________________________________ > nginx-devel mailing list > nginx-devel@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel
_______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel