[Asterisk-Dev] Signal timing can bring down Asterisk
Kristian Nielsen
kn at sifira.dk
Tue Aug 16 02:15:50 MST 2005
Hans Petter Selasky <hselasky at c2i.net> writes:
> Can the example above be done in some other way, so that I avoid these
> problems?
I don't follow your arguments, so let's clarify the issue, and maybe you
can explain how your thoughts fit in. This is how I understand a channel
driver should be used:
1. Call tech->requester() to get struct ast_channel *chan.
2. Now call tech-call() to start an outgoing call on the channel.
3. Now loop, sleeping in ast_wait*(), processing events (including
ANSWER, HANGUP) with tech->read() and tech->write().
4. Terminate the call using ast_softhangup() (which queues a HANGUP
event).
5. Finally, when the channel is completely done with, call
tech->hangup(). After this, the channel can no longer be used.
I don't think there is any problems like the races you mention. It is
the responsibility of the channel driver to make sure that it will not
reference the struct ast_channel * any more after tech->hangup()
returns.
Note that while tech->requestor() allocates the struct ast_channel *, it
is not freed by tech->hangup(). This is kind of asymetric, perhaps that
is what is causing your confusion?
- Kristian.
--
Kristian Nielsen kn at sifira.dk
Development Manager, Sifira A/S
More information about the asterisk-dev
mailing list