aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c80
-rw-r--r--src/rps/gnunet-service-rps_view.c8
2 files changed, 53 insertions, 35 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 76c5b10f9..6b0ecc58c 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -823,7 +823,7 @@ check_operation_scheduled (const struct GNUNET_PeerIdentity *peer,
823 return GNUNET_NO; 823 return GNUNET_NO;
824} 824}
825 825
826int 826static int
827Peers_remove_peer (const struct GNUNET_PeerIdentity *peer); 827Peers_remove_peer (const struct GNUNET_PeerIdentity *peer);
828 828
829/** 829/**
@@ -1099,12 +1099,12 @@ Peers_initialise (char* fn_valid_peers,
1099/** 1099/**
1100 * @brief Delete storage of peers that was created with #Peers_initialise () 1100 * @brief Delete storage of peers that was created with #Peers_initialise ()
1101 */ 1101 */
1102void 1102static void
1103Peers_terminate () 1103peers_terminate ()
1104{ 1104{
1105 if (GNUNET_SYSERR == 1105 if (GNUNET_SYSERR ==
1106 GNUNET_CONTAINER_multipeermap_iterate (peer_map, 1106 GNUNET_CONTAINER_multipeermap_iterate (peer_map,
1107 peermap_clear_iterator, 1107 &peermap_clear_iterator,
1108 NULL)) 1108 NULL))
1109 { 1109 {
1110 LOG (GNUNET_ERROR_TYPE_WARNING, 1110 LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -1114,7 +1114,9 @@ Peers_terminate ()
1114 peer_map = NULL; 1114 peer_map = NULL;
1115 store_valid_peers (); 1115 store_valid_peers ();
1116 GNUNET_free (filename_valid_peers); 1116 GNUNET_free (filename_valid_peers);
1117 filename_valid_peers = NULL;
1117 GNUNET_CONTAINER_multipeermap_destroy (valid_peers); 1118 GNUNET_CONTAINER_multipeermap_destroy (valid_peers);
1119 valid_peers = NULL;
1118} 1120}
1119 1121
1120 1122
@@ -1272,6 +1274,7 @@ destroy_peer (void *cls)
1272 Peers_remove_peer (&peer_ctx->peer_id); 1274 Peers_remove_peer (&peer_ctx->peer_id);
1273} 1275}
1274 1276
1277
1275static void 1278static void
1276destroy_channel (void *cls); 1279destroy_channel (void *cls);
1277 1280
@@ -1291,7 +1294,8 @@ schedule_channel_destruction (struct ChannelCtx *channel_ctx)
1291 GNUNET_NO == in_shutdown) 1294 GNUNET_NO == in_shutdown)
1292 { 1295 {
1293 channel_ctx->destruction_task = 1296 channel_ctx->destruction_task =
1294 GNUNET_SCHEDULER_add_now (destroy_channel, channel_ctx); 1297 GNUNET_SCHEDULER_add_now (&destroy_channel,
1298 channel_ctx);
1295 } 1299 }
1296} 1300}
1297 1301
@@ -1311,7 +1315,8 @@ schedule_peer_destruction (struct PeerContext *peer_ctx)
1311 GNUNET_NO == in_shutdown) 1315 GNUNET_NO == in_shutdown)
1312 { 1316 {
1313 peer_ctx->destruction_task = 1317 peer_ctx->destruction_task =
1314 GNUNET_SCHEDULER_add_now (destroy_peer, peer_ctx); 1318 GNUNET_SCHEDULER_add_now (&destroy_peer,
1319 peer_ctx);
1315 } 1320 }
1316} 1321}
1317 1322
@@ -1323,18 +1328,18 @@ schedule_peer_destruction (struct PeerContext *peer_ctx)
1323 * @return #GNUNET_YES if peer was removed 1328 * @return #GNUNET_YES if peer was removed
1324 * #GNUNET_NO otherwise 1329 * #GNUNET_NO otherwise
1325 */ 1330 */
1326int 1331static int
1327Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) 1332Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1328{ 1333{
1329 struct PeerContext *peer_ctx; 1334 struct PeerContext *peer_ctx;
1330 1335
1331 GNUNET_assert (NULL != peer_map); 1336 GNUNET_assert (NULL != peer_map);
1332 1337 if (GNUNET_NO ==
1333 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) 1338 GNUNET_CONTAINER_multipeermap_contains (peer_map,
1339 peer))
1334 { 1340 {
1335 return GNUNET_NO; 1341 return GNUNET_NO;
1336 } 1342 }
1337
1338 peer_ctx = get_peer_ctx (peer); 1343 peer_ctx = get_peer_ctx (peer);
1339 set_peer_flag (peer_ctx, Peers_TO_DESTROY); 1344 set_peer_flag (peer_ctx, Peers_TO_DESTROY);
1340 LOG (GNUNET_ERROR_TYPE_DEBUG, 1345 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1345,14 +1350,15 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1345 /* Clear list of pending operations */ 1350 /* Clear list of pending operations */
1346 // TODO this probably leaks memory 1351 // TODO this probably leaks memory
1347 // ('only' the cls to the function. Not sure what to do with it) 1352 // ('only' the cls to the function. Not sure what to do with it)
1348 GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0); 1353 GNUNET_array_grow (peer_ctx->pending_ops,
1349 1354 peer_ctx->num_pending_ops,
1355 0);
1350 /* Remove all pending messages */ 1356 /* Remove all pending messages */
1351 while (NULL != peer_ctx->pending_messages_head) 1357 while (NULL != peer_ctx->pending_messages_head)
1352 { 1358 {
1353 LOG (GNUNET_ERROR_TYPE_DEBUG, 1359 LOG (GNUNET_ERROR_TYPE_DEBUG,
1354 "Removing unsent %s\n", 1360 "Removing unsent %s\n",
1355 peer_ctx->pending_messages_head->type); 1361 peer_ctx->pending_messages_head->type);
1356 /* Cancle pending message, too */ 1362 /* Cancle pending message, too */
1357 if ( (NULL != peer_ctx->liveliness_check_pending) && 1363 if ( (NULL != peer_ctx->liveliness_check_pending) &&
1358 (0 == memcmp (peer_ctx->pending_messages_head, 1364 (0 == memcmp (peer_ctx->pending_messages_head,
@@ -1362,7 +1368,8 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1362 // TODO this may leak memory 1368 // TODO this may leak memory
1363 peer_ctx->liveliness_check_pending = NULL; 1369 peer_ctx->liveliness_check_pending = NULL;
1364 } 1370 }
1365 remove_pending_message (peer_ctx->pending_messages_head, GNUNET_YES); 1371 remove_pending_message (peer_ctx->pending_messages_head,
1372 GNUNET_YES);
1366 } 1373 }
1367 1374
1368 /* If we are still waiting for notification whether this peer is live 1375 /* If we are still waiting for notification whether this peer is live
@@ -1370,11 +1377,12 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1370 if (NULL != peer_ctx->liveliness_check_pending) 1377 if (NULL != peer_ctx->liveliness_check_pending)
1371 { 1378 {
1372 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1373 "Removing pending liveliness check for peer %s\n", 1380 "Removing pending liveliness check for peer %s\n",
1374 GNUNET_i2s (&peer_ctx->peer_id)); 1381 GNUNET_i2s (&peer_ctx->peer_id));
1375 // TODO wait until cadet sets mq->cancel_impl 1382 // TODO wait until cadet sets mq->cancel_impl
1376 //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev); 1383 //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
1377 remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES); 1384 remove_pending_message (peer_ctx->liveliness_check_pending,
1385 GNUNET_YES);
1378 peer_ctx->liveliness_check_pending = NULL; 1386 peer_ctx->liveliness_check_pending = NULL;
1379 } 1387 }
1380 1388
@@ -1382,8 +1390,7 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1382 /* Do we still have to wait for destruction of channels 1390 /* Do we still have to wait for destruction of channels
1383 * or issue the destruction? */ 1391 * or issue the destruction? */
1384 if (NULL != peer_ctx->send_channel_ctx && 1392 if (NULL != peer_ctx->send_channel_ctx &&
1385 NULL != peer_ctx->send_channel_ctx->destruction_task 1393 NULL != peer_ctx->send_channel_ctx->destruction_task)
1386 )
1387 { 1394 {
1388 schedule_peer_destruction (peer_ctx); 1395 schedule_peer_destruction (peer_ctx);
1389 return GNUNET_NO; 1396 return GNUNET_NO;
@@ -1412,14 +1419,18 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
1412 GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task); 1419 GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task);
1413 } 1420 }
1414 1421
1415 if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove_all (peer_map, &peer_ctx->peer_id)) 1422 if (GNUNET_YES !=
1423 GNUNET_CONTAINER_multipeermap_remove_all (peer_map,
1424 &peer_ctx->peer_id))
1416 { 1425 {
1417 LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n"); 1426 LOG (GNUNET_ERROR_TYPE_WARNING,
1427 "removing peer from peer_map failed\n");
1418 } 1428 }
1419 GNUNET_free (peer_ctx); 1429 GNUNET_free (peer_ctx);
1420 return GNUNET_YES; 1430 return GNUNET_YES;
1421} 1431}
1422 1432
1433
1423/** 1434/**
1424 * @brief set flags on a given peer. 1435 * @brief set flags on a given peer.
1425 * 1436 *
@@ -4073,12 +4084,14 @@ shutdown_task (void *cls)
4073 reply_cls); 4084 reply_cls);
4074 GNUNET_free (reply_cls); 4085 GNUNET_free (reply_cls);
4075 } 4086 }
4076 GNUNET_CONTAINER_DLL_remove (cli_ctx_head, cli_ctx_tail, client_ctx); 4087 GNUNET_CONTAINER_DLL_remove (cli_ctx_head,
4088 cli_ctx_tail,
4089 client_ctx);
4077 GNUNET_free (client_ctx); 4090 GNUNET_free (client_ctx);
4078 } 4091 }
4079 GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); 4092 GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle);
4080 GNUNET_PEERINFO_disconnect (peerinfo_handle); 4093 GNUNET_PEERINFO_disconnect (peerinfo_handle);
4081 4094 peerinfo_handle = NULL;
4082 if (NULL != do_round_task) 4095 if (NULL != do_round_task)
4083 { 4096 {
4084 GNUNET_SCHEDULER_cancel (do_round_task); 4097 GNUNET_SCHEDULER_cancel (do_round_task);
@@ -4097,18 +4110,21 @@ shutdown_task (void *cls)
4097 CustomPeerMap_destroy (pull_map); 4110 CustomPeerMap_destroy (pull_map);
4098 if (NULL != stats) 4111 if (NULL != stats)
4099 { 4112 {
4100 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 4113 GNUNET_STATISTICS_destroy (stats,
4114 GNUNET_NO);
4101 stats = NULL; 4115 stats = NULL;
4102 } 4116 }
4103 #ifdef ENABLE_MALICIOUS 4117#ifdef ENABLE_MALICIOUS
4104 struct AttackedPeer *tmp_att_peer; 4118 struct AttackedPeer *tmp_att_peer;
4105 /* it is ok to free this const during shutdown: */ 4119 /* it is ok to free this const during shutdown: */
4106 GNUNET_free ((char *) file_name_view_log); 4120 GNUNET_free ((char *) file_name_view_log);
4107 #ifdef TO_FILE 4121#ifdef TO_FILE
4108 GNUNET_free ((char *) file_name_observed_log); 4122 GNUNET_free ((char *) file_name_observed_log);
4109 GNUNET_CONTAINER_multipeermap_destroy (observed_unique_peers); 4123 GNUNET_CONTAINER_multipeermap_destroy (observed_unique_peers);
4110 #endif /* TO_FILE */ 4124#endif /* TO_FILE */
4111 GNUNET_array_grow (mal_peers, num_mal_peers, 0); 4125 GNUNET_array_grow (mal_peers,
4126 num_mal_peers,
4127 0);
4112 if (NULL != mal_peer_set) 4128 if (NULL != mal_peer_set)
4113 GNUNET_CONTAINER_multipeermap_destroy (mal_peer_set); 4129 GNUNET_CONTAINER_multipeermap_destroy (mal_peer_set);
4114 if (NULL != att_peer_set) 4130 if (NULL != att_peer_set)
@@ -4116,10 +4132,12 @@ shutdown_task (void *cls)
4116 while (NULL != att_peers_head) 4132 while (NULL != att_peers_head)
4117 { 4133 {
4118 tmp_att_peer = att_peers_head; 4134 tmp_att_peer = att_peers_head;
4119 GNUNET_CONTAINER_DLL_remove (att_peers_head, att_peers_tail, tmp_att_peer); 4135 GNUNET_CONTAINER_DLL_remove (att_peers_head,
4136 att_peers_tail,
4137 tmp_att_peer);
4120 GNUNET_free (tmp_att_peer); 4138 GNUNET_free (tmp_att_peer);
4121 } 4139 }
4122 #endif /* ENABLE_MALICIOUS */ 4140#endif /* ENABLE_MALICIOUS */
4123} 4141}
4124 4142
4125 4143
diff --git a/src/rps/gnunet-service-rps_view.c b/src/rps/gnunet-service-rps_view.c
index 1fa75fc53..26a0b22bc 100644
--- a/src/rps/gnunet-service-rps_view.c
+++ b/src/rps/gnunet-service-rps_view.c
@@ -229,11 +229,10 @@ View_get_peer_by_index (uint32_t index)
229void 229void
230View_clear () 230View_clear ()
231{ 231{
232 uint32_t i; 232 for (uint32_t i = 0; 0 < View_size (); i++)
233 uint32_t *index;
234
235 for (i = 0; 0 < View_size (); i++)
236 { /* Need to free indices stored at peers */ 233 { /* Need to free indices stored at peers */
234 uint32_t *index;
235
237 GNUNET_assert (GNUNET_YES == 236 GNUNET_assert (GNUNET_YES ==
238 GNUNET_CONTAINER_multipeermap_contains (mpm, &array[i])); 237 GNUNET_CONTAINER_multipeermap_contains (mpm, &array[i]));
239 index = GNUNET_CONTAINER_multipeermap_get (mpm, &array[i]); 238 index = GNUNET_CONTAINER_multipeermap_get (mpm, &array[i]);
@@ -244,6 +243,7 @@ View_clear ()
244 GNUNET_assert (0 == View_size ()); 243 GNUNET_assert (0 == View_size ());
245} 244}
246 245
246
247/** 247/**
248 * Destroy peermap. 248 * Destroy peermap.
249 * 249 *