[Kamailio-Devel] dialog callback - locks?

Ovidiu Sas osas at voipembedded.com
Wed Oct 15 20:40:20 CEST 2008


On Wed, Oct 15, 2008 at 2:27 PM, Klaus Darilion
<klaus.mailinglists at pernau.at> wrote:
> Ovidiu Sas wrote:
>>
>> On Wed, Oct 15, 2008 at 11:12 AM, Klaus Darilion
>> <klaus.mailinglists at pernau.at> wrote:
>>>
>>> Ovidiu Sas schrieb:
>>>>
>>>> On Mon, Oct 13, 2008 at 12:01 PM, Klaus Darilion
>>>> <klaus.mailinglists at pernau.at> wrote:
>>>>>
>>>>> Hi Ovidiu!
>>>>>
>>>>> Ovidiu Sas schrieb:
>>>>>>
>>>>>> [osas]
>>>>>> I think you will need to lock the dialog if you want to access the
>>>>>> content of the dialog structure during subsequent dialog callbacks.
>>>>>> One option would be to copy all the info that you might need during
>>>>>> the first callback from the dialog context into your module context
>>>>>> and then use then local one.  This will avoid the necessity to lock
>>>>>> the dialog context.  The whole purpose of passing a pointer back to
>>>>>> the dialog module during the initial dialog callback is to create a
>>>>>> link back into the local module context.
>>>>>
>>>>> This works for most of the dlg_cell parameters, except lifetime. How
>>>>> can
>>>>> I
>>>>> read dlg->lifetime in hte callback in a safe way?
>>>>>
>>>> The params structure should be enhanced and the lifetime should be
>>>> passed via the existing API (see how CURR_DLG_LIFETIME is computed
>>>> inside dlg_handlers.c:dlg_onroute() ).
>>>> BTW, the lifetime is available in the script via $DLG_lifetime pv.
>>>
>>> If I got it right: accessing params is fine during callback and those the
>>> dialog module should copy the lifetime into the params struct for other
>>> modules to access it.
>>
>> That is correct.  The params are initialized just before being passed
>> to the calling module.
>>
>>
>>> btw: if accessing dlg_cell in callback is not safe, why is it even
>>> signaled
>>> to the callback handler? (of course except DLG_CREATED handler)
>>
>> I don't know for sure ... just to keep a unique interface for all
>> callbacks ...
>
> Ok. I will try to enhance the documentation of the dialog module.
>
> One thing left: the to-tag. My callback handler can not access the totag
> (tag[1]) from dlg_cell as it is not available in the DLG_CREATED callback.
> What do you think is the preferred way for getting the totag? Currently I
> parse param->msg->... to get the totag manually. Do think it makes sense to
> extend the param struct for the totag too?

The to-tag can be extracted from the msg.  It doesn't make sense to
get it from the dlg_cell.
Beside that, during the early stage, you may get several to-tags in
case of a parallel forking.



More information about the Devel mailing list