]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix internal state machine session yuckyness
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 13 Feb 2006 17:37:10 +0000 (17:37 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 13 Feb 2006 17:37:10 +0000 (17:37 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@598 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_channel.c
src/switch_core.c

index 271ed22360c4ed07a14688cc910eb80c8480fce0..81fd54783419e84fe4e669a727c7db03a54a4339 100644 (file)
@@ -274,7 +274,7 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
                return state;
        }
 
-       if (last_state >= CS_HANGUP) {
+       if (last_state >= CS_HANGUP && state < last_state) {
                return last_state;
        }
 
index f36e9e714827ea14f8a43ed2aa83d9675991d14f..bdc3bffc6e4d342cf05e23542c7dc0029df9ccb7 100644 (file)
@@ -1764,6 +1764,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
                                        }
                                }
                                switch_channel_set_state(session->channel, CS_DONE);
+                               midstate == switch_channel_get_state(session->channel);
                                break;
                        case CS_INIT:           /* Basic setup tasks */
                                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State INIT\n");
@@ -1948,13 +1949,19 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
                                break;
                        }
 
+                       if (midstate == CS_DONE) {
+                               break;
+                       }
+
                        laststate = midstate;
                }
-
+               
+               
                if (state < CS_DONE && midstate == switch_channel_get_state(session->channel)) {
                        switch_thread_cond_wait(session->cond, session->mutex);
-               }
+               } 
        }
+
 }
 
 SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session)
@@ -2050,14 +2057,12 @@ SWITCH_DECLARE(void) switch_core_launch_thread(switch_thread_start_t func, void
 
 static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread *thread, void *obj)
 {
+       unsigned int id;
        switch_core_session *session = obj;
-
-
        session->thread = thread;
 
-       session->id = runtime.session_id++;
-       if (runtime.session_id >= sizeof(unsigned long))
-               runtime.session_id = 1;
+       id = runtime.session_id++;
+       session->id = id;
 
        snprintf(session->name, sizeof(session->name), "%ld", session->id);
 
@@ -2065,7 +2070,7 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread *thread
        switch_core_session_run(session);
        switch_core_hash_delete(runtime.session_table, session->uuid_str);
        switch_core_session_destroy(&session);
-
+       switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Session %ld Ended\n", id);
 
        return NULL;
 }