aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2016-09-25 15:08:59 +0000
committerJulius Bünger <buenger@mytum.de>2016-09-25 15:08:59 +0000
commit0f498b21da0314edd8d35b419ea10ca25128bc83 (patch)
treec639e2a8d42337999f902ed4e156d6f5c022e809 /src/rps
parentaa9e3d140b74dc0e6ffeee9e5eef351be7b06050 (diff)
downloadgnunet-0f498b21da0314edd8d35b419ea10ca25128bc83.tar.gz
gnunet-0f498b21da0314edd8d35b419ea10ca25128bc83.zip
-rps: proper cleaning/removing of peers
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps.c17
-rw-r--r--src/rps/gnunet-service-rps_peers.c23
-rw-r--r--src/rps/gnunet-service-rps_peers.h18
3 files changed, 32 insertions, 26 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 974953ea0..7d4b34103 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -813,12 +813,15 @@ clean_peer (const struct GNUNET_PeerIdentity *peer)
813 (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) && 813 (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
814 (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) && 814 (GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
815 (0 == RPS_sampler_count_id (prot_sampler, peer)) && 815 (0 == RPS_sampler_count_id (prot_sampler, peer)) &&
816 (0 == RPS_sampler_count_id (client_sampler, peer)) ) 816 (0 == RPS_sampler_count_id (client_sampler, peer)) &&
817 { /* We can safely remov this peer */ 817 (GNUNET_NO != Peers_check_removable (peer)) )
818 { /* We can safely remove this peer */
819 LOG (GNUNET_ERROR_TYPE_DEBUG,
820 "Going to remove peer %s\n",
821 GNUNET_i2s (peer));
818 remove_peer (peer); 822 remove_peer (peer);
819 return; 823 return;
820 } 824 }
821 Peers_clean_peer (peer);
822} 825}
823 826
824/** 827/**
@@ -826,6 +829,8 @@ clean_peer (const struct GNUNET_PeerIdentity *peer)
826 * 829 *
827 * Removes peer completely from our knowledge if the send_channel was destroyed 830 * Removes peer completely from our knowledge if the send_channel was destroyed
828 * Otherwise simply delete the recv_channel 831 * Otherwise simply delete the recv_channel
832 * Also check if the knowledge about this peer is still needed.
833 * If not, remove this peer from our knowledge.
829 * 834 *
830 * @param cls The closure 835 * @param cls The closure
831 * @param channel The channel being closed 836 * @param channel The channel being closed
@@ -1980,7 +1985,7 @@ do_round (void *cls)
1980 to_file (file_name_view_log, 1985 to_file (file_name_view_log,
1981 "-%s", 1986 "-%s",
1982 GNUNET_i2s_full (&peers_to_clean[i])); 1987 GNUNET_i2s_full (&peers_to_clean[i]));
1983 Peers_clean_peer (&peers_to_clean[i]); 1988 clean_peer (&peers_to_clean[i]);
1984 //peer_destroy_channel_send (sender); 1989 //peer_destroy_channel_send (sender);
1985 } 1990 }
1986 1991
@@ -2008,7 +2013,7 @@ do_round (void *cls)
2008 "Updating with peer %s from push list\n", 2013 "Updating with peer %s from push list\n",
2009 GNUNET_i2s (update_peer)); 2014 GNUNET_i2s (update_peer));
2010 insert_in_sampler (NULL, update_peer); 2015 insert_in_sampler (NULL, update_peer);
2011 Peers_clean_peer (update_peer); /* This cleans only if it is not in the view */ 2016 clean_peer (update_peer); /* This cleans only if it is not in the view */
2012 //peer_destroy_channel_send (sender); 2017 //peer_destroy_channel_send (sender);
2013 } 2018 }
2014 2019
@@ -2019,7 +2024,7 @@ do_round (void *cls)
2019 GNUNET_i2s (CustomPeerMap_get_peer_by_index (pull_map, i))); 2024 GNUNET_i2s (CustomPeerMap_get_peer_by_index (pull_map, i)));
2020 insert_in_sampler (NULL, CustomPeerMap_get_peer_by_index (pull_map, i)); 2025 insert_in_sampler (NULL, CustomPeerMap_get_peer_by_index (pull_map, i));
2021 /* This cleans only if it is not in the view */ 2026 /* This cleans only if it is not in the view */
2022 Peers_clean_peer (CustomPeerMap_get_peer_by_index (pull_map, i)); 2027 clean_peer (CustomPeerMap_get_peer_by_index (pull_map, i));
2023 //peer_destroy_channel_send (sender); 2028 //peer_destroy_channel_send (sender);
2024 } 2029 }
2025 2030
diff --git a/src/rps/gnunet-service-rps_peers.c b/src/rps/gnunet-service-rps_peers.c
index d2a995c1d..e0b278bd0 100644
--- a/src/rps/gnunet-service-rps_peers.c
+++ b/src/rps/gnunet-service-rps_peers.c
@@ -1073,26 +1073,26 @@ Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer)
1073 1073
1074 1074
1075/** 1075/**
1076 * @brief Remove unecessary data 1076 * @brief Check if peer is removable.
1077 * 1077 *
1078 * If the other peer is not intending to send messages, we have messages pending 1078 * Check if
1079 * to be sent to this peer and we are not waiting for a reply, remove the 1079 * - a recv channel exists
1080 * information about it (its #PeerContext). 1080 * - there are pending messages
1081 * - there is no pending pull reply
1081 * 1082 *
1082 * @param peer the peer to clean 1083 * @param peer the peer in question
1083 * @return #GNUNET_YES if peer was removed 1084 * @return #GNUNET_YES if peer is removable
1084 * #GNUNET_NO otherwise 1085 * #GNUNET_NO if peer is NOT removable
1086 * #GNUNET_SYSERR if peer is not known
1085 */ 1087 */
1086int 1088int
1087Peers_clean_peer (const struct GNUNET_PeerIdentity *peer) 1089Peers_check_removable (const struct GNUNET_PeerIdentity *peer)
1088{ 1090{
1089 struct PeerContext *peer_ctx; 1091 struct PeerContext *peer_ctx;
1090 1092
1091 // TODO actually remove unnecessary data
1092
1093 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) 1093 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
1094 { 1094 {
1095 return GNUNET_NO; 1095 return GNUNET_SYSERR;
1096 } 1096 }
1097 1097
1098 peer_ctx = get_peer_ctx (peer); 1098 peer_ctx = get_peer_ctx (peer);
@@ -1102,7 +1102,6 @@ Peers_clean_peer (const struct GNUNET_PeerIdentity *peer)
1102 { 1102 {
1103 return GNUNET_NO; 1103 return GNUNET_NO;
1104 } 1104 }
1105 Peers_remove_peer (peer);
1106 return GNUNET_YES; 1105 return GNUNET_YES;
1107} 1106}
1108 1107
diff --git a/src/rps/gnunet-service-rps_peers.h b/src/rps/gnunet-service-rps_peers.h
index c7b9ed265..bbac86003 100644
--- a/src/rps/gnunet-service-rps_peers.h
+++ b/src/rps/gnunet-service-rps_peers.h
@@ -172,18 +172,20 @@ int
172Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer); 172Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer);
173 173
174/** 174/**
175 * @brief Remove unecessary data 175 * @brief Check if peer is removable.
176 * 176 *
177 * If the other peer is not intending to send messages, we have messages pending 177 * Check if
178 * to be sent to this peer and we are not waiting for a reply, remove the 178 * - a recv channel exists
179 * information about it (its #PeerContext). 179 * - there are pending messages
180 * - there is no pending pull reply
180 * 181 *
181 * @param peer the peer to clean 182 * @param peer the peer in question
182 * @return #GNUNET_YES if peer was removed 183 * @return #GNUNET_YES if peer is removable
183 * #GNUNET_NO otherwise 184 * #GNUNET_NO if peer is NOT removable
185 * #GNUNET_SYSERR if peer is not known
184 */ 186 */
185int 187int
186Peers_clean_peer (const struct GNUNET_PeerIdentity *peer); 188Peers_check_removable (const struct GNUNET_PeerIdentity *peer);
187 189
188/** 190/**
189 * @brief Remove peer 191 * @brief Remove peer