diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-02-12 23:30:17 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-02-12 23:30:17 +0000 |
commit | 96ac2c8ae5aff6bf4fd1c10e52e5511ea3b5d9cc (patch) | |
tree | f780834d9bf6c020d8fdeb75ee637bd44d6361af | |
parent | 4a0562cbed3c62ea77c4f7780b7afa8411e6a7fb (diff) |
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: http://svn.digium.com/svn/asterisk/branches/1.4@246545 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | main/channel.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/main/channel.c b/main/channel.c index 8addc0d62..a4ffd629d 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1286,9 +1286,11 @@ void ast_channel_free(struct ast_channel *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_channel_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) */ |