diff --git a/src/mod/event_handlers/mod_erlang_event/handle_msg.c b/src/mod/event_handlers/mod_erlang_event/handle_msg.c index 944263b2f5..5ff207e1a1 100644 --- a/src/mod/event_handlers/mod_erlang_event/handle_msg.c +++ b/src/mod/event_handlers/mod_erlang_event/handle_msg.c @@ -1149,9 +1149,6 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg, if (se->spawn_reply && !strncmp(se->spawn_reply->hash, hash, 100)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "found matching session for %s : %s\n", hash, se->uuid_str); switch_mutex_lock(se->spawn_reply->mutex); - if (se->spawn_reply->state == reply_not_ready) { - switch_thread_cond_wait(se->spawn_reply->ready_or_found, se->spawn_reply->mutex); - } if (se->spawn_reply->state == reply_waiting) { se->spawn_reply->pid = pid; diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c index fa1ea86982..e24b30bb6d 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c @@ -1366,30 +1366,28 @@ session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *modul /* create a session list element */ session_elem_t *session_element = session_elem_create(listener, session); char hash[100]; - //void *p = NULL; spawn_reply_t *p; erlang_ref ref; - switch_set_flag_locked(session_element, LFLAG_WAITING_FOR_PID); - - /* attach the session to the listener */ - add_session_elem_to_listener(listener, session_element); ei_init_ref(listener->ec, &ref); ei_hash_ref(&ref, hash); - /* insert the waiting marker */ p = switch_core_alloc(session_element->pool, sizeof(*p)); switch_thread_cond_create(&p->ready_or_found, session_element->pool); switch_mutex_init(&p->mutex, SWITCH_MUTEX_UNNESTED, session_element->pool); - p->state = reply_not_ready; + p->state = reply_waiting; p->hash = hash; p->pid = NULL; session_element->spawn_reply = p; - switch_mutex_lock(p->mutex); - p->state = reply_waiting; + /* insert the waiting marker */ + switch_set_flag(session_element, LFLAG_WAITING_FOR_PID); + + /* attach the session to the listener */ + add_session_elem_to_listener(listener, session_element); + if (!strcmp(function, "!")) { /* send a message to request a pid */ @@ -1434,7 +1432,6 @@ session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *modul memcpy(&session_element->process.pid, p->pid, sizeof(erlang_pid)); session_element->spawn_reply = NULL; - switch_clear_flag_locked(session_element, LFLAG_OUTBOUND_INIT); switch_clear_flag_locked(session_element, LFLAG_WAITING_FOR_PID); ei_link(listener, ei_self(listener->ec), &session_element->process.pid);