mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 00:00:44 +00:00
fix internal state machine session yuckyness
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@598 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
1f820b1c1e
commit
abde08febc
@ -274,7 +274,7 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_state >= CS_HANGUP) {
|
if (last_state >= CS_HANGUP && state < last_state) {
|
||||||
return last_state;
|
return last_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1764,6 +1764,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_channel_set_state(session->channel, CS_DONE);
|
switch_channel_set_state(session->channel, CS_DONE);
|
||||||
|
midstate == switch_channel_get_state(session->channel);
|
||||||
break;
|
break;
|
||||||
case CS_INIT: /* Basic setup tasks */
|
case CS_INIT: /* Basic setup tasks */
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State INIT\n");
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (midstate == CS_DONE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
laststate = midstate;
|
laststate = midstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (state < CS_DONE && midstate == switch_channel_get_state(session->channel)) {
|
if (state < CS_DONE && midstate == switch_channel_get_state(session->channel)) {
|
||||||
switch_thread_cond_wait(session->cond, session->mutex);
|
switch_thread_cond_wait(session->cond, session->mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session)
|
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)
|
static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread *thread, void *obj)
|
||||||
{
|
{
|
||||||
|
unsigned int id;
|
||||||
switch_core_session *session = obj;
|
switch_core_session *session = obj;
|
||||||
|
|
||||||
|
|
||||||
session->thread = thread;
|
session->thread = thread;
|
||||||
|
|
||||||
session->id = runtime.session_id++;
|
id = runtime.session_id++;
|
||||||
if (runtime.session_id >= sizeof(unsigned long))
|
session->id = id;
|
||||||
runtime.session_id = 1;
|
|
||||||
|
|
||||||
snprintf(session->name, sizeof(session->name), "%ld", session->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_session_run(session);
|
||||||
switch_core_hash_delete(runtime.session_table, session->uuid_str);
|
switch_core_hash_delete(runtime.session_table, session->uuid_str);
|
||||||
switch_core_session_destroy(&session);
|
switch_core_session_destroy(&session);
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Session %ld Ended\n", id);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user