aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-service-rps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/gnunet-service-rps.c')
-rw-r--r--src/rps/gnunet-service-rps.c64
1 files changed, 7 insertions, 57 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 0d2e68b4a..f66459802 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -609,8 +609,8 @@ cadet_ntfy_tmt_rdy_cb (void *cls, size_t size, void *buf)
609{ 609{
610 struct PeerContext *peer_ctx = (struct PeerContext *) cls; 610 struct PeerContext *peer_ctx = (struct PeerContext *) cls;
611 611
612 if (NULL != buf || 612 if (NULL != buf
613 0 != size) 613 && 0 != size)
614 peer_is_live (peer_ctx); 614 peer_is_live (peer_ctx);
615 615
616 //if (NULL != peer_ctx->is_live_task) 616 //if (NULL != peer_ctx->is_live_task)
@@ -1441,57 +1441,10 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1441} 1441}
1442 1442
1443 1443
1444/**
1445 * Open a connection to given peer and store channel and mq.
1446 */
1447 void
1448insertCB (void *cls, struct RPS_Sampler *sampler,
1449 const struct GNUNET_PeerIdentity *id)
1450{
1451 // We open a channel to be notified when this peer goes down.
1452 (void) get_channel (peer_map, id);
1453}
1454
1455
1456/**
1457 * Close the connection to given peer and delete channel and mq
1458 * if the peer is not anymore in the sampler.
1459 */
1460 void
1461removeCB (void *cls, struct RPS_Sampler *sampler,
1462 const struct GNUNET_PeerIdentity *id)
1463{
1464 size_t s;
1465 struct PeerContext *ctx;
1466
1467 s = RPS_sampler_count_id (sampler, id);
1468 if ( 1 >= s )
1469 {
1470 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, id)
1471 && 0 != GNUNET_CRYPTO_cmp_peer_identity (id, &own_identity))
1472 {
1473 ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, id);
1474 if (NULL != ctx->send_channel)
1475 {
1476 if (NULL != ctx->mq)
1477 {
1478 GNUNET_MQ_destroy (ctx->mq);
1479 ctx->mq = NULL;
1480 }
1481 // may already be freed at shutdown of cadet
1482 // maybe this fails at our own channel
1483 GNUNET_CADET_channel_destroy (ctx->send_channel);
1484 ctx->send_channel = NULL;
1485 }
1486 // TODO cleanup peer
1487 //(void) GNUNET_CONTAINER_multipeermap_remove_all (peer_map, id);
1488 }
1489 }
1490}
1491
1492static void 1444static void
1493rps_start (struct GNUNET_SERVER_Handle *server); 1445rps_start (struct GNUNET_SERVER_Handle *server);
1494 1446
1447
1495/** 1448/**
1496 * This is called from GNUNET_CADET_get_peers(). 1449 * This is called from GNUNET_CADET_get_peers().
1497 * 1450 *
@@ -1511,7 +1464,8 @@ init_peer_cb (void *cls,
1511 struct PeerContext *peer_ctx; 1464 struct PeerContext *peer_ctx;
1512 1465
1513 server = (struct GNUNET_SERVER_Handle *) cls; 1466 server = (struct GNUNET_SERVER_Handle *) cls;
1514 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, peer)) 1467 if (NULL != peer
1468 && 0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, peer))
1515 { 1469 {
1516 LOG (GNUNET_ERROR_TYPE_DEBUG, 1470 LOG (GNUNET_ERROR_TYPE_DEBUG,
1517 "Got peer %s (at %p) from CADET (gossip_list_size: %u)\n", 1471 "Got peer %s (at %p) from CADET (gossip_list_size: %u)\n",
@@ -1890,12 +1844,8 @@ run (void *cls,
1890 half_round_interval = GNUNET_TIME_relative_multiply (round_interval, .5); 1844 half_round_interval = GNUNET_TIME_relative_multiply (round_interval, .5);
1891 max_round_interval = GNUNET_TIME_relative_add (round_interval, half_round_interval); 1845 max_round_interval = GNUNET_TIME_relative_add (round_interval, half_round_interval);
1892 1846
1893 prot_sampler = RPS_sampler_init (sampler_size_est_need, max_round_interval, 1847 prot_sampler = RPS_sampler_init (sampler_size_est_need, max_round_interval);
1894 //insertCB, NULL, removeCB, NULL); 1848 client_sampler = RPS_sampler_init (sampler_size_est_need, max_round_interval);
1895 NULL, NULL, NULL, NULL);
1896 client_sampler = RPS_sampler_init (sampler_size_est_need, max_round_interval,
1897 //nsertCB, NULL, removeCB, NULL);
1898 NULL, NULL, NULL, NULL);
1899 1849
1900 /* Initialise push and pull maps */ 1850 /* Initialise push and pull maps */
1901 push_list = NULL; 1851 push_list = NULL;