From 7d5d0311c1d08f98424764b3c392f214cddc52d2 Mon Sep 17 00:00:00 2001 From: David Vossel Date: Fri, 12 Feb 2010 23:32:33 +0000 Subject: Merged revisions 246545 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r246545 | dvossel | 2010-02-12 17:30:17 -0600 (Fri, 12 Feb 2010) | 16 lines lock channel during datastore removal On channel destruction the channel's datastores are removed and destroyed. Since there are public API calls to find and remove datastores on a channel, a lock should be held whenever datastores are removed and destroyed. This resolves a crash caused by a race condition in app_chanspy.c. (closes issue #16678) Reported by: tim_ringenbach Patches: datastore_destroy_race.diff uploaded by tim ringenbach (license 540) Tested by: dvossel ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@246546 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/channel.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'main/channel.c') diff --git a/main/channel.c b/main/channel.c index 1ba4f1a24..83b6590fc 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1844,9 +1844,11 @@ static void ast_channel_destructor(void *obj) ast_cel_check_retire_linkedid(chan); /* Get rid of each of the data stores on the channel */ + ast_channel_lock(chan); while ((datastore = AST_LIST_REMOVE_HEAD(&chan->datastores, entry))) /* Free the data store */ ast_datastore_free(datastore); + ast_channel_unlock(chan); /* Lock and unlock the channel just to be sure nobody has it locked still due to a reference that was stored in a datastore. (i.e. app_chanspy) */ -- cgit v1.2.3