<div dir="ltr">Thank you for your reply, I get it now.<div><br></div><div>In other case such as I showed above, it seems we needn't do like the following ?</div><div><br></div><div><div style="font-size:14px"> if (ev->timer_set) {</div><div style="font-size:14px"> ngx_del_timer(ev); </div><div style="font-size:14px">}</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-09-17 10:48 GMT+08:00 Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<br>
On Sat, Sep 17, 2016 at 08:25:54AM +0800, 洪志道 wrote:<br>
<br>
[...]<br>
<span class=""><br>
> static void<br>
> ngx_http_log_flush(ngx_open_<wbr>file_t *file, ngx_log_t *log)<br>
> {<br>
> ...<br>
> if (buffer->event && buffer->event->timer_set) {<br>
> ngx_del_timer(buffer->event);<br>
> }<br>
> }<br>
><br>
><br>
> I find there are two functions explicitly call event handler.<br>
> 1. ngx_event_cancel_timers happened as long as worker process quits.<br>
> 2. ngx_event_expire_timers in ngx_process_events_and_timers.<br>
><br>
> And they remove timer from timer rbtree, then set timer_set zero.<br>
> After that they call event->handler.<br>
><br>
> So why we call ngx_del_timer in ngx_http_log_flush again?<br>
<br>
</span>The ngx_http_log_flush() function is also used as a flush handler<br>
for the log file, notably called while reopening logs. In this<br>
case the timer can be set when ngx_http_log_flush() is called and<br>
should be deleted - and this is what the code in question does.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/" rel="noreferrer" target="_blank">http://nginx.org/</a><br>
<br>
______________________________<wbr>_________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx-devel</a></font></span></blockquote></div><br></div>