<div dir="ltr"><span style="font-size:14px">"First of all, we can set timeout zero if need to exit immediately."</span><br><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px">It's not a good idea.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-03-09 20:52 GMT+08:00 洪志道 <span dir="ltr"><<a href="mailto:hongzhidao@gmail.com" target="_blank">hongzhidao@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I get it.<div><br></div><div>Yep, we can do the cleanup work in exit process or pool cleanup when expired time happened.</div><div><br></div><div>I keep my opinion that it's useful and helpful if we set <font color="#000000"><i style="background-color:rgb(255,255,255)"><font size="1">ngx_shutdown_event.<wbr>cancelable = 0</font><span style="font-size:14px">.</span></i></font></div><div><font color="#000000"><i style="background-color:rgb(255,255,255)"><span style="font-size:14px"><br></span></i></font></div><div><span style="font-size:14px">First of all, we can set timeout zero if need to exit immediately.</span><br></div><div><span style="font-size:14px">The key point is whether we need to invoke event handler like ngx_http_log_flush_<wbr>handler.</span></div><div><span style="font-size:14px">And I think it's more</span> convenient to do the consequent things, </div><div>we still have the event information in event handler, but not sure in exit process phase.</div><div><br></div><div>By the way, is it a problem if I try to set <i style="color:rgb(0,0,0)"><font size="1">ngx_shutdown_event.<wbr>cancelable = 0</font><span style="font-size:14px">.</span></i></div><div><br></div><div>Thanks again.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-03-09 20:29 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 Thu, Mar 09, 2017 at 02:39:26PM +0800, 洪志道 wrote:<br>
<br>
[...]<br>
<span><br>
> "Cancelable timers are now preserved if there are other timers. There is no<br>
> need to cancel timers early if there are other timers blocking shutdown<br>
> anyway. Preserving such timers allows nginx to continue some periodic work<br>
> till the shutdown is actually possible. With the new approach, timers with<br>
> ev->cancelable are simply ignored when checking if there are any timers<br>
> left during shutdown."<br>
><br>
> But how to do the timers those are cancelable such as buffer-event in log<br>
> module.<br>
> When the worker process is shutting down, they lose the chance to do<br>
> registered handler.<br>
> Even so the log module also works well because of 'ngx_conf_flush_files'.<br>
<br>
</span>Cancelable timers are expected to do it's work normally until the<br>
actual shutdown is possible, but will not delay shutdown.<br>
<br>
You can't relay on them to do any cleanup work though, as they<br>
will not be called in many cases. For example, much like any<br>
other timers they will not be called on fast shutdown (aka<br>
ngx_terminate). To do a cleanup work you should use cleanup<br>
handlers and/or exit_process callbacks.<br>
<br>
In particular, the log module uses cancelable timers to do<br>
periodic flushes while the process is still running. The final<br>
flush will be done on the process exit in the<br>
ngx_conf_flush_files() exit_process callback.<br>
<span class="m_-5721540339631132507im m_-5721540339631132507HOEnZb"><br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/" rel="noreferrer" target="_blank">http://nginx.org/</a><br>
</span><div class="m_-5721540339631132507HOEnZb"><div class="m_-5721540339631132507h5">______________________________<wbr>_________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailm<wbr>an/listinfo/nginx-devel</a></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>