Index: pbx.c =================================================================== --- pbx.c (revision 7951) +++ pbx.c (working copy) @@ -2434,6 +2434,8 @@ ast_log(LOG_WARNING, "Don't know what to do with '%s'\n", c->name); out: if ((res != AST_PBX_KEEPALIVE) && ast_exists_extension(c, c->context, "h", 1, c->cid.cid_num)) { + if (c->cdr) + ast_cdr_end(c->cdr); c->exten[0] = 'h'; c->exten[1] = '\0'; c->priority = 1; Index: cdr.c =================================================================== --- cdr.c (revision 7951) +++ cdr.c (working copy) @@ -662,6 +662,11 @@ ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", chan); if (ast_tvzero(cdr->end)) cdr->end = ast_tvnow(); + cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec + (cdr->end.tv_usec - cdr->start.tv_usec) / 1000000; + if (!ast_tvzero(cdr->answer)) + cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec + (cdr->end.tv_usec - cdr->answer.tv_usec) / 1000000; + else + cdr->billsec = 0; cdr = cdr->next; } } @@ -809,11 +814,6 @@ ast_log(LOG_WARNING, "CDR on channel '%s' lacks end\n", chan); if (ast_tvzero(cdr->start)) ast_log(LOG_WARNING, "CDR on channel '%s' lacks start\n", chan); - cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec + (cdr->end.tv_usec - cdr->start.tv_usec) / 1000000; - if (!ast_tvzero(cdr->answer)) - cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec + (cdr->end.tv_usec - cdr->answer.tv_usec) / 1000000; - else - cdr->billsec = 0; ast_set_flag(cdr, AST_CDR_FLAG_POSTED); AST_LIST_LOCK(&be_list); AST_LIST_TRAVERSE(&be_list, i, list) {