[asterisk-bugs] [JIRA] Commented: (ASTERISK-20064) Can MWI frequency be reduced? pollmailboxes=yes results in double MWI

Kerry (JIRA) noreply at issues.asterisk.org
Mon Sep 3 18:58:07 CDT 2012


    [ https://issues.asterisk.org/jira/browse/ASTERISK-20064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=196538#comment-196538 ] 

Kerry commented on ASTERISK-20064:
----------------------------------

I debugged this problem with pollmailboxes extensively.  It is strangely compounded if you have more than one phone subscribed to the same mailbox.  I have 19 phones and use one common mailbox, which caused a huge number of packets to be repeatedly sent out (something like 19^3 times) and even crashed some of my ATAs every time someone left a message.  Some clients dealt with the problem with no unusual side-effects.  Polycom 501s make a strange stutter-tone instead of the usual MWI sound, as the repeated packets arrive.

Here's my patch.  I've been running with this patch in place for a year or more.

{{{NoFormat}}}
--- apps/app_voicemail.c	(revision 372115)
+++ apps/app_voicemail.c	(working copy)
@@ -12512,35 +12512,62 @@
 static int handle_subscribe(void *datap)
 {
 	unsigned int len;
-	struct mwi_sub *mwi_sub;
+        struct mwi_sub *mwi_sub = NULL;
 	struct mwi_sub_task *p = datap;
+        int had_it = 0;
+        char mbx_tmp[200];
 
-	len = sizeof(*mwi_sub);
-	if (!ast_strlen_zero(p->mailbox))
-		len += strlen(p->mailbox);
+        strcpy( mbx_tmp, p->mailbox );
+        if (!ast_strlen_zero(p->context)) {
+            strcat(mbx_tmp, "@");
+            strcat(mbx_tmp, p->context);
+        }
 
 	if (!ast_strlen_zero(p->context))
 		len += strlen(p->context) + 1; /* Allow for seperator */
 
-	if (!(mwi_sub = ast_calloc(1, len)))
-		return -1;
+        // KBC - check if already subscribed
+       AST_RWLIST_RDLOCK(&mwi_subs);
+       AST_RWLIST_TRAVERSE(&mwi_subs, mwi_sub, entry) {
+               if ( strcmp( mbx_tmp, mwi_sub->mailbox ) == 0 ) {
+                    had_it = 1;
+                }
+       }
+       AST_RWLIST_UNLOCK(&mwi_subs);
+        if ( had_it ) {
+            ast_log(AST_LOG_WARNING, "skipping already subscribed %s\n", p->mailbox);
+       } else {
+            ast_log(AST_LOG_WARNING, "subscribed %s\n", p->mailbox);
+       }
 
-	mwi_sub->uniqueid = p->uniqueid;
-	if (!ast_strlen_zero(p->mailbox))
-		strcpy(mwi_sub->mailbox, p->mailbox);
+        if ( ! had_it ) {
+           len = sizeof(*mwi_sub);
+           if (!ast_strlen_zero(p->mailbox))
+                   len += strlen(p->mailbox);
+    
+           if (!ast_strlen_zero(p->context))
+                   len += strlen(p->context) + 1; /* Allow for seperator */
 
-	if (!ast_strlen_zero(p->context)) {
-		strcat(mwi_sub->mailbox, "@");
-		strcat(mwi_sub->mailbox, p->context);
-	}
+           if (!(mwi_sub = ast_calloc(1, len)))
+                   return -1;
 
-	AST_RWLIST_WRLOCK(&mwi_subs);
-	AST_RWLIST_INSERT_TAIL(&mwi_subs, mwi_sub, entry);
-	AST_RWLIST_UNLOCK(&mwi_subs);
+           mwi_sub->uniqueid = p->uniqueid;
+           if (!ast_strlen_zero(p->mailbox))
+                   strcpy(mwi_sub->mailbox, p->mailbox);
+
+           if (!ast_strlen_zero(p->context)) {
+                   strcat(mwi_sub->mailbox, "@");
+                   strcat(mwi_sub->mailbox, p->context);
+           }
+
+           AST_RWLIST_WRLOCK(&mwi_subs);
+           AST_RWLIST_INSERT_TAIL(&mwi_subs, mwi_sub, entry);
+           AST_RWLIST_UNLOCK(&mwi_subs);
+           poll_subscribed_mailbox(mwi_sub);
+        }
 	ast_free((void *) p->mailbox);
 	ast_free((void *) p->context);
 	ast_free(p);
-	poll_subscribed_mailbox(mwi_sub);
 	return 0;
 }

{{{NoFormat}}}

> Can MWI frequency be reduced? pollmailboxes=yes results in double MWI
> ---------------------------------------------------------------------
>
>                 Key: ASTERISK-20064
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-20064
>             Project: Asterisk
>          Issue Type: Improvement
>      Security Level: None
>          Components: Applications/app_voicemail
>    Affects Versions: 1.8.11.1
>            Reporter: Henry Fernandes
>            Severity: Trivial
>
> I have 'pollmailboxes=yes' in voicemail.conf.  When someone leaves a new VM, Asterisk sends out MWI as per usual.  The problem is that it sends out MWI once again when it polls the voice mailboxes.  The same thing happens when I delete a VM.  Asterisk sends MWI once at that point and then again when it polls.
> We have our Polycom phones set to beep when when MWI is received, so this is causing the phones to beep frequently.  

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the asterisk-bugs mailing list