(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);
}
/**
*
* 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
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);
}
"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);
}
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);
}
/**
- * @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);
{
return GNUNET_NO;
}
- Peers_remove_peer (peer);
return GNUNET_YES;
}
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