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 /src/rps | |
parent | e05d529024e267dda1d65dd982a1d10a222ec7ca (diff) | |
download | gnunet-4ac8228b8f4940c0466b5d8c596005040b1647d0.tar.gz gnunet-4ac8228b8f4940c0466b5d8c596005040b1647d0.zip |
RPS: Some fixes
Diffstat (limited to 'src/rps')
-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) | |||
306 | struct GNUNET_TIME_Relative last_request_diff; | 306 | struct GNUNET_TIME_Relative last_request_diff; |
307 | struct RPS_Sampler *sampler; | 307 | struct RPS_Sampler *sampler; |
308 | double prob_observed_n; | 308 | double prob_observed_n; |
309 | uint32_t num_observed; | ||
309 | 310 | ||
310 | gpc->get_peer_task = NULL; | 311 | gpc->get_peer_task = NULL; |
311 | gpc->notify_ctx = NULL; | 312 | gpc->notify_ctx = NULL; |
@@ -380,10 +381,10 @@ sampler_mod_get_rand_peer (void *cls) | |||
380 | s_elem->num_peers, | 381 | s_elem->num_peers, |
381 | sampler->deficiency_factor); | 382 | sampler->deficiency_factor); |
382 | /* check if probability is above desired */ | 383 | /* check if probability is above desired */ |
383 | if (prob_observed_n >= sampler->desired_probability) | 384 | if (prob_observed_n < sampler->desired_probability) |
384 | { | 385 | { |
385 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 386 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
386 | "Probability of having observed all peers (%d) too small ( < %d).\n", | 387 | "Probability of having observed all peers (%f) too small ( < %f).\n", |
387 | prob_observed_n, | 388 | prob_observed_n, |
388 | sampler->desired_probability); | 389 | sampler->desired_probability); |
389 | GNUNET_assert (NULL == gpc->notify_ctx); | 390 | GNUNET_assert (NULL == gpc->notify_ctx); |
@@ -404,6 +405,7 @@ sampler_mod_get_rand_peer (void *cls) | |||
404 | // s_elem->num_change, | 405 | // s_elem->num_change, |
405 | // GNUNET_NO); | 406 | // GNUNET_NO); |
406 | 407 | ||
408 | num_observed = s_elem->num_peers; | ||
407 | RPS_sampler_elem_reinit (s_elem); | 409 | RPS_sampler_elem_reinit (s_elem); |
408 | s_elem->last_client_request = GNUNET_TIME_absolute_get (); | 410 | s_elem->last_client_request = GNUNET_TIME_absolute_get (); |
409 | 411 | ||
@@ -419,7 +421,7 @@ sampler_mod_get_rand_peer (void *cls) | |||
419 | gpc->req_single_info_handle->gpc_tail, | 421 | gpc->req_single_info_handle->gpc_tail, |
420 | gpc); | 422 | gpc); |
421 | } | 423 | } |
422 | gpc->cont (gpc->cont_cls, gpc->id, prob_observed_n, s_elem->num_peers); | 424 | gpc->cont (gpc->cont_cls, gpc->id, prob_observed_n, num_observed); |
423 | GNUNET_free (gpc); | 425 | GNUNET_free (gpc); |
424 | } | 426 | } |
425 | 427 | ||
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 (); | |||
73 | "Failed to create tmp_buf\n");\ | 73 | "Failed to create tmp_buf\n");\ |
74 | break;\ | 74 | break;\ |
75 | }\ | 75 | }\ |
76 | size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),"%s \n", tmp_buf);\ | 76 | (void) strncat(tmp_buf,"\n",512);\ |
77 | if (0 > size)\ | ||
78 | {\ | ||
79 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\ | ||
80 | "Failed to create tmp_buf\n");\ | ||
81 | break;\ | ||
82 | }\ | ||
83 | GNUNET_DISK_file_write (get_file_handle (file_name),\ | 77 | GNUNET_DISK_file_write (get_file_handle (file_name),\ |
84 | tmp_buf,\ | 78 | tmp_buf,\ |
85 | strnlen (tmp_buf, 512));\ | 79 | strnlen (tmp_buf, 512));\ |
@@ -96,13 +90,7 @@ close_all_files (); | |||
96 | "Failed to create tmp_buf\n");\ | 90 | "Failed to create tmp_buf\n");\ |
97 | break;\ | 91 | break;\ |
98 | }\ | 92 | }\ |
99 | size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),"%s\n", tmp_buf);\ | 93 | (void) strncat(tmp_buf,"\n",len);\ |
100 | if (0 > size)\ | ||
101 | {\ | ||
102 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\ | ||
103 | "Failed to create tmp_buf\n");\ | ||
104 | break;\ | ||
105 | }\ | ||
106 | GNUNET_DISK_file_write (get_file_handle (file_name),\ | 94 | GNUNET_DISK_file_write (get_file_handle (file_name),\ |
107 | tmp_buf,\ | 95 | tmp_buf,\ |
108 | strnlen (tmp_buf, len));\ | 96 | strnlen (tmp_buf, len));\ |