diff options
Diffstat (limited to 'src/dht/gnunet-dht-driver.c')
-rw-r--r-- | src/dht/gnunet-dht-driver.c | 220 |
1 files changed, 100 insertions, 120 deletions
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 649d8ff13..b74e8a367 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c | |||
@@ -503,10 +503,6 @@ static unsigned long long peers_left; | |||
503 | */ | 503 | */ |
504 | static struct GNUNET_TESTING_PeerGroup *pg; | 504 | static struct GNUNET_TESTING_PeerGroup *pg; |
505 | 505 | ||
506 | /** | ||
507 | * Global scheduler, used for all GNUNET_SCHEDULER_* functions. | ||
508 | */ | ||
509 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
510 | 506 | ||
511 | /** | 507 | /** |
512 | * Global config handle. | 508 | * Global config handle. |
@@ -743,7 +739,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
743 | while (test_put != NULL) | 739 | while (test_put != NULL) |
744 | { | 740 | { |
745 | if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) | 741 | if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) |
746 | GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); | 742 | GNUNET_SCHEDULER_cancel(test_put->disconnect_task); |
747 | if (test_put->dht_handle != NULL) | 743 | if (test_put->dht_handle != NULL) |
748 | GNUNET_DHT_disconnect(test_put->dht_handle); | 744 | GNUNET_DHT_disconnect(test_put->dht_handle); |
749 | test_put = test_put->next; | 745 | test_put = test_put->next; |
@@ -752,7 +748,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
752 | while (test_get != NULL) | 748 | while (test_get != NULL) |
753 | { | 749 | { |
754 | if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) | 750 | if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) |
755 | GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); | 751 | GNUNET_SCHEDULER_cancel(test_get->disconnect_task); |
756 | if (test_get->get_handle != NULL) | 752 | if (test_get->get_handle != NULL) |
757 | GNUNET_DHT_get_stop(test_get->get_handle); | 753 | GNUNET_DHT_get_stop(test_get->get_handle); |
758 | if (test_get->dht_handle != NULL) | 754 | if (test_get->dht_handle != NULL) |
@@ -813,7 +809,7 @@ log_topology_cb (void *cls, | |||
813 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Topology iteration (%u/%u) finished (%u connections, %u peers)\n", topo_ctx->current_iteration, topo_ctx->total_iterations, topo_ctx->total_connections, topo_ctx->total_peers); | 809 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Topology iteration (%u/%u) finished (%u connections, %u peers)\n", topo_ctx->current_iteration, topo_ctx->total_iterations, topo_ctx->total_connections, topo_ctx->total_peers); |
814 | dhtlog_handle->update_topology(topo_ctx->total_connections); | 810 | dhtlog_handle->update_topology(topo_ctx->total_connections); |
815 | if (topo_ctx->cont != NULL) | 811 | if (topo_ctx->cont != NULL) |
816 | GNUNET_SCHEDULER_add_now (sched, topo_ctx->cont, topo_ctx->cls); | 812 | GNUNET_SCHEDULER_add_now (topo_ctx->cont, topo_ctx->cls); |
817 | if (topo_ctx->peers_seen != NULL) | 813 | if (topo_ctx->peers_seen != NULL) |
818 | GNUNET_CONTAINER_multihashmap_destroy(topo_ctx->peers_seen); | 814 | GNUNET_CONTAINER_multihashmap_destroy(topo_ctx->peers_seen); |
819 | GNUNET_free(topo_ctx); | 815 | GNUNET_free(topo_ctx); |
@@ -854,7 +850,7 @@ stats_finished (void *cls, int result) | |||
854 | fprintf(stderr, "Finished getting all peers statistics, iterating!\n"); | 850 | fprintf(stderr, "Finished getting all peers statistics, iterating!\n"); |
855 | GNUNET_CONTAINER_multihashmap_iterate(stats_map, &stats_iterate, NULL); | 851 | GNUNET_CONTAINER_multihashmap_iterate(stats_map, &stats_iterate, NULL); |
856 | GNUNET_CONTAINER_multihashmap_destroy(stats_map); | 852 | GNUNET_CONTAINER_multihashmap_destroy(stats_map); |
857 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | 853 | GNUNET_SCHEDULER_add_now (&finish_testing, NULL); |
858 | } | 854 | } |
859 | 855 | ||
860 | /** | 856 | /** |
@@ -969,7 +965,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
969 | while (test_put != NULL) | 965 | while (test_put != NULL) |
970 | { | 966 | { |
971 | if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) | 967 | if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) |
972 | GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); | 968 | GNUNET_SCHEDULER_cancel(test_put->disconnect_task); |
973 | if (test_put->dht_handle != NULL) | 969 | if (test_put->dht_handle != NULL) |
974 | GNUNET_DHT_disconnect(test_put->dht_handle); | 970 | GNUNET_DHT_disconnect(test_put->dht_handle); |
975 | test_put = test_put->next; | 971 | test_put = test_put->next; |
@@ -978,7 +974,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
978 | while (test_get != NULL) | 974 | while (test_get != NULL) |
979 | { | 975 | { |
980 | if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) | 976 | if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) |
981 | GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); | 977 | GNUNET_SCHEDULER_cancel(test_get->disconnect_task); |
982 | if (test_get->get_handle != NULL) | 978 | if (test_get->get_handle != NULL) |
983 | GNUNET_DHT_get_stop(test_get->get_handle); | 979 | GNUNET_DHT_get_stop(test_get->get_handle); |
984 | if (test_get->dht_handle != NULL) | 980 | if (test_get->dht_handle != NULL) |
@@ -1067,7 +1063,7 @@ decrement_find_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1067 | if ((0 == test_find_peer->find_peer_context->total) && | 1063 | if ((0 == test_find_peer->find_peer_context->total) && |
1068 | (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value > 60)) | 1064 | (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value > 60)) |
1069 | { | 1065 | { |
1070 | GNUNET_SCHEDULER_add_now(sched, &count_new_peers, test_find_peer->find_peer_context); | 1066 | GNUNET_SCHEDULER_add_now(&count_new_peers, test_find_peer->find_peer_context); |
1071 | } | 1067 | } |
1072 | GNUNET_free(test_find_peer); | 1068 | GNUNET_free(test_find_peer); |
1073 | } | 1069 | } |
@@ -1085,7 +1081,7 @@ handle_find_peer_sent (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc | |||
1085 | struct TestFindPeer *test_find_peer = cls; | 1081 | struct TestFindPeer *test_find_peer = cls; |
1086 | 1082 | ||
1087 | GNUNET_DHT_disconnect(test_find_peer->dht_handle); | 1083 | GNUNET_DHT_disconnect(test_find_peer->dht_handle); |
1088 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_divide(find_peer_delay, 2), &decrement_find_peers, test_find_peer); | 1084 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_divide(find_peer_delay, 2), &decrement_find_peers, test_find_peer); |
1089 | } | 1085 | } |
1090 | 1086 | ||
1091 | 1087 | ||
@@ -1096,18 +1092,18 @@ send_find_peer_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t | |||
1096 | 1092 | ||
1097 | if (test_find_peer->find_peer_context->outstanding > max_outstanding_find_peers) | 1093 | if (test_find_peer->find_peer_context->outstanding > max_outstanding_find_peers) |
1098 | { | 1094 | { |
1099 | GNUNET_SCHEDULER_add_delayed(sched, find_peer_offset, &send_find_peer_request, test_find_peer); | 1095 | GNUNET_SCHEDULER_add_delayed(find_peer_offset, &send_find_peer_request, test_find_peer); |
1100 | return; | 1096 | return; |
1101 | } | 1097 | } |
1102 | 1098 | ||
1103 | test_find_peer->find_peer_context->outstanding++; | 1099 | test_find_peer->find_peer_context->outstanding++; |
1104 | if (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value == 0) | 1100 | if (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).rel_value == 0) |
1105 | { | 1101 | { |
1106 | GNUNET_SCHEDULER_add_now(sched, &decrement_find_peers, test_find_peer); | 1102 | GNUNET_SCHEDULER_add_now(&decrement_find_peers, test_find_peer); |
1107 | return; | 1103 | return; |
1108 | } | 1104 | } |
1109 | 1105 | ||
1110 | test_find_peer->dht_handle = GNUNET_DHT_connect(sched, test_find_peer->daemon->cfg, 1); | 1106 | test_find_peer->dht_handle = GNUNET_DHT_connect(test_find_peer->daemon->cfg, 1); |
1111 | GNUNET_assert(test_find_peer->dht_handle != NULL); | 1107 | GNUNET_assert(test_find_peer->dht_handle != NULL); |
1112 | GNUNET_DHT_find_peers (test_find_peer->dht_handle, | 1108 | GNUNET_DHT_find_peers (test_find_peer->dht_handle, |
1113 | &handle_find_peer_sent, test_find_peer); | 1109 | &handle_find_peer_sent, test_find_peer); |
@@ -1290,11 +1286,11 @@ count_peers_churn_cb (void *cls, | |||
1290 | { | 1286 | { |
1291 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); | 1287 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); |
1292 | GNUNET_CONTAINER_heap_iterate (find_peer_context->peer_min_heap, &iterate_min_heap_peers, find_peer_context); | 1288 | GNUNET_CONTAINER_heap_iterate (find_peer_context->peer_min_heap, &iterate_min_heap_peers, find_peer_context); |
1293 | GNUNET_SCHEDULER_add_now(sched, &schedule_churn_find_peer_requests, find_peer_context); | 1289 | GNUNET_SCHEDULER_add_now(&schedule_churn_find_peer_requests, find_peer_context); |
1294 | } | 1290 | } |
1295 | else if ((GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0) && (find_peer_context->last_sent != 0)) | 1291 | else if ((GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0) && (find_peer_context->last_sent != 0)) |
1296 | { | 1292 | { |
1297 | GNUNET_SCHEDULER_add_now(sched, &schedule_churn_find_peer_requests, find_peer_context); | 1293 | GNUNET_SCHEDULER_add_now(&schedule_churn_find_peer_requests, find_peer_context); |
1298 | } | 1294 | } |
1299 | else | 1295 | else |
1300 | { | 1296 | { |
@@ -1310,15 +1306,15 @@ count_peers_churn_cb (void *cls, | |||
1310 | topo_ctx->cls = all_gets; | 1306 | topo_ctx->cls = all_gets; |
1311 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; | 1307 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; |
1312 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); | 1308 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); |
1313 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), | 1309 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), |
1314 | &end_badly, "from do gets (count_peers_churn_cb)"); | 1310 | &end_badly, "from do gets (count_peers_churn_cb)"); |
1315 | GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); | 1311 | GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx); |
1316 | } | 1312 | } |
1317 | else | 1313 | else |
1318 | { | 1314 | { |
1319 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), | 1315 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), |
1320 | &end_badly, "from do gets (count_peers_churn_cb)"); | 1316 | &end_badly, "from do gets (count_peers_churn_cb)"); |
1321 | GNUNET_SCHEDULER_add_now(sched, &do_get, all_gets); | 1317 | GNUNET_SCHEDULER_add_now(&do_get, all_gets); |
1322 | } | 1318 | } |
1323 | } | 1319 | } |
1324 | } | 1320 | } |
@@ -1372,7 +1368,7 @@ schedule_churn_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_Task | |||
1372 | test_find_peer->daemon = GNUNET_TESTING_daemon_get_by_id(pg, &peer_count->peer_id); | 1368 | test_find_peer->daemon = GNUNET_TESTING_daemon_get_by_id(pg, &peer_count->peer_id); |
1373 | GNUNET_assert(test_find_peer->daemon != NULL); | 1369 | GNUNET_assert(test_find_peer->daemon != NULL); |
1374 | test_find_peer->find_peer_context = find_peer_ctx; | 1370 | test_find_peer->find_peer_context = find_peer_ctx; |
1375 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); | 1371 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); |
1376 | } | 1372 | } |
1377 | 1373 | ||
1378 | if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL)) | 1374 | if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL)) |
@@ -1416,7 +1412,7 @@ static void churn_complete (void *cls, const char *emsg) | |||
1416 | if (emsg != NULL) | 1412 | if (emsg != NULL) |
1417 | { | 1413 | { |
1418 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ending test, churning of peers failed with error `%s'", emsg); | 1414 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ending test, churning of peers failed with error `%s'", emsg); |
1419 | GNUNET_SCHEDULER_add_now(sched, &end_badly, (void *)emsg); | 1415 | GNUNET_SCHEDULER_add_now(&end_badly, (void *)emsg); |
1420 | return; | 1416 | return; |
1421 | } | 1417 | } |
1422 | 1418 | ||
@@ -1443,7 +1439,7 @@ static void churn_complete (void *cls, const char *emsg) | |||
1443 | } | 1439 | } |
1444 | } | 1440 | } |
1445 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Added %d peers to heap, total size %d\n", count_added, GNUNET_CONTAINER_heap_get_size(find_peer_context->peer_min_heap)); | 1441 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Added %d peers to heap, total size %d\n", count_added, GNUNET_CONTAINER_heap_get_size(find_peer_context->peer_min_heap)); |
1446 | GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_PEER_DISCONNECT_TIMEOUT, &schedule_churn_get_topology, find_peer_context); | 1442 | GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &schedule_churn_get_topology, find_peer_context); |
1447 | //GNUNET_TESTING_get_topology (pg, &count_peers_churn_cb, find_peer_context); | 1443 | //GNUNET_TESTING_get_topology (pg, &count_peers_churn_cb, find_peer_context); |
1448 | } | 1444 | } |
1449 | else | 1445 | else |
@@ -1459,19 +1455,19 @@ static void churn_complete (void *cls, const char *emsg) | |||
1459 | calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout); | 1455 | calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout); |
1460 | calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT); | 1456 | calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT); |
1461 | calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT); | 1457 | calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT); |
1462 | die_task = GNUNET_SCHEDULER_add_delayed (sched, calc_timeout, | 1458 | die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout, |
1463 | &end_badly, "from do gets (churn_complete)"); | 1459 | &end_badly, "from do gets (churn_complete)"); |
1464 | GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_PEER_DISCONNECT_TIMEOUT, &capture_current_topology, topo_ctx); | 1460 | GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &capture_current_topology, topo_ctx); |
1465 | } | 1461 | } |
1466 | else | 1462 | else |
1467 | { | 1463 | { |
1468 | calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout); | 1464 | calc_timeout = GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout); |
1469 | calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT); | 1465 | calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT); |
1470 | die_task = GNUNET_SCHEDULER_add_delayed (sched, calc_timeout, | 1466 | die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout, |
1471 | &end_badly, "from do gets (churn_complete)"); | 1467 | &end_badly, "from do gets (churn_complete)"); |
1472 | if (dhtlog_handle != NULL) | 1468 | if (dhtlog_handle != NULL) |
1473 | dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished); | 1469 | dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished); |
1474 | GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, all_gets); | 1470 | GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, all_gets); |
1475 | } | 1471 | } |
1476 | } | 1472 | } |
1477 | } | 1473 | } |
@@ -1565,7 +1561,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1565 | if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) | 1561 | if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) |
1566 | { | 1562 | { |
1567 | fprintf(stderr, "Canceling die task (get_stop_finished) %llu gets completed, %llu gets failed\n", gets_completed, gets_failed); | 1563 | fprintf(stderr, "Canceling die task (get_stop_finished) %llu gets completed, %llu gets failed\n", gets_completed, gets_failed); |
1568 | GNUNET_SCHEDULER_cancel(sched, die_task); | 1564 | GNUNET_SCHEDULER_cancel(die_task); |
1569 | reset_meter(put_meter); | 1565 | reset_meter(put_meter); |
1570 | reset_meter(get_meter); | 1566 | reset_meter(get_meter); |
1571 | /** | 1567 | /** |
@@ -1581,10 +1577,10 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1581 | topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); | 1577 | topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); |
1582 | topo_ctx->cont = &log_dht_statistics; | 1578 | topo_ctx->cont = &log_dht_statistics; |
1583 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); | 1579 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); |
1584 | GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); | 1580 | GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx); |
1585 | } | 1581 | } |
1586 | else | 1582 | else |
1587 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | 1583 | GNUNET_SCHEDULER_add_now (&finish_testing, NULL); |
1588 | } | 1584 | } |
1589 | else if (current_churn_round < churns_per_round * (rounds_finished + 1)) /* Do next round of churn */ | 1585 | else if (current_churn_round < churns_per_round * (rounds_finished + 1)) /* Do next round of churn */ |
1590 | { | 1586 | { |
@@ -1595,7 +1591,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1595 | if (dhtlog_handle != NULL) | 1591 | if (dhtlog_handle != NULL) |
1596 | dhtlog_handle->insert_round(DHT_ROUND_CHURN, rounds_finished); | 1592 | dhtlog_handle->insert_round(DHT_ROUND_CHURN, rounds_finished); |
1597 | 1593 | ||
1598 | GNUNET_SCHEDULER_add_now(sched, &churn_peers, NULL); | 1594 | GNUNET_SCHEDULER_add_now(&churn_peers, NULL); |
1599 | } | 1595 | } |
1600 | else if (rounds_finished < total_rounds - 1) /* Start a new complete round */ | 1596 | else if (rounds_finished < total_rounds - 1) /* Start a new complete round */ |
1601 | { | 1597 | { |
@@ -1610,17 +1606,17 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1610 | if (dhtlog_handle != NULL) | 1606 | if (dhtlog_handle != NULL) |
1611 | dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished); | 1607 | dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished); |
1612 | 1608 | ||
1613 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), | 1609 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), |
1614 | &end_badly, "from do gets (next round)"); | 1610 | &end_badly, "from do gets (next round)"); |
1615 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_get, all_gets); | 1611 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_get, all_gets); |
1616 | } | 1612 | } |
1617 | else | 1613 | else |
1618 | { | 1614 | { |
1619 | if (dhtlog_handle != NULL) | 1615 | if (dhtlog_handle != NULL) |
1620 | dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished); | 1616 | dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished); |
1621 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2)), | 1617 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2)), |
1622 | &end_badly, "from do puts"); | 1618 | &end_badly, "from do puts"); |
1623 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_put, all_puts); | 1619 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, round_delay), &do_put, all_puts); |
1624 | } | 1620 | } |
1625 | } | 1621 | } |
1626 | } | 1622 | } |
@@ -1640,7 +1636,7 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1640 | GNUNET_DHT_get_stop(test_get->get_handle); | 1636 | GNUNET_DHT_get_stop(test_get->get_handle); |
1641 | test_get->get_handle = NULL; | 1637 | test_get->get_handle = NULL; |
1642 | test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 1638 | test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
1643 | GNUNET_SCHEDULER_add_now (sched, &get_stop_finished, test_get); | 1639 | GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get); |
1644 | } | 1640 | } |
1645 | 1641 | ||
1646 | /** | 1642 | /** |
@@ -1685,8 +1681,8 @@ get_result_iterator (void *cls, | |||
1685 | #if VERBOSE > 1 | 1681 | #if VERBOSE > 1 |
1686 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n"); | 1682 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n"); |
1687 | #endif | 1683 | #endif |
1688 | GNUNET_SCHEDULER_cancel(sched, test_get->disconnect_task); | 1684 | GNUNET_SCHEDULER_cancel(test_get->disconnect_task); |
1689 | GNUNET_SCHEDULER_add_continuation(sched, &get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 1685 | GNUNET_SCHEDULER_add_continuation(&get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
1690 | } | 1686 | } |
1691 | 1687 | ||
1692 | 1688 | ||
@@ -1701,8 +1697,8 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1701 | 1697 | ||
1702 | if (num_gets == 0) | 1698 | if (num_gets == 0) |
1703 | { | 1699 | { |
1704 | GNUNET_SCHEDULER_cancel(sched, die_task); | 1700 | GNUNET_SCHEDULER_cancel(die_task); |
1705 | GNUNET_SCHEDULER_add_now(sched, &finish_testing, NULL); | 1701 | GNUNET_SCHEDULER_add_now(&finish_testing, NULL); |
1706 | } | 1702 | } |
1707 | 1703 | ||
1708 | if (test_get == NULL) | 1704 | if (test_get == NULL) |
@@ -1715,20 +1711,20 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1715 | { | 1711 | { |
1716 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue get request from is down, skipping.\n"); | 1712 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue get request from is down, skipping.\n"); |
1717 | gets_failed++; | 1713 | gets_failed++; |
1718 | GNUNET_SCHEDULER_add_now (sched, &get_stop_finished, test_get); | 1714 | GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get); |
1719 | GNUNET_SCHEDULER_add_now (sched, &do_get, test_get->next); | 1715 | GNUNET_SCHEDULER_add_now (&do_get, test_get->next); |
1720 | return; | 1716 | return; |
1721 | } | 1717 | } |
1722 | 1718 | ||
1723 | /* Check if more gets are outstanding than should be */ | 1719 | /* Check if more gets are outstanding than should be */ |
1724 | if (outstanding_gets > max_outstanding_gets) | 1720 | if (outstanding_gets > max_outstanding_gets) |
1725 | { | 1721 | { |
1726 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_get, test_get); | 1722 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_get, test_get); |
1727 | return; | 1723 | return; |
1728 | } | 1724 | } |
1729 | 1725 | ||
1730 | /* Connect to the first peer's DHT */ | 1726 | /* Connect to the first peer's DHT */ |
1731 | test_get->dht_handle = GNUNET_DHT_connect(sched, test_get->daemon->cfg, 10); | 1727 | test_get->dht_handle = GNUNET_DHT_connect(test_get->daemon->cfg, 10); |
1732 | GNUNET_assert(test_get->dht_handle != NULL); | 1728 | GNUNET_assert(test_get->dht_handle != NULL); |
1733 | outstanding_gets++; | 1729 | outstanding_gets++; |
1734 | 1730 | ||
@@ -1748,10 +1744,10 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1748 | test_get->uid, | 1744 | test_get->uid, |
1749 | test_get->daemon->shortname); | 1745 | test_get->daemon->shortname); |
1750 | #endif | 1746 | #endif |
1751 | test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, get_timeout, &get_stop_task, test_get); | 1747 | test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(get_timeout, &get_stop_task, test_get); |
1752 | 1748 | ||
1753 | /* Schedule the next request in the linked list of get requests */ | 1749 | /* Schedule the next request in the linked list of get requests */ |
1754 | GNUNET_SCHEDULER_add_now (sched, &do_get, test_get->next); | 1750 | GNUNET_SCHEDULER_add_now (&do_get, test_get->next); |
1755 | } | 1751 | } |
1756 | 1752 | ||
1757 | /** | 1753 | /** |
@@ -1773,12 +1769,12 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1773 | if (replicate_same == GNUNET_NO) | 1769 | if (replicate_same == GNUNET_NO) |
1774 | test_put->daemon = GNUNET_TESTING_daemon_get(pg, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); | 1770 | test_put->daemon = GNUNET_TESTING_daemon_get(pg, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); |
1775 | 1771 | ||
1776 | GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); | 1772 | GNUNET_SCHEDULER_cancel(test_put->disconnect_task); |
1777 | test_put->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &put_disconnect_task, test_put); | 1773 | test_put->disconnect_task = GNUNET_SCHEDULER_add_now(&put_disconnect_task, test_put); |
1778 | if (GNUNET_YES == update_meter(put_meter)) | 1774 | if (GNUNET_YES == update_meter(put_meter)) |
1779 | { | 1775 | { |
1780 | GNUNET_assert(outstanding_puts == 0); | 1776 | GNUNET_assert(outstanding_puts == 0); |
1781 | GNUNET_SCHEDULER_cancel (sched, die_task); | 1777 | GNUNET_SCHEDULER_cancel (die_task); |
1782 | if (dhtlog_handle != NULL) | 1778 | if (dhtlog_handle != NULL) |
1783 | { | 1779 | { |
1784 | topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); | 1780 | topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); |
@@ -1786,16 +1782,16 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1786 | topo_ctx->cls = all_gets; | 1782 | topo_ctx->cls = all_gets; |
1787 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; | 1783 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; |
1788 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); | 1784 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); |
1789 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), | 1785 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT), |
1790 | &end_badly, "from do gets (put finished)"); | 1786 | &end_badly, "from do gets (put finished)"); |
1791 | GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); | 1787 | GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx); |
1792 | } | 1788 | } |
1793 | else | 1789 | else |
1794 | { | 1790 | { |
1795 | fprintf(stderr, "Scheduling die task (put finished)\n"); | 1791 | fprintf(stderr, "Scheduling die task (put finished)\n"); |
1796 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), | 1792 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add(DEFAULT_GET_TIMEOUT, all_get_timeout), |
1797 | &end_badly, "from do gets (put finished)"); | 1793 | &end_badly, "from do gets (put finished)"); |
1798 | GNUNET_SCHEDULER_add_delayed(sched, DEFAULT_GET_TIMEOUT, &do_get, all_gets); | 1794 | GNUNET_SCHEDULER_add_delayed(DEFAULT_GET_TIMEOUT, &do_get, all_gets); |
1799 | } | 1795 | } |
1800 | return; | 1796 | return; |
1801 | } | 1797 | } |
@@ -1819,7 +1815,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1819 | { | 1815 | { |
1820 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue put request at is down, skipping.\n"); | 1816 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue put request at is down, skipping.\n"); |
1821 | update_meter(put_meter); | 1817 | update_meter(put_meter); |
1822 | GNUNET_SCHEDULER_add_now (sched, &do_put, test_put->next); | 1818 | GNUNET_SCHEDULER_add_now (&do_put, test_put->next); |
1823 | return; | 1819 | return; |
1824 | } | 1820 | } |
1825 | 1821 | ||
@@ -1830,7 +1826,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1830 | 1826 | ||
1831 | if (outstanding_puts > max_outstanding_puts) | 1827 | if (outstanding_puts > max_outstanding_puts) |
1832 | { | 1828 | { |
1833 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_put, test_put); | 1829 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200), &do_put, test_put); |
1834 | return; | 1830 | return; |
1835 | } | 1831 | } |
1836 | 1832 | ||
@@ -1839,7 +1835,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1839 | test_put->uid, | 1835 | test_put->uid, |
1840 | test_put->daemon->shortname); | 1836 | test_put->daemon->shortname); |
1841 | #endif | 1837 | #endif |
1842 | test_put->dht_handle = GNUNET_DHT_connect(sched, test_put->daemon->cfg, 10); | 1838 | test_put->dht_handle = GNUNET_DHT_connect(test_put->daemon->cfg, 10); |
1843 | 1839 | ||
1844 | GNUNET_assert(test_put->dht_handle != NULL); | 1840 | GNUNET_assert(test_put->dht_handle != NULL); |
1845 | outstanding_puts++; | 1841 | outstanding_puts++; |
@@ -1851,9 +1847,9 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1851 | GNUNET_TIME_UNIT_FOREVER_ABS, | 1847 | GNUNET_TIME_UNIT_FOREVER_ABS, |
1852 | put_delay, | 1848 | put_delay, |
1853 | &put_finished, test_put); | 1849 | &put_finished, test_put); |
1854 | test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put); | 1850 | test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put); |
1855 | rand = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 2); | 1851 | rand = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 2); |
1856 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, rand), &do_put, test_put->next); | 1852 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, rand), &do_put, test_put->next); |
1857 | } | 1853 | } |
1858 | 1854 | ||
1859 | static void | 1855 | static void |
@@ -1911,7 +1907,7 @@ count_peers_cb (void *cls, | |||
1911 | (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && | 1907 | (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && |
1912 | (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0)) | 1908 | (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0)) |
1913 | { | 1909 | { |
1914 | GNUNET_SCHEDULER_add_now(sched, &schedule_find_peer_requests, find_peer_context); | 1910 | GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context); |
1915 | } | 1911 | } |
1916 | else | 1912 | else |
1917 | { | 1913 | { |
@@ -1993,7 +1989,7 @@ schedule_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_TaskContex | |||
1993 | } | 1989 | } |
1994 | 1990 | ||
1995 | test_find_peer->find_peer_context = find_peer_ctx; | 1991 | test_find_peer->find_peer_context = find_peer_ctx; |
1996 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); | 1992 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(find_peer_offset, i), &send_find_peer_request, test_find_peer); |
1997 | } | 1993 | } |
1998 | 1994 | ||
1999 | if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL)) | 1995 | if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap == NULL)) |
@@ -2055,10 +2051,10 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
2055 | all_gets = test_get; | 2051 | all_gets = test_get; |
2056 | } | 2052 | } |
2057 | 2053 | ||
2058 | /*GNUNET_SCHEDULER_cancel (sched, die_task);*/ | 2054 | /*GNUNET_SCHEDULER_cancel (die_task);*/ |
2059 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2), | 2055 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2), |
2060 | &end_badly, "from do puts"); | 2056 | &end_badly, "from do puts"); |
2061 | GNUNET_SCHEDULER_add_now (sched, &do_put, all_puts); | 2057 | GNUNET_SCHEDULER_add_now (&do_put, all_puts); |
2062 | 2058 | ||
2063 | } | 2059 | } |
2064 | 2060 | ||
@@ -2087,15 +2083,15 @@ continue_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t | |||
2087 | topo_ctx->total_iterations = max; | 2083 | topo_ctx->total_iterations = max; |
2088 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); | 2084 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); |
2089 | //fprintf(stderr, "scheduled topology iteration in %d minutes\n", i); | 2085 | //fprintf(stderr, "scheduled topology iteration in %d minutes\n", i); |
2090 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, i * 3), &capture_current_topology, topo_ctx); | 2086 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, i * 3), &capture_current_topology, topo_ctx); |
2091 | } | 2087 | } |
2092 | topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); | 2088 | topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); |
2093 | topo_ctx->cont = &setup_puts_and_gets; | 2089 | topo_ctx->cont = &setup_puts_and_gets; |
2094 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); | 2090 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); |
2095 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &capture_current_topology, topo_ctx); | 2091 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &capture_current_topology, topo_ctx); |
2096 | } | 2092 | } |
2097 | else | 2093 | else |
2098 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &setup_puts_and_gets, NULL); | 2094 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (settle_time + 90)), &setup_puts_and_gets, NULL); |
2099 | 2095 | ||
2100 | if (dhtlog_handle != NULL) | 2096 | if (dhtlog_handle != NULL) |
2101 | dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished); | 2097 | dhtlog_handle->insert_round(DHT_ROUND_NORMAL, rounds_finished); |
@@ -2106,7 +2102,7 @@ continue_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t | |||
2106 | find_peer_context = GNUNET_malloc(sizeof(struct FindPeerContext)); | 2102 | find_peer_context = GNUNET_malloc(sizeof(struct FindPeerContext)); |
2107 | find_peer_context->count_peers_cb = &count_peers_cb; | 2103 | find_peer_context->count_peers_cb = &count_peers_cb; |
2108 | find_peer_context->endtime = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time)); | 2104 | find_peer_context->endtime = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time)); |
2109 | GNUNET_SCHEDULER_add_now(sched, &schedule_find_peer_requests, find_peer_context); | 2105 | GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context); |
2110 | } | 2106 | } |
2111 | else | 2107 | else |
2112 | { | 2108 | { |
@@ -2130,14 +2126,12 @@ malicious_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext | |||
2130 | 2126 | ||
2131 | if (malicious_completed == malicious_getters + malicious_putters + malicious_droppers) | 2127 | if (malicious_completed == malicious_getters + malicious_putters + malicious_droppers) |
2132 | { | 2128 | { |
2133 | GNUNET_SCHEDULER_cancel(sched, die_task); | 2129 | GNUNET_SCHEDULER_cancel(die_task); |
2134 | fprintf(stderr, "Finished setting all malicious peers up, calling continuation!\n"); | 2130 | fprintf(stderr, "Finished setting all malicious peers up, calling continuation!\n"); |
2135 | if (dhtlog_handle != NULL) | 2131 | if (dhtlog_handle != NULL) |
2136 | GNUNET_SCHEDULER_add_now (sched, | 2132 | GNUNET_SCHEDULER_add_now (&continue_puts_and_gets, NULL); |
2137 | &continue_puts_and_gets, NULL); | ||
2138 | else | 2133 | else |
2139 | GNUNET_SCHEDULER_add_delayed (sched, | 2134 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), |
2140 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), | ||
2141 | &continue_puts_and_gets, NULL); | 2135 | &continue_puts_and_gets, NULL); |
2142 | } | 2136 | } |
2143 | 2137 | ||
@@ -2150,8 +2144,8 @@ static void | |||
2150 | malicious_done_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | 2144 | malicious_done_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) |
2151 | { | 2145 | { |
2152 | struct MaliciousContext *ctx = cls; | 2146 | struct MaliciousContext *ctx = cls; |
2153 | GNUNET_SCHEDULER_cancel(sched, ctx->disconnect_task); | 2147 | GNUNET_SCHEDULER_cancel(ctx->disconnect_task); |
2154 | GNUNET_SCHEDULER_add_now(sched, &malicious_disconnect_task, ctx); | 2148 | GNUNET_SCHEDULER_add_now(&malicious_disconnect_task, ctx); |
2155 | } | 2149 | } |
2156 | 2150 | ||
2157 | /** | 2151 | /** |
@@ -2164,13 +2158,13 @@ set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
2164 | 2158 | ||
2165 | if (outstanding_malicious > DEFAULT_MAX_OUTSTANDING_GETS) | 2159 | if (outstanding_malicious > DEFAULT_MAX_OUTSTANDING_GETS) |
2166 | { | 2160 | { |
2167 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &set_malicious, ctx); | 2161 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &set_malicious, ctx); |
2168 | return; | 2162 | return; |
2169 | } | 2163 | } |
2170 | 2164 | ||
2171 | if (ctx->dht_handle == NULL) | 2165 | if (ctx->dht_handle == NULL) |
2172 | { | 2166 | { |
2173 | ctx->dht_handle = GNUNET_DHT_connect(sched, ctx->daemon->cfg, 1); | 2167 | ctx->dht_handle = GNUNET_DHT_connect(ctx->daemon->cfg, 1); |
2174 | outstanding_malicious++; | 2168 | outstanding_malicious++; |
2175 | } | 2169 | } |
2176 | 2170 | ||
@@ -2186,24 +2180,21 @@ set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
2186 | { | 2180 | { |
2187 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: | 2181 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET: |
2188 | GNUNET_DHT_set_malicious_getter(ctx->dht_handle, malicious_get_frequency); | 2182 | GNUNET_DHT_set_malicious_getter(ctx->dht_handle, malicious_get_frequency); |
2189 | GNUNET_SCHEDULER_add_now (sched, | 2183 | GNUNET_SCHEDULER_add_now (&malicious_done_task, ctx); |
2190 | &malicious_done_task, ctx); | ||
2191 | break; | 2184 | break; |
2192 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT: | 2185 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT: |
2193 | GNUNET_DHT_set_malicious_putter(ctx->dht_handle, malicious_put_frequency); | 2186 | GNUNET_DHT_set_malicious_putter(ctx->dht_handle, malicious_put_frequency); |
2194 | GNUNET_SCHEDULER_add_now (sched, | 2187 | GNUNET_SCHEDULER_add_now (&malicious_done_task, ctx); |
2195 | &malicious_done_task, ctx); | ||
2196 | break; | 2188 | break; |
2197 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP: | 2189 | case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP: |
2198 | GNUNET_DHT_set_malicious_dropper(ctx->dht_handle); | 2190 | GNUNET_DHT_set_malicious_dropper(ctx->dht_handle); |
2199 | GNUNET_SCHEDULER_add_now (sched, &malicious_done_task, ctx); | 2191 | GNUNET_SCHEDULER_add_now (&malicious_done_task, ctx); |
2200 | break; | 2192 | break; |
2201 | default: | 2193 | default: |
2202 | break; | 2194 | break; |
2203 | } | 2195 | } |
2204 | 2196 | ||
2205 | ctx->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, | 2197 | ctx->disconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, |
2206 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
2207 | &malicious_disconnect_task, ctx); | 2198 | &malicious_disconnect_task, ctx); |
2208 | } | 2199 | } |
2209 | 2200 | ||
@@ -2225,7 +2216,7 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc | |||
2225 | temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); | 2216 | temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); |
2226 | ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); | 2217 | ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); |
2227 | ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET; | 2218 | ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET; |
2228 | GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx); | 2219 | GNUNET_SCHEDULER_add_now (&set_malicious, ctx); |
2229 | 2220 | ||
2230 | } | 2221 | } |
2231 | 2222 | ||
@@ -2235,7 +2226,7 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc | |||
2235 | temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); | 2226 | temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); |
2236 | ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); | 2227 | ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); |
2237 | ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT; | 2228 | ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT; |
2238 | GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx); | 2229 | GNUNET_SCHEDULER_add_now (&set_malicious, ctx); |
2239 | 2230 | ||
2240 | } | 2231 | } |
2241 | 2232 | ||
@@ -2245,7 +2236,7 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc | |||
2245 | temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); | 2236 | temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); |
2246 | ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); | 2237 | ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); |
2247 | ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP; | 2238 | ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP; |
2248 | GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx); | 2239 | GNUNET_SCHEDULER_add_now (&set_malicious, ctx); |
2249 | } | 2240 | } |
2250 | 2241 | ||
2251 | /** | 2242 | /** |
@@ -2255,14 +2246,13 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc | |||
2255 | if (malicious_getters + malicious_putters + malicious_droppers > 0) | 2246 | if (malicious_getters + malicious_putters + malicious_droppers > 0) |
2256 | { | 2247 | { |
2257 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Giving malicious set tasks some time before starting testing!\n"); | 2248 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Giving malicious set tasks some time before starting testing!\n"); |
2258 | die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (malicious_getters + malicious_putters + malicious_droppers) * 2), | 2249 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (malicious_getters + malicious_putters + malicious_droppers) * 2), |
2259 | &end_badly, "from set malicious"); | 2250 | &end_badly, "from set malicious"); |
2260 | } | 2251 | } |
2261 | else /* Otherwise, continue testing */ | 2252 | else /* Otherwise, continue testing */ |
2262 | { | 2253 | { |
2263 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Scheduling continue_puts_and_gets now!\n"); | 2254 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Scheduling continue_puts_and_gets now!\n"); |
2264 | GNUNET_SCHEDULER_add_now (sched, | 2255 | GNUNET_SCHEDULER_add_now (&continue_puts_and_gets, NULL); |
2265 | &continue_puts_and_gets, NULL); | ||
2266 | } | 2256 | } |
2267 | } | 2257 | } |
2268 | 2258 | ||
@@ -2321,8 +2311,8 @@ topology_callback (void *cls, | |||
2321 | dhtlog_handle->insert_topology(expected_connections); | 2311 | dhtlog_handle->insert_topology(expected_connections); |
2322 | } | 2312 | } |
2323 | 2313 | ||
2324 | GNUNET_SCHEDULER_cancel (sched, die_task); | 2314 | GNUNET_SCHEDULER_cancel (die_task); |
2325 | /*die_task = GNUNET_SCHEDULER_add_delayed (sched, DEFAULT_TIMEOUT, | 2315 | /*die_task = GNUNET_SCHEDULER_add_delayed (DEFAULT_TIMEOUT, |
2326 | &end_badly, "from setup puts/gets");*/ | 2316 | &end_badly, "from setup puts/gets");*/ |
2327 | if ((dhtlog_handle != NULL) && (settle_time > 0)) | 2317 | if ((dhtlog_handle != NULL) && (settle_time > 0)) |
2328 | { | 2318 | { |
@@ -2330,21 +2320,19 @@ topology_callback (void *cls, | |||
2330 | topo_ctx->cont = &setup_malicious_peers; | 2320 | topo_ctx->cont = &setup_malicious_peers; |
2331 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); | 2321 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create(num_peers); |
2332 | //topo_ctx->cont = &continue_puts_and_gets; | 2322 | //topo_ctx->cont = &continue_puts_and_gets; |
2333 | GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx); | 2323 | GNUNET_SCHEDULER_add_now(&capture_current_topology, topo_ctx); |
2334 | } | 2324 | } |
2335 | else | 2325 | else |
2336 | { | 2326 | { |
2337 | GNUNET_SCHEDULER_add_now(sched, &setup_malicious_peers, NULL); | 2327 | GNUNET_SCHEDULER_add_now(&setup_malicious_peers, NULL); |
2338 | /*GNUNET_SCHEDULER_add_delayed (sched, | 2328 | /*GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), |
2339 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), | ||
2340 | &continue_puts_and_gets, NULL);*/ | 2329 | &continue_puts_and_gets, NULL);*/ |
2341 | } | 2330 | } |
2342 | } | 2331 | } |
2343 | else if (total_connections + failed_connections == expected_connections) | 2332 | else if (total_connections + failed_connections == expected_connections) |
2344 | { | 2333 | { |
2345 | GNUNET_SCHEDULER_cancel (sched, die_task); | 2334 | GNUNET_SCHEDULER_cancel (die_task); |
2346 | die_task = GNUNET_SCHEDULER_add_now (sched, | 2335 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); |
2347 | &end_badly, "from topology_callback (too many failed connections)"); | ||
2348 | } | 2336 | } |
2349 | } | 2337 | } |
2350 | 2338 | ||
@@ -2376,7 +2364,7 @@ peers_started_callback (void *cls, | |||
2376 | "All %d daemons started, now connecting peers!\n", | 2364 | "All %d daemons started, now connecting peers!\n", |
2377 | num_peers); | 2365 | num_peers); |
2378 | #endif | 2366 | #endif |
2379 | GNUNET_SCHEDULER_cancel (sched, die_task); | 2367 | GNUNET_SCHEDULER_cancel (die_task); |
2380 | 2368 | ||
2381 | expected_connections = UINT_MAX; | 2369 | expected_connections = UINT_MAX; |
2382 | if ((pg != NULL) && (peers_left == 0)) | 2370 | if ((pg != NULL) && (peers_left == 0)) |
@@ -2389,12 +2377,10 @@ peers_started_callback (void *cls, | |||
2389 | 2377 | ||
2390 | if (expected_connections == GNUNET_SYSERR) | 2378 | if (expected_connections == GNUNET_SYSERR) |
2391 | { | 2379 | { |
2392 | die_task = GNUNET_SCHEDULER_add_now (sched, | 2380 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); |
2393 | &end_badly, "from connect topology (bad return)"); | ||
2394 | } | 2381 | } |
2395 | 2382 | ||
2396 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 2383 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, DEFAULT_CONNECT_TIMEOUT * expected_connections), |
2397 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, DEFAULT_CONNECT_TIMEOUT * expected_connections), | ||
2398 | &end_badly, "from connect topology (timeout)"); | 2384 | &end_badly, "from connect topology (timeout)"); |
2399 | 2385 | ||
2400 | ok = 0; | 2386 | ok = 0; |
@@ -2415,14 +2401,12 @@ create_topology () | |||
2415 | } | 2401 | } |
2416 | else | 2402 | else |
2417 | { | 2403 | { |
2418 | GNUNET_SCHEDULER_cancel (sched, die_task); | 2404 | GNUNET_SCHEDULER_cancel (die_task); |
2419 | die_task = GNUNET_SCHEDULER_add_now (sched, | 2405 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)"); |
2420 | &end_badly, "from create topology (bad return)"); | ||
2421 | } | 2406 | } |
2422 | GNUNET_free_non_null(blacklist_transports); | 2407 | GNUNET_free_non_null(blacklist_transports); |
2423 | GNUNET_SCHEDULER_cancel (sched, die_task); | 2408 | GNUNET_SCHEDULER_cancel (die_task); |
2424 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 2409 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), |
2425 | GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), | ||
2426 | &end_badly, "from continue startup (timeout)"); | 2410 | &end_badly, "from continue startup (timeout)"); |
2427 | } | 2411 | } |
2428 | 2412 | ||
@@ -2459,13 +2443,12 @@ hostkey_callback (void *cls, | |||
2459 | "All %d hostkeys created, now creating topology!\n", | 2443 | "All %d hostkeys created, now creating topology!\n", |
2460 | num_peers); | 2444 | num_peers); |
2461 | #endif | 2445 | #endif |
2462 | GNUNET_SCHEDULER_cancel (sched, die_task); | 2446 | GNUNET_SCHEDULER_cancel (die_task); |
2463 | /* Set up task in case topology creation doesn't finish | 2447 | /* Set up task in case topology creation doesn't finish |
2464 | * within a reasonable amount of time */ | 2448 | * within a reasonable amount of time */ |
2465 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 2449 | die_task = GNUNET_SCHEDULER_add_delayed (DEFAULT_TOPOLOGY_TIMEOUT, |
2466 | DEFAULT_TOPOLOGY_TIMEOUT, | ||
2467 | &end_badly, "from create_topology"); | 2450 | &end_badly, "from create_topology"); |
2468 | GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); | 2451 | GNUNET_SCHEDULER_add_now(&create_topology, NULL); |
2469 | ok = 0; | 2452 | ok = 0; |
2470 | } | 2453 | } |
2471 | } | 2454 | } |
@@ -2473,7 +2456,6 @@ hostkey_callback (void *cls, | |||
2473 | 2456 | ||
2474 | static void | 2457 | static void |
2475 | run (void *cls, | 2458 | run (void *cls, |
2476 | struct GNUNET_SCHEDULER_Handle *s, | ||
2477 | char *const *args, | 2459 | char *const *args, |
2478 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | 2460 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
2479 | { | 2461 | { |
@@ -2503,9 +2485,8 @@ run (void *cls, | |||
2503 | char *churn_filename; | 2485 | char *churn_filename; |
2504 | int count; | 2486 | int count; |
2505 | int ret; | 2487 | int ret; |
2506 | unsigned int line_number; | 2488 | int line_number; |
2507 | 2489 | ||
2508 | sched = s; | ||
2509 | config = cfg; | 2490 | config = cfg; |
2510 | rounds_finished = 0; | 2491 | rounds_finished = 0; |
2511 | memset(&trial_info, 0, sizeof(struct GNUNET_DHTLOG_TrialInfo)); | 2492 | memset(&trial_info, 0, sizeof(struct GNUNET_DHTLOG_TrialInfo)); |
@@ -2986,8 +2967,7 @@ run (void *cls, | |||
2986 | 2967 | ||
2987 | 2968 | ||
2988 | /* Set up a task to end testing if peer start fails */ | 2969 | /* Set up a task to end testing if peer start fails */ |
2989 | die_task = GNUNET_SCHEDULER_add_delayed (sched, | 2970 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), |
2990 | GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), | ||
2991 | &end_badly, "didn't generate all hostkeys within allowed startup time!"); | 2971 | &end_badly, "didn't generate all hostkeys within allowed startup time!"); |
2992 | 2972 | ||
2993 | if (dhtlog_handle == NULL) | 2973 | if (dhtlog_handle == NULL) |
@@ -3032,7 +3012,7 @@ run (void *cls, | |||
3032 | 3012 | ||
3033 | put_meter = create_meter(num_puts, "Puts completed ", GNUNET_YES); | 3013 | put_meter = create_meter(num_puts, "Puts completed ", GNUNET_YES); |
3034 | get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES); | 3014 | get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES); |
3035 | pg = GNUNET_TESTING_daemons_start (sched, cfg, | 3015 | pg = GNUNET_TESTING_daemons_start (cfg, |
3036 | peers_left, | 3016 | peers_left, |
3037 | GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), | 3017 | GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers), |
3038 | &hostkey_callback, NULL, | 3018 | &hostkey_callback, NULL, |