]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
reply state seems to be unnecessary FS-3432
authorTamas Cseke <tamas.cseke@virtual-call-center.eu>
Tue, 12 Jun 2012 09:37:35 +0000 (11:37 +0200)
committerTamas Cseke <tamas.cseke@virtual-call-center.eu>
Tue, 12 Jun 2012 09:37:35 +0000 (11:37 +0200)
src/mod/event_handlers/mod_erlang_event/handle_msg.c
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h

index 77088487aa98750c88ff57e45f156b61340b4ea2..e6d0d7a5f9308671ae0f54def91febb75e979b52 100644 (file)
@@ -1115,6 +1115,7 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg,
        void *val;
        session_elem_t *se;
        switch_hash_index_t *iter;
+       int found = 0;
 
        ei_decode_tuple_header(buf->buff, &buf->index, &arity);
 
@@ -1137,29 +1138,32 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg,
                switch_hash_this(iter, &key, NULL, &val);
                se = (session_elem_t*)val;
                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_waiting) {
-                               se->spawn_reply->pid = switch_core_alloc(se->pool, sizeof(erlang_pid));
-                               switch_assert(se->spawn_reply->pid != NULL);
-                               memcpy(se->spawn_reply->pid, &pid, sizeof(erlang_pid));
-                               switch_thread_cond_signal(se->spawn_reply->ready_or_found);
-                               ei_x_encode_atom(rbuf, "ok");
-                               switch_mutex_unlock(se->spawn_reply->mutex);
-                               switch_thread_rwlock_unlock(listener->session_rwlock);
-                               return SWITCH_STATUS_SUCCESS;
-                       }
+                       se->spawn_reply->pid = switch_core_alloc(se->pool, sizeof(erlang_pid));
+                       switch_assert(se->spawn_reply->pid != NULL);
+                       memcpy(se->spawn_reply->pid, &pid, sizeof(erlang_pid));
+                       switch_thread_cond_signal(se->spawn_reply->ready_or_found);
+
                        switch_mutex_unlock(se->spawn_reply->mutex);
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "get_pid came in too late for %s; %s\n", hash, se->uuid_str);
+
+                       found++;
+
                        break;
                }
        }
        switch_thread_rwlock_unlock(listener->session_rwlock);
 
-       ei_x_encode_tuple_header(rbuf, 2);
-       ei_x_encode_atom(rbuf, "error");
-       ei_x_encode_atom(rbuf, "notfound");
+       if (found) {
+               ei_x_encode_atom(rbuf, "ok");
+       } else {
+               ei_x_encode_tuple_header(rbuf, 2);
+               ei_x_encode_atom(rbuf, "error");
+               ei_x_encode_atom(rbuf, "notfound");
+       }
 
        return SWITCH_STATUS_SUCCESS;
 }
index 4b3eaa7ecd333a8ec7ac350b927538db5db5c98f..b8e13b2a5c6d0eb858de13d1ece3efd91b2f563e 100644 (file)
@@ -1376,7 +1376,6 @@ session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *modul
        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_waiting;
        p->hash = switch_core_strdup(session_element->pool, hash);
        p->pid = NULL;
 
@@ -1421,7 +1420,6 @@ session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *modul
        if (!p->pid) {
                switch_channel_t *channel = switch_core_session_get_channel(session);
 
-               p->state = reply_timeout;
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Timed out when waiting for outbound pid %s %s\n", hash, session_element->uuid_str);
                switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
                return NULL;
index d5f890d0a1e9addd6274879bc22f131618eed9aa..c1730b5dba2412f5fe6f6cbdc675122595f7b8b2 100644 (file)
@@ -71,7 +71,6 @@ struct spawn_reply_struct
 {
        switch_thread_cond_t *ready_or_found;
        switch_mutex_t *mutex;
-       enum reply_state state;
        erlang_pid *pid;
        char *hash;
 };