summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-01-10 23:40:13 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-01-10 23:40:13 +0000
commitc88f243d8d6ca80f98cd36fd6c0ff17529766af4 (patch)
tree6b06c71a82f742ae75791c9850be922da04663af /channels
parent3d47a43ac205b104a85f40624621471ea4fdb813 (diff)
Merged revisions 97973 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r97973 | tilghman | 2008-01-10 17:08:36 -0600 (Thu, 10 Jan 2008) | 6 lines 1) When we get a translated frame out, clone it, because if the translator pvt is freed before we use the frame, bad things happen. 2) Getting a failure from ast_sched_delete means that the schedule ID is currently running. Don't just ignore it. (Closes issue #11698) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@97978 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 3d1b3158f..10847f7b2 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -3044,11 +3044,18 @@ static void sip_destroy_peer(struct sip_peer *peer)
ast_variables_destroy(peer->chanvars);
peer->chanvars = NULL;
}
- if (peer->expire > -1)
- ast_sched_del(sched, peer->expire);
- if (peer->pokeexpire > -1)
- ast_sched_del(sched, peer->pokeexpire);
+ /* If the schedule delete fails, that means the schedule is currently
+ * running, which means we should wait for that thread to complete.
+ * Otherwise, there's a crashable race condition.
+ *
+ * NOTE: once peer is refcounted, this probably is no longer necessary.
+ */
+ while (peer->expire > -1 && ast_sched_del(sched, peer->expire))
+ usleep(1);
+ while (peer->pokeexpire > -1 && ast_sched_del(sched, peer->pokeexpire))
+ usleep(1);
+
register_peer_exten(peer, FALSE);
ast_free_ha(peer->ha);
if (peer->selfdestruct)