[OpenSER-Users] TM request function - callback data parameter

Bogdan-Andrei Iancu bogdan at voice-system.ro
Wed Jul 25 09:14:11 CEST 2007


Hi Tiberius,

Normally, the module registering the callback has to free the callback 
parameter mem, because it knows exactly what kind of data it put there. 
That's why you saw that all the modules free it when done with the callback.

There are some cases when the callback is not called, but it needs to be 
destroyed (like a failed transaction with no callbacks called) - it this 
cases, the TM tries to free the parameters (if still there) to avoid mem 
leak (even if it is not 100% guaranteed).

Shortly -  the callback should free the param after callback execution 
and set the pointer to 0; if the param still exists when the callback is 
destroyed, it will be freed by TM as a single chunk.

Regards,
bogdan


Tiberius DULUMAN wrote:
> Hello,
>
> I'm confused with the callback data parameter of request function of 
> TM module: does TM takes the ownership of the callback data? I've seen 
> that, if there is an error, t_request function frees the callback 
> data. Also, I've seen empty_tmcb_list function that free that callback 
> data, too.
>
> I've checked other modules, to see how do they use this parameter, and 
> I've got even more confused.
>
> msilo.c : it initialize the pointer from an int; there is a problem in 
> request function from uac.c file, after the 'err:' label, when 'if 
> (cp) shm_free(cp)' is executed.
>
> pua.c and send_publish.c: the callback functions free the callback 
> data parameter; if the TM took the ownership, then that memory is 
> freed twice.
>
> So, what is the right way to handle the memory pointed by callback data?
>
> Thank you
>
> _________________________________________________________________
> Don't just search. Find. Check out the new MSN Search! 
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>
>
> _______________________________________________
> Users mailing list
> Users at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/users
>





More information about the Users mailing list