From f4d0fb91c3850eb69a3e25800518d974bc7ee1f7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 20 May 2018 18:54:47 +0200 Subject: [PATCH] add logic to count concurrently active GNS requests --- src/gns/gnunet-gns-benchmark.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gns/gnunet-gns-benchmark.c b/src/gns/gnunet-gns-benchmark.c index 3754eec09..574251c87 100644 --- a/src/gns/gnunet-gns-benchmark.c +++ b/src/gns/gnunet-gns-benchmark.c @@ -84,7 +84,7 @@ struct Request * this struct (optimizing memory consumption by reducing * total number of allocations). */ - char *hostname; + const char *hostname; /** * While we are fetching the record, the value is set to the @@ -176,6 +176,11 @@ static struct GNUNET_TIME_Relative request_delay; */ static struct GNUNET_TIME_Relative timeout; +/** + * Number of requests we have concurrently active. + */ +static unsigned int active_cnt; + /** * Free @a req and data structures reachable from it. @@ -210,6 +215,7 @@ process_result (void *cls, (void) gns_tld; (void) rd_count; (void) rd; + active_cnt--; req->lr = NULL; req->latency = GNUNET_TIME_absolute_get_duration (req->op_start_time); GNUNET_CONTAINER_DLL_remove (act_head, @@ -244,11 +250,14 @@ process_queue (void *cls) duration = GNUNET_TIME_absolute_get_duration (req->op_start_time); if (duration.rel_value_us < timeout.rel_value_us) break; - GNUNET_GNS_lookup_with_tld_cancel (req->lr); GNUNET_CONTAINER_DLL_remove (act_head, act_tail, req); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Failing request `%s' due to timeout\n", + req->hostname); failures[req->cat]++; + active_cnt--; free_request (req); } if (NULL == (req = todo_head)) @@ -274,7 +283,12 @@ process_queue (void *cls) act_tail, req); lookups[req->cat]++; + active_cnt++; req->op_start_time = GNUNET_TIME_absolute_get (); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Starting request `%s' (%u in parallel)\n", + req->hostname, + active_cnt); req->lr = GNUNET_GNS_lookup_with_tld (gns, req->hostname, GNUNET_GNSRECORD_TYPE_ANY, -- 2.25.1