summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-02-18 17:45:48 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-02-18 17:45:48 +0000
commit2c3c489adec8e3daaaa70d8fb681084a0c7fb114 (patch)
treeccb920662eea11408952b9d9198d738bc5f3564d /channels
parentf04d5fb83dd36e600e1e257568ea3ca53154315e (diff)
Merged revisions 103780 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r103780 | tilghman | 2008-02-18 11:31:52 -0600 (Mon, 18 Feb 2008) | 9 lines When a SIP channel is being auto-destroyed, it's possible for it to still be in bridge code. When that happens, we crash. Delay the RTP destruction until the bridge is ended. (closes issue #11960) Reported by: norman Patches: 20080215__bug11960__2.diff.txt uploaded by Corydon76 (license 14) Tested by: norman ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103781 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 6f4ed046b..43ed8648d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -4134,6 +4134,21 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
ast_debug(2, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
}
+ /* Unlink us from the owner if we have one */
+ if (p->owner) {
+ if (lockowner)
+ ast_channel_lock(p->owner);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
+ p->owner->tech_pvt = NULL;
+ /* Make sure that the channel knows its backend is going away */
+ p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ if (lockowner)
+ ast_channel_unlock(p->owner);
+ /* Give the channel a chance to react before deallocation */
+ usleep(1);
+ }
+
/* Remove link from peer to subscription of MWI */
if (p->relatedpeer && p->relatedpeer->mwipvt)
p->relatedpeer->mwipvt = dialog_unref(p->relatedpeer->mwipvt);
@@ -4150,12 +4165,22 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
AST_SCHED_DEL(sched, p->waitid);
AST_SCHED_DEL(sched, p->autokillid);
- if (p->rtp)
+ /* We absolutely cannot destroy the rtp struct while a bridge is active or we WILL crash */
+ if (p->rtp) {
+ while (ast_rtp_get_bridged(p->rtp))
+ usleep(1);
ast_rtp_destroy(p->rtp);
- if (p->vrtp)
+ }
+ if (p->vrtp) {
+ while (ast_rtp_get_bridged(p->vrtp))
+ usleep(1);
ast_rtp_destroy(p->vrtp);
- if (p->trtp)
+ }
+ if (p->trtp) {
+ while (ast_rtp_get_bridged(p->trtp))
+ usleep(1);
ast_rtp_destroy(p->trtp);
+ }
if (p->udptl)
ast_udptl_destroy(p->udptl);
if (p->refer)
@@ -4177,15 +4202,6 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
ast_free(p->stimer);
}
- /* Unlink us from the owner if we have one */
- if (p->owner) {
- if (lockowner)
- ast_channel_lock(p->owner);
- ast_debug(1, "Detaching from %s\n", p->owner->name);
- p->owner->tech_pvt = NULL;
- if (lockowner)
- ast_channel_unlock(p->owner);
- }
/* Clear history */
if (p->history) {
struct sip_history *hist;