[asterisk-commits] oej: branch oej/pinerana-lock-mwipvt-trunk r334451 - /team/oej/pinerana-lock-...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 5 08:36:14 CDT 2011
Author: oej
Date: Mon Sep 5 08:36:01 2011
New Revision: 334451
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=334451
Log:
Moving locks in accord to the review made by irroot on reviewboard.
(issue ASTERISK-18288)
Modified:
team/oej/pinerana-lock-mwipvt-trunk/channels/chan_sip.c
Modified: team/oej/pinerana-lock-mwipvt-trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinerana-lock-mwipvt-trunk/channels/chan_sip.c?view=diff&rev=334451&r1=334450&r2=334451
==============================================================================
--- team/oej/pinerana-lock-mwipvt-trunk/channels/chan_sip.c (original)
+++ team/oej/pinerana-lock-mwipvt-trunk/channels/chan_sip.c Mon Sep 5 08:36:01 2011
@@ -14324,9 +14324,7 @@
{
struct sip_peer *peer = userdata;
- ao2_lock(peer);
sip_send_mwi_to_peer(peer, 0);
- ao2_unlock(peer);
}
static void network_change_event_subscribe(void)
@@ -24883,9 +24881,7 @@
ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
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, 0);
- ao2_unlock(p->relatedpeer);
}
} else if (p->subscribed != CALL_COMPLETION) {
@@ -25595,6 +25591,7 @@
}
/*! \brief Send message waiting indication to alert peer that they've got voicemail
+ * \note Locks the peer (if it exists)
* \returns -1 on failure, 0 on success
*/
static int sip_send_mwi_to_peer(struct sip_peer *peer, int cache_only)
@@ -25611,6 +25608,7 @@
if (ast_sockaddr_isnull(&peer->addr) && ast_sockaddr_isnull(&peer->defaddr)) {
return -1;
}
+ ao2_lock(peer);
/* Attempt to use cached mwi to get message counts. */
if (!get_cached_mwi(peer, &newmsgs, &oldmsgs) && !cache_only) {
@@ -25619,6 +25617,7 @@
peer_mailboxes_to_str(&mailbox_str, peer);
/* if there is no mailbox do nothing */
if (ast_strlen_zero(mailbox_str->str)) {
+ ao2_unlock(peer);
return -1;
}
ast_app_inboxcount(mailbox_str->str, &newmsgs, &oldmsgs);
@@ -25629,8 +25628,11 @@
p = dialog_ref(peer->mwipvt, "sip_send_mwi_to_peer: Setting dialog ptr p from peer->mwipvt-- should this be done?");
} else {
/* Build temporary dialog for this message */
- if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL)))
+ if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL))) {
+ ao2_unlock(peer);
return -1;
+ }
+
/* If we don't set the socket type to 0, then create_addr_from_peer will fail immediately if the peer
* uses any transport other than UDP. We set the type to 0 here and then let create_addr_from_peer copy
* the peer's socket information to the sip_pvt we just allocated
@@ -25641,6 +25643,7 @@
dialog_unlink_all(p, TRUE, TRUE);
dialog_unref(p, "unref dialog p just created via sip_alloc");
/* sip_destroy(p); */
+ ao2_unlock(peer);
return -1;
}
/* Recalculate our side, and recalculate Call ID */
@@ -25668,6 +25671,7 @@
transmit_notify_with_mwi(p, newmsgs, oldmsgs, peer->vmexten);
sip_pvt_unlock(p);
dialog_unref(p, "unref dialog ptr p just before it goes out of scope at the end of sip_send_mwi_to_peer.");
+ ao2_unlock(peer);
return 0;
}
More information about the asterisk-commits
mailing list