From: Olivier CrĂȘte Date: Fri, 16 Nov 2018 22:34:16 +0000 (-0500) Subject: udp-turn: Create locked version of realm&nonce cache function X-Git-Tag: 0.1.15~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c29a99cac3cfd73a1cdeff11d0ab2606b46b14c;p=platform%2Fupstream%2Flibnice.git udp-turn: Create locked version of realm&nonce cache function To be able to call it from a context that is already locked. --- 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;