diff options
author | Julius Bünger <buenger@mytum.de> | 2019-04-09 00:46:16 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2019-04-09 00:46:16 +0200 |
commit | 4ac8228b8f4940c0466b5d8c596005040b1647d0 (patch) | |
tree | 03515eba19299a5ae038d8d7640c28ede48d96ae | |
parent | e05d529024e267dda1d65dd982a1d10a222ec7ca (diff) |
RPS: Some fixes
-rw-r--r-- | src/rps/rps-sampler_client.c | 8 | ||||
-rw-r--r-- | src/rps/rps-test_util.h | 16 |
2 files changed, 7 insertions, 17 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));\ |