From d4358d5f7a7d6f4b63ec8519ab6988c500b9cd49 Mon Sep 17 00:00:00 2001 From: Naveen Albert Date: Tue, 1 Oct 2024 20:24:00 -0400 Subject: [PATCH] chan_dahdi: Never send MWI while off-hook. In some circumstances, it is possible for the do_monitor thread to erroneously think that a line is on-hook and send an MWI FSK spill to it when the line is really off-hook and no MWI should be sent. Commit 0a8b3d34673277b70be6b0e8ac50191b1f3c72c6 previously fixed this issue in a more readily encountered scenario, but it has still been possible for MWI to be sent when it shouldn't be. To robustly fix this issue, query DAHDI for the hook status to ensure we don't send MWI on a line that is actually still off hook. Resolves: #928 --- channels/chan_dahdi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 76f0124128..7db72836ac 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -11983,7 +11983,11 @@ static void *do_monitor(void *data) && !last->owner && (!ast_strlen_zero(last->mailbox) || last->mwioverride_active) && !analog_p->subs[SUB_REAL].owner /* could be a recall ring from a flash hook hold */ - && (thispass - analog_p->onhooktime > 3)) { + && (thispass - analog_p->onhooktime > 3) + /* In some cases, all of the above checks will pass even if the line is really off-hook. + * This last check will give the right answer 100% of the time, but is relatively + * "expensive" (it requires an ioctl), so it is last to avoid unnecessary system calls. */ + && !my_is_off_hook(last)) { res = has_voicemail(last); if (analog_p->msgstate != res) { /* Set driver resources for signalling VMWI */ @@ -11993,6 +11997,7 @@ static void *do_monitor(void *data) ast_debug(3, "Unable to control message waiting led on channel %d: %s\n", last->channel, strerror(errno)); } /* If enabled for FSK spill then initiate it */ + ast_debug(5, "Initiating MWI FSK spill on channel %d\n", last->channel); if (mwi_send_init(last)) { ast_log(LOG_WARNING, "Unable to initiate mwi send sequence on channel %d\n", last->channel); }