summaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_ats.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-25 21:27:31 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-25 21:27:31 +0000
commit4939e6e943f7480ebc9d5c23b6cc3251e8a42286 (patch)
tree81d279e8326ab022e6135c131420b1894547af18 /src/transport/gnunet-service-transport_ats.c
parent896e28ee7d8aee5fb15c905eef18a6f73e844d7f (diff)
fixing wrong assertions
Diffstat (limited to 'src/transport/gnunet-service-transport_ats.c')
-rw-r--r--src/transport/gnunet-service-transport_ats.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c
index 4fcf7c9dc..f862f8c47 100644
--- a/src/transport/gnunet-service-transport_ats.c
+++ b/src/transport/gnunet-service-transport_ats.c
@@ -108,6 +108,8 @@ find_ai_cb (void *cls,
fc->ret = ai;
return GNUNET_NO;
}
+ GNUNET_assert ( (fc->session != ai->session) ||
+ (NULL == ai->session) );
return GNUNET_YES;
}
@@ -138,6 +140,21 @@ find_ai (const struct GNUNET_HELLO_Address *address,
/**
+ * Test if ATS knows about this address.
+ *
+ * @param address the address
+ * @param session the session
+ * @return #GNUNET_YES if address is known, #GNUNET_NO if not.
+ */
+int
+GST_ats_is_known (const struct GNUNET_HELLO_Address *address,
+ struct Session *session)
+{
+ return (NULL != find_ai (address, session)) ? GNUNET_YES : GNUNET_NO;
+}
+
+
+/**
* Notify ATS about the new address including the network this address is
* located in.
*
@@ -170,10 +187,6 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
{
GNUNET_break (NULL != session);
}
- else
- {
- GNUNET_break (NULL == session);
- }
ai = find_ai (address, session);
if (NULL != ai)
{
@@ -183,7 +196,7 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
if (NULL == (papi = GST_plugins_find (address->transport_name)))
{
/* we don't have the plugin for this address */
- GNUNET_break(0);
+ GNUNET_assert (0);
return;
}
if (NULL != session)
@@ -244,7 +257,12 @@ GST_ats_new_session (const struct GNUNET_HELLO_Address *address,
ai = find_ai (address, NULL);
if (NULL == ai)
{
- GNUNET_break (NULL != (find_ai (address, session)));
+ /* We may already be aware of the session, even if some other part
+ of the code could not tell if it just created a new session or
+ just got one recycled from the plugin; hence, we may be called
+ with "new" session even for an "old" session; in that case,
+ check that this is the case, but just ignore it. */
+ GNUNET_assert (NULL != (find_ai (address, session)));
return;
}
GNUNET_break (NULL == ai->session);
@@ -330,9 +348,9 @@ GST_ats_update_metrics (const struct GNUNET_HELLO_Address *address,
and if we get metrics for those, they were never known to
ATS which means we end up here (however, in this
case, the address must be an outbound address). */
- GNUNET_break (GNUNET_YES !=
- GNUNET_HELLO_address_check_option (address,
- GNUNET_HELLO_ADDRESS_INFO_INBOUND));
+ GNUNET_assert (GNUNET_YES !=
+ GNUNET_HELLO_address_check_option (address,
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND));
return;
}
@@ -394,7 +412,7 @@ GST_ats_expire_address (const struct GNUNET_HELLO_Address *address)
ai = find_ai (address, NULL);
if (NULL == ai)
{
- GNUNET_break (0);
+ GNUNET_assert (0);
return;
}
GNUNET_assert (GNUNET_YES ==