gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r38010 - gnunet/src/rps


From: gnunet
Subject: [GNUnet-SVN] r38010 - gnunet/src/rps
Date: Sun, 25 Sep 2016 17:08:59 +0200

Author: ch3
Date: 2016-09-25 17:08:59 +0200 (Sun, 25 Sep 2016)
New Revision: 38010

Modified:
   gnunet/src/rps/gnunet-service-rps.c
   gnunet/src/rps/gnunet-service-rps_peers.c
   gnunet/src/rps/gnunet-service-rps_peers.h
Log:
-rps: proper cleaning/removing of peers

Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2016-09-25 15:08:55 UTC (rev 38009)
+++ gnunet/src/rps/gnunet-service-rps.c 2016-09-25 15:08:59 UTC (rev 38010)
@@ -813,12 +813,15 @@
        (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
        (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
        (0 == RPS_sampler_count_id (prot_sampler,   peer)) &&
-       (0 == RPS_sampler_count_id (client_sampler, peer)) )
-  { /* We can safely remov this peer */
+       (0 == RPS_sampler_count_id (client_sampler, peer)) &&
+       (GNUNET_NO != Peers_check_removable (peer)) )
+  { /* We can safely remove this peer */
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+        "Going to remove peer %s\n",
+        GNUNET_i2s (peer));
     remove_peer (peer);
     return;
   }
-  Peers_clean_peer (peer);
 }
 
 /**
@@ -826,6 +829,8 @@
  *
  * Removes peer completely from our knowledge if the send_channel was destroyed
  * Otherwise simply delete the recv_channel
+ * Also check if the knowledge about this peer is still needed.
+ * If not, remove this peer from our knowledge.
  *
  * @param cls The closure
  * @param channel The channel being closed
@@ -1980,7 +1985,7 @@
       to_file (file_name_view_log,
                "-%s",
                GNUNET_i2s_full (&peers_to_clean[i]));
-      Peers_clean_peer (&peers_to_clean[i]);
+      clean_peer (&peers_to_clean[i]);
       //peer_destroy_channel_send (sender);
     }
 
@@ -2008,7 +2013,7 @@
          "Updating with peer %s from push list\n",
          GNUNET_i2s (update_peer));
     insert_in_sampler (NULL, update_peer);
-    Peers_clean_peer (update_peer); /* This cleans only if it is not in the 
view */
+    clean_peer (update_peer); /* This cleans only if it is not in the view */
     //peer_destroy_channel_send (sender);
   }
 
@@ -2019,7 +2024,7 @@
          GNUNET_i2s (CustomPeerMap_get_peer_by_index (pull_map, i)));
     insert_in_sampler (NULL, CustomPeerMap_get_peer_by_index (pull_map, i));
     /* This cleans only if it is not in the view */
-    Peers_clean_peer (CustomPeerMap_get_peer_by_index (pull_map, i));
+    clean_peer (CustomPeerMap_get_peer_by_index (pull_map, i));
     //peer_destroy_channel_send (sender);
   }
 

Modified: gnunet/src/rps/gnunet-service-rps_peers.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps_peers.c   2016-09-25 15:08:55 UTC (rev 
38009)
+++ gnunet/src/rps/gnunet-service-rps_peers.c   2016-09-25 15:08:59 UTC (rev 
38010)
@@ -1073,26 +1073,26 @@
 
 
 /**
- * @brief Remove unecessary data
+ * @brief Check if peer is removable.
  *
- * If the other peer is not intending to send messages, we have messages 
pending
- * to be sent to this peer and we are not waiting for a reply, remove the
- * information about it (its #PeerContext).
+ * Check if
+ *  - a recv channel exists
+ *  - there are pending messages
+ *  - there is no pending pull reply
  *
- * @param peer the peer to clean
- * @return #GNUNET_YES if peer was removed
- *         #GNUNET_NO  otherwise
+ * @param peer the peer in question
+ * @return #GNUNET_YES    if peer is removable
+ *         #GNUNET_NO     if peer is NOT removable
+ *         #GNUNET_SYSERR if peer is not known
  */
 int
-Peers_clean_peer (const struct GNUNET_PeerIdentity *peer)
+Peers_check_removable (const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *peer_ctx;
 
-  // TODO actually remove unnecessary data
-
   if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
   {
-    return GNUNET_NO;
+    return GNUNET_SYSERR;
   }
 
   peer_ctx = get_peer_ctx (peer);
@@ -1102,7 +1102,6 @@
   {
     return GNUNET_NO;
   }
-  Peers_remove_peer (peer);
   return GNUNET_YES;
 }
 

Modified: gnunet/src/rps/gnunet-service-rps_peers.h
===================================================================
--- gnunet/src/rps/gnunet-service-rps_peers.h   2016-09-25 15:08:55 UTC (rev 
38009)
+++ gnunet/src/rps/gnunet-service-rps_peers.h   2016-09-25 15:08:59 UTC (rev 
38010)
@@ -172,18 +172,20 @@
 Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer);
 
 /**
- * @brief Remove unecessary data
+ * @brief Check if peer is removable.
  *
- * If the other peer is not intending to send messages, we have messages 
pending
- * to be sent to this peer and we are not waiting for a reply, remove the
- * information about it (its #PeerContext).
+ * Check if
+ *  - a recv channel exists
+ *  - there are pending messages
+ *  - there is no pending pull reply
  *
- * @param peer the peer to clean
- * @return #GNUNET_YES if peer was removed
- *         #GNUNET_NO  otherwise
+ * @param peer the peer in question
+ * @return #GNUNET_YES    if peer is removable
+ *         #GNUNET_NO     if peer is NOT removable
+ *         #GNUNET_SYSERR if peer is not known
  */
 int
-Peers_clean_peer (const struct GNUNET_PeerIdentity *peer);
+Peers_check_removable (const struct GNUNET_PeerIdentity *peer);
 
 /**
  * @brief Remove peer




reply via email to

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