diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-04-16 16:17:08 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-04-16 16:17:08 +0000 |
commit | 55dc08b2dd423ecb9ab96676f015aa9a7d5376dc (patch) | |
tree | f38327e6d5dd59591e1283f283e8ab48782b1367 /src/testbed | |
parent | 84d0f5e3b8a3389931cd89268244717a3ffae6db (diff) | |
download | gnunet-55dc08b2dd423ecb9ab96676f015aa9a7d5376dc.tar.gz gnunet-55dc08b2dd423ecb9ab96676f015aa9a7d5376dc.zip |
- stop iterating through waiting operations earlier
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/testbed_api_operations.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/testbed/testbed_api_operations.c b/src/testbed/testbed_api_operations.c index ed8461606..fd1df0e76 100644 --- a/src/testbed/testbed_api_operations.c +++ b/src/testbed/testbed_api_operations.c | |||
@@ -547,8 +547,11 @@ merge_ops (struct GNUNET_TESTBED_Operation ***old, | |||
547 | * Checks for the readiness of an operation and schedules a operation start task | 547 | * Checks for the readiness of an operation and schedules a operation start task |
548 | * | 548 | * |
549 | * @param op the operation | 549 | * @param op the operation |
550 | * @param GNUNET_NO if the given operation cannot be made active; GNUNET_YES if | ||
551 | * it can be activated (has enough resources) and is kept in ready | ||
552 | * queue | ||
550 | */ | 553 | */ |
551 | static void | 554 | static int |
552 | check_readiness (struct GNUNET_TESTBED_Operation *op) | 555 | check_readiness (struct GNUNET_TESTBED_Operation *op) |
553 | { | 556 | { |
554 | struct GNUNET_TESTBED_Operation **evict_ops; | 557 | struct GNUNET_TESTBED_Operation **evict_ops; |
@@ -569,7 +572,7 @@ check_readiness (struct GNUNET_TESTBED_Operation *op) | |||
569 | &ops, &n_ops)) | 572 | &ops, &n_ops)) |
570 | { | 573 | { |
571 | GNUNET_free_non_null (evict_ops); | 574 | GNUNET_free_non_null (evict_ops); |
572 | return; | 575 | return GNUNET_NO; |
573 | } | 576 | } |
574 | if (NULL == ops) | 577 | if (NULL == ops) |
575 | continue; | 578 | continue; |
@@ -584,12 +587,13 @@ check_readiness (struct GNUNET_TESTBED_Operation *op) | |||
584 | evict_ops = NULL; | 587 | evict_ops = NULL; |
585 | /* Evicting the operations should schedule this operation */ | 588 | /* Evicting the operations should schedule this operation */ |
586 | GNUNET_assert (OP_STATE_READY == op->state); | 589 | GNUNET_assert (OP_STATE_READY == op->state); |
587 | return; | 590 | return GNUNET_YES; |
588 | } | 591 | } |
589 | for (i = 0; i < op->nqueues; i++) | 592 | for (i = 0; i < op->nqueues; i++) |
590 | op->queues[i]->active += op->nres[i]; | 593 | op->queues[i]->active += op->nres[i]; |
591 | change_state (op, OP_STATE_READY); | 594 | change_state (op, OP_STATE_READY); |
592 | rq_add (op); | 595 | rq_add (op); |
596 | return GNUNET_YES; | ||
593 | } | 597 | } |
594 | 598 | ||
595 | 599 | ||
@@ -699,7 +703,8 @@ recheck_waiting (struct OperationQueue *opq) | |||
699 | while (NULL != entry) | 703 | while (NULL != entry) |
700 | { | 704 | { |
701 | entry2 = entry->next; | 705 | entry2 = entry->next; |
702 | check_readiness (entry->op); | 706 | if (GNUNET_NO == check_readiness (entry->op)) |
707 | break; | ||
703 | entry = entry2; | 708 | entry = entry2; |
704 | } | 709 | } |
705 | } | 710 | } |
@@ -786,7 +791,7 @@ GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation *op) | |||
786 | { | 791 | { |
787 | GNUNET_assert (NULL == op->rq_entry); | 792 | GNUNET_assert (NULL == op->rq_entry); |
788 | change_state (op, OP_STATE_WAITING); | 793 | change_state (op, OP_STATE_WAITING); |
789 | check_readiness (op); | 794 | (void) check_readiness (op); |
790 | } | 795 | } |
791 | 796 | ||
792 | 797 | ||
@@ -812,6 +817,8 @@ GNUNET_TESTBED_operation_inactivate_ (struct GNUNET_TESTBED_Operation *op) | |||
812 | nqueues = op->nqueues; | 817 | nqueues = op->nqueues; |
813 | ms = sizeof (struct OperationQueue *) * nqueues; | 818 | ms = sizeof (struct OperationQueue *) * nqueues; |
814 | queues = GNUNET_malloc (ms); | 819 | queues = GNUNET_malloc (ms); |
820 | /* Cloning is needed as the operation be released by waiting operations and | ||
821 | hence its nqueues memory ptr will be freed */ | ||
815 | GNUNET_assert (NULL != (queues = memcpy (queues, op->queues, ms))); | 822 | GNUNET_assert (NULL != (queues = memcpy (queues, op->queues, ms))); |
816 | for (i = 0; i < nqueues; i++) | 823 | for (i = 0; i < nqueues; i++) |
817 | recheck_waiting (queues[i]); | 824 | recheck_waiting (queues[i]); |