aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c72
1 files changed, 49 insertions, 23 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index f66459802..1bcaf3158 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -385,6 +385,12 @@ uint32_t num_hist_update_tasks;
385#define unset_peer_flag(peer_ctx, mask) (peer_ctx->peer_flags &= (~mask)) 385#define unset_peer_flag(peer_ctx, mask) (peer_ctx->peer_flags &= (~mask))
386 386
387 387
388/**
389 * Clean the send channel of a peer
390 */
391void
392peer_clean (const struct GNUNET_PeerIdentity *peer);
393
388 394
389/** 395/**
390 * Check if peer is already in peer array. 396 * Check if peer is already in peer array.
@@ -745,6 +751,8 @@ insert_in_pull_list (void *cls, const struct GNUNET_PeerIdentity *peer)
745{ 751{
746 if (GNUNET_NO == in_arr (pull_list, pull_list_size, peer)) 752 if (GNUNET_NO == in_arr (pull_list, pull_list_size, peer))
747 GNUNET_array_append (pull_list, pull_list_size, *peer); 753 GNUNET_array_append (pull_list, pull_list_size, *peer);
754
755 peer_clean (peer);
748} 756}
749 757
750/** 758/**
@@ -1346,7 +1354,6 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1346 1354
1347 1355
1348 /* Update gossip list */ 1356 /* Update gossip list */
1349 uint32_t r_index;
1350 1357
1351 if ( push_list_size <= alpha * gossip_list_size && 1358 if ( push_list_size <= alpha * gossip_list_size &&
1352 push_list_size != 0 && 1359 push_list_size != 0 &&
@@ -1356,6 +1363,16 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1356 1363
1357 uint32_t first_border; 1364 uint32_t first_border;
1358 uint32_t second_border; 1365 uint32_t second_border;
1366 uint32_t r_index;
1367 uint32_t peers_to_clean_size;
1368 struct GNUNET_PeerIdentity *peers_to_clean;
1369
1370 peers_to_clean = NULL;
1371 peers_to_clean_size = 0;
1372 GNUNET_array_grow (peers_to_clean, peers_to_clean_size, gossip_list_size);
1373 memcpy (peers_to_clean,
1374 gossip_list,
1375 gossip_list_size * sizeof (struct GNUNET_PeerIdentity));
1359 1376
1360 first_border = ceil (alpha * sampler_size_est_need); 1377 first_border = ceil (alpha * sampler_size_est_need);
1361 second_border = first_border + ceil (beta * sampler_size_est_need); 1378 second_border = first_border + ceil (beta * sampler_size_est_need);
@@ -1388,6 +1405,13 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1388 // TODO change the peer_flags accordingly 1405 // TODO change the peer_flags accordingly
1389 } 1406 }
1390 1407
1408 for (i = 0 ; i < gossip_list_size ; i++)
1409 rem_from_list (&peers_to_clean, &peers_to_clean_size, &gossip_list[i]);
1410
1411 for (i = 0 ; i < peers_to_clean_size ; i++)
1412 peer_clean (&peers_to_clean[i]);
1413
1414 GNUNET_free (peers_to_clean);
1391 } 1415 }
1392 else 1416 else
1393 { 1417 {
@@ -1397,7 +1421,6 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1397 1421
1398 1422
1399 /* Update samplers */ 1423 /* Update samplers */
1400
1401 for ( i = 0 ; i < push_list_size ; i++ ) 1424 for ( i = 0 ; i < push_list_size ; i++ )
1402 { 1425 {
1403 RPS_sampler_update (prot_sampler, &push_list[i]); 1426 RPS_sampler_update (prot_sampler, &push_list[i]);
@@ -1421,6 +1444,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1421 struct GNUNET_TIME_Relative half_round_interval; 1444 struct GNUNET_TIME_Relative half_round_interval;
1422 unsigned int rand_delay; 1445 unsigned int rand_delay;
1423 1446
1447
1424 /* Compute random time value between .5 * round_interval and 1.5 *round_interval */ 1448 /* Compute random time value between .5 * round_interval and 1.5 *round_interval */
1425 half_round_interval = GNUNET_TIME_relative_divide (round_interval, 2); 1449 half_round_interval = GNUNET_TIME_relative_divide (round_interval, 2);
1426 do 1450 do
@@ -1502,26 +1526,27 @@ init_peer_cb (void *cls,
1502} 1526}
1503 1527
1504 1528
1505///** 1529/**
1506// * Clean the send channel of a peer 1530 * Clean the send channel of a peer
1507// */ 1531 */
1508//void 1532void
1509//peer_clean (const struct GNUNET_PeerIdentity *peer) 1533peer_clean (const struct GNUNET_PeerIdentity *peer)
1510//{ 1534{
1511// struct PeerContext *peer_ctx; 1535 struct PeerContext *peer_ctx;
1512// struct GNUNET_CADET_Channel *channel; 1536 struct GNUNET_CADET_Channel *channel;
1513// 1537
1514// if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) 1538 if (GNUNET_YES != in_arr (gossip_list, gossip_list_size, peer)
1515// { 1539 && GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
1516// peer_ctx = get_peer_ctx (peer_map, peer); 1540 {
1517// if (NULL != peer_ctx->send_channel) 1541 peer_ctx = get_peer_ctx (peer_map, peer);
1518// { 1542 if (NULL != peer_ctx->send_channel)
1519// channel = peer_ctx->send_channel; 1543 {
1520// peer_ctx->send_channel = NULL; 1544 channel = peer_ctx->send_channel;
1521// GNUNET_CADET_channel_destroy (channel); 1545 peer_ctx->send_channel = NULL;
1522// } 1546 GNUNET_CADET_channel_destroy (channel);
1523// } 1547 }
1524//} 1548 }
1549}
1525 1550
1526 1551
1527/** 1552/**
@@ -1604,7 +1629,8 @@ shutdown_task (void *cls,
1604 1629
1605 1630
1606 { 1631 {
1607 if (GNUNET_SYSERR == GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL)) 1632 if (GNUNET_SYSERR ==
1633 GNUNET_CONTAINER_multipeermap_iterate (peer_map, peer_remove_cb, NULL))
1608 LOG (GNUNET_ERROR_TYPE_WARNING, 1634 LOG (GNUNET_ERROR_TYPE_WARNING,
1609 "Iterating over peers to disconnect from them was cancelled\n"); 1635 "Iterating over peers to disconnect from them was cancelled\n");
1610 } 1636 }