Commit dbef6bc5 authored by Youness Alaoui's avatar Youness Alaoui

If a channel bind couldn't be renewed when it expired, then renew it after we...

If a channel bind couldn't be renewed when it expired, then renew it after we finish the current binding
parent a41e12df
...@@ -66,7 +66,7 @@ typedef struct { ...@@ -66,7 +66,7 @@ typedef struct {
typedef struct { typedef struct {
NiceAddress peer; NiceAddress peer;
uint16_t channel; uint16_t channel;
gboolean active; gboolean renew;
guint timeout_source; guint timeout_source;
} ChannelBinding; } ChannelBinding;
...@@ -706,11 +706,11 @@ priv_binding_timeout (gpointer data) ...@@ -706,11 +706,11 @@ priv_binding_timeout (gpointer data)
return FALSE; return FALSE;
} }
/* find current binding and inactivate it */ /* find current binding and mark it for renewal */
for (i = priv->channels ; i; i = i->next) { for (i = priv->channels ; i; i = i->next) {
ChannelBinding *b = i->data; ChannelBinding *b = i->data;
if (b->timeout_source == g_source_get_id (source)) { if (b->timeout_source == g_source_get_id (source)) {
b->active = FALSE; b->renew = TRUE;
/* Install timer to expire the permission */ /* Install timer to expire the permission */
b->timeout_source = g_timeout_add_seconds (STUN_EXPIRE_TIMEOUT, b->timeout_source = g_timeout_add_seconds (STUN_EXPIRE_TIMEOUT,
priv_binding_expired_timeout, priv); priv_binding_expired_timeout, priv);
...@@ -898,7 +898,7 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock, ...@@ -898,7 +898,7 @@ nice_turn_socket_parse_recv (NiceSocket *sock, NiceSocket **from_sock,
priv->current_binding = NULL; priv->current_binding = NULL;
if (binding) { if (binding) {
binding->active = TRUE; binding->renew = FALSE;
/* Remove any existing timer */ /* Remove any existing timer */
if (binding->timeout_source) if (binding->timeout_source)
...@@ -1069,12 +1069,28 @@ static void ...@@ -1069,12 +1069,28 @@ static void
priv_process_pending_bindings (TurnPriv *priv) priv_process_pending_bindings (TurnPriv *priv)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
while (priv->pending_bindings != NULL && ret == FALSE) { while (priv->pending_bindings != NULL && ret == FALSE) {
NiceAddress *peer = priv->pending_bindings->data; NiceAddress *peer = priv->pending_bindings->data;
ret = priv_add_channel_binding (priv, peer); ret = priv_add_channel_binding (priv, peer);
priv->pending_bindings = g_list_remove (priv->pending_bindings, peer); priv->pending_bindings = g_list_remove (priv->pending_bindings, peer);
nice_address_free (peer); nice_address_free (peer);
} }
/* If no new channel bindings are in progress and there are no
pending bindings, then renew the soon to be expired bindings */
if (priv->pending_bindings == NULL && priv->current_binding_msg == NULL) {
GList *i = NULL;
/* find binding to renew */
for (i = priv->channels ; i; i = i->next) {
ChannelBinding *b = i->data;
if (b->renew) {
priv_send_channel_bind (priv, NULL, b->channel, &b->peer);
break;
}
}
}
} }
......
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