Avoid trying to disconnect a neighbour twice
[oweals/gnunet.git] / src / transport / transport_api_address_to_string.c
index afd0c7deb91babf14c61561c0cea3fc0f3c2b38d..801bcac8455ba76b15ff2dc26f6b128b2e8d59aa 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009-2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009-2014 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
@@ -73,11 +73,12 @@ address_response_processor (void *cls,
 
   if (NULL == msg)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Disconnected from transport, address resolution failed\n");
     alucb->cb (alucb->cb_cls,
                NULL,
                GNUNET_SYSERR);
-    GNUNET_CLIENT_disconnect (alucb->client);
-    GNUNET_free (alucb);
+    GNUNET_TRANSPORT_address_to_string_cancel (alucb);
     return;
   }
   GNUNET_break (ntohs (msg->type) ==
@@ -90,8 +91,7 @@ address_response_processor (void *cls,
     alucb->cb (alucb->cb_cls,
                NULL,
                GNUNET_SYSERR);
-    GNUNET_CLIENT_disconnect (alucb->client);
-    GNUNET_free (alucb);
+    GNUNET_TRANSPORT_address_to_string_cancel (alucb);
     return;
   }
   atsm = (const struct AddressToStringResultMessage *) msg;
@@ -101,6 +101,8 @@ address_response_processor (void *cls,
   {
     /* expect more replies; as this is not the last
        call, we must pass the empty string for the address */
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Address resolution failed\n");
     alucb->cb (alucb->cb_cls,
                "",
                GNUNET_NO);
@@ -126,8 +128,7 @@ address_response_processor (void *cls,
     alucb->cb (alucb->cb_cls,
                NULL,
                GNUNET_OK);
-    GNUNET_CLIENT_disconnect (alucb->client);
-    GNUNET_free (alucb);
+    GNUNET_TRANSPORT_address_to_string_cancel (alucb);
     return;
   }
   address = (const char *) &atsm[1];
@@ -139,8 +140,7 @@ address_response_processor (void *cls,
     alucb->cb (alucb->cb_cls,
                NULL,
                GNUNET_SYSERR);
-    GNUNET_CLIENT_disconnect (alucb->client);
-    GNUNET_free (alucb);
+    GNUNET_TRANSPORT_address_to_string_cancel (alucb);
     return;
   }
   /* expect more replies */
@@ -194,11 +194,15 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cf
   }
   client = GNUNET_CLIENT_connect ("transport", cfg);
   if (NULL == client)
+  {
+    GNUNET_break (0);
     return NULL;
+  }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Client %p tries to resolve for peer `%s'address len %u \n",
+              "Client %p tries to resolve for peer `%s' address plugin %s len %u\n",
               client,
               GNUNET_i2s (&address->peer),
+              address->transport_name,
               address->address_length);
 
   msg = GNUNET_malloc (len);