diff options
-rw-r--r-- | src/rps/gnunet-service-rps.c | 57 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps_sampler.c | 10 |
2 files changed, 35 insertions, 32 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index d2a8fa0d0..489e415c6 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -1487,11 +1487,9 @@ init_peer_cb (void *cls, | |||
1487 | unsigned int best_path) // "How long is the best path? | 1487 | unsigned int best_path) // "How long is the best path? |
1488 | // (0 = unknown, 1 = ourselves, 2 = neighbor)" | 1488 | // (0 = unknown, 1 = ourselves, 2 = neighbor)" |
1489 | { | 1489 | { |
1490 | struct GNUNET_SERVER_Handle *server; | ||
1491 | struct PeerOutstandingOp out_op; | 1490 | struct PeerOutstandingOp out_op; |
1492 | struct PeerContext *peer_ctx; | 1491 | struct PeerContext *peer_ctx; |
1493 | 1492 | ||
1494 | server = (struct GNUNET_SERVER_Handle *) cls; | ||
1495 | if (NULL != peer | 1493 | if (NULL != peer |
1496 | && 0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, peer)) | 1494 | && 0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, peer)) |
1497 | { | 1495 | { |
@@ -1501,32 +1499,32 @@ init_peer_cb (void *cls, | |||
1501 | 1499 | ||
1502 | // maybe create a function for that | 1500 | // maybe create a function for that |
1503 | peer_ctx = get_peer_ctx (peer_map, peer); | 1501 | peer_ctx = get_peer_ctx (peer_map, peer); |
1504 | // FIXME this peer might already be marked as LIVE | 1502 | if (GNUNET_YES != get_peer_flag (peer_ctx, VALID)) |
1505 | if (GNUNET_NO == insert_in_sampler_scheduled (peer_ctx)) | ||
1506 | { | 1503 | { |
1507 | out_op.op = insert_in_sampler; | 1504 | if (GNUNET_NO == insert_in_sampler_scheduled (peer_ctx)) |
1508 | out_op.op_cls = NULL; | 1505 | { |
1509 | GNUNET_array_append (peer_ctx->outstanding_ops, | 1506 | out_op.op = insert_in_sampler; |
1510 | peer_ctx->num_outstanding_ops, | 1507 | out_op.op_cls = NULL; |
1511 | out_op); | 1508 | GNUNET_array_append (peer_ctx->outstanding_ops, |
1512 | } | 1509 | peer_ctx->num_outstanding_ops, |
1510 | out_op); | ||
1511 | } | ||
1513 | 1512 | ||
1514 | if (GNUNET_NO == insert_in_gossip_list_scheduled (peer_ctx)) | 1513 | if (GNUNET_NO == insert_in_gossip_list_scheduled (peer_ctx)) |
1515 | { | 1514 | { |
1516 | out_op.op = insert_in_gossip_list; | 1515 | out_op.op = insert_in_gossip_list; |
1517 | out_op.op_cls = NULL; | 1516 | out_op.op_cls = NULL; |
1518 | GNUNET_array_append (peer_ctx->outstanding_ops, | 1517 | GNUNET_array_append (peer_ctx->outstanding_ops, |
1519 | peer_ctx->num_outstanding_ops, | 1518 | peer_ctx->num_outstanding_ops, |
1520 | out_op); | 1519 | out_op); |
1521 | } | 1520 | } |
1522 | 1521 | ||
1523 | /* Trigger livelyness test on peer */ | 1522 | /* Trigger livelyness test on peer */ |
1524 | (void) get_channel (peer_map, peer); | 1523 | (void) get_channel (peer_map, peer); |
1524 | } | ||
1525 | 1525 | ||
1526 | // send push/pull to each of those peers? | 1526 | // send push/pull to each of those peers? |
1527 | } | 1527 | } |
1528 | else if (NULL == peer) | ||
1529 | rps_start (server); | ||
1530 | } | 1528 | } |
1531 | 1529 | ||
1532 | 1530 | ||
@@ -1774,14 +1772,12 @@ rps_start (struct GNUNET_SERVER_Handle *server) | |||
1774 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Ready to receive requests from clients\n"); | 1772 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Ready to receive requests from clients\n"); |
1775 | 1773 | ||
1776 | 1774 | ||
1777 | num_hist_update_tasks = 0; | ||
1778 | |||
1779 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); | 1775 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); |
1780 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); | 1776 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); |
1781 | 1777 | ||
1782 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1778 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
1783 | &shutdown_task, | 1779 | &shutdown_task, |
1784 | NULL); | 1780 | NULL); |
1785 | } | 1781 | } |
1786 | 1782 | ||
1787 | 1783 | ||
@@ -1886,10 +1882,15 @@ run (void *cls, | |||
1886 | pending_pull_reply_list_size = 0; | 1882 | pending_pull_reply_list_size = 0; |
1887 | 1883 | ||
1888 | 1884 | ||
1889 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting peers from CADET\n"); | 1885 | num_hist_update_tasks = 0; |
1890 | GNUNET_CADET_get_peers (cadet_handle, &init_peer_cb, server); | 1886 | |
1891 | 1887 | ||
1888 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting peers from CADET\n"); | ||
1889 | GNUNET_CADET_get_peers (cadet_handle, &init_peer_cb, NULL); | ||
1892 | // TODO send push/pull to each of those peers? | 1890 | // TODO send push/pull to each of those peers? |
1891 | |||
1892 | |||
1893 | rps_start (server); | ||
1893 | } | 1894 | } |
1894 | 1895 | ||
1895 | 1896 | ||
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c index 222a600bd..f1e48d9f8 100644 --- a/src/rps/gnunet-service-rps_sampler.c +++ b/src/rps/gnunet-service-rps_sampler.c | |||
@@ -610,7 +610,6 @@ sampler_get_rand_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
610 | uint32_t tmp_client_get_index; | 610 | uint32_t tmp_client_get_index; |
611 | 611 | ||
612 | gpc->get_peer_task = NULL; | 612 | gpc->get_peer_task = NULL; |
613 | GNUNET_CONTAINER_DLL_remove (gpc_head, gpc_tail, gpc); | ||
614 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 613 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
615 | return; | 614 | return; |
616 | 615 | ||
@@ -630,13 +629,14 @@ sampler_get_rand_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
630 | do | 629 | do |
631 | { /* Get first non empty sampler */ | 630 | { /* Get first non empty sampler */ |
632 | if (tmp_client_get_index == client_get_index) | 631 | if (tmp_client_get_index == client_get_index) |
633 | { | 632 | { /* We once cycled over the whole list */ |
634 | LOG (GNUNET_ERROR_TYPE_DEBUG, "reached tmp_index %" PRIX32 ".\n", | 633 | LOG (GNUNET_ERROR_TYPE_DEBUG, "reached tmp_index %" PRIX32 ".\n", |
635 | client_get_index); | 634 | client_get_index); |
636 | GNUNET_assert (NULL == gpc->get_peer_task); | 635 | GNUNET_assert (NULL == gpc->get_peer_task); |
637 | gpc->get_peer_task = | 636 | gpc->get_peer_task = |
638 | GNUNET_SCHEDULER_add_delayed (gpc->sampler->max_round_interval, | 637 | GNUNET_SCHEDULER_add_delayed (gpc->sampler->max_round_interval, |
639 | &sampler_get_rand_peer, cls); | 638 | &sampler_get_rand_peer, |
639 | cls); | ||
640 | return; | 640 | return; |
641 | } | 641 | } |
642 | 642 | ||
@@ -680,7 +680,8 @@ sampler_get_rand_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
680 | GNUNET_assert (NULL == gpc->get_peer_task); | 680 | GNUNET_assert (NULL == gpc->get_peer_task); |
681 | gpc->get_peer_task = | 681 | gpc->get_peer_task = |
682 | GNUNET_SCHEDULER_add_delayed (gpc->sampler->max_round_interval, | 682 | GNUNET_SCHEDULER_add_delayed (gpc->sampler->max_round_interval, |
683 | &sampler_get_rand_peer, cls); | 683 | &sampler_get_rand_peer, |
684 | cls); | ||
684 | return; | 685 | return; |
685 | } | 686 | } |
686 | // TODO add other reasons to wait here | 687 | // TODO add other reasons to wait here |
@@ -688,6 +689,7 @@ sampler_get_rand_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
688 | 689 | ||
689 | s_elem->last_client_request = GNUNET_TIME_absolute_get (); | 690 | s_elem->last_client_request = GNUNET_TIME_absolute_get (); |
690 | 691 | ||
692 | GNUNET_CONTAINER_DLL_remove (gpc_head, gpc_tail, gpc); | ||
691 | gpc->cont (gpc->cont_cls, gpc->id); | 693 | gpc->cont (gpc->cont_cls, gpc->id); |
692 | GNUNET_free (gpc); | 694 | GNUNET_free (gpc); |
693 | } | 695 | } |