Don't crash when address suggestor fails
authorLRN <lrn1986@gmail.com>
Thu, 6 Dec 2012 01:34:18 +0000 (01:34 +0000)
committerLRN <lrn1986@gmail.com>
Thu, 6 Dec 2012 01:34:18 +0000 (01:34 +0000)
src/ats/gnunet-service-ats_addresses.c
src/ats/gnunet-service-ats_addresses_simplistic.c

index b42fadb9bef53084b111650df1b225a3069f2014..605853b5bef9797c095ddb2ff10f1ad145b18024 100644 (file)
@@ -775,19 +775,20 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer)
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
   else
+  {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Suggesting address %p for peer `%s'\n", aa, GNUNET_i2s (peer));
 
-  ats_count = assemble_ats_information (aa, &ats);
-  GAS_scheduling_transmit_address_suggestion (peer,
-                                              aa->plugin,
-                                              aa->addr, aa->addr_len,
-                                              aa->session_id,
-                                              ats, ats_count,
-                                              aa->assigned_bw_out,
-                                              aa->assigned_bw_in);
-  GNUNET_free (ats);
-
+    ats_count = assemble_ats_information (aa, &ats);
+    GAS_scheduling_transmit_address_suggestion (peer,
+                                                aa->plugin,
+                                                aa->addr, aa->addr_len,
+                                                aa->session_id,
+                                                ats, ats_count,
+                                                aa->assigned_bw_out,
+                                                aa->assigned_bw_in);
+    GNUNET_free (ats);
+  }
 }
 
 
index 670b9edf221eacb302c4159e856e067b6ce379d6..201064c905b9db4f6ff9fdbdfe46c59e74698500 100644 (file)
@@ -262,13 +262,15 @@ GAS_simplistic_get_preferred_address (void *solver,
   if (NULL == aa)
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
   else
+  {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Suggesting address %p for peer `%s'\n", aa, GNUNET_i2s (peer));
 
-  if (GNUNET_NO == aa->active)
-  {
-    aa->active = GNUNET_YES;
-    s->active_addresses++;
-    recalculate_assigned_bw (s, addresses);
+    if (GNUNET_NO == aa->active)
+    {
+      aa->active = GNUNET_YES;
+      s->active_addresses++;
+      recalculate_assigned_bw (s, addresses);
+    }
   }
 
   return aa;