aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testbed/testbed_api_testbed.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index 767d91cb9..09e9cacb5 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -293,6 +293,13 @@ struct RunContext
293 293
294}; 294};
295 295
296
297/**
298 * Return a 32-bit key from a pointer
299 *
300 * @param rcop the pointer
301 * @return 32-bit key
302 */
296static uint32_t 303static uint32_t
297rcop_key (void *rcop) 304rcop_key (void *rcop)
298{ 305{
@@ -300,13 +307,31 @@ rcop_key (void *rcop)
300} 307}
301 308
302 309
310/**
311 * Context information used for finding a pointer in the rcop_map
312 */
303struct SearchContext 313struct SearchContext
304{ 314{
315 /**
316 * The operation pointer to look for
317 */
305 struct GNUNET_TESTBED_Operation *query; 318 struct GNUNET_TESTBED_Operation *query;
306 319
320 /**
321 * The Run context operation which has the operation being queried
322 */
307 struct RunContextOperation *result; 323 struct RunContextOperation *result;
308}; 324};
309 325
326
327/**
328 * Iterator for searching over the elements matching a given query
329 *
330 * @param cls the SearchContext
331 * @param key the 32-bit key
332 * @param value the RunContextOperation element
333 * @return GNUNET_YES to continue iteration; GNUNET_NO to cancel it
334 */
310static int 335static int
311search_iterator (void *cls, uint32_t key, void *value) 336search_iterator (void *cls, uint32_t key, void *value)
312{ 337{
@@ -323,6 +348,15 @@ search_iterator (void *cls, uint32_t key, void *value)
323 return GNUNET_YES; 348 return GNUNET_YES;
324} 349}
325 350
351
352/**
353 * Initiate a search for the given operation in the rcop_map
354 *
355 * @param rc the RunContext whose rcop_map will be searched for the given
356 * operation
357 * @param op the given operation to search for
358 * @return the matching RunContextOperation if found; NULL if not
359 */
326static struct RunContextOperation * 360static struct RunContextOperation *
327search_rcop (struct RunContext *rc, struct GNUNET_TESTBED_Operation *op) 361search_rcop (struct RunContext *rc, struct GNUNET_TESTBED_Operation *op)
328{ 362{
@@ -342,6 +376,13 @@ search_rcop (struct RunContext *rc, struct GNUNET_TESTBED_Operation *op)
342 return NULL; 376 return NULL;
343} 377}
344 378
379
380/**
381 * Insert an RunContextOperation into the rcop_map of the given RunContext
382 *
383 * @param rc the RunContext into whose map is to be used for insertion
384 * @param rcop the RunContextOperation to insert
385 */
345static void 386static void
346insert_rcop (struct RunContext *rc, struct RunContextOperation *rcop) 387insert_rcop (struct RunContext *rc, struct RunContextOperation *rcop)
347{ 388{
@@ -351,6 +392,14 @@ insert_rcop (struct RunContext *rc, struct RunContextOperation *rcop)
351 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 392 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
352} 393}
353 394
395
396/**
397 * Remove a RunContextOperation from the rcop_map of the given RunContext
398 *
399 * @param rc the RunContext from whose map the given RunContextOperaton has to
400 * be removed
401 * @param rcop the RunContextOperation
402 */
354static void 403static void
355remove_rcop (struct RunContext *rc, struct RunContextOperation *rcop) 404remove_rcop (struct RunContext *rc, struct RunContextOperation *rcop)
356{ 405{
@@ -395,6 +444,15 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
395 GNUNET_free (rc); 444 GNUNET_free (rc);
396} 445}
397 446
447
448/**
449 * Iterator for cleaning up elements from rcop_map
450 *
451 * @param cls the RunContext
452 * @param key the 32-bit key
453 * @param value the RunContextOperation element
454 * @return always GNUNET_YES
455 */
398static int 456static int
399rcop_cleanup_iterator (void *cls, uint32_t key, void *value) 457rcop_cleanup_iterator (void *cls, uint32_t key, void *value)
400{ 458{
@@ -408,6 +466,13 @@ rcop_cleanup_iterator (void *cls, uint32_t key, void *value)
408 return GNUNET_YES; 466 return GNUNET_YES;
409} 467}
410 468
469
470/**
471 * Frees memory, closes pending operations, cancels actives tasks of the given
472 * RunContext
473 *
474 * @param rc the RunContext
475 */
411static void 476static void
412cleanup (struct RunContext *rc) 477cleanup (struct RunContext *rc)
413{ 478{
@@ -509,6 +574,12 @@ shutdown_now (struct RunContext *rc)
509} 574}
510 575
511 576
577/**
578 * Task run upon any interrupt. Common ones are SIGINT & SIGTERM.
579 *
580 * @param cls the RunContext which has to be acted upon
581 * @param tc the scheduler task context
582 */
512static void 583static void
513interrupt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 584interrupt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
514{ 585{