gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r6177 - GNUnet/src/applications/fs/gap


From: gnunet
Subject: [GNUnet-SVN] r6177 - GNUnet/src/applications/fs/gap
Date: Wed, 6 Feb 2008 22:43:38 -0700 (MST)

Author: grothoff
Date: 2008-02-06 22:43:37 -0700 (Wed, 06 Feb 2008)
New Revision: 6177

Modified:
   GNUnet/src/applications/fs/gap/TODO
   GNUnet/src/applications/fs/gap/gap.c
Log:
gap disconnect clean up implemented

Modified: GNUnet/src/applications/fs/gap/TODO
===================================================================
--- GNUnet/src/applications/fs/gap/TODO 2008-02-07 05:16:18 UTC (rev 6176)
+++ GNUnet/src/applications/fs/gap/TODO 2008-02-07 05:43:37 UTC (rev 6177)
@@ -1,9 +1,9 @@
 DETAILS:
 1) make sure that anonymity-level zero content is pushed into
    the DHT by both fs (on insert/index) and by migration (for refresh)
-2) cleanup of data in gap.c using core's new disconnect notification!
 
+
 OUT-OF-SCOPE:
 1) modify datastore to return diverse subsets of large response sets,
-   except when processing for loopback! -- medium  --- 100 minutes
+   except when processing for loopback!
 2) make sure core polls whenever outbound bandwidth is available

Modified: GNUnet/src/applications/fs/gap/gap.c
===================================================================
--- GNUnet/src/applications/fs/gap/gap.c        2008-02-07 05:16:18 UTC (rev 
6176)
+++ GNUnet/src/applications/fs/gap/gap.c        2008-02-07 05:43:37 UTC (rev 
6177)
@@ -22,10 +22,6 @@
  * @file fs/gap/gap.c
  * @brief protocol that performs anonymous routing
  * @author Christian Grothoff
- *
- * TODO:
- * - clean up active requests from another peer
- *   if that peer disconnects
  */
 
 #include "platform.h"
@@ -359,6 +355,50 @@
   return (unsigned int) (tot / active);
 }
 
+/**
+ * We were disconnected from another peer.
+ * Remove all of its pending queries.
+ */
+static void
+cleanup_on_peer_disconnect(const GNUNET_PeerIdentity * peer,
+                          void * unused)
+{
+  unsigned int i;
+  struct RequestList * rl;
+  struct RequestList * prev;
+  PID_INDEX pid;
+
+  GNUNET_mutex_lock (GNUNET_FS_lock);
+  pid = GNUNET_FS_PT_intern(peer);
+  for (i=0;i<table_size;i++)
+    {
+      rl = table[i];
+      prev = NULL;
+      while (rl != NULL)
+       {
+         if (pid == rl->response_target)
+           {
+             if (prev == NULL)
+               table[i] = rl->next;
+             else
+               prev->next = rl->next;
+             GNUNET_FS_SHARED_free_request_list(rl);
+             if (prev == NULL)
+               rl = table[i];
+             else
+               rl = prev->next;              
+           } 
+         else
+           {
+             prev = rl;
+             rl = rl->next;
+           }
+       }
+    }
+  GNUNET_FS_PT_change_rc(pid, -1);
+  GNUNET_mutex_unlock (GNUNET_FS_lock);
+}
+
 int
 GNUNET_FS_GAP_init (GNUNET_CoreAPIForPlugins * capi)
 {
@@ -380,6 +420,9 @@
   table_size = ts;
   table = GNUNET_malloc (sizeof (struct RequestList *) * table_size);
   memset (table, 0, sizeof (struct RequestList *) * table_size);
+  GNUNET_GE_ASSERT (coreAPI->ectx,
+                    GNUNET_SYSERR !=
+                    coreAPI->register_notify_peer_disconnect 
(&cleanup_on_peer_disconnect, NULL));
   cron = GNUNET_cron_create (coreAPI->ectx);
   GNUNET_cron_start (cron);
   return 0;
@@ -400,6 +443,9 @@
         }
     }
   GNUNET_free (table);
+  GNUNET_GE_ASSERT (coreAPI->ectx,
+                    GNUNET_SYSERR !=
+                    coreAPI->unregister_notify_peer_disconnect 
(&cleanup_on_peer_disconnect, NULL));
   coreAPI->release_service (datastore);
   datastore = NULL;
   GNUNET_cron_stop (cron);





reply via email to

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