[asterisk-commits] tilghman: trunk r97978 - in /trunk: ./ channels/chan_sip.c main/translate.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 10 17:40:13 CST 2008


Author: tilghman
Date: Thu Jan 10 17:40:13 2008
New Revision: 97978

URL: http://svn.digium.com/view/asterisk?view=rev&rev=97978
Log:
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)

........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c
    trunk/main/translate.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=97978&r1=97977&r2=97978
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Jan 10 17:40:13 2008
@@ -3044,11 +3044,18 @@
 		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)

Modified: trunk/main/translate.c
URL: http://svn.digium.com/view/asterisk/trunk/main/translate.c?view=diff&rev=97978&r1=97977&r2=97978
==============================================================================
--- trunk/main/translate.c (original)
+++ trunk/main/translate.c Thu Jan 10 17:40:13 2008
@@ -225,7 +225,10 @@
 	f->offset = AST_FRIENDLY_OFFSET;
 	f->src = pvt->t->name;
 	f->data = pvt->outbuf;
-	return f;
+	/* We must clone the frame, because the pvt could disappear
+	 * the moment after we return (and unlock the source channel).
+	 */
+	return ast_frisolate(f);
 }
 
 static struct ast_frame *default_frameout(struct ast_trans_pvt *pvt)




More information about the asterisk-commits mailing list