]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 246546 via svnmerge from
authorDavid Vossel <dvossel@digium.com>
Fri, 12 Feb 2010 23:34:10 +0000 (23:34 +0000)
committerDavid Vossel <dvossel@digium.com>
Fri, 12 Feb 2010 23:34:10 +0000 (23:34 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

................
  r246546 | dvossel | 2010-02-12 17:32:33 -0600 (Fri, 12 Feb 2010) | 21 lines

  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/branches/1.6.1@246548 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c

index 3c6536811a763615ea51f10e257b2c36dc2a143a..b7b8e1b62461c7c430a342023e6abaaf20e762ac 100644 (file)
@@ -1389,9 +1389,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_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) */