<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7169">View Change</a></p><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(+), 16 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/69/7169/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/asterisk.c b/main/asterisk.c<br>index d555949..bc1990d 100644<br>--- a/main/asterisk.c<br>+++ b/main/asterisk.c<br>@@ -1761,13 +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>+ if (ast_alertpipe_writable(sig_alert_pipe)) {<br>+ if (ast_alertpipe_write(sig_alert_pipe)) {<br> fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));<br> }<br> }<br>@@ -2169,10 +2169,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,10 +2205,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>+ if (ast_alertpipe_writable(sig_alert_pipe)) {<br>+ if (ast_alertpipe_write(sig_alert_pipe)) {<br> fprintf(stderr, "quit_handler: write() failed: %s\n", strerror(errno));<br> }<br> }<br>@@ -3887,7 +3883,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>@@ -3902,8 +3898,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>@@ -4710,9 +4705,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: newchange </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: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>