Commit 3c29a99c authored by Olivier Crête's avatar Olivier Crête 👻 Committed by Olivier Crête

udp-turn: Create locked version of realm&nonce cache function

To be able to call it from a context that is already locked.
parent ceef96fe
Pipeline #9176 passed with stage
in 49 seconds
...@@ -1224,16 +1224,15 @@ priv_binding_timeout (gpointer data) ...@@ -1224,16 +1224,15 @@ priv_binding_timeout (gpointer data)
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
void static void
nice_udp_turn_socket_cache_realm_nonce (NiceSocket *sock, StunMessage *msg) nice_udp_turn_socket_cache_realm_nonce_locked (NiceSocket *sock,
StunMessage *msg)
{ {
UdpTurnPriv *priv = sock->priv; UdpTurnPriv *priv = sock->priv;
gconstpointer tmp; gconstpointer tmp;
g_assert (sock->type == NICE_SOCKET_TYPE_UDP_TURN); g_assert (sock->type == NICE_SOCKET_TYPE_UDP_TURN);
g_mutex_lock (&mutex);
g_free (priv->cached_realm); g_free (priv->cached_realm);
priv->cached_realm = NULL; priv->cached_realm = NULL;
priv->cached_realm_len = 0; priv->cached_realm_len = 0;
...@@ -1250,6 +1249,14 @@ nice_udp_turn_socket_cache_realm_nonce (NiceSocket *sock, StunMessage *msg) ...@@ -1250,6 +1249,14 @@ nice_udp_turn_socket_cache_realm_nonce (NiceSocket *sock, StunMessage *msg)
if (tmp && priv->cached_nonce_len < 764) if (tmp && priv->cached_nonce_len < 764)
priv->cached_nonce = g_memdup (tmp, priv->cached_nonce_len); priv->cached_nonce = g_memdup (tmp, priv->cached_nonce_len);
}
void
nice_udp_turn_socket_cache_realm_nonce (NiceSocket *sock,
StunMessage *msg)
{
g_mutex_lock (&mutex);
nice_udp_turn_socket_cache_realm_nonce_locked (sock, msg);
g_mutex_unlock (&mutex); g_mutex_unlock (&mutex);
} }
...@@ -1454,7 +1461,7 @@ nice_udp_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock, ...@@ -1454,7 +1461,7 @@ nice_udp_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
g_free (priv->current_binding_msg); g_free (priv->current_binding_msg);
priv->current_binding_msg = NULL; priv->current_binding_msg = NULL;
nice_udp_turn_socket_cache_realm_nonce (sock, &msg); nice_udp_turn_socket_cache_realm_nonce_locked (sock, &msg);
if (binding) if (binding)
priv_send_channel_bind (priv, binding->channel, priv_send_channel_bind (priv, binding->channel,
&binding->peer); &binding->peer);
...@@ -1558,7 +1565,7 @@ nice_udp_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock, ...@@ -1558,7 +1565,7 @@ nice_udp_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
g_free (current_create_permission_msg); g_free (current_create_permission_msg);
current_create_permission_msg = NULL; current_create_permission_msg = NULL;
nice_udp_turn_socket_cache_realm_nonce (sock, &msg); nice_udp_turn_socket_cache_realm_nonce_locked (sock, &msg);
/* resend CreatePermission */ /* resend CreatePermission */
priv_send_create_permission (priv, &to); priv_send_create_permission (priv, &to);
goto done; goto done;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment