]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Undoes 310726 for further analysis
authorJonathan Rose <jrose@digium.com>
Mon, 14 Mar 2011 21:30:25 +0000 (21:30 +0000)
committerJonathan Rose <jrose@digium.com>
Mon, 14 Mar 2011 21:30:25 +0000 (21:30 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@310733 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c

index 90d72aaa693e6f90e8aa2113dad29de4a86ea477..cada40f85816058c20df16be0cb6680af4091b2d 100644 (file)
@@ -2313,6 +2313,7 @@ static void ast_channel_destructor(void *obj)
        struct ast_var_t *vardata;
        struct ast_frame *f;
        struct varshead *headp;
+       struct ast_datastore *datastore;
        char device_name[AST_CHANNEL_NAME];
 
        if (chan->name) {
@@ -2321,6 +2322,18 @@ 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) */
+       ast_channel_lock(chan);
+       ast_channel_unlock(chan);
+
        if (chan->tech_pvt) {
                ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name);
                ast_free(chan->tech_pvt);
@@ -2671,7 +2684,6 @@ int ast_hangup(struct ast_channel *chan)
 {
        int res = 0;
        char extra_str[64]; /* used for cel logging below */
-       struct ast_datastore *datastore;
 
        /* Don't actually hang up a channel that will masquerade as someone else, or
           if someone is going to masquerade as us */
@@ -2778,15 +2790,6 @@ int ast_hangup(struct ast_channel *chan)
                ast_channel_unlock(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);
-
-
        chan = ast_channel_release(chan);
 
        return res;