gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r25769 - gnunet/src/ats
Date: Mon, 14 Jan 2013 12:11:15 +0100

Author: wachs
Date: 2013-01-14 12:11:15 +0100 (Mon, 14 Jan 2013)
New Revision: 25769

Modified:
   gnunet/src/ats/ats_api_scheduling.c
Log:
adding suggest handle to allow transport to check if we have pending address 
request


Modified: gnunet/src/ats/ats_api_scheduling.c
===================================================================
--- gnunet/src/ats/ats_api_scheduling.c 2013-01-14 11:00:04 UTC (rev 25768)
+++ gnunet/src/ats/ats_api_scheduling.c 2013-01-14 11:11:15 UTC (rev 25769)
@@ -94,6 +94,15 @@
   socklen_t length;
 };
 
+/**
+ * Handle for address suggestions
+ */
+struct GNUNET_ATS_SuggestHandle
+{
+  struct GNUNET_ATS_SuggestHandle *prev;
+  struct GNUNET_ATS_SuggestHandle *next;
+  struct GNUNET_PeerIdentity id;
+};
 
 
 /**
@@ -118,6 +127,16 @@
   void *suggest_cb_cls;
 
   /**
+   * DLL for suggestions head
+   */
+  struct GNUNET_ATS_SuggestHandle *sug_head;
+
+  /**
+   * DLL for suggestions tail
+   */
+  struct GNUNET_ATS_SuggestHandle *sug_tail;
+
+  /**
    * Connection to ATS service.
    */
   struct GNUNET_CLIENT_Connection *client;
@@ -953,7 +972,8 @@
 GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh)
 {
   struct PendingMessage *p;
-
+  struct GNUNET_ATS_SuggestHandle *cur;
+  struct GNUNET_ATS_SuggestHandle *next;
   while (NULL != (p = sh->pending_head))
   {
     GNUNET_CONTAINER_DLL_remove (sh->pending_head, sh->pending_tail, p);
@@ -970,6 +990,14 @@
     sh->task = GNUNET_SCHEDULER_NO_TASK;
   }
 
+  next = sh->sug_head;
+  while (NULL != (cur = next))
+  {
+               next = cur->next;
+               GNUNET_CONTAINER_DLL_remove (sh->sug_head, sh->sug_tail, cur);
+               GNUNET_free (cur);
+  }
+
   delete_networks (sh);
   if (sh->interface_task != GNUNET_SCHEDULER_NO_TASK)
   {
@@ -1014,13 +1042,15 @@
  *
  * @param sh handle
  * @param peer identity of the peer we need an address for
+ * @return suggest handle
  */
-void
+struct GNUNET_ATS_SuggestHandle *
 GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
                             const struct GNUNET_PeerIdentity *peer)
 {
   struct PendingMessage *p;
   struct RequestAddressMessage *m;
+  struct GNUNET_ATS_SuggestHandle *s;
 
   // FIXME: ATS needs to remember this in case of
   // a disconnect!
@@ -1035,6 +1065,10 @@
   m->peer = *peer;
   GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
   do_transmit (sh);
+  s = GNUNET_malloc (sizeof (struct GNUNET_ATS_SuggestHandle));
+  s->id = (*peer);
+  GNUNET_CONTAINER_DLL_insert_tail (sh->sug_head, sh->sug_tail, s);
+  return s;
 }
 
 
@@ -1050,7 +1084,22 @@
 {
   struct PendingMessage *p;
   struct RequestAddressMessage *m;
+  struct GNUNET_ATS_SuggestHandle *s;
 
+  for (s = sh->sug_head; NULL != s; s = s->next)
+       if (0 == memcmp(peer, &s->id, sizeof (s->id)))
+               break;
+  if (NULL == s)
+  {
+       GNUNET_break (0);
+       return;
+  }
+  else
+  {
+       GNUNET_CONTAINER_DLL_remove (sh->sug_head, sh->sug_tail, s);
+       GNUNET_free (s);
+  }
+
   p = GNUNET_malloc (sizeof (struct PendingMessage) +
                      sizeof (struct RequestAddressMessage));
   p->size = sizeof (struct RequestAddressMessage);




reply via email to

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