aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-transport.c
diff options
context:
space:
mode:
authorBertrand Marc <beberking@gmail.com>2012-06-06 20:47:48 +0200
committerBertrand Marc <beberking@gmail.com>2012-06-06 20:47:48 +0200
commit740b30688bd745a527f96f9116c19acb3480971a (patch)
tree2709a3f4dba11c174aa9e1ba3612e30c578e76a9 /src/transport/gnunet-transport.c
parent2b81464a43485fcc8ce079fafdee7b7a171835f4 (diff)
Imported Upstream version 0.9.3upstream/0.9.3
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r--src/transport/gnunet-transport.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index ee977f5..3b6b7e4 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -37,8 +37,10 @@
/**
* How long do we wait for the NAT test to report success?
+ * Should match NAT_SERVER_TIMEOUT in 'nat_test.c'.
*/
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
+#define RESOLUTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
/**
* Which peer should we connect to?
@@ -121,6 +123,8 @@ static struct GNUNET_PeerIdentity pid;
*/
static GNUNET_SCHEDULER_TaskIdentifier end;
+static struct GNUNET_CONTAINER_MultiHashMap *peers;
+
/**
* Selected level of verbosity.
*/
@@ -193,7 +197,7 @@ display_test_result (struct TestContext *tc, int result)
if ((0 == resolver_users) && (NULL != resolver))
{
GNUNET_break (0 == GNUNET_OS_process_kill (resolver, SIGTERM));
- GNUNET_OS_process_close (resolver);
+ GNUNET_OS_process_destroy (resolver);
resolver = NULL;
}
}
@@ -443,19 +447,32 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
traffic_received += ntohs (message->size);
}
-void
+struct ResolutionContext
+{
+ struct GNUNET_HELLO_Address *addrcp;
+
+ int printed;
+};
+
+
+static void
process_string (void *cls, const char *address)
{
- struct GNUNET_HELLO_Address *addrcp = cls;
+ struct ResolutionContext *rc = cls;
+ struct GNUNET_HELLO_Address *addrcp = rc->addrcp;
- if ((address != NULL))
+ if (address != NULL)
{
FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name, address);
+ rc->printed = GNUNET_YES;
}
else
{
/* done */
- GNUNET_free (addrcp);
+ if (GNUNET_NO == rc->printed)
+ FPRINTF (stdout, _("Peer `%s': %s <unable to resolve address>\n"), GNUNET_i2s (&addrcp->peer), addrcp->transport_name);
+ GNUNET_free (rc->addrcp);
+ GNUNET_free (rc);
}
}
@@ -471,6 +488,7 @@ process_address (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address)
{
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+ struct ResolutionContext *rc;
if (peer == NULL)
{
@@ -484,10 +502,16 @@ process_address (void *cls, const struct GNUNET_PeerIdentity *peer,
return;
}
+ rc = GNUNET_malloc(sizeof (struct ResolutionContext));
+ rc->addrcp = GNUNET_HELLO_address_copy(address);
+ rc->printed = GNUNET_NO;
+
+ GNUNET_assert (NULL != rc);
+
/* Resolve address to string */
GNUNET_TRANSPORT_address_to_string (cfg, address, numeric,
- GNUNET_TIME_UNIT_MINUTES, &process_string,
- GNUNET_HELLO_address_copy(address));
+ RESOLUTION_TIMEOUT, &process_string,
+ rc);
}
@@ -504,7 +528,13 @@ shutdown_task (void *cls,
{
struct GNUNET_TRANSPORT_PeerIterateContext *pic = cls;
- GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pic);
+ GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pic);
+
+ if (NULL != peers)
+ {
+ GNUNET_CONTAINER_multihashmap_destroy (peers);
+ peers = NULL;
+ }
}
@@ -561,8 +591,9 @@ run (void *cls, char *const *args, const char *cfgfile,
}
if (iterate_connections)
{
+ peers = GNUNET_CONTAINER_multihashmap_create (20);
GNUNET_TRANSPORT_peer_get_active_addresses (cfg, NULL, GNUNET_YES,
- GNUNET_TIME_UNIT_MINUTES,
+ TIMEOUT,
&process_address, (void *) cfg);
}
if (monitor_connections)