summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2018-10-28 14:43:42 +0000
committerOlivier CrĂȘte <olivier.crete@collabora.com>2018-10-28 15:19:02 +0000
commitd2cdf2e284c04e633f6703945c591db7b75423d3 (patch)
tree2927b3beab607bd2cb231dbc002664e89bd820f2
parent16d51b09cf43349c10dae93b9a45de5180de5213 (diff)
downloadlibnice-d2cdf2e284c04e633f6703945c591db7b75423d3.tar.gz
udp-turn: Restore synchronized seconds timeout
-rw-r--r--socket/udp-turn.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/socket/udp-turn.c b/socket/udp-turn.c
index 466ec32..d55c368 100644
--- a/socket/udp-turn.c
+++ b/socket/udp-turn.c
@@ -439,6 +439,23 @@ priv_timeout_add_with_context (UdpTurnPriv *priv, guint interval,
return source;
}
+/* interval is given in seconds */
+static GSource *
+priv_timeout_add_seconds_with_context (UdpTurnPriv *priv, guint interval,
+ GSourceFunc function, gpointer data)
+{
+ GSource *source = NULL;
+
+ g_return_val_if_fail (function != NULL, NULL);
+
+ source = g_timeout_source_new_seconds (interval);
+
+ g_source_set_callback (source, function, data, NULL);
+ g_source_attach (source, priv->ctx);
+
+ return source;
+}
+
static StunMessageReturn
stun_message_append_ms_connection_id(StunMessage *msg,
uint8_t *ms_connection_id, uint32_t ms_sequence_num)
@@ -1065,8 +1082,8 @@ priv_binding_timeout (gpointer data)
}
/* Install timer to expire the permission */
- b->timeout_source = priv_timeout_add_with_context (priv,
- STUN_EXPIRE_TIMEOUT * 1000, priv_binding_expired_timeout, priv);
+ b->timeout_source = priv_timeout_add_seconds_with_context (priv,
+ STUN_EXPIRE_TIMEOUT, priv_binding_expired_timeout, priv);
/* Send renewal */
if (!priv->current_binding_msg)
@@ -1337,8 +1354,8 @@ nice_udp_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
}
/* Install timer to schedule refresh of the permission */
binding->timeout_source =
- priv_timeout_add_with_context (priv,
- STUN_BINDING_TIMEOUT * 1000, priv_binding_timeout, priv);
+ priv_timeout_add_seconds_with_context (priv,
+ STUN_BINDING_TIMEOUT, priv_binding_timeout, priv);
}
priv_process_pending_bindings (priv);
}
@@ -1428,8 +1445,8 @@ nice_udp_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
if (stun_message_get_class (&msg) == STUN_RESPONSE &&
!priv->permission_timeout_source) {
priv->permission_timeout_source =
- priv_timeout_add_with_context (priv,
- STUN_PERMISSION_TIMEOUT * 1000, priv_permission_timeout,
+ priv_timeout_add_seconds_with_context (priv,
+ STUN_PERMISSION_TIMEOUT, priv_permission_timeout,
priv);
}