<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10615">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 b4f4e11..174f9f7 100644</span><br><span>--- a/main/asterisk.c</span><br><span>+++ b/main/asterisk.c</span><br><span>@@ -391,6 +391,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>@@ -2136,10 +2137,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>@@ -2773,7 +2773,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>@@ -3316,7 +3316,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>@@ -3348,7 +3348,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>@@ -3408,7 +3408,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>@@ -4341,6 +4341,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 a79bdf6..b4b7c8c 100644</span><br><span>--- a/main/options.c</span><br><span>+++ b/main/options.c</span><br><span>@@ -314,7 +314,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/10615">change 10615</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/10615"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </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: 10615 </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>