static int iax2_predestroy(int callno)
{
struct ast_channel *c = NULL;
- struct chan_iax2_pvt *pvt = NULL;
-
- ast_mutex_lock(&iaxsl[callno]);
+ struct chan_iax2_pvt *pvt = iaxs[callno];
- if (!(pvt = iaxs[callno])) {
- ast_mutex_unlock(&iaxsl[callno]);
+ if (!pvt)
return -1;
- }
if (!ast_test_flag(pvt, IAX_ALREADYGONE)) {
iax2_destroy_helper(pvt);
ast_update_use_count();
}
- ast_mutex_unlock(&iaxsl[callno]);
-
return 0;
}
struct ast_channel *owner = NULL;
retry:
- ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
gettimeofday(&lastused[callno], NULL);
ast_log(LOG_NOTICE, "Avoiding IAX destroy deadlock\n");
ast_mutex_unlock(&iaxsl[callno]);
usleep(1);
+ ast_mutex_lock(&iaxsl[callno]);
goto retry;
}
}
if (owner) {
ast_mutex_unlock(&owner->lock);
}
- ast_mutex_unlock(&iaxsl[callno]);
if (callno & 0x4000)
update_max_trunk();
}