<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7169">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">core: Use ast_alertpipe for Asterisk signal monitoring thread.<br><br>Reduce the signal monitoring thread file descriptor use from two to one<br>on systems that support eventfd.<br><br>Change-Id: Id4041a237d481ff699639e153ea6982fee14a462<br>---<br>M main/asterisk.c<br>1 file changed, 9 insertions(+), 20 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/asterisk.c b/main/asterisk.c<br>index 40986a4..7cea6cd 100644<br>--- a/main/asterisk.c<br>+++ b/main/asterisk.c<br>@@ -1761,15 +1761,13 @@<br> <br> static void _hup_handler(int num)<br> {<br>- int a = 0, save_errno = errno;<br>+ int save_errno = errno;<br> printf("Received HUP signal -- Reloading configs\n");<br> if (restartnow)<br> execvp(_argv[0], _argv);<br> sig_flags.need_reload = 1;<br>- if (sig_alert_pipe[1] != -1) {<br>- if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {<br>- fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));<br>- }<br>+ if (ast_alertpipe_write(sig_alert_pipe)) {<br>+ fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));<br> }<br> errno = save_errno;<br> }<br>@@ -2169,10 +2167,7 @@<br> close(ast_consock);<br> if (!ast_opt_remote)<br> unlink(ast_config_AST_PID);<br>- if (sig_alert_pipe[0])<br>- close(sig_alert_pipe[0]);<br>- if (sig_alert_pipe[1])<br>- close(sig_alert_pipe[1]);<br>+ ast_alertpipe_close(sig_alert_pipe);<br> printf("%s", term_quit());<br> if (restart) {<br> int i;<br>@@ -2208,12 +2203,9 @@<br> <br> static void __quit_handler(int num)<br> {<br>- int a = 0;<br> sig_flags.need_quit = 1;<br>- if (sig_alert_pipe[1] != -1) {<br>- if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {<br>- fprintf(stderr, "quit_handler: write() failed: %s\n", strerror(errno));<br>- }<br>+ if (ast_alertpipe_write(sig_alert_pipe)) {<br>+ fprintf(stderr, "quit_handler: write() failed: %s\n", strerror(errno));<br> }<br> /* There is no need to restore the signal handler here, since the app<br> * is going to exit */<br>@@ -3877,7 +3869,7 @@<br> {<br> for (;;) {<br> struct pollfd p = { sig_alert_pipe[0], POLLIN, 0 };<br>- int a;<br>+<br> ast_poll(&p, 1, -1);<br> if (sig_flags.need_reload) {<br> sig_flags.need_reload = 0;<br>@@ -3892,8 +3884,7 @@<br> quit_handler(0, SHUTDOWN_NORMAL, 0);<br> }<br> }<br>- if (read(sig_alert_pipe[0], &a, sizeof(a)) != sizeof(a)) {<br>- }<br>+ ast_alertpipe_read(sig_alert_pipe);<br> }<br> <br> return NULL;<br>@@ -4700,9 +4691,7 @@<br> consolethread = pthread_self();<br> }<br> <br>- if (pipe(sig_alert_pipe)) {<br>- sig_alert_pipe[0] = sig_alert_pipe[1] = -1;<br>- }<br>+ ast_alertpipe_init(sig_alert_pipe);<br> <br> ast_process_pending_reloads();<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7169">change 7169</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7169"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Id4041a237d481ff699639e153ea6982fee14a462 </div>
<div style="display:none"> Gerrit-Change-Number: 7169 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>