--- asterisk-1.8.4.2/channels/chan_sip.c.orig 2011-06-11 23:58:03.000000000 -0400 +++ asterisk-1.8.4.2/channels/chan_sip.c 2011-06-11 23:59:55.000000000 -0400 @@ -1248,7 +1248,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, char **name, char **number, int set_call_forward); -static int sip_send_mwi_to_peer(struct sip_peer *peer, const struct ast_event *event, int cache_only); +static int sip_send_mwi_to_peer(struct sip_peer *peer, const struct ast_event *event); /* Misc dialog routines */ static int __sip_autodestruct(const void *data); @@ -13795,7 +13795,7 @@ struct sip_peer *peer = userdata; ao2_lock(peer); - sip_send_mwi_to_peer(peer, event, 0); + sip_send_mwi_to_peer(peer, event); ao2_unlock(peer); } @@ -23696,7 +23696,7 @@ transmit_response(p, "200 OK", req); if (p->relatedpeer) { /* Send first notification */ ao2_lock(p->relatedpeer); /* was WRLOCK */ - sip_send_mwi_to_peer(p->relatedpeer, NULL, 0); + sip_send_mwi_to_peer(p->relatedpeer, NULL); ao2_unlock(p->relatedpeer); } } else if (p->subscribed != CALL_COMPLETION) { @@ -24530,7 +24530,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, int cache_only) +static int sip_send_mwi_to_peer(struct sip_peer *peer, const struct ast_event *event) { /* Called with peerl lock, but releases it */ struct sip_pvt *p; @@ -24546,10 +24546,6 @@ if (event) { newmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS); oldmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_OLDMSGS); - } else if (!cache_only) { /* Fall back to manually checking the mailbox */ - struct ast_str *mailbox_str = ast_str_alloca(512); - peer_mailboxes_to_str(&mailbox_str, peer); - ast_app_inboxcount(mailbox_str->str, &newmsgs, &oldmsgs); } else { get_cached_mwi(peer, &newmsgs, &oldmsgs); } @@ -26659,10 +26655,10 @@ if (!devstate_only && !ast_test_flag(&peer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY) && !AST_LIST_EMPTY(&peer->mailboxes)) { add_peer_mwi_subs(peer); - /* Send MWI from the event cache only. This is so we can send initial + /* Send MWI from the event cache. 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); + sip_send_mwi_to_peer(peer, NULL); } peer->the_mark = 0;