From 3afe1a3435697b01fee557420a701fba1821dbe5 Mon Sep 17 00:00:00 2001 From: Julius Bünger Date: Mon, 8 Apr 2019 00:55:35 +0200 Subject: RPS: Retrieve more info from sampler for profiling --- src/rps/rps-sampler_client.c | 64 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) (limited to 'src/rps/rps-sampler_client.c') diff --git a/src/rps/rps-sampler_client.c b/src/rps/rps-sampler_client.c index 0de25df07..61f9b6385 100644 --- a/src/rps/rps-sampler_client.c +++ b/src/rps/rps-sampler_client.c @@ -158,6 +158,46 @@ struct RPS_SamplerRequestHandle void *cls; }; + +/** + * Closure to _get_rand_peer_info() + */ +struct RPS_SamplerRequestHandleSingleInfo +{ + /** + * DLL + */ + struct RPS_SamplerRequestHandleSingleInfo *next; + struct RPS_SamplerRequestHandleSingleInfo *prev; + + /** + * Pointer to the id + */ + struct GNUNET_PeerIdentity *id; + + /** + * Head and tail for the DLL to store the tasks for single requests + */ + struct GetPeerCls *gpc_head; + struct GetPeerCls *gpc_tail; + + /** + * Sampler. + */ + struct RPS_Sampler *sampler; + + /** + * Callback to be called when all ids are available. + */ + RPS_sampler_sinlge_info_ready_cb callback; + + /** + * Closure given to the callback + */ + void *cls; +}; + + ///** // * Global sampler variable. // */ @@ -269,7 +309,12 @@ sampler_mod_get_rand_peer (void *cls) gpc->get_peer_task = NULL; gpc->notify_ctx = NULL; - sampler = gpc->req_handle->sampler; + GNUNET_assert ( (NULL != gpc->req_handle) || + (NULL != gpc->req_single_info_handle) ); + if (NULL != gpc->req_handle) + sampler = gpc->req_handle->sampler; + else + sampler = gpc->req_single_info_handle->sampler; LOG (GNUNET_ERROR_TYPE_DEBUG, "Single peer was requested\n"); @@ -362,10 +407,19 @@ sampler_mod_get_rand_peer (void *cls) RPS_sampler_elem_reinit (s_elem); s_elem->last_client_request = GNUNET_TIME_absolute_get (); - GNUNET_CONTAINER_DLL_remove (gpc->req_handle->gpc_head, - gpc->req_handle->gpc_tail, - gpc); - gpc->cont (gpc->cont_cls, gpc->id); + if (NULL != gpc->req_handle) + { + GNUNET_CONTAINER_DLL_remove (gpc->req_handle->gpc_head, + gpc->req_handle->gpc_tail, + gpc); + } + else + { + GNUNET_CONTAINER_DLL_remove (gpc->req_single_info_handle->gpc_head, + gpc->req_single_info_handle->gpc_tail, + gpc); + } + gpc->cont (gpc->cont_cls, gpc->id, prob_observed_n, s_elem->num_peers); GNUNET_free (gpc); } -- cgit v1.2.3