[asterisk-dev] CDR fixes--- Wait a minute!! (LONG)

Stephen Davies stephen.l.davies at gmail.com
Mon Jun 18 05:11:56 CDT 2007


On 13/06/07, Steve Murphy <murf at digium.com> wrote:
> On Tue, 2007-06-12 at 23:05 +0200, Stephen Davies wrote:
> > On 12/06/07, Stephen Davies <stephen.l.davies at gmail.com> wrote:
> > > Maybe just maybe another fix is that ast_cdr_init should also do the
> > > S_OR(s->macrocontext, s->context) stuff that ast_cdr_update does.
> >
> >
> > Excuse me for talking to myself, but this does do the job.
> >
> > Here's a patch:
> >
> > Index: cdr.c
> > ===================================================================
> > --- cdr.c       (revision 67303)
> > +++ cdr.c       (working copy)
> > @@ -776,8 +776,8 @@
> >                         cdr->amaflags = c->amaflags ? c->amaflags :
> > ast_default_amaflags;
> >                         ast_copy_string(cdr->accountcode,
> > c->accountcode, sizeof(cdr->accountcode));
> >                         /* Destination information */
> > -                       ast_copy_string(cdr->dst, c->exten, sizeof(cdr->dst));
> > -                       ast_copy_string(cdr->dcontext, c->context,
> > sizeof(cdr->dcontext));
> > +                       ast_copy_string(cdr->dst, S_OR(c->macroexten,
> > c->exten), sizeof(cdr->dst));
> > +                       ast_copy_string(cdr->dcontext,
> > S_OR(c->macrocontext, c->context), sizeof(cdr->dcontext));
> >                         /* Unique call identifier */
> >                         ast_copy_string(cdr->uniqueid, c->uniqueid,
> > sizeof(cdr->uniqueid));
> >                 }
> >
> > Do you need it on the bug tracker?
> >
>
> Steve--
>
> The fact that this change fixes your problem blows my mind. Please, tell
> me more about the exact situation. What kind of devices? What's going
> on?
>
> The change itself seems harmless. It's not often that we'd be in a macro
> when the cdr init func is run!


Hi Steve,

I don't see that my dialplan is very unusual.

Here's the exact dialplan flow for one of these calls that was getting
a CDR initialised whilst in a macro:

    -- Accepting call from '0824655842' to '6730' on channel 0/1, span 1
    -- Executing [6730 at from-peer-pri-hetzner:1] Goto("Zap/1-1",
"0216736730|1") in new stack
    -- Goto (from-peer-pri-hetzner,0216736730,1)
    -- Executing [0216736730 at from-peer-pri-hetzner:1] NoOp("Zap/1-1",
"") in new stack
    -- Executing [0216736730 at from-peer-pri-hetzner:2] Macro("Zap/1-1",
"to-dest-customer|phonehome|IAX2/phonehome-1/0216736730||0216736730 -
phonehome-1") in new stack
    -- Executing [s at macro-to-dest-customer:1] GotoIf("Zap/1-1", "1?4")
in new stack
    -- Goto (macro-to-dest-customer,s,4)
    -- Executing [s at macro-to-dest-customer:4] Macro("Zap/1-1",
"rewrite-callerid|voip|") in new stack
    -- Executing [s at macro-rewrite-callerid:1] GotoIf("Zap/1-1", "0?3")
in new stack
    -- Executing [s at macro-rewrite-callerid:2] Set("Zap/1-1",
"ORIG_CID=0824655842") in new stack
    -- Executing [s at macro-rewrite-callerid:3] Set("Zap/1-1",
"stop=N|argc=0|CALLERID(num)=0824655842") in new stack
    -- Executing [s at macro-rewrite-callerid:4] GotoIf("Zap/1-1",
"0?99") in new stack
    -- Executing [s at macro-rewrite-callerid:5] Set("Zap/1-1", "argc=1")
in new stack
    -- Executing [s at macro-rewrite-callerid:6] GotoIf("Zap/1-1",
"0?99") in new stack
    -- Executing [s at macro-rewrite-callerid:7] Macro("Zap/1-1",
"one-rewrite|voip") in new stack
    -- Executing [s at macro-one-rewrite:1] Goto("Zap/1-1",
"voip-0824655842|1") in new stack
    -- Goto (macro-one-rewrite,voip-0824655842,1)
    -- Executing [s at macro-rewrite-callerid:8] Goto("Zap/1-1", "4") in new stack
    -- Goto (macro-rewrite-callerid,s,4)
    -- Executing [s at macro-rewrite-callerid:4] GotoIf("Zap/1-1",
"0?99") in new stack
    -- Executing [s at macro-rewrite-callerid:5] Set("Zap/1-1", "argc=2")
in new stack
    -- Executing [s at macro-rewrite-callerid:6] GotoIf("Zap/1-1",
"1?99") in new stack
    -- Goto (macro-rewrite-callerid,s,99)
    -- Executing [s at macro-rewrite-callerid:99] Verbose("Zap/1-1",
"3|Rewriter started with 0824655842 and ended with 0824655842") in new
stack
    -- Rewriter started with 0824655842 and ended with 0824655842
    -- Executing [s at macro-to-dest-customer:5] Macro("Zap/1-1",
"setcdruserfield|cust|phonehome|dial:IAX2/phonehome-1/0216736730") in
new stack
    -- Executing [s at macro-setcdruserfield:1] DumpChan("Zap/1-1", "9")
in new stack
    -- Executing [s at macro-setcdruserfield:2] Set("Zap/1-1",
"CDR(userfield)=SRC_CUST=^SRC_PEER=^ORIG_CID=0824655842^DST_TYPE=cust^DST_CUST=phonehome^ACTION=dial:IAX2/phonehome-1/0216736730")
in new stack
    -- Executing [s at macro-to-dest-customer:6] Dial("Zap/1-1",
"IAX2/phonehome-1/0216736730|90") in new stack
    -- Called phonehome-1/0216736730
    -- Call accepted by 196.40.106.60 (format ulaw)
    -- Format for call is ulaw
    -- IAX2/phonehome-1-56 answered Zap/1-1

Only comment is that the first thing the dialplan does of any
significance is to call a macro, and its that macro's name that gets
put into the CDR.  Before the macro call there is only a Goto and a
Noop.

I can only assume some ast_cdr_init call somewhere has been removed of
conditions retuned so that it doesn't get called any more, meaning
that the cdr gets initialised later.

But the change definitely fixes the problem and is more consistent and
is defintely the "right thing" to do.

Regards,
Steve



More information about the asterisk-dev mailing list