]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_forkcdr: ForkCDR v option does not keep CDR variables for subsequent records
authorKevin Harwell <kharwell@digium.com>
Fri, 21 Feb 2014 20:21:46 +0000 (20:21 +0000)
committerKevin Harwell <kharwell@digium.com>
Fri, 21 Feb 2014 20:21:46 +0000 (20:21 +0000)
When the 'v' option is specified to ForkCDR application, AST_CDR_FLAG_KEEP_VARS
flag is set only for the first CDR in the chain. So ForkCDR works fine with this
option only once. After the second and further calls to ForkCDR, CDR variables
get cleared on all CDRs besides the first one and moved to the newly forked CDR.
It always sets the KEEP_VARS flag on the first CDR in the chain, instead of the
most recent CDR which is used as a base to fork a new CDR.

This patch sets KEEP_VARS flag on the most recent CDR on the stack (the CDR used
for forking).

(closes issue ASTERISK-23260)
Reported by: zvision
Patches:
     app_forkcdr.diff uploaded by zvision (license 5755)
........

Merged revisions 408747 from http://svn.asterisk.org/svn/asterisk/branches/1.8

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

apps/app_forkcdr.c

index 354792fb9a49d80b8b6e7154a95aaff66894a8d4..558b1146e75ebf2c29ed1fc325787db75e852647 100644 (file)
@@ -239,13 +239,14 @@ static int forkcdr_exec(struct ast_channel *chan, const char *data)
 {
        int res = 0;
        char *argcopy = NULL;
+       struct ast_cdr *cdr;
        struct ast_flags flags = {0};
        char *opts[OPT_ARG_ARRAY_SIZE];
        AST_DECLARE_APP_ARGS(arglist,
                AST_APP_ARG(options);
        );
 
-       if (!ast_channel_cdr(chan)) {
+       if (!(cdr = ast_channel_cdr(chan))) {
                ast_log(LOG_WARNING, "Channel does not have a CDR\n");
                return 0;
        }
@@ -261,9 +262,12 @@ static int forkcdr_exec(struct ast_channel *chan, const char *data)
 
        if (!ast_strlen_zero(data)) {
                int keepvars = ast_test_flag(&flags, OPT_KEEPVARS) ? 1 : 0;
-               ast_set2_flag(ast_channel_cdr(chan), keepvars, AST_CDR_FLAG_KEEP_VARS);
+               while (cdr->next) {
+                       cdr = cdr->next;
+               }
+               ast_set2_flag(cdr, keepvars, AST_CDR_FLAG_KEEP_VARS);
        }
-       
+
        ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]);
 
        return res;