summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2018-11-16 17:34:16 -0500
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>2018-11-19 09:05:13 +0000
commit3c29a99cac3cfd73a1cdeff11d0ab2606b46b14c (patch)
treebaf07ab0e99012c744cc2fa7a6f796ff50329cfe
parentceef96fe322e7ad9a9f1d851a0b8421da0cfd416 (diff)
downloadlibnice-3c29a99cac3cfd73a1cdeff11d0ab2606b46b14c.tar.gz
udp-turn: Create locked version of realm&nonce cache function
To be able to call it from a context that is already locked.
-rw-r--r--socket/udp-turn.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/socket/udp-turn.c b/socket/udp-turn.c
index 3993d53..bf81fd9 100644
--- a/socket/udp-turn.c
+++ b/socket/udp-turn.c
@@ -1224,16 +1224,15 @@ priv_binding_timeout (gpointer data)
return G_SOURCE_REMOVE;
}
-void
-nice_udp_turn_socket_cache_realm_nonce (NiceSocket *sock, StunMessage *msg)
+static void
+nice_udp_turn_socket_cache_realm_nonce_locked (NiceSocket *sock,
+ StunMessage *msg)
{
UdpTurnPriv *priv = sock->priv;
gconstpointer tmp;
g_assert (sock->type == NICE_SOCKET_TYPE_UDP_TURN);
- g_mutex_lock (&mutex);
-
g_free (priv->cached_realm);
priv->cached_realm = NULL;
priv->cached_realm_len = 0;
@@ -1250,6 +1249,14 @@ nice_udp_turn_socket_cache_realm_nonce (NiceSocket *sock, StunMessage *msg)
if (tmp && priv->cached_nonce_len < 764)
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);
}
@@ -1454,7 +1461,7 @@ nice_udp_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
g_free (priv->current_binding_msg);
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)
priv_send_channel_bind (priv, binding->channel,
&binding->peer);
@@ -1558,7 +1565,7 @@ nice_udp_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
g_free (current_create_permission_msg);
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 */
priv_send_create_permission (priv, &to);
goto done;