From 9baa7c3f6e6b7f1a29e3004147b9c70dddd33c74 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 29 Oct 2015 14:27:37 +0000 Subject: [PATCH] replacing deprecated transport_try_connect call with ATS call --- src/core/test_core_api.c | 41 ++------------------------- src/core/test_core_api_reliability.c | 29 +++---------------- src/core/test_core_quota_compliance.c | 33 +++++---------------- 3 files changed, 14 insertions(+), 89 deletions(-) diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index b1c6c8212..9404aa0e6 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -50,8 +50,6 @@ static struct PeerContext p2; static struct GNUNET_SCHEDULER_Task *err_task; -static struct GNUNET_SCHEDULER_Task *con_task; - static int ok; #define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) @@ -107,11 +105,6 @@ terminate_task (void *cls, GNUNET_assert (ok == 6); terminate_peer (&p1); terminate_peer (&p2); - if (NULL != con_task) - { - GNUNET_SCHEDULER_cancel (con_task); - con_task = NULL; - } ok = 0; } @@ -126,11 +119,6 @@ terminate_task_error (void *cls, GNUNET_break (0); terminate_peer (&p1); terminate_peer (&p2); - if (NULL != con_task) - { - GNUNET_SCHEDULER_cancel (con_task); - con_task = NULL; - } ok = 42; } @@ -164,11 +152,6 @@ connect_notify (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection established to peer `%4s'\n", GNUNET_i2s (peer)); - if (NULL != con_task) - { - GNUNET_SCHEDULER_cancel (con_task); - con_task = NULL; - } pc->connect_status = 1; if (pc == &p1) { @@ -248,26 +231,6 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { }; -static void -connect_task (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) - { - con_task = NULL; - return; - } - con_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &connect_task, - NULL); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Asking transport (1) to connect to peer `%4s'\n", - GNUNET_i2s (&p2.id)); - GNUNET_TRANSPORT_try_connect (p1.th, &p2.id, NULL, NULL); /*FIXME TRY_CONNECT change */ -} - - static void init_notify (void *cls, const struct GNUNET_PeerIdentity *my_identity) @@ -293,7 +256,9 @@ init_notify (void *cls, GNUNET_assert (ok == 3); OKPP; GNUNET_assert (cls == &p2); - con_task = GNUNET_SCHEDULER_add_now (&connect_task, NULL); + p1.ats_sh = GNUNET_ATS_connectivity_suggest (p1.ats, + &p2.id, + 1); } } diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index dfea0cdcc..ffbdd3a28 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2009, 2010 Christian Grothoff (and other contributing authors) + Copyright (C) 2009, 2010, 2015 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -55,8 +55,6 @@ static struct GNUNET_TIME_Absolute start_time; static struct GNUNET_SCHEDULER_Task *err_task; -static struct GNUNET_SCHEDULER_Task *connect_task; - struct PeerContext { @@ -137,11 +135,6 @@ terminate_task (void *cls, terminate_peer (&p1); terminate_peer (&p2); - if (NULL != connect_task) - { - GNUNET_SCHEDULER_cancel (connect_task); - connect_task = NULL; - } delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; FPRINTF (stderr, "\nThroughput was %llu kb/s\n", @@ -159,26 +152,10 @@ terminate_task_error (void *cls, GNUNET_break (0); terminate_peer (&p1); terminate_peer (&p2); - if (NULL != connect_task) - { - GNUNET_SCHEDULER_cancel (connect_task); - connect_task = NULL; - } ok = 42; } -static void -try_connect (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - connect_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, - NULL); - GNUNET_TRANSPORT_try_connect (p1.th, &p2.id, NULL, NULL); /*FIXME TRY_CONNECT change */ -} - - static size_t transmit_ready (void *cls, size_t size, void *buf) { @@ -396,7 +373,9 @@ init_notify (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking transport (1) to connect to peer `%s'\n", GNUNET_i2s (&p2.id)); - connect_task = GNUNET_SCHEDULER_add_now (&try_connect, NULL); + p1.ats_sh = GNUNET_ATS_connectivity_suggest (p1.ats, + &p2.id, + 1); } } diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index ce62dbe3b..32edb50c7 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c @@ -64,8 +64,6 @@ static struct GNUNET_SCHEDULER_Task *err_task; static struct GNUNET_SCHEDULER_Task *measure_task; -static struct GNUNET_SCHEDULER_Task *connect_task; - struct PeerContext { @@ -160,11 +158,6 @@ terminate_task (void *cls, err_task = NULL; terminate_peer (&p1); terminate_peer (&p2); - if (NULL != connect_task) - { - GNUNET_SCHEDULER_cancel (connect_task); - connect_task = NULL; - } } @@ -185,27 +178,10 @@ terminate_task_error (void *cls, GNUNET_SCHEDULER_cancel (measure_task); measure_task = NULL; } - if (NULL != connect_task) - { - GNUNET_SCHEDULER_cancel (connect_task); - connect_task = NULL; - } ok = 42; } -static void -try_connect (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - connect_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, - NULL); - GNUNET_TRANSPORT_try_connect (p1.th, &p2.id, NULL, NULL); /*FIXME TRY_CONNECT change */ - GNUNET_TRANSPORT_try_connect (p2.th, &p1.id, NULL, NULL); /*FIXME TRY_CONNECT change */ -} - - /** * Callback function to process statistic values. * @@ -553,9 +529,14 @@ init_notify (void *cls, OKPP; GNUNET_assert (cls == &p2); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Asking core (1) to connect to peer `%4s'\n", + "Asking core (1) to connect to peer `%s' and vice-versa\n", GNUNET_i2s (&p2.id)); - connect_task = GNUNET_SCHEDULER_add_now (&try_connect, NULL); + p1.ats_sh = GNUNET_ATS_connectivity_suggest (p1.ats, + &p2.id, + 1); + p2.ats_sh = GNUNET_ATS_connectivity_suggest (p2.ats, + &p1.id, + 1); } } -- 2.25.1