[svn-commits] russell: branch russell/events r59249 - /team/russell/events/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Mar 26 20:55:45 MST 2007


Author: russell
Date: Mon Mar 26 22:55:45 2007
New Revision: 59249

URL: http://svn.digium.com/view/asterisk?view=rev&rev=59249
Log:
Make sure we still send the initial MWI to peers regardless of the order of
which chan_sip and app_voicemail get loaded.

Modified:
    team/russell/events/channels/chan_sip.c

Modified: team/russell/events/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/channels/chan_sip.c?view=diff&rev=59249&r1=59248&r2=59249
==============================================================================
--- team/russell/events/channels/chan_sip.c (original)
+++ team/russell/events/channels/chan_sip.c Mon Mar 26 22:55:45 2007
@@ -1292,7 +1292,7 @@
 static void copy_request(struct sip_request *dst, const struct sip_request *src);
 static void receive_message(struct sip_pvt *p, struct sip_request *req);
 static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req);
-static int sip_send_mwi_to_peer(struct sip_peer *peer, const struct ast_event *event);
+static int sip_send_mwi_to_peer(struct sip_peer *peer, const struct ast_event *event, int cache_only);
 
 /*--- Dialog management */
 static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *sin,
@@ -8725,7 +8725,7 @@
 	ASTOBJ_CONTAINER_TRAVERSE(&peerl, 1, do {
 		ASTOBJ_RDLOCK(iterator);
 		if (!strcmp(mailbox, iterator->mailbox))
-			sip_send_mwi_to_peer(iterator, event);
+			sip_send_mwi_to_peer(iterator, event, 0);
 		ASTOBJ_UNLOCK(iterator);
 	} while (0) );
 	ASTOBJ_CONTAINER_UNLOCK(&peerl);
@@ -15206,7 +15206,7 @@
 			transmit_response(p, "200 OK", req);
 			if (p->relatedpeer) {	/* Send first notification */
 				ASTOBJ_WRLOCK(p->relatedpeer);
-				sip_send_mwi_to_peer(p->relatedpeer, NULL);
+				sip_send_mwi_to_peer(p->relatedpeer, NULL, 0);
 				ASTOBJ_UNLOCK(p->relatedpeer);
 			}
 		} else {
@@ -15617,7 +15617,7 @@
 }
 
 /*! \brief Send message waiting indication to alert peer that they've got voicemail */
-static int sip_send_mwi_to_peer(struct sip_peer *peer, const struct ast_event *event)
+static int sip_send_mwi_to_peer(struct sip_peer *peer, const struct ast_event *event, int cache_only)
 {
 	/* Called with peerl lock, but releases it */
 	struct sip_pvt *p;
@@ -15641,6 +15641,8 @@
 		oldmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_OLDMSGS);
 		if (cache_event)
 			ast_event_destroy(cache_event);
+	} else if (cache_only) {
+		return 0;
 	} else /* Fall back to manually checking the mailbox */
 		ast_app_inboxcount(peer->mailbox, &newmsgs, &oldmsgs);
 	
@@ -16864,6 +16866,10 @@
 		peer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb,
 			AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, peer->mailbox,
 			AST_EVENT_IE_END);
+		/* Send MWI from the event cache only.  This is so we can send initial
+		 * MWI if app_voicemail got loaded before chan_sip.  If it is the other
+		 * way, then we will get events when app_voicemail gets loaded. */
+		sip_send_mwi_to_peer(peer, NULL, 1);
 	}
 
 	ASTOBJ_UNMARK(peer);



More information about the svn-commits mailing list