[svn-commits] file: branch file/cdrbatchretry r38366 -
/team/file/cdrbatchretry/cdr.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Thu Jul 27 11:52:45 MST 2006
Author: file
Date: Thu Jul 27 13:52:44 2006
New Revision: 38366
URL: http://svn.digium.com/view/asterisk?rev=38366&view=rev
Log:
Change the logic of how the max deferrals option works. This sort of opens up a best practices chapter for CDR engines so here are my thoughts. If a CDR engine can post the record but for whatever reason (for example, a maintenance mode is enabled in the driver) then it should reply with DEFER. This will cause the record to be continued to be retried indefinitely. If a CDR engine tried to post the record but failed then it should reply with FAILED. This will increment the count and be checked against the max deferrals option. If a record gets back both a DEFER and FAILED, the DEFER will get priority and the max deferrals option will not be in effect.
Modified:
team/file/cdrbatchretry/cdr.c
Modified: team/file/cdrbatchretry/cdr.c
URL: http://svn.digium.com/view/asterisk/team/file/cdrbatchretry/cdr.c?rev=38366&r1=38365&r2=38366&view=diff
==============================================================================
--- team/file/cdrbatchretry/cdr.c (original)
+++ team/file/cdrbatchretry/cdr.c Thu Jul 27 13:52:44 2006
@@ -797,7 +797,7 @@
static void *do_batch_backend_process(void *data)
{
char *chan = NULL;
- int defer = 0;
+ int defer = 0, failed = 0;
struct ast_cdr_batch_item *batch_item = data;
struct ast_cdr_beitem *be = NULL;
AST_LIST_HEAD_NOLOCK(local_batch_list, ast_cdr_batch_item) local_batch_list;
@@ -813,10 +813,8 @@
/* Thankfully we don't need to hold the lock on the above since it only exists to us */
while ((batch_item = AST_LIST_REMOVE_HEAD(&local_batch_list, list))) {
- /* Increment deferral count */
- batch_item->deferrals++;
- /* Reset defer state to 0 */
- defer = 0;
+ /* Reset defer and failed state to 0 */
+ defer = failed = 0;
/* Now we have to process this batched item */
chan = S_OR(batch_item->cdr->channel, "<unknown>");
/* If this item has not been processed through the regular points before, do so */
@@ -834,21 +832,36 @@
/* Okay, we pass this CDR off to the engine if not already done and check the result */
if (!batch_item->engine[be->num]) {
res = be->be(batch_item->cdr);
- if (res == AST_CDR_ENGINE_SUCCESS || res == AST_CDR_ENGINE_DISCARD) {
+ switch (res) {
+ case AST_CDR_ENGINE_SUCCESS:
+ case AST_CDR_ENGINE_DISCARD:
batch_item->engine[be->num] = 1;
- } else if (res == AST_CDR_ENGINE_DEFER || res == AST_CDR_ENGINE_FAILED) {
- /* Continue processing through the engines, but rerun this CDR record again */
- defer = 1;
+ break;
+ case AST_CDR_ENGINE_DEFER:
+ defer++;
+ break;
+ case AST_CDR_ENGINE_FAILED:
+ failed++;
+ break;
+ default:
+ break;
}
}
}
AST_LIST_UNLOCK(&be_list);
- /* If this has reached the maximum number of deferrals... don't defer it any longer */
- if (batchmaxdeferrals > 0 && batch_item->deferrals == batchmaxdeferrals) {
- defer = 0;
+ /* Increment deferral count if any failed and we have no explicit defers */
+ if (!defer) {
+ if (failed > 0) {
+ batch_item->deferrals++;
+ }
+ /* If this has reached the maximum number of deferrals... don't defer it any longer */
+ if (batchmaxdeferrals > 0 && batch_item->deferrals == batchmaxdeferrals) {
+ /* Make sure this is not tried again */
+ failed = 0;
+ }
}
/* Okay... if we need to defer this entry for another attempt and we have not reached the max, do so... otherwise drop it */
- if (defer) {
+ if (defer || failed) {
/* Insert it into the regular batch list */
AST_LIST_LOCK(&batch_list);
AST_LIST_INSERT_HEAD(&batch_list, batch_item, list);
More information about the svn-commits
mailing list