From: Joshua Colp Date: Wed, 27 Jun 2007 20:23:24 +0000 (+0000) Subject: I may possibly get shot for doing this... but... defer CDR processing until after... X-Git-Tag: 1.2.20~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2303602f151834aa5507f5bc359ffa831514cd0f;p=thirdparty%2Fasterisk.git I may possibly get shot for doing this... but... defer CDR processing until after the channel has been dealt with. This should eliminate all of the issues with channels going funky (SIP/PRI) when you are posting CDRs to a database that is either slow or unavailable and do not want to enable batching. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@72256 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channel.c b/channel.c index 10ef85fc2f..a96d7d2d4c 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; }