diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index bc37dd2e6c..86d6769bc6 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -678,6 +678,7 @@ SWITCH_DECLARE(void) switch_channel_process_device_hangup(switch_channel_t *chan SWITCH_DECLARE(switch_caller_extension_t *) switch_channel_get_queued_extension(switch_channel_t *channel); SWITCH_DECLARE(void) switch_channel_transfer_to_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension); SWITCH_DECLARE(const char *) switch_channel_get_partner_uuid(switch_channel_t *channel); +SWITCH_DECLARE(const char *) switch_channel_get_partner_uuid_copy(switch_channel_t *channel, char *buf, switch_size_t blen); SWITCH_DECLARE(switch_hold_record_t *) switch_channel_get_hold_record(switch_channel_t *channel); SWITCH_DECLARE(void) switch_channel_state_thread_lock(switch_channel_t *channel); SWITCH_DECLARE(void) switch_channel_state_thread_unlock(switch_channel_t *channel); diff --git a/src/switch_channel.c b/src/switch_channel.c index 4cbe5890c7..09fefa1f2a 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -4687,6 +4687,25 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t * return status; } +SWITCH_DECLARE(const char *) switch_channel_get_partner_uuid_copy(switch_channel_t *channel, char *buf, switch_size_t blen) +{ + const char *uuid = NULL; + + switch_mutex_lock(channel->profile_mutex); + if (!(uuid = switch_channel_get_variable_dup(channel, SWITCH_SIGNAL_BOND_VARIABLE, SWITCH_TRUE, -1))) { + uuid = switch_channel_get_variable_dup(channel, SWITCH_ORIGINATE_SIGNAL_BOND_VARIABLE, SWITCH_TRUE, -1); + } + + if (uuid) { + strncpy(buf, uuid, blen); + uuid = (const char *) buf; + } + switch_mutex_unlock(channel->profile_mutex); + + return uuid; +} + + SWITCH_DECLARE(const char *) switch_channel_get_partner_uuid(switch_channel_t *channel) { const char *uuid = NULL; diff --git a/src/switch_core_session.c b/src/switch_core_session.c index a810cc45cd..b57e239f92 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -190,8 +190,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_get_partner(switch_c const char *file, const char *func, int line) { const char *uuid; + char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; - if ((uuid = switch_channel_get_partner_uuid(session->channel))) { + if ((uuid = switch_channel_get_partner_uuid_copy(session->channel, uuid_str, sizeof(uuid_str)))) { if ((*partner = switch_core_session_perform_locate(uuid, file, func, line))) { return SWITCH_STATUS_SUCCESS; }