aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-rps-profiler.c7
-rw-r--r--src/rps/gnunet-service-rps.c18
-rw-r--r--src/rps/gnunet-service-rps_custommap.c9
-rw-r--r--src/rps/rps-test_util.c16
4 files changed, 32 insertions, 18 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 82aeffb79..908dcca17 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -3067,9 +3067,10 @@ run (void *cls,
3067 } 3067 }
3068 else 3068 else
3069 { 3069 {
3070 duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3070 duration = GNUNET_TIME_relative_multiply (
3071 (timeout.rel_value_us / 1000000) 3071 GNUNET_TIME_UNIT_SECONDS,
3072 * 0.75); 3072 ( (double) timeout.rel_value_us / (double) 1000000)
3073 * 0.75);
3073 } 3074 }
3074 } 3075 }
3075 else 3076 else
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index dc4c5dab7..56eab288e 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -965,8 +965,6 @@ remove_channel_ctx (struct ChannelCtx *channel_ctx)
965 channel_ctx->destruction_task = NULL; 965 channel_ctx->destruction_task = NULL;
966 } 966 }
967 967
968 GNUNET_free (channel_ctx);
969
970 if (NULL == peer_ctx) 968 if (NULL == peer_ctx)
971 return; 969 return;
972 if (channel_ctx == peer_ctx->send_channel_ctx) 970 if (channel_ctx == peer_ctx->send_channel_ctx)
@@ -978,6 +976,7 @@ remove_channel_ctx (struct ChannelCtx *channel_ctx)
978 { 976 {
979 peer_ctx->recv_channel_ctx = NULL; 977 peer_ctx->recv_channel_ctx = NULL;
980 } 978 }
979 GNUNET_free (channel_ctx);
981} 980}
982 981
983 982
@@ -2637,7 +2636,7 @@ insert_in_sampler (void *cls,
2637 } 2636 }
2638#ifdef TO_FILE 2637#ifdef TO_FILE
2639 sub->num_observed_peers++; 2638 sub->num_observed_peers++;
2640 GNUNET_CONTAINER_multipeermap_put 2639 (void) GNUNET_CONTAINER_multipeermap_put
2641 (sub->observed_unique_peers, 2640 (sub->observed_unique_peers,
2642 peer, 2641 peer,
2643 NULL, 2642 NULL,
@@ -2802,7 +2801,7 @@ clean_peer (struct Sub *sub,
2802 peer))) && 2801 peer))) &&
2803 (GNUNET_NO == View_contains_peer (sub->view, peer)) && 2802 (GNUNET_NO == View_contains_peer (sub->view, peer)) &&
2804 (GNUNET_NO == CustomPeerMap_contains_peer (sub->push_map, peer)) && 2803 (GNUNET_NO == CustomPeerMap_contains_peer (sub->push_map, peer)) &&
2805 (GNUNET_NO == CustomPeerMap_contains_peer (sub->push_map, peer)) && 2804 (GNUNET_NO == CustomPeerMap_contains_peer (sub->pull_map, peer)) &&
2806 (0 == RPS_sampler_count_id (sub->sampler, peer)) && 2805 (0 == RPS_sampler_count_id (sub->sampler, peer)) &&
2807 (GNUNET_YES == check_removable (get_peer_ctx (sub->peer_map, peer)))) 2806 (GNUNET_YES == check_removable (get_peer_ctx (sub->peer_map, peer))))
2808 { /* We can safely remove this peer */ 2807 { /* We can safely remove this peer */
@@ -2836,13 +2835,20 @@ cleanup_destroyed_channel (void *cls,
2836 (void) channel; 2835 (void) channel;
2837 2836
2838 channel_ctx->channel = NULL; 2837 channel_ctx->channel = NULL;
2839 remove_channel_ctx (channel_ctx);
2840 if ((NULL != peer_ctx) && 2838 if ((NULL != peer_ctx) &&
2841 (peer_ctx->send_channel_ctx == channel_ctx) && 2839 (peer_ctx->send_channel_ctx == channel_ctx) &&
2842 (GNUNET_YES == check_sending_channel_needed (channel_ctx->peer_ctx)) ) 2840 (GNUNET_YES == check_sending_channel_needed (peer_ctx)) )
2843 { 2841 {
2842 remove_channel_ctx (channel_ctx);
2844 remove_peer (peer_ctx->sub, &peer_ctx->peer_id); 2843 remove_peer (peer_ctx->sub, &peer_ctx->peer_id);
2845 } 2844 }
2845 else
2846 {
2847 /* We need this if-else construct because we need to make sure the channel
2848 * (context) is cleaned up before removing the peer, but still neet to
2849 * compare it while checking the condition */
2850 remove_channel_ctx (channel_ctx);
2851 }
2846} 2852}
2847 2853
2848 2854
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index 54e361d32..392c29397 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -206,6 +206,7 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
206 struct GNUNET_PeerIdentity *p; 206 struct GNUNET_PeerIdentity *p;
207 uint32_t *last_index; 207 uint32_t *last_index;
208 struct GNUNET_PeerIdentity *last_p; 208 struct GNUNET_PeerIdentity *last_p;
209 int ret;
209 210
210 if (GNUNET_NO == CustomPeerMap_contains_peer (c_peer_map, 211 if (GNUNET_NO == CustomPeerMap_contains_peer (c_peer_map,
211 peer)) 212 peer))
@@ -234,9 +235,11 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
234 last_p); 235 last_p);
235 GNUNET_assert (NULL != last_index); 236 GNUNET_assert (NULL != last_index);
236 GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index); 237 GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index);
237 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, 238 ret = GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map,
238 *index, last_p, 239 *index,
239 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 240 last_p,
241 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
242 GNUNET_assert (GNUNET_OK == ret);
240 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, 243 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map,
241 *last_index); 244 *last_index);
242 *last_index = *index; 245 *last_index = *index;
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 497225973..6dee20c95 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -152,12 +152,16 @@ close_all_files ()
152{ 152{
153 int ret; 153 int ret;
154 154
155 ret = GNUNET_CONTAINER_multihashmap_iterate (open_files, 155 if (NULL != open_files)
156 close_files_iter, 156 {
157 NULL); 157 ret = GNUNET_CONTAINER_multihashmap_iterate (open_files,
158 GNUNET_CONTAINER_multihashmap_destroy (open_files); 158 close_files_iter,
159 open_files = NULL; 159 NULL);
160 return ret; 160 GNUNET_CONTAINER_multihashmap_destroy (open_files);
161 open_files = NULL;
162 return ret;
163 }
164 return GNUNET_YES;
161} 165}
162 166
163 167