aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-17 18:57:45 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-17 18:57:45 +0000
commit7ca66b4821d0333922d95a30b7b1449260464056 (patch)
treed5ddd7dc95fc1999c5aff1ae4aea7936d495e251 /channels
parentbee0b1d97ce799595734f3f072d18a21df915c19 (diff)
Merged revisions 123391 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r123391 | tilghman | 2008-06-17 13:56:53 -0500 (Tue, 17 Jun 2008) | 3 lines Fix 3 more places where failure to lock the structure could cause the wrong lock to be unlocked. (Closes issue #12795) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@123392 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 9741fbb64..fd33bd5c9 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -9670,9 +9670,10 @@ static int iax2_do_register(struct iax2_registry *reg)
* call has the pointer to IP and must be updated to the new one
*/
if (reg->dnsmgr && ast_dnsmgr_changed(reg->dnsmgr) && (reg->callno > 0)) {
- ast_mutex_lock(&iaxsl[reg->callno]);
- iax2_destroy(reg->callno);
- ast_mutex_unlock(&iaxsl[reg->callno]);
+ int callno = reg->callno;
+ ast_mutex_lock(&iaxsl[callno]);
+ iax2_destroy(callno);
+ ast_mutex_unlock(&iaxsl[callno]);
reg->callno = 0;
}
if (!reg->addr.sin_addr.s_addr) {
@@ -10274,13 +10275,14 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
static void peer_destructor(void *obj)
{
struct iax2_peer *peer = obj;
+ int callno = peer->callno;
ast_free_ha(peer->ha);
- if (peer->callno > 0) {
- ast_mutex_lock(&iaxsl[peer->callno]);
- iax2_destroy(peer->callno);
- ast_mutex_unlock(&iaxsl[peer->callno]);
+ if (callno > 0) {
+ ast_mutex_lock(&iaxsl[callno]);
+ iax2_destroy(callno);
+ ast_mutex_unlock(&iaxsl[callno]);
}
register_peer_exten(peer, 0);
@@ -10789,12 +10791,13 @@ static void delete_users(void)
while ((reg = AST_LIST_REMOVE_HEAD(&registrations, entry))) {
AST_SCHED_DEL(sched, reg->expire);
if (reg->callno) {
- ast_mutex_lock(&iaxsl[reg->callno]);
- if (iaxs[reg->callno]) {
- iaxs[reg->callno]->reg = NULL;
- iax2_destroy(reg->callno);
+ int callno = reg->callno;
+ ast_mutex_lock(&iaxsl[callno]);
+ if (iaxs[callno]) {
+ iaxs[callno]->reg = NULL;
+ iax2_destroy(callno);
}
- ast_mutex_unlock(&iaxsl[reg->callno]);
+ ast_mutex_unlock(&iaxsl[callno]);
}
if (reg->dnsmgr)
ast_dnsmgr_release(reg->dnsmgr);