gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (11029ef9d -> 4ac8228b8)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (11029ef9d -> 4ac8228b8)
Date: Tue, 09 Apr 2019 00:46:48 +0200

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a change to branch master
in repository gnunet.

    from 11029ef9d RPS service: Record the number of observed peers
     new e05d52902 RPS api: Correct type of callback and handle for collecting 
gossip
     new 4ac8228b8 RPS: Some fixes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/rps/rps-sampler_client.c |  8 +++++---
 src/rps/rps-test_util.h      | 16 ++--------------
 src/rps/rps_api.c            | 29 ++++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/src/rps/rps-sampler_client.c b/src/rps/rps-sampler_client.c
index 61f9b6385..20cd9d0c4 100644
--- a/src/rps/rps-sampler_client.c
+++ b/src/rps/rps-sampler_client.c
@@ -306,6 +306,7 @@ sampler_mod_get_rand_peer (void *cls)
   struct GNUNET_TIME_Relative last_request_diff;
   struct RPS_Sampler *sampler;
   double prob_observed_n;
+  uint32_t num_observed;
 
   gpc->get_peer_task = NULL;
   gpc->notify_ctx = NULL;
@@ -380,10 +381,10 @@ sampler_mod_get_rand_peer (void *cls)
                                            s_elem->num_peers,
                                            sampler->deficiency_factor);
   /* check if probability is above desired */
-  if (prob_observed_n >= sampler->desired_probability)
+  if (prob_observed_n < sampler->desired_probability)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Probability of having observed all peers (%d) too small ( < %d).\n",
+        "Probability of having observed all peers (%f) too small ( < %f).\n",
         prob_observed_n,
         sampler->desired_probability);
     GNUNET_assert (NULL == gpc->notify_ctx);
@@ -404,6 +405,7 @@ sampler_mod_get_rand_peer (void *cls)
 //                         s_elem->num_change,
 //                         GNUNET_NO);
 
+  num_observed = s_elem->num_peers;
   RPS_sampler_elem_reinit (s_elem);
   s_elem->last_client_request = GNUNET_TIME_absolute_get ();
 
@@ -419,7 +421,7 @@ sampler_mod_get_rand_peer (void *cls)
                                  gpc->req_single_info_handle->gpc_tail,
                                  gpc);
   }
-  gpc->cont (gpc->cont_cls, gpc->id, prob_observed_n, s_elem->num_peers);
+  gpc->cont (gpc->cont_cls, gpc->id, prob_observed_n, num_observed);
   GNUNET_free (gpc);
 }
 
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index 3094b9bea..d5a2db9de 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -73,13 +73,7 @@ close_all_files ();
            "Failed to create tmp_buf\n");\
       break;\
     }\
-    size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),"%s \n", tmp_buf);\
-    if (0 > size)\
-    {\
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
-           "Failed to create tmp_buf\n");\
-      break;\
-    }\
+    (void) strncat(tmp_buf,"\n",512);\
     GNUNET_DISK_file_write (get_file_handle (file_name),\
                             tmp_buf,\
                             strnlen (tmp_buf, 512));\
@@ -96,13 +90,7 @@ close_all_files ();
            "Failed to create tmp_buf\n");\
       break;\
     }\
-    size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),"%s\n", tmp_buf);\
-    if (0 > size)\
-    {\
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
-           "Failed to create tmp_buf\n");\
-      break;\
-    }\
+    (void) strncat(tmp_buf,"\n",len);\
     GNUNET_DISK_file_write (get_file_handle (file_name),\
                             tmp_buf,\
                             strnlen (tmp_buf, len));\
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index fd0c12f47..9e405fdef 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -419,6 +419,33 @@ collect_peers_cb (void *cls,
 }
 
 
+/**
+ * @brief Callback to collect the peers from the biased stream and put those
+ * into the sampler.
+ *
+ * This version is for the modified #GNUNET_RPS_Request_Handle_Single_Info
+ *
+ * @param cls The #GNUNET_RPS_Request_Handle
+ * @param num_peers The number of peer that have been returned
+ * @param peers The array of @a num_peers that have been returned
+ */
+static void
+collect_peers_info_cb (void *cls,
+                       uint64_t num_peers,
+                       const struct GNUNET_PeerIdentity *peers)
+{
+  struct GNUNET_RPS_Request_Handle_Single_Info *rhs = cls;
+
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Service sent %" PRIu64 " peers from stream\n",
+       num_peers);
+  for (uint64_t i = 0; i < num_peers; i++)
+  {
+    RPS_sampler_update (rhs->sampler, &peers[i]);
+  }
+}
+
+
 /* Get internals for debugging/profiling purposes */
 
 /**
@@ -979,7 +1006,7 @@ GNUNET_RPS_request_peer_info (struct GNUNET_RPS_Handle 
*rps_handle,
                                                    peer_info_ready_cb,
                                                    rhs);
   rhs->srh = GNUNET_RPS_stream_request (rps_handle,
-                                       collect_peers_cb,
+                                       collect_peers_info_cb,
                                        rhs); /* cls */
   rhs->ready_cb = ready_cb;
   rhs->ready_cb_cls = cls;

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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