log
[oweals/gnunet.git] / src / transport / gnunet-transport.c
index 1195848105bc03667ce4a1efc202487b848f9926..fb8ec60ebff18470e9995815cf176c19fe643954 100644 (file)
@@ -263,6 +263,27 @@ struct TestContext
 
 };
 
+static struct ValidationResolutionContext *vc_head;
+static struct ValidationResolutionContext *vc_tail;
+
+struct ValidationResolutionContext
+{
+  struct ValidationResolutionContext *next;
+  struct ValidationResolutionContext *prev;
+
+  struct GNUNET_PeerIdentity id;
+  struct GNUNET_HELLO_Address *addrcp;
+  struct GNUNET_TIME_Absolute last_validation;
+  struct GNUNET_TIME_Absolute valid_until;
+  struct GNUNET_TIME_Absolute next_validation;
+  enum GNUNET_TRANSPORT_ValidationState state;
+
+  struct GNUNET_TRANSPORT_AddressToStringContext *asc;
+
+  char *transport;
+  int printed;
+};
+
 struct MonitoredPeer
 {
   enum GNUNET_TRANSPORT_PeerState state;
@@ -293,6 +314,8 @@ static void
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_TIME_Relative duration;
+  struct ValidationResolutionContext *cur;
+  struct ValidationResolutionContext *next;
   end = GNUNET_SCHEDULER_NO_TASK;
   if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
   {
@@ -314,6 +337,19 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_TRANSPORT_monitor_validation_entries_cancel (vic);
     vic = NULL;
   }
+
+  next = vc_head;
+  for (cur = next; NULL != cur; cur = next)
+  {
+    next = cur->next;
+
+    GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
+    GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, cur);
+    GNUNET_free (cur->transport);
+    GNUNET_HELLO_address_free (cur->addrcp);
+    GNUNET_free (cur);
+  }
+
   if (NULL != th)
   {
     GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
@@ -365,26 +401,7 @@ struct PeerResolutionContext
   int printed;
 };
 
-static struct ValidationResolutionContext *vc_head;
-static struct ValidationResolutionContext *vc_tail;
 
-struct ValidationResolutionContext
-{
-  struct ValidationResolutionContext *next;
-  struct ValidationResolutionContext *prev;
-
-  struct GNUNET_PeerIdentity id;
-  struct GNUNET_HELLO_Address *addrcp;
-  struct GNUNET_TIME_Absolute last_validation;
-  struct GNUNET_TIME_Absolute valid_until;
-  struct GNUNET_TIME_Absolute next_validation;
-  enum GNUNET_TRANSPORT_ValidationState state;
-
-  struct GNUNET_TRANSPORT_AddressToStringContext *asc;
-
-  char *transport;
-  int printed;
-};
 
 static void
 operation_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -950,7 +967,9 @@ print_info (const struct GNUNET_PeerIdentity *id, const char *transport,
     const char *addr, enum GNUNET_TRANSPORT_PeerState state,
     struct GNUNET_TIME_Absolute state_timeout)
 {
-  if ((GNUNET_YES == iterate_all) || (GNUNET_YES == monitor_connections) )
+
+  if ( ((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) ||
+       (GNUNET_YES == monitor_connections) )
   {
     FPRINTF (stdout, _("Peer `%s': %s %s in state `%s' until %s\n"),
         GNUNET_i2s (id),
@@ -959,12 +978,12 @@ print_info (const struct GNUNET_PeerIdentity *id, const char *transport,
         GNUNET_TRANSPORT_ps2s (state),
         GNUNET_STRINGS_absolute_time_to_string (state_timeout));
   }
-  else
+  else if ( (GNUNET_YES == iterate_connections) &&
+             (GNUNET_TRANSPORT_is_connected(state)) )
   {
     /* Only connected peers, skip state */
     FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (id), transport, addr);
   }
-
 }
 
 static void
@@ -1407,7 +1426,7 @@ testservice_task (void *cls, int result)
     GNUNET_break(0);
     return;
   }
-
+  GNUNET_break (0);
   end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
       &shutdown_task, NULL );