X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ftestbed%2Ftestbed_api_operations.c;h=47d135ffd47d09532d5c44a61bd788c6a88b5156;hb=a900b29ddaa9ea46c731b054b5e3ef3e725b95a8;hp=ed8461606ac5ec89a4d99486887576f1a5be45b2;hpb=05126a4092d93b60bb0d941519f1ec5794bc8a69;p=oweals%2Fgnunet.git diff --git a/src/testbed/testbed_api_operations.c b/src/testbed/testbed_api_operations.c index ed8461606..47d135ffd 100644 --- a/src/testbed/testbed_api_operations.c +++ b/src/testbed/testbed_api_operations.c @@ -548,7 +548,7 @@ merge_ops (struct GNUNET_TESTBED_Operation ***old, * * @param op the operation */ -static void +static int check_readiness (struct GNUNET_TESTBED_Operation *op) { struct GNUNET_TESTBED_Operation **evict_ops; @@ -569,7 +569,7 @@ check_readiness (struct GNUNET_TESTBED_Operation *op) &ops, &n_ops)) { GNUNET_free_non_null (evict_ops); - return; + return GNUNET_NO; } if (NULL == ops) continue; @@ -584,12 +584,13 @@ check_readiness (struct GNUNET_TESTBED_Operation *op) evict_ops = NULL; /* Evicting the operations should schedule this operation */ GNUNET_assert (OP_STATE_READY == op->state); - return; + return GNUNET_YES; } for (i = 0; i < op->nqueues; i++) op->queues[i]->active += op->nres[i]; change_state (op, OP_STATE_READY); rq_add (op); + return GNUNET_YES; } @@ -699,7 +700,8 @@ recheck_waiting (struct OperationQueue *opq) while (NULL != entry) { entry2 = entry->next; - check_readiness (entry->op); + if (GNUNET_NO == check_readiness (entry->op)) + break; entry = entry2; } } @@ -786,7 +788,7 @@ GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation *op) { GNUNET_assert (NULL == op->rq_entry); change_state (op, OP_STATE_WAITING); - check_readiness (op); + (void) check_readiness (op); } @@ -812,6 +814,8 @@ GNUNET_TESTBED_operation_inactivate_ (struct GNUNET_TESTBED_Operation *op) nqueues = op->nqueues; ms = sizeof (struct OperationQueue *) * nqueues; queues = GNUNET_malloc (ms); + /* Cloning is needed as the operation be released by waiting operations and + hence its nqueues memory ptr will be freed */ GNUNET_assert (NULL != (queues = memcpy (queues, op->queues, ms))); for (i = 0; i < nqueues; i++) recheck_waiting (queues[i]);