diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-21 08:55:24 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-21 08:55:24 +0000 |
commit | 1538babdc61ea7e25fa1b738db11d8567a52667d (patch) | |
tree | ef4a62c5b51a933df5c43bedc69f6e30c48f38dd /src | |
parent | fec48540241c2476f96a89f2be431f5a2330babd (diff) | |
download | gnunet-1538babdc61ea7e25fa1b738db11d8567a52667d.tar.gz gnunet-1538babdc61ea7e25fa1b738db11d8567a52667d.zip |
tracking forwarded operations as part of link controllers operation
Diffstat (limited to 'src')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 85 |
1 files changed, 70 insertions, 15 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index 0f75f028d..b0334b898 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -370,6 +370,11 @@ struct LCFContext | |||
370 | struct GNUNET_SERVER_Client *client; | 370 | struct GNUNET_SERVER_Client *client; |
371 | 371 | ||
372 | /** | 372 | /** |
373 | * Handle for operations which are forwarded while linking controllers | ||
374 | */ | ||
375 | struct ForwardedOperationContext *fopc; | ||
376 | |||
377 | /** | ||
373 | * The id of the operation which created this context | 378 | * The id of the operation which created this context |
374 | */ | 379 | */ |
375 | uint64_t operation_id; | 380 | uint64_t operation_id; |
@@ -1352,11 +1357,10 @@ lcf_proc_cc (void *cls, const char *emsg) | |||
1352 | 1357 | ||
1353 | 1358 | ||
1354 | /** | 1359 | /** |
1355 | * Callback to be called when forwarded link controllers operation is | 1360 | * Callback to relay the reply msg of a forwarded operation back to the client |
1356 | * successfull. We have to relay the reply msg back to the client | ||
1357 | * | 1361 | * |
1358 | * @param cls ForwardedOperationContext | 1362 | * @param cls ForwardedOperationContext |
1359 | * @param msg the peer create success message | 1363 | * @param msg the message to relay |
1360 | */ | 1364 | */ |
1361 | static void | 1365 | static void |
1362 | forwarded_operation_reply_relay (void *cls, | 1366 | forwarded_operation_reply_relay (void *cls, |
@@ -1379,7 +1383,7 @@ forwarded_operation_reply_relay (void *cls, | |||
1379 | 1383 | ||
1380 | 1384 | ||
1381 | /** | 1385 | /** |
1382 | * Task to free resources when forwarded link controllers has been timedout | 1386 | * Task to free resources when forwarded operation has been timedout |
1383 | * | 1387 | * |
1384 | * @param cls the ForwardedOperationContext | 1388 | * @param cls the ForwardedOperationContext |
1385 | * @param tc the task context from scheduler | 1389 | * @param tc the task context from scheduler |
@@ -1405,11 +1409,61 @@ forwarded_operation_timeout (void *cls, | |||
1405 | * @param tc the Task context from scheduler | 1409 | * @param tc the Task context from scheduler |
1406 | */ | 1410 | */ |
1407 | static void | 1411 | static void |
1412 | lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
1413 | |||
1414 | |||
1415 | /** | ||
1416 | * Callback to be called when forwarded link controllers operation is | ||
1417 | * successfull. We have to relay the reply msg back to the client | ||
1418 | * | ||
1419 | * @param cls the LCFContext | ||
1420 | * @param msg the message to relay | ||
1421 | */ | ||
1422 | static void | ||
1423 | lcf_forwarded_operation_reply_relay (void *cls, | ||
1424 | const struct GNUNET_MessageHeader *msg) | ||
1425 | { | ||
1426 | struct LCFContext *lcf = cls; | ||
1427 | |||
1428 | GNUNET_assert (NULL != lcf->fopc); | ||
1429 | forwarded_operation_reply_relay (lcf->fopc, msg); | ||
1430 | lcf->fopc = NULL; | ||
1431 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | ||
1432 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | ||
1433 | } | ||
1434 | |||
1435 | |||
1436 | /** | ||
1437 | * Task to free resources when forwarded link controllers has been timedout | ||
1438 | * | ||
1439 | * @param cls the LCFContext | ||
1440 | * @param tc the task context from scheduler | ||
1441 | */ | ||
1442 | static void | ||
1443 | lcf_forwarded_operation_timeout (void *cls, | ||
1444 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1445 | { | ||
1446 | struct LCFContext *lcf = cls; | ||
1447 | |||
1448 | GNUNET_assert (NULL != lcf->fopc); | ||
1449 | forwarded_operation_timeout (lcf->fopc, tc); | ||
1450 | lcf->fopc = NULL; | ||
1451 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | ||
1452 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | ||
1453 | } | ||
1454 | |||
1455 | |||
1456 | /** | ||
1457 | * The Link Controller forwarding task | ||
1458 | * | ||
1459 | * @param cls the LCFContext | ||
1460 | * @param tc the Task context from scheduler | ||
1461 | */ | ||
1462 | static void | ||
1408 | lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1463 | lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1409 | { | 1464 | { |
1410 | struct LCFContext *lcf = cls; | 1465 | struct LCFContext *lcf = cls; |
1411 | struct LCFContextQueue *lcfq; | 1466 | struct LCFContextQueue *lcfq; |
1412 | struct ForwardedOperationContext *fopc; | ||
1413 | 1467 | ||
1414 | lcf_proc_task_id = GNUNET_SCHEDULER_NO_TASK; | 1468 | lcf_proc_task_id = GNUNET_SCHEDULER_NO_TASK; |
1415 | switch (lcf->state) | 1469 | switch (lcf->state) |
@@ -1445,20 +1499,19 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1445 | } | 1499 | } |
1446 | break; | 1500 | break; |
1447 | case SLAVE_HOST_REGISTERED: | 1501 | case SLAVE_HOST_REGISTERED: |
1448 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); | 1502 | lcf->fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); |
1449 | fopc->client = lcf->client; | 1503 | lcf->fopc->client = lcf->client; |
1450 | fopc->operation_id = lcf->operation_id; | 1504 | lcf->fopc->operation_id = lcf->operation_id; |
1451 | fopc->opc = | 1505 | lcf->fopc->opc = |
1452 | GNUNET_TESTBED_forward_operation_msg_ (lcf->gateway->controller, | 1506 | GNUNET_TESTBED_forward_operation_msg_ (lcf->gateway->controller, |
1453 | lcf->operation_id, | 1507 | lcf->operation_id, |
1454 | &lcf->msg->header, | 1508 | &lcf->msg->header, |
1455 | &forwarded_operation_reply_relay, | 1509 | &lcf_forwarded_operation_reply_relay, |
1456 | fopc); | 1510 | lcf); |
1457 | fopc->timeout_task = | 1511 | lcf->fopc->timeout_task = |
1458 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &forwarded_operation_timeout, | 1512 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &lcf_forwarded_operation_timeout, |
1459 | fopc); | 1513 | lcf); |
1460 | lcf->state = FINISHED; | 1514 | lcf->state = FINISHED; |
1461 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | ||
1462 | break; | 1515 | break; |
1463 | case FINISHED: | 1516 | case FINISHED: |
1464 | lcfq = lcfq_head; | 1517 | lcfq = lcfq_head; |
@@ -3635,6 +3688,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3635 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | 3688 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); |
3636 | for (lcfq = lcfq_head; NULL != lcfq; lcfq = lcfq_head) | 3689 | for (lcfq = lcfq_head; NULL != lcfq; lcfq = lcfq_head) |
3637 | { | 3690 | { |
3691 | if (NULL != lcfq->lcf->fopc) | ||
3692 | GNUNET_TESTBED_forward_operation_msg_cancel_ (lcfq->lcf->fopc->opc); | ||
3638 | GNUNET_free (lcfq->lcf->msg); | 3693 | GNUNET_free (lcfq->lcf->msg); |
3639 | GNUNET_free (lcfq->lcf); | 3694 | GNUNET_free (lcfq->lcf); |
3640 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); | 3695 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); |