diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-26 14:27:22 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-26 14:27:22 +0000 |
commit | 550494990e79b226774326b9fb83fd96515ef5b9 (patch) | |
tree | 5bf4f22648ea9ffea00ae94263e63f8649a89c4a /src/testbed/gnunet-service-testbed_oc.c | |
parent | 6de27f2fd0e5cfaba3f70955002cb0d6cab73df5 (diff) | |
download | gnunet-550494990e79b226774326b9fb83fd96515ef5b9.tar.gz gnunet-550494990e79b226774326b9fb83fd96515ef5b9.zip |
bound remote overlay connect operation execution to limited number of open file descriptors
Diffstat (limited to 'src/testbed/gnunet-service-testbed_oc.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed_oc.c | 75 |
1 files changed, 58 insertions, 17 deletions
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index 94d29cb1d..2daf4ffbd 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c | |||
@@ -1282,6 +1282,11 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1282 | static void | 1282 | static void |
1283 | cleanup_rocc (struct RemoteOverlayConnectCtx *rocc) | 1283 | cleanup_rocc (struct RemoteOverlayConnectCtx *rocc) |
1284 | { | 1284 | { |
1285 | if (NULL != rocc->lop) | ||
1286 | { | ||
1287 | GNUNET_TESTBED_operation_release_ (rocc->lop); | ||
1288 | return; | ||
1289 | } | ||
1285 | LOG_DEBUG ("0x%llx: Cleaning up rocc\n", rocc->op_id); | 1290 | LOG_DEBUG ("0x%llx: Cleaning up rocc\n", rocc->op_id); |
1286 | if (GNUNET_SCHEDULER_NO_TASK != rocc->attempt_connect_task_id) | 1291 | if (GNUNET_SCHEDULER_NO_TASK != rocc->attempt_connect_task_id) |
1287 | GNUNET_SCHEDULER_cancel (rocc->attempt_connect_task_id); | 1292 | GNUNET_SCHEDULER_cancel (rocc->attempt_connect_task_id); |
@@ -1419,6 +1424,52 @@ attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1419 | 1424 | ||
1420 | 1425 | ||
1421 | /** | 1426 | /** |
1427 | * Callback which will be called when remote overlay connect operation is | ||
1428 | * started | ||
1429 | * | ||
1430 | * @param cls the remote overlay connect context | ||
1431 | */ | ||
1432 | static void | ||
1433 | opstart_remote_overlay_connect (void *cls) | ||
1434 | { | ||
1435 | struct RemoteOverlayConnectCtx *rocc = cls; | ||
1436 | |||
1437 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rocc->timeout_rocc_task_id); | ||
1438 | rocc->tcc.op_id = rocc->op_id; | ||
1439 | rocc->tcc.th = | ||
1440 | GNUNET_TRANSPORT_connect (rocc->peer->details.local.cfg, NULL, rocc, NULL, | ||
1441 | &transport_connect_notify, NULL); | ||
1442 | if (NULL == rocc->tcc.th) | ||
1443 | { | ||
1444 | rocc->timeout_rocc_task_id = | ||
1445 | GNUNET_SCHEDULER_add_now (&timeout_rocc_task, rocc); | ||
1446 | return; | ||
1447 | } | ||
1448 | rocc->tcc.pid = &rocc->a_id; | ||
1449 | rocc->attempt_connect_task_id = | ||
1450 | GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc); | ||
1451 | rocc->timeout_rocc_task_id = | ||
1452 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_rocc_task, rocc); | ||
1453 | } | ||
1454 | |||
1455 | |||
1456 | /** | ||
1457 | * Callback which will be called when remote overlay connect operation is | ||
1458 | * released | ||
1459 | * | ||
1460 | * @param cls the remote overlay connect context | ||
1461 | */ | ||
1462 | static void | ||
1463 | oprelease_remote_overlay_connect (void *cls) | ||
1464 | { | ||
1465 | struct RemoteOverlayConnectCtx *rocc = cls; | ||
1466 | |||
1467 | GNUNET_assert (NULL != rocc->lop); | ||
1468 | rocc->lop = NULL; | ||
1469 | cleanup_rocc (rocc); | ||
1470 | } | ||
1471 | |||
1472 | /** | ||
1422 | * Handler for GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECT messages | 1473 | * Handler for GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECT messages |
1423 | * | 1474 | * |
1424 | * @param cls NULL | 1475 | * @param cls NULL |
@@ -1487,25 +1538,15 @@ GST_handle_remote_overlay_connect (void *cls, | |||
1487 | "from local peer %u to peer %4s with hello size: %u\n", | 1538 | "from local peer %u to peer %4s with hello size: %u\n", |
1488 | rocc->op_id, peer_id, GNUNET_i2s (&rocc->a_id), hsize); | 1539 | rocc->op_id, peer_id, GNUNET_i2s (&rocc->a_id), hsize); |
1489 | rocc->peer = peer; | 1540 | rocc->peer = peer; |
1490 | rocc->peer->reference_cnt++; | 1541 | rocc->peer->reference_cnt++; |
1491 | rocc->tcc.op_id = rocc->op_id; | ||
1492 | rocc->tcc.th = | ||
1493 | GNUNET_TRANSPORT_connect (rocc->peer->details.local.cfg, NULL, rocc, NULL, | ||
1494 | &transport_connect_notify, NULL); | ||
1495 | if (NULL == rocc->tcc.th) | ||
1496 | { | ||
1497 | GNUNET_break (0); | ||
1498 | GNUNET_free (rocc); | ||
1499 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1500 | return; | ||
1501 | } | ||
1502 | rocc->tcc.pid = &rocc->a_id; | ||
1503 | rocc->hello = GNUNET_malloc (hsize); | 1542 | rocc->hello = GNUNET_malloc (hsize); |
1504 | memcpy (rocc->hello, msg->hello, hsize); | 1543 | memcpy (rocc->hello, msg->hello, hsize); |
1505 | rocc->attempt_connect_task_id = | 1544 | rocc->lop = |
1506 | GNUNET_SCHEDULER_add_now (&attempt_connect_task, rocc); | 1545 | GNUNET_TESTBED_operation_create_ (rocc, &opstart_remote_overlay_connect, |
1507 | rocc->timeout_rocc_task_id = | 1546 | &oprelease_remote_overlay_connect); |
1508 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_rocc_task, rocc); | 1547 | /* This operation needs only 1 connection to transport */ |
1548 | GNUNET_TESTBED_operation_queue_insert2_ (GST_opq_openfds, rocc->lop, 1); | ||
1549 | GNUNET_TESTBED_operation_begin_wait_ (rocc->lop); | ||
1509 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1550 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1510 | } | 1551 | } |
1511 | 1552 | ||