replacing deprecated transport_try_connect call with ATS call
authorChristian Grothoff <christian@grothoff.org>
Thu, 29 Oct 2015 14:27:37 +0000 (14:27 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 29 Oct 2015 14:27:37 +0000 (14:27 +0000)
src/core/test_core_api.c
src/core/test_core_api_reliability.c
src/core/test_core_quota_compliance.c

index b1c6c8212884f4f968cc3e87ff7a3c44a5ee5ffe..9404aa0e63f35ced85746eacfc59dca4ac78c615 100644 (file)
@@ -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);
   }
 }
 
index dfea0cdcc52132128ee0f5918b12674b198ac8ca..ffbdd3a28c5e32b755163eccffdce09cbe98d66f 100644 (file)
@@ -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);
   }
 }
 
index ce62dbe3b004e6c8f19f53d1de6bdcf7108f3aa6..32edb50c76fd2b87d66c360ab55f8ce9fff15510 100644 (file)
@@ -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);
   }
 }