[farsight2/master] Make the stun timeout process respect the max timeout

Olivier Crête olivier.crete at collabora.co.uk
Tue Jan 6 14:50:03 PST 2009


---
 transmitters/rawudp/fs-rawudp-component.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/transmitters/rawudp/fs-rawudp-component.c b/transmitters/rawudp/fs-rawudp-component.c
index d2981ab..933bfcb 100644
--- a/transmitters/rawudp/fs-rawudp-component.c
+++ b/transmitters/rawudp/fs-rawudp-component.c
@@ -1422,24 +1422,22 @@ stun_timeout_func (gpointer user_data)
   gboolean emit = TRUE;
   GstClockTime next_stun_timeout;
   GError *error = NULL;
-  guint total_timeout_ms = 100;
+  guint next_timeout_ms = 100;
+  guint timeout_accum_ms = 0;
 
   sysclock = gst_system_clock_obtain ();
   if (sysclock == NULL)
   {
     fs_rawudp_component_emit_error (self, FS_ERROR_INTERNAL,
         "Could not obtain gst system clock", NULL);
-    emit = FALSE;
     FS_RAWUDP_COMPONENT_LOCK(self);
-    goto error;
+    goto interrupt;
   }
 
   FS_RAWUDP_COMPONENT_LOCK(self);
   while (!self->priv->stun_stop &&
-      (total_timeout_ms / 1000) < self->priv->stun_timeout &&
-      total_timeout_ms < 1000 * MAX_STUN_TIMEOUT)
+      timeout_accum_ms < self->priv->stun_timeout * 1000)
   {
-
     FS_RAWUDP_COMPONENT_UNLOCK(self);
     if (!fs_rawudp_component_send_stun (self, &error))
     {
@@ -1448,30 +1446,35 @@ stun_timeout_func (gpointer user_data)
       g_clear_error (&error);
       FS_RAWUDP_COMPONENT_LOCK (self);
       fs_rawudp_component_stop_stun_locked (self);
-      goto error;
+      goto interrupt;
     }
     FS_RAWUDP_COMPONENT_LOCK(self);
 
     if (self->priv->stun_stop)
-      goto error;
+      goto interrupt;
 
     next_stun_timeout = gst_clock_get_time (sysclock) +
-      total_timeout_ms * GST_MSECOND;
-    total_timeout_ms *= 2;
-    total_timeout_ms += 100;
+      next_timeout_ms * GST_MSECOND;
 
     id = self->priv->stun_timeout_id = gst_clock_new_single_shot_id (sysclock,
         next_stun_timeout);
 
+    GST_LOG ("C:%u Waiting for STUN reply for %u ms, next: %u ms",
+        self->priv->component, next_timeout_ms, timeout_accum_ms);
+
     FS_RAWUDP_COMPONENT_UNLOCK(self);
     gst_clock_id_wait (id, NULL);
     FS_RAWUDP_COMPONENT_LOCK(self);
 
     gst_clock_id_unref (id);
     self->priv->stun_timeout_id = NULL;
+
+    next_timeout_ms *= 2;
+    next_timeout_ms += 100;
+    timeout_accum_ms += next_timeout_ms;
   }
- error:
 
+ interrupt:
   if (self->priv->stun_stop)
   {
     GST_DEBUG ("C:%u STUN process interrupted", self->priv->component);
-- 
1.5.6.5




More information about the farsight-commits mailing list