aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps-sampler_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/rps-sampler_client.c')
-rw-r--r--src/rps/rps-sampler_client.c64
1 files changed, 59 insertions, 5 deletions
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
158 void *cls; 158 void *cls;
159}; 159};
160 160
161
162/**
163 * Closure to _get_rand_peer_info()
164 */
165struct RPS_SamplerRequestHandleSingleInfo
166{
167 /**
168 * DLL
169 */
170 struct RPS_SamplerRequestHandleSingleInfo *next;
171 struct RPS_SamplerRequestHandleSingleInfo *prev;
172
173 /**
174 * Pointer to the id
175 */
176 struct GNUNET_PeerIdentity *id;
177
178 /**
179 * Head and tail for the DLL to store the tasks for single requests
180 */
181 struct GetPeerCls *gpc_head;
182 struct GetPeerCls *gpc_tail;
183
184 /**
185 * Sampler.
186 */
187 struct RPS_Sampler *sampler;
188
189 /**
190 * Callback to be called when all ids are available.
191 */
192 RPS_sampler_sinlge_info_ready_cb callback;
193
194 /**
195 * Closure given to the callback
196 */
197 void *cls;
198};
199
200
161///** 201///**
162// * Global sampler variable. 202// * Global sampler variable.
163// */ 203// */
@@ -269,7 +309,12 @@ sampler_mod_get_rand_peer (void *cls)
269 309
270 gpc->get_peer_task = NULL; 310 gpc->get_peer_task = NULL;
271 gpc->notify_ctx = NULL; 311 gpc->notify_ctx = NULL;
272 sampler = gpc->req_handle->sampler; 312 GNUNET_assert ( (NULL != gpc->req_handle) ||
313 (NULL != gpc->req_single_info_handle) );
314 if (NULL != gpc->req_handle)
315 sampler = gpc->req_handle->sampler;
316 else
317 sampler = gpc->req_single_info_handle->sampler;
273 318
274 LOG (GNUNET_ERROR_TYPE_DEBUG, "Single peer was requested\n"); 319 LOG (GNUNET_ERROR_TYPE_DEBUG, "Single peer was requested\n");
275 320
@@ -362,10 +407,19 @@ sampler_mod_get_rand_peer (void *cls)
362 RPS_sampler_elem_reinit (s_elem); 407 RPS_sampler_elem_reinit (s_elem);
363 s_elem->last_client_request = GNUNET_TIME_absolute_get (); 408 s_elem->last_client_request = GNUNET_TIME_absolute_get ();
364 409
365 GNUNET_CONTAINER_DLL_remove (gpc->req_handle->gpc_head, 410 if (NULL != gpc->req_handle)
366 gpc->req_handle->gpc_tail, 411 {
367 gpc); 412 GNUNET_CONTAINER_DLL_remove (gpc->req_handle->gpc_head,
368 gpc->cont (gpc->cont_cls, gpc->id); 413 gpc->req_handle->gpc_tail,
414 gpc);
415 }
416 else
417 {
418 GNUNET_CONTAINER_DLL_remove (gpc->req_single_info_handle->gpc_head,
419 gpc->req_single_info_handle->gpc_tail,
420 gpc);
421 }
422 gpc->cont (gpc->cont_cls, gpc->id, prob_observed_n, s_elem->num_peers);
369 GNUNET_free (gpc); 423 GNUNET_free (gpc);
370} 424}
371 425