ao2_ref(outgoing, +1);
+ ast_mutex_lock(&outgoing->lock);
+
if (ast_pthread_create_detached(&thread, NULL, pbx_outgoing_exec, outgoing)) {
ast_log(LOG_WARNING, "Unable to spawn dialing thread for '%s/%s'\n", type, addr);
if (channel) {
}
/* Wait for dialing to complete */
- if (synchronous) {
- ast_mutex_lock(&outgoing->lock);
+ if (channel || synchronous) {
if (channel) {
ast_channel_unlock(*channel);
}
if (channel) {
ast_channel_lock(*channel);
}
- ast_mutex_unlock(&outgoing->lock);
}
/* Wait for execution to complete */
if (synchronous > 1) {
- ast_mutex_lock(&outgoing->lock);
while (!outgoing->executed) {
ast_cond_wait(&outgoing->cond, &outgoing->lock);
}
- ast_mutex_unlock(&outgoing->lock);
}
+ ast_mutex_unlock(&outgoing->lock);
+
if (reason) {
*reason = ast_dial_reason(outgoing->dial, 0);
}