-fix config, shutdown issue
[oweals/gnunet.git] / src / ats / test_ats_solver_alternative_after_delete_address.c
index 8a14b384e1b0200f733fb1b665084d259387f6b8..fcaf0db70e827b66e11ce585546cb6a007cdce7d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  This file is part of GNUnet.
- (C) 2010-2013 Christian Grothoff (and other contributing authors)
Copyright (C) 2010-2013 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
@@ -44,6 +44,11 @@ static struct GNUNET_STATISTICS_Handle *stats;
  */
 static struct GNUNET_ATS_SchedulingHandle *sched_ats;
 
+/**
+ * Connectivity handle
+ */
+static struct GNUNET_ATS_ConnectivityHandle *connect_ats;
+
 /**
  * Return value
  */
@@ -125,12 +130,16 @@ stat_cb (void *cls, const char *subsystem, const char *name, uint64_t value,
 static void
 end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  if (die_task != NULL)
+  if (NULL != die_task)
   {
     GNUNET_SCHEDULER_cancel (die_task);
     die_task = NULL;
   }
-
+  if (NULL != connect_ats)
+  {
+    GNUNET_ATS_connectivity_done (connect_ats);
+    connect_ats = NULL;
+  }
   if (NULL != sched_ats)
   {
     GNUNET_ATS_scheduling_done (sched_ats);
@@ -182,9 +191,8 @@ address_suggest_cb (void *cls,
                     struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Received a sugggestion for peer `%s' : `%s'\n",
-    GNUNET_i2s (&address->peer), (char *) address->address);
-
+              "Received a sugggestion for peer `%s'\n",
+              GNUNET_i2s (peer));
   if (GNUNET_NO == first_address_suggested)
   {
     if  (NULL == first_suggestion)
@@ -205,7 +213,7 @@ address_suggest_cb (void *cls,
 
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   "Received 1st sugggestion for peer `%s' : `%s'\n",
-        GNUNET_i2s (&address->peer), (char *) address->address);
+                  GNUNET_i2s (&address->peer), (char *) address->address);
 
       first_suggestion = GNUNET_HELLO_address_copy (address);
       first_address_suggested = GNUNET_YES;
@@ -313,7 +321,7 @@ stat_cb(void *cls, const char *subsystem,
                 "All addresses added, requesting....\n");
     /* We have 2 addresses, so we can request */
     addresses_added = GNUNET_YES;
-    GNUNET_ATS_suggest_address (sched_ats, &p.id);
+    GNUNET_ATS_connectivity_suggest (connect_ats, &p.id);
   }
   return GNUNET_OK;
 }
@@ -328,6 +336,7 @@ run (void *cls,
   stats = GNUNET_STATISTICS_create ("ats", mycfg);
   GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
 
+  connect_ats = GNUNET_ATS_connectivity_init (mycfg);
 
   /* Connect to ATS scheduling */
   sched_ats = GNUNET_ATS_scheduling_init (mycfg, &address_suggest_cb, NULL);