]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_dahdi: Never send MWI while off-hook.
authorNaveen Albert <asterisk@phreaknet.org>
Wed, 2 Oct 2024 00:24:00 +0000 (20:24 -0400)
committerNaveen Albert <asterisk@phreaknet.org>
Tue, 8 Oct 2024 14:17:47 +0000 (14:17 +0000)
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

index 76f012412866bce381a6a5cd0d90d2cc09fa0356..7db72836ac607bba7a8431d75be396f10dd5a1a1 100644 (file)
@@ -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);
                                                                }