[Asterisk-Dev] Signal timing can bring down Asterisk

Hans Petter Selasky hselasky at c2i.net
Mon Aug 15 12:46:08 MST 2005


Hi,

I'm writing a channel driver for asterisk and I have hit some problems.

1)

I want to have my channel driver under a BSD license, but I see no
ASTERISK_BSD_KEY. Must all code be under GPL or is BSD also allowed?


2)

What happens if two different threads call "ast_hangup()" at the same time on 
the same "ast_channel" ?

For example a telephony call has two parties. What happens if asterisk 
processes the disconnect signals from the two parties at exactly the same 
time. I suspect that the last thread calling "ast_hangup()" is going to 
access freed memory.

So all the functions that can be called from the channel drivers taking 
"struct ast_channel *" as an argument, needs some kind of check to verify 
that this pointer is still valid before proceeding. So to do that you need to 
hold "ast_channel->lock", but hence this structure can be freed, the pointer 
to this lock must be passes as an argument from the caller in addition to the 
ast_channel pointer. Then only the mutex must me static.


So if the timing of the signals are wrong Asterisk will crash, or am I wrong?


Any comments ?


--HPS



More information about the asterisk-dev mailing list