]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a problem with GROUP() settings on a masquerade.
authorRussell Bryant <russell@russellbryant.com>
Tue, 9 Dec 2008 14:52:25 +0000 (14:52 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 9 Dec 2008 14:52:25 +0000 (14:52 +0000)
The previous code carried over group settings from the old channel to the new
one.  However, it did nothing with the group settings that were already on the
new channel.  This patch removes all group settings that already existed on the
new channel.

I have a more complicated version of this patch which addresses only the most
blatant problem with this, which is that a channel can end up with multiple
group settings in the same category.  However, I could not think of a use case
for keeping any of the group settings from the old channel, so I went this route
for now.

(closes AST-152)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@161948 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/app.c

index bad03e09b69823e17cb9c429c8a4a25d52288c52..88346f42470c2eea07db09e81b35e00e2208d2bf 100644 (file)
@@ -915,10 +915,15 @@ int ast_app_group_update(struct ast_channel *old, struct ast_channel *new)
        struct ast_group_info *gi = NULL;
 
        AST_LIST_LOCK(&groups);
-       AST_LIST_TRAVERSE(&groups, gi, list) {
-               if (gi->chan == old)
+       AST_LIST_TRAVERSE_SAFE_BEGIN(&groups, gi, list) {
+               if (gi->chan == old) {
                        gi->chan = new;
+               } else if (gi->chan == new) {
+                       AST_LIST_REMOVE_CURRENT(&groups, list);
+                       free(gi);
+               }
        }
+       AST_LIST_TRAVERSE_SAFE_END
        AST_LIST_UNLOCK(&groups);
 
        return 0;