[Asterisk-Dev] rtp jitterbuffer synchronization question

Slav Klenov slav at securax.org
Wed Apr 6 07:35:57 MST 2005


Thanks for the reply stevek.

Well, it seems the io record is always removed on destroy, but I don't 
see any mutex locking, preventing from the following scenario
to happen:

- in the sip monitor thread, ast_io_wait() is called before the io 
record has been removed from ast_rtp_destroy(), and rtpread() is
  currently executed.
- at this moment the Linux scheduler pauses the thread and resumes a 
thread which executes ast_rtp_destroy().
- ast_rtp_destroy() removes the io record and performs a cleanup, 
destroying all we need in rtpread().
- the monitor thread is again resumed in rtpread() and ... segfault here.

Of course, this won't be possible if __sip_destroy() (which calls 
rtp_destroy()) is always invoked from the monitor thread. But looking
through the code, this doesn't seems to be the case.

Slav.


Steve Kann wrote:

> Slav Klenov wrote:
>
>> Hello * core developers,
>>
>> Currently I'm working on jitterbuffer integration in rtp.c. My 
>> previous experience with chan_sip jb
>> integration showed some synchronization issues, so I'm trying to be 
>> very careful with this now.
>>
>> Basicly what I'm doing is:
>> - from chan_sip (in example) create an rtp in callback mode which 
>> adds rtpread() into the chan_sip
>>  io context - rtpread() will be always invoked from 
>> chan_sip::do_monitor(), right?
>> - rtpread(), when invoked, puts frames into the jitterbuff.
>> - I have another function, which is scheduled to get frames from the 
>> jitterbuff and delivers them
>>  to the channel.
>>
>> The problem is that all these activities should be stopped when the 
>> channel is distroyed (or maybe
>> even earler - on hangup or when the network socket is closed???)
>>
>> My question is:
>> Is it possible (not only for chan_sip, but for all rtp channels) 
>> rtpread() to be invoked after
>> rtp_destroy()?
>
>
>
> It seems that rtpread will end up being called from ast_io_wait, which 
> presently gets called from chan_sip.   I suppose it could get called 
> after rtp_destroy only if a packet arrives on the UDP socket 
> associated with the io record, and the rtp io record is still there, 
> but it seems the record gets removed in ast_rtp_destroy.
>
>
>>
>> Thanks,
>> Slav
>> _______________________________________________
>> Asterisk-Dev mailing list
>> Asterisk-Dev at lists.digium.com
>> http://lists.digium.com/mailman/listinfo/asterisk-dev
>> To UNSUBSCRIBE or update options visit:
>>   http://lists.digium.com/mailman/listinfo/asterisk-dev
>>
>
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-dev





More information about the asterisk-dev mailing list