[Asterisk-code-review] openr2(2/6): Stop polling channels when DAHDI returns -ENODEV (e.g: p... (...asterisk[13])
Oron Peled
asteriskteam at digium.com
Mon Jul 8 18:09:06 CDT 2019
Hello Tzafrir Cohen,
I'd like you to do a code review. Please visit
https://gerrit.asterisk.org/c/asterisk/+/11534
to review the following change.
Change subject: openr2(2/6): Stop polling channels when DAHDI returns -ENODEV (e.g: plug-out)
......................................................................
openr2(2/6): Stop polling channels when DAHDI returns -ENODEV (e.g: plug-out)
Otherwise, OpenR2 threads go crazy and consume almost all CPU resources
Change-Id: I10a41f617613fe7399c5bdced5c64a2751173f28
Signed-off-by: Oron Peled <oron.peled at xorcom.com>
---
M channels/chan_dahdi.c
1 file changed, 15 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/34/11534/1
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index fb63307..20ef64e 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -761,6 +761,7 @@
openr2_context_t *protocol_context; /*!< OpenR2 context handle */
struct dahdi_pvt *pvts[SIG_MFCR2_MAX_CHANNELS]; /*!< Member channel pvt structs */
int numchans; /*!< Number of channels in this R2 block */
+ int nodev; /*!< Link disconnected? */
struct dahdi_mfcr2_conf conf; /*!< Configuration used to setup this pseudo-link */
};
@@ -3704,6 +3705,17 @@
static void dahdi_r2_on_os_error(openr2_chan_t *r2chan, int errorcode)
{
ast_log(LOG_ERROR, "OS error on chan %d: %s\n", openr2_chan_get_number(r2chan), strerror(errorcode));
+ struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
+ ast_mutex_lock(&p->lock);
+ /* Disconnected? */
+ if (errorcode == ENODEV) {
+ struct dahdi_mfcr2 *r2link = p->mfcr2;
+ p->mfcr2call = 0;
+ if (r2link) {
+ r2link->nodev = 1;
+ }
+ }
+ ast_mutex_unlock(&p->lock);
}
static void dahdi_r2_on_protocol_error(openr2_chan_t *r2chan, openr2_protocol_error_t reason)
@@ -13844,6 +13856,9 @@
if (mfcr2->pvts[i]->owner) {
continue;
}
+ if (mfcr2->nodev) {
+ continue;
+ }
if (!mfcr2->pvts[i]->r2chan) {
ast_debug(1, "Wow, no r2chan on channel %d\n", mfcr2->pvts[i]->channel);
quit_loop = 1;
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11534
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I10a41f617613fe7399c5bdced5c64a2751173f28
Gerrit-Change-Number: 11534
Gerrit-PatchSet: 1
Gerrit-Owner: Oron Peled <oron.peled at xorcom.com>
Gerrit-Reviewer: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190708/58950ced/attachment-0001.html>
More information about the asterisk-code-review
mailing list