-getting rid of silly, stupid, useless, often wrong DEFAULTCONFIG setting
[oweals/gnunet.git] / src / ats / ats_api_scheduling.c
index 88a6423b44f45eb433bdc70b055b592b374439f1..db71d1e1e95a3fafb69e4838e670d3240b609900 100644 (file)
@@ -346,6 +346,22 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
     sh->reconnect = GNUNET_YES;
     return NULL;
   }
+  /* This check exploits the fact that first field of a session object
+   * is peer identity.
+   */
+  if (0 !=
+      memcmp (peer, sh->session_array[session_id].session,
+              sizeof (struct GNUNET_PeerIdentity)))
+  {
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
+              "Session %p belongs to peer `%s'\n",
+              sh->session_array[session_id].session, GNUNET_i2s_full ((struct GNUNET_PeerIdentity *)sh->session_array[session_id].session));
+/*
+    GNUNET_break (0);
+    sh->reconnect = GNUNET_YES;
+    return NULL;
+*/
+  }
   return sh->session_array[session_id].session;
 }
 
@@ -1049,7 +1065,7 @@ GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh,
  *
  * @param sh handle
  * @param address the address
- * @param session session handle (if available)
+ * @param session session handle, can be NULL
  * @param ats performance data for the address
  * @param ats_count number of performance records in 'ats'
  * @return GNUNET_OK on success, GNUNET_SYSERR on error
@@ -1075,11 +1091,6 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  if ((address == NULL) && (session == NULL))
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
 
   namelen =
       (address->transport_name ==
@@ -1153,7 +1164,7 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
  *
  * @param sh handle
  * @param address the address
- * @param session session handle (if available)
+ * @param session session handle, can be NULL
  * @param ats performance data for the address
  * @param ats_count number of performance records in 'ats'
  */
@@ -1177,11 +1188,6 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
     GNUNET_break (0);
     return;
   }
-  if ((address == NULL) && (session == NULL))
-  {
-    GNUNET_break (0);
-    return;
-  }
 
   namelen =
       (address->transport_name ==
@@ -1248,7 +1254,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
  *
  * @param sh handle
  * @param address the address
- * @param session session handle
+ * @param session session handle, can be NULL
  * @param in_use GNUNET_YES if this address is now used, GNUNET_NO
  * if address is not used any more
  */
@@ -1328,7 +1334,7 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
  *
  * @param sh handle
  * @param address the address
- * @param session session handle that is no longer valid
+ * @param session session handle that is no longer valid, can be NULL
  */
 void
 GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
@@ -1342,6 +1348,12 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
   size_t msize;
   uint32_t s = 0;
 
+  if (address == NULL)
+  {
+    GNUNET_break (0);
+    return;
+  }
+
   GNUNET_assert (address->transport_name != NULL);
   namelen = strlen (address->transport_name) + 1;
   GNUNET_assert (namelen > 1);