aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--channel.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/channel.c b/channel.c
index 10ef85fc2..a96d7d2d4 100644
--- a/channel.c
+++ b/channel.c
@@ -1326,6 +1326,7 @@ static void free_translation(struct ast_channel *clone)
int ast_hangup(struct ast_channel *chan)
{
int res = 0;
+ struct ast_cdr *cdr = NULL;
/* Don't actually hang up a channel that will masquerade as someone else, or
if someone is going to masquerade as us */
@@ -1372,7 +1373,7 @@ int ast_hangup(struct ast_channel *chan)
chan->generator = NULL;
if (chan->cdr) { /* End the CDR if it hasn't already */
ast_cdr_end(chan->cdr);
- ast_cdr_detach(chan->cdr); /* Post and Free the CDR */
+ cdr = chan->cdr;
chan->cdr = NULL;
}
if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
@@ -1403,6 +1404,11 @@ int ast_hangup(struct ast_channel *chan)
ast_cause2str(chan->hangupcause)
);
ast_channel_free(chan);
+
+ /* Defer CDR processing until later */
+ if (cdr)
+ ast_cdr_detach(cdr);
+
return res;
}