gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35766 - gnunet/src/peerstore


From: gnunet
Subject: [GNUnet-SVN] r35766 - gnunet/src/peerstore
Date: Thu, 21 May 2015 11:54:13 +0200

Author: grothoff
Date: 2015-05-21 11:54:13 +0200 (Thu, 21 May 2015)
New Revision: 35766

Modified:
   gnunet/src/peerstore/peerstore_api.c
Log:
-no need to abort iterations on reconnect if they are not yet running

Modified: gnunet/src/peerstore/peerstore_api.c
===================================================================
--- gnunet/src/peerstore/peerstore_api.c        2015-05-21 09:50:14 UTC (rev 
35765)
+++ gnunet/src/peerstore/peerstore_api.c        2015-05-21 09:54:13 UTC (rev 
35766)
@@ -391,15 +391,21 @@
   struct GNUNET_PEERSTORE_StoreContext *sc;
   struct GNUNET_MQ_Envelope *ev;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting...\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Reconnecting...\n");
   for (ic = h->iterate_head; NULL != ic; ic = next)
   {
     next = ic->next;
-    icb = ic->callback;
-    icb_cls = ic->callback_cls;
-    GNUNET_PEERSTORE_iterate_cancel (ic);
-    if (NULL != icb)
-      icb (icb_cls, NULL, _("Iteration canceled due to reconnection."));
+    if (GNUNET_YES == ic->iterating)
+    {
+      icb = ic->callback;
+      icb_cls = ic->callback_cls;
+      GNUNET_PEERSTORE_iterate_cancel (ic);
+      if (NULL != icb)
+        icb (icb_cls,
+             NULL,
+             "Iteration canceled due to reconnection");
+    }
   }
   if (NULL != h->mq)
   {
@@ -530,12 +536,11 @@
  * @param sync_first send any pending STORE requests before disconnecting
  */
 void
-GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first)
+GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h,
+                             int sync_first)
 {
   struct GNUNET_PEERSTORE_IterateContext *ic;
-  struct GNUNET_PEERSTORE_IterateContext *ic_iter;
   struct GNUNET_PEERSTORE_StoreContext *sc;
-  struct GNUNET_PEERSTORE_StoreContext *sc_iter;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting.\n");
   if (NULL != h->watches)
@@ -544,12 +549,9 @@
     GNUNET_CONTAINER_multihashmap_destroy (h->watches);
     h->watches = NULL;
   }
-  ic_iter = h->iterate_head;
-  while (NULL != ic_iter)
+  while (NULL != (ic = h->iterate_head))
   {
     GNUNET_break (0);
-    ic = ic_iter;
-    ic_iter = ic_iter->next;
     GNUNET_PEERSTORE_iterate_cancel (ic);
   }
   if (NULL != h->store_head)
@@ -561,13 +563,8 @@
       h->disconnecting = GNUNET_YES;
       return;
     }
-    sc_iter = h->store_head;
-    while (NULL != sc_iter)
-    {
-      sc = sc_iter;
-      sc_iter = sc_iter->next;
+    while (NULL != (sc = h->store_head))
       GNUNET_PEERSTORE_store_cancel (sc);
-    }
   }
   do_disconnect (h);
 }
@@ -736,7 +733,9 @@
   }
   if (GNUNET_NO == ic->iterating)
   {
-    GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head, ic->h->iterate_tail, ic);
+    GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head,
+                                 ic->h->iterate_tail,
+                                 ic);
     GNUNET_free (ic->sub_system);
     if (NULL != ic->key)
       GNUNET_free (ic->key);




reply via email to

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