*/
SWITCH_DECLARE(char *) switch_core_get_uuid(void);
-#ifdef SWITCH_DEBUG_RWLOCKS
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line);
-#endif
-#ifdef SWITCH_DEBUG_RWLOCKS
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line);
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_force_locate(const char *uuid_str, const char *file, const char *func, int line);
-#endif
+
/*!
\brief Locate a session based on it's uuid
\return the session or NULL
\note if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock()
*/
-#ifdef SWITCH_DEBUG_RWLOCKS
+
#define switch_core_session_locate(uuid_str) switch_core_session_perform_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
-#else
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(_In_z_ const char *uuid_str);
-#endif
/*!
\brief Locate a session based on it's uuid even if the channel is not ready
\return the session or NULL
\note if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock()
*/
-#ifdef SWITCH_DEBUG_RWLOCKS
+
#define switch_core_session_force_locate(uuid_str) switch_core_session_perform_force_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
-#else
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_force_locate(_In_z_ const char *uuid_str);
-#endif
+
/*!
\brief Retrieve a global variable from the core
\param partner [out] The session's partner, or NULL if it wasnt found
\return SWITCH_STATUS_SUCCESS or SWITCH_STATUS_FALSE if this session isn't bridged
*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_get_partner(switch_core_session_t *session, switch_core_session_t **partner);
+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_get_partner(switch_core_session_t *session, switch_core_session_t **partner,
+ const char *file, const char *func, int line);
+
+#define switch_core_session_get_partner(_session, _partner) switch_core_session_perform_get_partner(_session, _partner, __FILE__, __SWITCH_FUNC__, __LINE__)
/*!
\brief Send a message to another session using it's uuid
if (!sofia_test_flag(tech_pvt, TFLAG_SDP)) {
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
+ int r = sofia_test_flag(other_tech_pvt, TFLAG_REINVITED);
+ switch_core_session_rwunlock(other_session);
- if(sofia_test_flag(other_tech_pvt, TFLAG_REINVITED)) {
-
+ if (r) {
/* Due to a race between simultaneous reinvites to both legs of a bridge,
an earlier call to nua_invite silently failed.
So we reject the incoming invite with a 491 and redo the failed outgoing invite. */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Other leg already handling a reinvite, so responding with 491\n");
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ "Other leg already handling a reinvite, so responding with 491\n");
+
nua_respond(tech_pvt->nh, SIP_491_REQUEST_PENDING, TAG_END());
- switch_core_session_rwunlock(other_session);
sofia_glue_do_invite(session);
goto done;
}
switch_yield(250000);
launch_media_on_hold(session);
+ switch_core_session_rwunlock(other_session);
goto done;
}
}
/* The other leg won the reinvite race */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Other leg already handling reinvite, so responding with 491\n");
nua_respond(tech_pvt->nh, SIP_491_REQUEST_PENDING, TAG_END());
- switch_core_session_rwunlock(other_session);
+ switch_core_session_rwunlock(other_session);
goto done;
}
sofia_set_flag(tech_pvt, TFLAG_REINVITED);
}
-#ifdef SWITCH_DEBUG_RWLOCKS
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line)
-#else
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_locate(const char *uuid_str)
-#endif
{
switch_core_session_t *session = NULL;
-#ifdef SWITCH_DEBUG_RWLOCKS
+
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_force_locate(const char *uuid_str, const char *file, const char *func, int line)
-#else
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_force_locate(const char *uuid_str)
-#endif
{
switch_core_session_t *session = NULL;
switch_status_t status;
}
-SWITCH_DECLARE(switch_status_t) switch_core_session_get_partner(switch_core_session_t *session, switch_core_session_t **partner)
+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_get_partner(switch_core_session_t *session, switch_core_session_t **partner,
+ const char *file, const char *func, int line)
{
const char *uuid;
if ((uuid = switch_channel_get_partner_uuid(session->channel))) {
- if ((*partner = switch_core_session_locate(uuid))) {
+ if ((*partner = switch_core_session_perform_locate(uuid, file, func, line))) {
return SWITCH_STATUS_SUCCESS;
}
}