gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35273 - gnunet/src/rps


From: gnunet
Subject: [GNUnet-SVN] r35273 - gnunet/src/rps
Date: Mon, 16 Feb 2015 19:56:22 +0100

Author: ch3
Date: 2015-02-16 19:56:22 +0100 (Mon, 16 Feb 2015)
New Revision: 35273

Modified:
   gnunet/src/rps/gnunet-service-rps.c
   gnunet/src/rps/gnunet-service-rps_sampler.c
Log:
- fixed slow startup of service

Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-02-15 17:20:19 UTC (rev 35272)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-02-16 18:56:22 UTC (rev 35273)
@@ -1487,11 +1487,9 @@
               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 @@
 
     // 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 @@
   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 @@
   pending_pull_reply_list_size = 0;
 
 
+  num_hist_update_tasks = 0;
+
+
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting peers from CADET\n");
-  GNUNET_CADET_get_peers (cadet_handle, &init_peer_cb, server);
+  GNUNET_CADET_get_peers (cadet_handle, &init_peer_cb, NULL);
+  // TODO send push/pull to each of those peers?
 
-  // TODO send push/pull to each of those peers?
+
+  rps_start (server);
 }
 
 

Modified: gnunet/src/rps/gnunet-service-rps_sampler.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps_sampler.c 2015-02-15 17:20:19 UTC (rev 
35272)
+++ gnunet/src/rps/gnunet-service-rps_sampler.c 2015-02-16 18:56:22 UTC (rev 
35273)
@@ -610,7 +610,6 @@
   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 @@
   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 @@
       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 @@
 
   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);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]