<p>Oron Peled would like Tzafrir Cohen to <strong>review</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11534">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">openr2(2/6): Stop polling channels when DAHDI returns -ENODEV (e.g: plug-out)<br><br>Otherwise, OpenR2 threads go crazy and consume almost all CPU resources<br><br>Change-Id: I10a41f617613fe7399c5bdced5c64a2751173f28<br>Signed-off-by: Oron Peled <oron.peled@xorcom.com><br>---<br>M channels/chan_dahdi.c<br>1 file changed, 15 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/34/11534/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c</span><br><span>index fb63307..20ef64e 100644</span><br><span>--- a/channels/chan_dahdi.c</span><br><span>+++ b/channels/chan_dahdi.c</span><br><span>@@ -761,6 +761,7 @@</span><br><span> openr2_context_t *protocol_context; /*!< OpenR2 context handle */</span><br><span> struct dahdi_pvt *pvts[SIG_MFCR2_MAX_CHANNELS]; /*!< Member channel pvt structs */</span><br><span> int numchans; /*!< Number of channels in this R2 block */</span><br><span style="color: hsl(120, 100%, 40%);">+ int nodev; /*!< Link disconnected? */</span><br><span> struct dahdi_mfcr2_conf conf; /*!< Configuration used to setup this pseudo-link */</span><br><span> };</span><br><span> </span><br><span>@@ -3704,6 +3705,17 @@</span><br><span> static void dahdi_r2_on_os_error(openr2_chan_t *r2chan, int errorcode)</span><br><span> {</span><br><span> ast_log(LOG_ERROR, "OS error on chan %d: %s\n", openr2_chan_get_number(r2chan), strerror(errorcode));</span><br><span style="color: hsl(120, 100%, 40%);">+ struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_mutex_lock(&p->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Disconnected? */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (errorcode == ENODEV) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct dahdi_mfcr2 *r2link = p->mfcr2;</span><br><span style="color: hsl(120, 100%, 40%);">+ p->mfcr2call = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (r2link) {</span><br><span style="color: hsl(120, 100%, 40%);">+ r2link->nodev = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_mutex_unlock(&p->lock);</span><br><span> }</span><br><span> </span><br><span> static void dahdi_r2_on_protocol_error(openr2_chan_t *r2chan, openr2_protocol_error_t reason)</span><br><span>@@ -13844,6 +13856,9 @@</span><br><span> if (mfcr2->pvts[i]->owner) {</span><br><span> continue;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (mfcr2->nodev) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> if (!mfcr2->pvts[i]->r2chan) {</span><br><span> ast_debug(1, "Wow, no r2chan on channel %d\n", mfcr2->pvts[i]->channel);</span><br><span> quit_loop = 1;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11534">change 11534</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/c/asterisk/+/11534"/><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-Change-Id: I10a41f617613fe7399c5bdced5c64a2751173f28 </div>
<div style="display:none"> Gerrit-Change-Number: 11534 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Oron Peled <oron.peled@xorcom.com> </div>
<div style="display:none"> Gerrit-Reviewer: Tzafrir Cohen <tzafrir.cohen@xorcom.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>