[core] allow external ID to be same as the session UUID
This commit is contained in:
parent
c2e240d6dc
commit
6b6b721c10
|
@ -2080,7 +2080,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_external_id(switch_core_
|
|||
|
||||
|
||||
switch_mutex_lock(runtime.session_hash_mutex);
|
||||
if (switch_core_hash_find(session_manager.session_table, use_external_id)) {
|
||||
if (strcmp(use_external_id, session->uuid_str) && switch_core_hash_find(session_manager.session_table, use_external_id)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Duplicate External ID!\n");
|
||||
switch_mutex_unlock(runtime.session_hash_mutex);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -2088,11 +2088,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_external_id(switch_core_
|
|||
|
||||
switch_channel_set_variable(session->channel, "session_external_id", use_external_id);
|
||||
|
||||
if (session->external_id) {
|
||||
if (session->external_id && strcmp(session->external_id, session->uuid_str)) {
|
||||
switch_core_hash_delete(session_manager.session_table, session->external_id);
|
||||
}
|
||||
|
||||
session->external_id = switch_core_session_strdup(session, use_external_id);
|
||||
|
||||
if (strcmp(session->external_id, session->uuid_str)) {
|
||||
switch_core_hash_insert(session_manager.session_table, session->external_id, session);
|
||||
}
|
||||
switch_mutex_unlock(runtime.session_hash_mutex);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
|
|
@ -48,7 +48,8 @@ FST_CORE_BEGIN("./conf")
|
|||
|
||||
FST_SESSION_BEGIN(session_external_id)
|
||||
{
|
||||
fst_check(switch_core_session_set_external_id(fst_session, switch_core_session_get_uuid(fst_session)) != SWITCH_STATUS_SUCCESS);
|
||||
fst_check(switch_core_session_set_external_id(fst_session, switch_core_session_get_uuid(fst_session)) == SWITCH_STATUS_SUCCESS);
|
||||
fst_check_string_equals(switch_core_session_get_external_id(fst_session), switch_core_session_get_uuid(fst_session));
|
||||
fst_check(switch_core_session_set_external_id(fst_session, "foo") == SWITCH_STATUS_SUCCESS);
|
||||
switch_core_session_t *session = switch_core_session_locate("foo");
|
||||
fst_requires(session);
|
||||
|
|
Loading…
Reference in New Issue