gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r17463 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r17463 - gnunet/src/ats
Date: Thu, 13 Oct 2011 22:04:52 +0200

Author: grothoff
Date: 2011-10-13 22:04:52 +0200 (Thu, 13 Oct 2011)
New Revision: 17463

Modified:
   gnunet/src/ats/ats_api_scheduling.c
Log:
fix stack overflow

Modified: gnunet/src/ats/ats_api_scheduling.c
===================================================================
--- gnunet/src/ats/ats_api_scheduling.c 2011-10-13 19:52:48 UTC (rev 17462)
+++ gnunet/src/ats/ats_api_scheduling.c 2011-10-13 20:04:52 UTC (rev 17463)
@@ -105,6 +105,11 @@
    * Unused entries are also NULL.
    */
   struct Session **session_array;
+
+  /**
+   * Task to trigger reconnect.
+   */ 
+  GNUNET_SCHEDULER_TaskIdentifier task;
   
   /**
    * Size of the session array.
@@ -123,7 +128,25 @@
 reconnect (struct GNUNET_ATS_SchedulingHandle *sh);
 
 
+
 /**
+ * Re-establish the connection to the ATS service.
+ *
+ * @param cls handle to use to re-connect.
+ * @param tc scheduler context
+ */
+static void
+reconnect_task (void *cls,
+               const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_ATS_SchedulingHandle *sh = cls;
+
+  sh->task = GNUNET_SCHEDULER_NO_TASK;
+  reconnect (sh);
+}
+
+
+/**
  * Transmit messages from the message queue to the service
  * (if there are any, and if we are not already trying).
  *
@@ -289,7 +312,8 @@
   {
     GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
     sh->client = NULL;
-    reconnect (sh);
+    sh->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                            &reconnect_task, sh);
     return;
   }
   if ( (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION) ||
@@ -298,7 +322,8 @@
     GNUNET_break (0);
     GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
     sh->client = NULL;
-    reconnect (sh);
+    sh->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                            &reconnect_task, sh);
     return;
   }
   m = (const struct AddressSuggestionMessage*) msg;
@@ -318,7 +343,8 @@
     GNUNET_break (0);
     GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
     sh->client = NULL;
-    reconnect (sh);
+    sh->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                            &reconnect_task, sh);
     return;
   }
   sh->suggest_cb (sh->suggest_cb_cls,
@@ -416,7 +442,16 @@
                                 p);
     GNUNET_free (p);
   }
-  GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
+  if (NULL != sh->client)
+  {
+    GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
+    sh->client = NULL;
+  }
+  if (GNUNET_SCHEDULER_NO_TASK != sh->task)
+  {
+    GNUNET_SCHEDULER_cancel (sh->task);
+    sh->task = GNUNET_SCHEDULER_NO_TASK;
+  }
   GNUNET_array_grow (sh->session_array,
                     sh->session_array_size,
                     0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]