[asterisk-users] MySql and custom CDR

Tilghman Lesher tlesher at digium.com
Fri Sep 11 19:45:32 CDT 2009


On Friday 11 September 2009 16:45:30 Steve Edwards wrote:
> On Fri, 11 Sep 2009, Steve Edwards wrote:
> >> I'm a 1.2 Luddite, but I found cdr_addon_mysql.c pretty easy to hack
> >> on. For example, I added a channel variable named PRODUCT. Here's the
> >> code I used:
> >>
> >>  	channel_pointer = ast_get_channel_by_name_locked(channel);
> >>  	product_pointer = pbx_builtin_getvar_helper(channel_pointer
> >>  		, "PRODUCT");
> >>
> >> and then add ",product", ",'%s'" and product_pointer to the sprintf
> >> that builds the insert statement.
>
> On Fri, 11 Sep 2009, Tilghman Lesher wrote:
> > 1) There's no guarantee that the channel will still be alive at the time
> > the CDR is posted.  In fact, if you're doing bulk posting of CDRs, it's
> > pretty much guaranteed the channel will be gone.
>
> I do check for ast_get_channel_by_name_locked() and
> pbx_builtin_getvar_helper() returning 0 and syslog it. It never happens in
> this environment. I just didn't include it in the snippet.
>
> > 2) CDR variables were created for exactly this reason -- they are
> > allocated to the CDR, not the channel, and thus, they are available even
> > after the channel is destroyed.  They are available to use in 1.2.
>
> Well shame on me. I assumed that the CDR function only operated on the
> "standard" set of CDR variables. Thanks for the clarification. That would
> clean up that section of code a bit. Unfortunately I doubt the client will
> pay for fixing something that isn't failing.
>
> So if a CDR exists after the channel is destroyed, when is the CDR
> destroyed?

The in-memory CDR is destroyed after it is posted to the CDR backends (which
presumably go to disk, somewhere, although the core isn't concerned with
that).

-- 
Tilghman Lesher
Digium, Inc. | Senior Software Developer
twitter: Corydon76 | IRC: Corydon76-dig (Freenode)
Check us out at: www.digium.com & www.asterisk.org



More information about the asterisk-users mailing list