<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10616">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">core: Ensure that el_end is always run when needed.<br><br>* Ignore console=yes configuration option in remote console processes.<br>* Use new flag to tell consolethread to run el_end and exit when needed.<br><br>ASTERISK-28158<br><br>Change-Id: I9e23b31d4211417ddc88c6bbfd83ea4c9f3e5438<br>---<br>M main/asterisk.c<br>M main/options.c<br>2 files changed, 17 insertions(+), 9 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/asterisk.c b/main/asterisk.c</span><br><span>index 1d52567..a751c3b 100644</span><br><span>--- a/main/asterisk.c</span><br><span>+++ b/main/asterisk.c</span><br><span>@@ -392,6 +392,7 @@</span><br><span>        unsigned int need_reload:1;</span><br><span>          unsigned int need_quit:1;</span><br><span>    unsigned int need_quit_handler:1;</span><br><span style="color: hsl(120, 100%, 40%);">+     unsigned int need_el_end:1;</span><br><span> } sig_flags;</span><br><span> </span><br><span> #if !defined(LOW_MEMORY)</span><br><span>@@ -2018,10 +2019,9 @@</span><br><span>                        if (el_hist != NULL) {</span><br><span>                               history_end(el_hist);</span><br><span>                        }</span><br><span style="color: hsl(0, 100%, 40%);">-               } else if (mon_sig_flags == pthread_self()) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   if (consolethread != AST_PTHREADT_NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">-                               pthread_kill(consolethread, SIGURG);</span><br><span style="color: hsl(0, 100%, 40%);">-                    }</span><br><span style="color: hsl(120, 100%, 40%);">+             } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      sig_flags.need_el_end = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+                    pthread_kill(consolethread, SIGURG);</span><br><span>                 }</span><br><span>    }</span><br><span>    active_channels = ast_active_channels();</span><br><span>@@ -2638,7 +2638,7 @@</span><br><span>             }</span><br><span>            res = ast_poll(fds, max, -1);</span><br><span>                if (res < 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-                       if (sig_flags.need_quit || sig_flags.need_quit_handler) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (sig_flags.need_quit || sig_flags.need_quit_handler || sig_flags.need_el_end) {</span><br><span>                           break;</span><br><span>                       }</span><br><span>                    if (errno == EINTR) {</span><br><span>@@ -3166,7 +3166,7 @@</span><br><span>                sprintf(tmp, "%s%s", prefix, data);</span><br><span>                if (write(ast_consock, tmp, strlen(tmp) + 1) < 0) {</span><br><span>                       ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno));</span><br><span style="color: hsl(0, 100%, 40%);">-                  if (sig_flags.need_quit || sig_flags.need_quit_handler) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (sig_flags.need_quit || sig_flags.need_quit_handler || sig_flags.need_el_end) {</span><br><span>                           return;</span><br><span>                      }</span><br><span>            }</span><br><span>@@ -3198,7 +3198,7 @@</span><br><span>                    char buffer[512] = "", *curline = buffer, *nextline;</span><br><span>                       int not_written = 1;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                        if (sig_flags.need_quit || sig_flags.need_quit_handler) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (sig_flags.need_quit || sig_flags.need_quit_handler || sig_flags.need_el_end) {</span><br><span>                           break;</span><br><span>                       }</span><br><span> </span><br><span>@@ -3258,7 +3258,7 @@</span><br><span>        for (;;) {</span><br><span>           ebuf = (char *)el_gets(el, &num);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-               if (sig_flags.need_quit || sig_flags.need_quit_handler) {</span><br><span style="color: hsl(120, 100%, 40%);">+             if (sig_flags.need_quit || sig_flags.need_quit_handler || sig_flags.need_el_end) {</span><br><span>                   break;</span><br><span>               }</span><br><span> </span><br><span>@@ -4201,6 +4201,12 @@</span><br><span>               el_set(el, EL_GETCFN, ast_el_read_char);</span><br><span> </span><br><span>                 for (;;) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    if (sig_flags.need_el_end) {</span><br><span style="color: hsl(120, 100%, 40%);">+                          el_end(el);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                         return;</span><br><span style="color: hsl(120, 100%, 40%);">+                       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                  if (sig_flags.need_quit || sig_flags.need_quit_handler) {</span><br><span>                            quit_handler(0, SHUTDOWN_FAST, 0);</span><br><span>                           break;</span><br><span>diff --git a/main/options.c b/main/options.c</span><br><span>index 4f9b3dc..ea97a6a 100644</span><br><span>--- a/main/options.c</span><br><span>+++ b/main/options.c</span><br><span>@@ -322,7 +322,9 @@</span><br><span>                    ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);</span><br><span>          /* Run as console (-c at startup, implies nofork) */</span><br><span>                 } else if (!strcasecmp(v->name, "console")) {</span><br><span style="color: hsl(0, 100%, 40%);">-                      ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);</span><br><span style="color: hsl(120, 100%, 40%);">+                  if (!ast_opt_remote) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);</span><br><span style="color: hsl(120, 100%, 40%);">+                  }</span><br><span>            /* Run with high priority if the O/S permits (-p at startup) */</span><br><span>              } else if (!strcasecmp(v->name, "highpriority")) {</span><br><span>                      ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIGH_PRIORITY);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10616">change 10616</a>. To unsubscribe, or for help writing mail filters, 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/10616"/><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: I9e23b31d4211417ddc88c6bbfd83ea4c9f3e5438 </div>
<div style="display:none"> Gerrit-Change-Number: 10616 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>