]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
cleanup process spawning, remove mutex lock and add session to listener only if reply...
authorTamas Cseke <tamas.cseke@virtual-call-center.eu>
Thu, 24 May 2012 12:55:29 +0000 (14:55 +0200)
committerTamas Cseke <tamas.cseke@virtual-call-center.eu>
Thu, 24 May 2012 12:55:29 +0000 (14:55 +0200)
src/mod/event_handlers/mod_erlang_event/handle_msg.c
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c

index 944263b2f5c41d28547af7c48f3e75641009b82b..5ff207e1a128697df15f4615ae91400b5326012f 100644 (file)
@@ -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;
index fa1ea869821a8d45be45bf8ad2a72e15821933d0..e24b30bb6d7d31c7631c07533974e7fdafef361d 100644 (file)
@@ -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);