Commit 93f4e934 authored by Tristan Matthews's avatar Tristan Matthews

* #19129: iax: fix deadlock on registration

Before the migration to pthreads, the lock was being held and
subsequently locked again. It should only be locked when accessing
iax_* library calls, and released immediately after.
parent 0f8a36d0
......@@ -122,30 +122,39 @@ IAXVoIPLink::terminate()
bool
IAXVoIPLink::getEvent()
{
iax_event *event = NULL;
{
sfl::ScopedLock lock(mutexIAX_);
iax_event *event;
event = iax_get_event(0);
}
while ((event = iax_get_event(0)) != NULL) {
while (event != NULL) {
// If we received an 'ACK', libiax2 tells apps to ignore them.
if (event->etype == IAX_EVENT_NULL) {
iax_event_free(event);
continue;
}
// If we received an 'ACK', libiax2 tells apps to ignore them.
if (event->etype == IAX_EVENT_NULL) {
sfl::ScopedLock lock(mutexIAX_);
iax_event_free(event);
event = iax_get_event(0);
continue;
}
IAXCall *call = iaxFindCallBySession(event->session);
IAXCall *call = iaxFindCallBySession(event->session);
if (call) {
iaxHandleCallEvent(event, call);
}
else if (event->session && event->session == regSession_) {
iaxHandleRegReply(event); // This is a registration session, deal with it
}
else // We've got an event before it's associated with any call
iaxHandlePrecallEvent(event);
if (call) {
iaxHandleCallEvent(event, call);
} else if (event->session && event->session == regSession_) {
// This is a registration session, deal with it
iaxHandleRegReply(event);
} else {
// We've got an event before it's associated with any call
iaxHandlePrecallEvent(event);
}
{
sfl::ScopedLock lock(mutexIAX_);
iax_event_free(event);
event = iax_get_event(0);
}
}
......@@ -665,9 +674,11 @@ void IAXVoIPLink::iaxHandleRegReply(iax_event* event)
if (event->etype != IAX_EVENT_REGREJ && event->etype != IAX_EVENT_REGACK)
return;
sfl::ScopedLock m(mutexIAX_);
iax_destroy(regSession_);
regSession_ = NULL;
{
sfl::ScopedLock m(mutexIAX_);
iax_destroy(regSession_);
regSession_ = NULL;
}
account->setRegistrationState((event->etype == IAX_EVENT_REGREJ) ? ERROR_AUTH : REGISTERED);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment