diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-03 21:35:11 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-03 21:35:11 +0000 |
commit | ae5d47ddbdd14184563996190e84b68e54ddb3f4 (patch) | |
tree | ae043abaf3307a8b817bcbb0de41923a8e9cbee5 /channels | |
parent | 33d1d68d0dacaf9c390f26ca6fcaf2e889276942 (diff) |
Merged revisions 120168 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r120168 | russell | 2008-06-03 16:34:55 -0500 (Tue, 03 Jun 2008) | 4 lines
Fix another place where peer->callno could change at a very bad time, and also
fix a place where a peer was used after the reference was released.
(inspired by rev 120001)
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@120169 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_iax2.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index bdff92869..ce8553f15 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -9833,15 +9833,17 @@ static char *handle_cli_iax2_provision(struct ast_cli_entry *e, int cmd, struct static void __iax2_poke_noanswer(const void *data) { struct iax2_peer *peer = (struct iax2_peer *)data; + int callno; + if (peer->lastms > -1) { ast_log(LOG_NOTICE, "Peer '%s' is now UNREACHABLE! Time: %d\n", peer->name, peer->lastms); manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Unreachable\r\nTime: %d\r\n", peer->name, peer->lastms); ast_device_state_changed("IAX2/%s", peer->name); /* Activate notification */ } - if (peer->callno > 0) { - ast_mutex_lock(&iaxsl[peer->callno]); - iax2_destroy(peer->callno); - ast_mutex_unlock(&iaxsl[peer->callno]); + if ((callno = peer->callno) > 0) { + ast_mutex_lock(&iaxsl[callno]); + iax2_destroy(callno); + ast_mutex_unlock(&iaxsl[callno]); } peer->callno = 0; peer->lastms = -1; @@ -9894,7 +9896,7 @@ static int iax2_poke_peer(struct iax2_peer *peer, int heldcall) } if (heldcall) ast_mutex_unlock(&iaxsl[heldcall]); - peer->callno = find_callno(0, 0, &peer->addr, NEW_FORCE, peer->sockfd, 0); + callno = peer->callno = find_callno(0, 0, &peer->addr, NEW_FORCE, peer->sockfd, 0); if (heldcall) ast_mutex_lock(&iaxsl[heldcall]); if (peer->callno < 1) { @@ -9924,11 +9926,11 @@ static int iax2_poke_peer(struct iax2_peer *peer, int heldcall) peer_unref(peer); /* And send the poke */ - ast_mutex_lock(&iaxsl[peer->callno]); - if (iaxs[peer->callno]) { - send_command(iaxs[peer->callno], AST_FRAME_IAX, IAX_COMMAND_POKE, 0, NULL, 0, -1); + ast_mutex_lock(&iaxsl[callno]); + if (iaxs[callno]) { + send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_POKE, 0, NULL, 0, -1); } - ast_mutex_unlock(&iaxsl[peer->callno]); + ast_mutex_unlock(&iaxsl[callno]); return 0; } |