diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-24 20:34:03 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-24 20:34:03 +0000 |
commit | e58e6a7ff78981fb4d592587a30e0a94b873a912 (patch) | |
tree | b401864812a88bf1b58972d5be74c480efbad932 /src/testbed | |
parent | 20e7f1aee4f3bcdd46ff99a5a9e5ba81765cb878 (diff) | |
download | gnunet-e58e6a7ff78981fb4d592587a30e0a94b873a912.tar.gz gnunet-e58e6a7ff78981fb4d592587a30e0a94b873a912.zip |
multiple operation queues for an operation
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 4 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_operations.c | 2 | ||||
-rw-r--r-- | src/testbed/testbed_api.c | 2 | ||||
-rw-r--r-- | src/testbed/testbed_api_operations.c | 60 | ||||
-rw-r--r-- | src/testbed/testbed_api_operations.h | 25 | ||||
-rw-r--r-- | src/testbed/testbed_api_peers.c | 6 | ||||
-rw-r--r-- | src/testbed/testbed_api_services.c | 1 | ||||
-rw-r--r-- | src/testbed/testbed_api_topology.c | 1 | ||||
-rw-r--r-- | src/testbed/x64_misc.supp | 10 |
9 files changed, 85 insertions, 26 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index 1c6bfe013..81cf29c5f 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -3265,8 +3265,8 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
3265 | /* rhc is now set to the existing one from the hash map by | 3265 | /* rhc is now set to the existing one from the hash map by |
3266 | reghost_match_iterator() */ | 3266 | reghost_match_iterator() */ |
3267 | /* if queue is empty then ignore creating focc and proceed with | 3267 | /* if queue is empty then ignore creating focc and proceed with |
3268 | normal forwarding */ | 3268 | normal forwarding */ |
3269 | if (NULL == rhc->focc_dll_head) | 3269 | if (RHC_OL_CONNECT == rhc->state) |
3270 | skip_focc = GNUNET_YES; | 3270 | skip_focc = GNUNET_YES; |
3271 | } | 3271 | } |
3272 | if (GNUNET_NO == skip_focc) | 3272 | if (GNUNET_NO == skip_focc) |
diff --git a/src/testbed/test_testbed_api_operations.c b/src/testbed/test_testbed_api_operations.c index af59cdaf5..45f2db103 100644 --- a/src/testbed/test_testbed_api_operations.c +++ b/src/testbed/test_testbed_api_operations.c | |||
@@ -194,8 +194,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
194 | op2 = GNUNET_TESTBED_operation_create_ (&op2, start_cb, release_cb); | 194 | op2 = GNUNET_TESTBED_operation_create_ (&op2, start_cb, release_cb); |
195 | GNUNET_TESTBED_operation_queue_insert_ (q1, op1); | 195 | GNUNET_TESTBED_operation_queue_insert_ (q1, op1); |
196 | GNUNET_TESTBED_operation_queue_insert_ (q2, op1); | 196 | GNUNET_TESTBED_operation_queue_insert_ (q2, op1); |
197 | GNUNET_TESTBED_operation_begin_wait_ (op1); | ||
197 | GNUNET_TESTBED_operation_queue_insert_ (q1, op2); | 198 | GNUNET_TESTBED_operation_queue_insert_ (q1, op2); |
198 | GNUNET_TESTBED_operation_queue_insert_ (q2, op2); | 199 | GNUNET_TESTBED_operation_queue_insert_ (q2, op2); |
200 | GNUNET_TESTBED_operation_begin_wait_ (op2); | ||
199 | result = TEST_INIT; | 201 | result = TEST_INIT; |
200 | } | 202 | } |
201 | 203 | ||
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 3d2d44897..c55e7373a 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -1884,6 +1884,7 @@ GNUNET_TESTBED_controller_link_2_ (void *op_cls, | |||
1884 | &oprelease_link_controllers); | 1884 | &oprelease_link_controllers); |
1885 | GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, | 1885 | GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, |
1886 | opc->op); | 1886 | opc->op); |
1887 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
1887 | return opc->op; | 1888 | return opc->op; |
1888 | } | 1889 | } |
1889 | 1890 | ||
@@ -2103,6 +2104,7 @@ GNUNET_TESTBED_get_slave_config_ (void *op_cls, | |||
2103 | &oprelease_get_slave_config); | 2104 | &oprelease_get_slave_config); |
2104 | GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, | 2105 | GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, |
2105 | opc->op); | 2106 | opc->op); |
2107 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
2106 | return opc->op; | 2108 | return opc->op; |
2107 | } | 2109 | } |
2108 | 2110 | ||
diff --git a/src/testbed/testbed_api_operations.c b/src/testbed/testbed_api_operations.c index b897cb453..f609b1770 100644 --- a/src/testbed/testbed_api_operations.c +++ b/src/testbed/testbed_api_operations.c | |||
@@ -78,14 +78,24 @@ struct OperationQueue | |||
78 | */ | 78 | */ |
79 | enum OperationState | 79 | enum OperationState |
80 | { | 80 | { |
81 | /** | 81 | /** |
82 | * The operation is currently waiting for resources | 82 | * The operation is just created and is in initial state |
83 | */ | 83 | */ |
84 | OP_STATE_INIT, | ||
85 | |||
86 | /** | ||
87 | * The operation is currently waiting for resources | ||
88 | */ | ||
84 | OP_STATE_WAITING, | 89 | OP_STATE_WAITING, |
85 | 90 | ||
86 | /** | 91 | /** |
87 | * The operation has started | 92 | * The operation is ready to be started |
88 | */ | 93 | */ |
94 | OP_STATE_READY, | ||
95 | |||
96 | /** | ||
97 | * The operation has started | ||
98 | */ | ||
89 | OP_STATE_STARTED | 99 | OP_STATE_STARTED |
90 | }; | 100 | }; |
91 | 101 | ||
@@ -164,8 +174,7 @@ check_readiness (struct GNUNET_TESTBED_Operation *op) | |||
164 | { | 174 | { |
165 | unsigned int i; | 175 | unsigned int i; |
166 | 176 | ||
167 | if (GNUNET_SCHEDULER_NO_TASK != op->start_task_id) | 177 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == op->start_task_id); |
168 | return; | ||
169 | for (i = 0; i < op->nqueues; i++) | 178 | for (i = 0; i < op->nqueues; i++) |
170 | { | 179 | { |
171 | if (0 == op->queues[i]->active) | 180 | if (0 == op->queues[i]->active) |
@@ -175,6 +184,7 @@ check_readiness (struct GNUNET_TESTBED_Operation *op) | |||
175 | { | 184 | { |
176 | op->queues[i]->active--; | 185 | op->queues[i]->active--; |
177 | } | 186 | } |
187 | op->state = OP_STATE_READY; | ||
178 | op->start_task_id = GNUNET_SCHEDULER_add_now (&call_start, op); | 188 | op->start_task_id = GNUNET_SCHEDULER_add_now (&call_start, op); |
179 | } | 189 | } |
180 | 190 | ||
@@ -195,6 +205,7 @@ GNUNET_TESTBED_operation_create_ (void *cls, OperationStart start, | |||
195 | 205 | ||
196 | op = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Operation)); | 206 | op = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Operation)); |
197 | op->start = start; | 207 | op->start = start; |
208 | op->state = OP_STATE_INIT; | ||
198 | op->release = release; | 209 | op->release = release; |
199 | op->cb_cls = cls; | 210 | op->cb_cls = cls; |
200 | op->start_task_id = GNUNET_SCHEDULER_NO_TASK; | 211 | op->start_task_id = GNUNET_SCHEDULER_NO_TASK; |
@@ -236,13 +247,10 @@ GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue) | |||
236 | 247 | ||
237 | 248 | ||
238 | /** | 249 | /** |
239 | * Add an operation to a queue. An operation can be in multiple | 250 | * Add an operation to a queue. An operation can be in multiple queues at |
240 | * queues at once. Once all queues permit the operation to become | 251 | * once. Once the operation is inserted into all the queues |
241 | * active, the operation will be activated. The actual activation | 252 | * GNUNET_TESTBED_operation_begin_wait_() has to be called to actually start |
242 | * will occur in a separate task (thus allowing multiple queue | 253 | * waiting for the operation to become active. |
243 | * insertions to be made without having the first one instantly | ||
244 | * trigger the operation if the first queue has sufficient | ||
245 | * resources). | ||
246 | * | 254 | * |
247 | * @param queue queue to add the operation to | 255 | * @param queue queue to add the operation to |
248 | * @param operation operation to add to the queue | 256 | * @param operation operation to add to the queue |
@@ -262,6 +270,24 @@ GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, | |||
262 | sizeof (struct OperationQueue *) * | 270 | sizeof (struct OperationQueue *) * |
263 | (++operation->nqueues)); | 271 | (++operation->nqueues)); |
264 | operation->queues[operation->nqueues - 1] = queue; | 272 | operation->queues[operation->nqueues - 1] = queue; |
273 | } | ||
274 | |||
275 | |||
276 | /** | ||
277 | * Marks the given operation as waiting on the queues. Once all queues permit | ||
278 | * the operation to become active, the operation will be activated. The actual | ||
279 | * activation will occur in a separate task (thus allowing multiple queue | ||
280 | * insertions to be made without having the first one instantly trigger the | ||
281 | * operation if the first queue has sufficient resources). | ||
282 | * | ||
283 | * @param operation the operation to marks as waiting | ||
284 | */ | ||
285 | void | ||
286 | GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation | ||
287 | *operation) | ||
288 | { | ||
289 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == operation->start_task_id); | ||
290 | operation->state = OP_STATE_WAITING; | ||
265 | check_readiness (operation); | 291 | check_readiness (operation); |
266 | } | 292 | } |
267 | 293 | ||
@@ -293,7 +319,7 @@ GNUNET_TESTBED_operation_queue_remove_ (struct OperationQueue *queue, | |||
293 | GNUNET_CONTAINER_DLL_remove (queue->head, queue->tail, entry); | 319 | GNUNET_CONTAINER_DLL_remove (queue->head, queue->tail, entry); |
294 | GNUNET_free (entry); | 320 | GNUNET_free (entry); |
295 | for (; NULL != entry2; entry2 = entry2->next) | 321 | for (; NULL != entry2; entry2 = entry2->next) |
296 | if (OP_STATE_STARTED != entry2->op->state) | 322 | if (OP_STATE_WAITING == entry2->op->state) |
297 | break; | 323 | break; |
298 | if (NULL == entry2) | 324 | if (NULL == entry2) |
299 | return; | 325 | return; |
diff --git a/src/testbed/testbed_api_operations.h b/src/testbed/testbed_api_operations.h index 519c68139..e78ed0fcc 100644 --- a/src/testbed/testbed_api_operations.h +++ b/src/testbed/testbed_api_operations.h | |||
@@ -59,13 +59,10 @@ GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue); | |||
59 | 59 | ||
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Add an operation to a queue. An operation can be in multiple | 62 | * Add an operation to a queue. An operation can be in multiple queues at |
63 | * queues at once. Once all queues permit the operation to become | 63 | * once. Once the operation is inserted into all the queues |
64 | * active, the operation will be activated. The actual activation | 64 | * GNUNET_TESTBED_operation_begin_wait_() has to be called to actually start |
65 | * will occur in a separate task (thus allowing multiple queue | 65 | * waiting for the operation to become active. |
66 | * insertions to be made without having the first one instantly | ||
67 | * trigger the operation if the first queue has sufficient | ||
68 | * resources). | ||
69 | * | 66 | * |
70 | * @param queue queue to add the operation to | 67 | * @param queue queue to add the operation to |
71 | * @param operation operation to add to the queue | 68 | * @param operation operation to add to the queue |
@@ -77,6 +74,20 @@ GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, | |||
77 | 74 | ||
78 | 75 | ||
79 | /** | 76 | /** |
77 | * Marks the given operation as waiting on the queues. Once all queues permit | ||
78 | * the operation to become active, the operation will be activated. The actual | ||
79 | * activation will occur in a separate task (thus allowing multiple queue | ||
80 | * insertions to be made without having the first one instantly trigger the | ||
81 | * operation if the first queue has sufficient resources). | ||
82 | * | ||
83 | * @param operation the operation to marks as waiting | ||
84 | */ | ||
85 | void | ||
86 | GNUNET_TESTBED_operation_begin_wait_ (struct GNUNET_TESTBED_Operation | ||
87 | *operation); | ||
88 | |||
89 | |||
90 | /** | ||
80 | * Remove an operation from a queue. This can be because the | 91 | * Remove an operation from a queue. This can be because the |
81 | * oeration was active and has completed (and the resources have | 92 | * oeration was active and has completed (and the resources have |
82 | * been released), or because the operation was cancelled and | 93 | * been released), or because the operation was cancelled and |
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index 527b0f70a..b509df40b 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c | |||
@@ -452,6 +452,7 @@ GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id, | |||
452 | &oprelease_peer_create); | 452 | &oprelease_peer_create); |
453 | GNUNET_TESTBED_operation_queue_insert_ (controller->opq_parallel_operations, | 453 | GNUNET_TESTBED_operation_queue_insert_ (controller->opq_parallel_operations, |
454 | opc->op); | 454 | opc->op); |
455 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
455 | return opc->op; | 456 | return opc->op; |
456 | } | 457 | } |
457 | 458 | ||
@@ -532,6 +533,7 @@ GNUNET_TESTBED_peer_start (void *op_cls, | |||
532 | &oprelease_peer_start); | 533 | &oprelease_peer_start); |
533 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, | 534 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
534 | opc->op); | 535 | opc->op); |
536 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
535 | return opc->op; | 537 | return opc->op; |
536 | } | 538 | } |
537 | 539 | ||
@@ -568,6 +570,7 @@ GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer, | |||
568 | &oprelease_peer_stop); | 570 | &oprelease_peer_stop); |
569 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, | 571 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
570 | opc->op); | 572 | opc->op); |
573 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
571 | return opc->op; | 574 | return opc->op; |
572 | } | 575 | } |
573 | 576 | ||
@@ -611,6 +614,7 @@ GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, | |||
611 | &oprelease_peer_getinfo); | 614 | &oprelease_peer_getinfo); |
612 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, | 615 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
613 | opc->op); | 616 | opc->op); |
617 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
614 | return opc->op; | 618 | return opc->op; |
615 | } | 619 | } |
616 | 620 | ||
@@ -658,6 +662,7 @@ GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer) | |||
658 | &oprelease_peer_destroy); | 662 | &oprelease_peer_destroy); |
659 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, | 663 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
660 | opc->op); | 664 | opc->op); |
665 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
661 | return opc->op; | 666 | return opc->op; |
662 | } | 667 | } |
663 | 668 | ||
@@ -730,6 +735,7 @@ GNUNET_TESTBED_overlay_connect (void *op_cls, | |||
730 | /* opc->op); */ | 735 | /* opc->op); */ |
731 | GNUNET_TESTBED_operation_queue_insert_ | 736 | GNUNET_TESTBED_operation_queue_insert_ |
732 | (opc->c->opq_parallel_overlay_connect_operations, opc->op); | 737 | (opc->c->opq_parallel_overlay_connect_operations, opc->op); |
738 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); | ||
733 | return opc->op; | 739 | return opc->op; |
734 | } | 740 | } |
735 | 741 | ||
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c index 16ea06077..c755a13a5 100644 --- a/src/testbed/testbed_api_services.c +++ b/src/testbed/testbed_api_services.c | |||
@@ -282,6 +282,7 @@ GNUNET_TESTBED_service_connect (void *op_cls, | |||
282 | GNUNET_TESTBED_operation_queue_insert_ (peer-> | 282 | GNUNET_TESTBED_operation_queue_insert_ (peer-> |
283 | controller->opq_parallel_operations, | 283 | controller->opq_parallel_operations, |
284 | data->operation); | 284 | data->operation); |
285 | GNUNET_TESTBED_operation_begin_wait_ (data->operation); | ||
285 | return data->operation; | 286 | return data->operation; |
286 | } | 287 | } |
287 | 288 | ||
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c index 4279299eb..84202ec8c 100644 --- a/src/testbed/testbed_api_topology.c +++ b/src/testbed/testbed_api_topology.c | |||
@@ -349,6 +349,7 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, | |||
349 | &oprelease_overlay_configure_topology); | 349 | &oprelease_overlay_configure_topology); |
350 | GNUNET_TESTBED_operation_queue_insert_ | 350 | GNUNET_TESTBED_operation_queue_insert_ |
351 | (c->opq_parallel_topology_config_operations, op); | 351 | (c->opq_parallel_topology_config_operations, op); |
352 | GNUNET_TESTBED_operation_begin_wait_ (op); | ||
352 | return op; | 353 | return op; |
353 | } | 354 | } |
354 | 355 | ||
diff --git a/src/testbed/x64_misc.supp b/src/testbed/x64_misc.supp index 7998f068d..e6a19c33e 100644 --- a/src/testbed/x64_misc.supp +++ b/src/testbed/x64_misc.supp | |||
@@ -22,3 +22,13 @@ | |||
22 | obj:/home/harsha/repos/gnunet/src/util/.libs/libgnunetutil.so.8.0.0 | 22 | obj:/home/harsha/repos/gnunet/src/util/.libs/libgnunetutil.so.8.0.0 |
23 | } | 23 | } |
24 | 24 | ||
25 | { | ||
26 | <insert_a_suppression_name_here> | ||
27 | Memcheck:Leak | ||
28 | fun:malloc | ||
29 | ... | ||
30 | fun:gcry_control | ||
31 | fun:GNUNET_CRYPTO_random_init | ||
32 | obj:/home/totakura/gnunet/src/util/.libs/libgnunetutil.so.8.0.0 | ||
33 | obj:/home/totakura/gnunet/src/util/.libs/libgnunetutil.so.8.0.0 | ||
34 | } | ||