fixing mantis #1970
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 28 Nov 2011 14:38:15 +0000 (14:38 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 28 Nov 2011 14:38:15 +0000 (14:38 +0000)
bug: ats only deleted active addresses, but should delete all addresses with session removed and addrlen 0

src/ats/ats_api_scheduling.c
src/ats/gnunet-service-ats_addresses.c

index f9f4d2bbbe1bb682a02ff24fc8178a455b542210..89a3bb4724aed2ab306383bf3e28500289ec4e2c 100644 (file)
@@ -542,6 +542,18 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
   address.address = plugin_address;
   address.address_length = plugin_address_length;
   address.transport_name = plugin_name;
+
+  if ((s == NULL) && (0 == address.address_length))
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+        "ATS returned invalid address for peer `%s' transport `%s' address length %i, session_id %i\n",
+        GNUNET_i2s(&address.peer) , address.transport_name, plugin_address_length, session_id);
+    GNUNET_break_op (0);
+    GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh,
+                           GNUNET_TIME_UNIT_FOREVER_REL);
+    return;
+  }
+
   sh->suggest_cb (sh->suggest_cb_cls, &address, s, m->bandwidth_out,
                   m->bandwidth_in, atsi, ats_count);
 
index 726d10879681d49ef80b20e8a6cced151d724da0..626ffbf61d96bdba915f8344ce92311ec2049f89 100644 (file)
@@ -316,7 +316,7 @@ destroy_by_session_id (void *cls, const GNUNET_HashCode * key, void *value)
                     aa->addr,
                     aa->addr_len)) )
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Deleting address for peer `%s': `%s'\n",
                GNUNET_i2s (&aa->peer), aa->plugin);
     if (GNUNET_YES == destroy_address (aa))
@@ -329,14 +329,18 @@ destroy_by_session_id (void *cls, const GNUNET_HashCode * key, void *value)
     GNUNET_break (0 == strcmp (info->plugin, aa->plugin));
   /* session died */
   aa->session_id = 0;
+
   if (GNUNET_YES == aa->active)
   {
     aa->active = GNUNET_NO;
     active_addr_count--;
-    if (aa->addr_len == 0)
-      (void) destroy_address (aa);
     recalculate_assigned_bw ();
   }
+
+  /* session == 0 and addrlen == 0 : destroy address */
+  if (aa->addr_len == 0)
+    (void) destroy_address (aa);
+
   return GNUNET_OK;
 }