Merged revisions 82444 via svnmerge from
authorSteve Murphy <murf@digium.com>
Fri, 14 Sep 2007 21:30:44 +0000 (21:30 +0000)
committerSteve Murphy <murf@digium.com>
Fri, 14 Sep 2007 21:30:44 +0000 (21:30 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r82444 | murf | 2007-09-14 15:19:27 -0600 (Fri, 14 Sep 2007) | 1 line

closes issue #10668; thanks to arkadia for his patch; had to leave out the bit about ending the previous cdr in the fork; it would destroy current implementations.
........

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

main/cdr.c

index 16fa842..9bd79cf 100644 (file)
@@ -308,20 +308,22 @@ int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int
        }
 
        for (; cdr; cdr = recur ? cdr->next : NULL) {
-               headp = &cdr->varshead;
-               AST_LIST_TRAVERSE_SAFE_BEGIN(headp, newvariable, entries) {
-                       if (!strcasecmp(ast_var_name(newvariable), name)) {
-                               /* there is already such a variable, delete it */
-                               AST_LIST_REMOVE_CURRENT(headp, entries);
-                               ast_var_delete(newvariable);
-                               break;
+               if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
+                       headp = &cdr->varshead;
+                       AST_LIST_TRAVERSE_SAFE_BEGIN(headp, newvariable, entries) {
+                               if (!strcasecmp(ast_var_name(newvariable), name)) {
+                                       /* there is already such a variable, delete it */
+                                       AST_LIST_REMOVE_CURRENT(headp, entries);
+                                       ast_var_delete(newvariable);
+                                       break;
+                               }
                        }
-               }
-               AST_LIST_TRAVERSE_SAFE_END;
+                       AST_LIST_TRAVERSE_SAFE_END;
 
-               if (value) {
-                       newvariable = ast_var_assign(name, value);
-                       AST_LIST_INSERT_HEAD(headp, newvariable, entries);
+                       if (value) {
+                               newvariable = ast_var_assign(name, value);
+                               AST_LIST_INSERT_HEAD(headp, newvariable, entries);
+                       }
                }
        }
 
@@ -691,11 +693,13 @@ void ast_cdr_answer(struct ast_cdr *cdr)
 {
 
        for (; cdr; cdr = cdr->next) {
-               check_post(cdr);
-               if (cdr->disposition < AST_CDR_ANSWERED)
-                       cdr->disposition = AST_CDR_ANSWERED;
-               if (ast_tvzero(cdr->answer))
-                       cdr->answer = ast_tvnow();
+               if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
+                       check_post(cdr);
+                       if (cdr->disposition < AST_CDR_ANSWERED)
+                               cdr->disposition = AST_CDR_ANSWERED;
+                       if (ast_tvzero(cdr->answer))
+                               cdr->answer = ast_tvnow();
+               }
        }
 }
 
@@ -841,15 +845,17 @@ int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *c)
 void ast_cdr_end(struct ast_cdr *cdr)
 {
        for ( ; cdr ; cdr = cdr->next) {
-               check_post(cdr);
-               if (ast_tvzero(cdr->end))
-                       cdr->end = ast_tvnow();
-               if (ast_tvzero(cdr->start)) {
-                       ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", S_OR(cdr->channel, "<unknown>"));
-                       cdr->disposition = AST_CDR_FAILED;
-               } else
-                       cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec;
-               cdr->billsec = ast_tvzero(cdr->answer) ? 0 : cdr->end.tv_sec - cdr->answer.tv_sec;
+               if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
+                       check_post(cdr);
+                       if (ast_tvzero(cdr->end))
+                               cdr->end = ast_tvnow();
+                       if (ast_tvzero(cdr->start)) {
+                               ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", S_OR(cdr->channel, "<unknown>"));
+                               cdr->disposition = AST_CDR_FAILED;
+                       } else
+                               cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec;
+                       cdr->billsec = ast_tvzero(cdr->answer) ? 0 : cdr->end.tv_sec - cdr->answer.tv_sec;
+               }
        }
 }