summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-02-16 18:56:22 +0000
committerJulius Bünger <buenger@mytum.de>2015-02-16 18:56:22 +0000
commitf4215c5cfa1a76c75aee6ceff1da057f2fa20c2a (patch)
tree2ce680cb7d321b04faeb87dcce8ee9a0eb8e27a6 /src
parent0f5f329643649dfadc85a89273b845d1854e8f6d (diff)
- fixed slow startup of service
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c57
-rw-r--r--src/rps/gnunet-service-rps_sampler.c10
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,
unsigned int best_path) // "How long is the best path?
// (0 = unknown, 1 = ourselves, 2 = neighbor)"
{
- struct GNUNET_SERVER_Handle *server;
struct PeerOutstandingOp out_op;
struct PeerContext *peer_ctx;
- server = (struct GNUNET_SERVER_Handle *) cls;
if (NULL != peer
&& 0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, peer))
{
@@ -1501,32 +1499,32 @@ init_peer_cb (void *cls,
// maybe create a function for that
peer_ctx = get_peer_ctx (peer_map, peer);
- // FIXME this peer might already be marked as LIVE
- if (GNUNET_NO == insert_in_sampler_scheduled (peer_ctx))
+ if (GNUNET_YES != get_peer_flag (peer_ctx, VALID))
{
- out_op.op = insert_in_sampler;
- out_op.op_cls = NULL;
- GNUNET_array_append (peer_ctx->outstanding_ops,
- peer_ctx->num_outstanding_ops,
- out_op);
- }
+ if (GNUNET_NO == insert_in_sampler_scheduled (peer_ctx))
+ {
+ out_op.op = insert_in_sampler;
+ out_op.op_cls = NULL;
+ GNUNET_array_append (peer_ctx->outstanding_ops,
+ peer_ctx->num_outstanding_ops,
+ out_op);
+ }
- if (GNUNET_NO == insert_in_gossip_list_scheduled (peer_ctx))
- {
- out_op.op = insert_in_gossip_list;
- out_op.op_cls = NULL;
- GNUNET_array_append (peer_ctx->outstanding_ops,
- peer_ctx->num_outstanding_ops,
- out_op);
- }
+ if (GNUNET_NO == insert_in_gossip_list_scheduled (peer_ctx))
+ {
+ out_op.op = insert_in_gossip_list;
+ out_op.op_cls = NULL;
+ GNUNET_array_append (peer_ctx->outstanding_ops,
+ peer_ctx->num_outstanding_ops,
+ out_op);
+ }
- /* Trigger livelyness test on peer */
- (void) get_channel (peer_map, peer);
+ /* Trigger livelyness test on peer */
+ (void) get_channel (peer_map, peer);
+ }
// send push/pull to each of those peers?
}
- else if (NULL == peer)
- rps_start (server);
}
@@ -1774,14 +1772,12 @@ rps_start (struct GNUNET_SERVER_Handle *server)
LOG (GNUNET_ERROR_TYPE_DEBUG, "Ready to receive requests from clients\n");
- num_hist_update_tasks = 0;
-
do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL);
LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n");
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
- NULL);
+ &shutdown_task,
+ NULL);
}
@@ -1886,10 +1882,15 @@ run (void *cls,
pending_pull_reply_list_size = 0;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting peers from CADET\n");
- GNUNET_CADET_get_peers (cadet_handle, &init_peer_cb, server);
+ num_hist_update_tasks = 0;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting peers from CADET\n");
+ GNUNET_CADET_get_peers (cadet_handle, &init_peer_cb, NULL);
// TODO send push/pull to each of those peers?
+
+
+ rps_start (server);
}
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)
uint32_t tmp_client_get_index;
gpc->get_peer_task = NULL;
- GNUNET_CONTAINER_DLL_remove (gpc_head, gpc_tail, gpc);
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
@@ -630,13 +629,14 @@ sampler_get_rand_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
do
{ /* Get first non empty sampler */
if (tmp_client_get_index == client_get_index)
- {
+ { /* We once cycled over the whole list */
LOG (GNUNET_ERROR_TYPE_DEBUG, "reached tmp_index %" PRIX32 ".\n",
client_get_index);
GNUNET_assert (NULL == gpc->get_peer_task);
gpc->get_peer_task =
GNUNET_SCHEDULER_add_delayed (gpc->sampler->max_round_interval,
- &sampler_get_rand_peer, cls);
+ &sampler_get_rand_peer,
+ cls);
return;
}
@@ -680,7 +680,8 @@ sampler_get_rand_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_assert (NULL == gpc->get_peer_task);
gpc->get_peer_task =
GNUNET_SCHEDULER_add_delayed (gpc->sampler->max_round_interval,
- &sampler_get_rand_peer, cls);
+ &sampler_get_rand_peer,
+ cls);
return;
}
// TODO add other reasons to wait here
@@ -688,6 +689,7 @@ sampler_get_rand_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
s_elem->last_client_request = GNUNET_TIME_absolute_get ();
+ GNUNET_CONTAINER_DLL_remove (gpc_head, gpc_tail, gpc);
gpc->cont (gpc->cont_cls, gpc->id);
GNUNET_free (gpc);
}