aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_ats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport_ats.c')
-rw-r--r--src/transport/gnunet-service-transport_ats.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c
index 4fcf7c9dc..a660f252f 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,
108 fc->ret = ai; 108 fc->ret = ai;
109 return GNUNET_NO; 109 return GNUNET_NO;
110 } 110 }
111 GNUNET_assert ( (fc->session != ai->session) ||
112 (NULL == ai->session) );
111 return GNUNET_YES; 113 return GNUNET_YES;
112} 114}
113 115
@@ -138,6 +140,21 @@ find_ai (const struct GNUNET_HELLO_Address *address,
138 140
139 141
140/** 142/**
143 * Test if ATS knows about this address.
144 *
145 * @param address the address
146 * @param session the session
147 * @return #GNUNET_YES if address is known, #GNUNET_NO if not.
148 */
149int
150GST_ats_is_known (const struct GNUNET_HELLO_Address *address,
151 struct Session *session)
152{
153 return (NULL != find_ai (address, session)) ? GNUNET_YES : GNUNET_NO;
154}
155
156
157/**
141 * Notify ATS about the new address including the network this address is 158 * Notify ATS about the new address including the network this address is
142 * located in. 159 * located in.
143 * 160 *
@@ -183,7 +200,7 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
183 if (NULL == (papi = GST_plugins_find (address->transport_name))) 200 if (NULL == (papi = GST_plugins_find (address->transport_name)))
184 { 201 {
185 /* we don't have the plugin for this address */ 202 /* we don't have the plugin for this address */
186 GNUNET_break(0); 203 GNUNET_assert (0);
187 return; 204 return;
188 } 205 }
189 if (NULL != session) 206 if (NULL != session)
@@ -244,7 +261,12 @@ GST_ats_new_session (const struct GNUNET_HELLO_Address *address,
244 ai = find_ai (address, NULL); 261 ai = find_ai (address, NULL);
245 if (NULL == ai) 262 if (NULL == ai)
246 { 263 {
247 GNUNET_break (NULL != (find_ai (address, session))); 264 /* We may already be aware of the session, even if some other part
265 of the code could not tell if it just created a new session or
266 just got one recycled from the plugin; hence, we may be called
267 with "new" session even for an "old" session; in that case,
268 check that this is the case, but just ignore it. */
269 GNUNET_assert (NULL != (find_ai (address, session)));
248 return; 270 return;
249 } 271 }
250 GNUNET_break (NULL == ai->session); 272 GNUNET_break (NULL == ai->session);
@@ -330,9 +352,9 @@ GST_ats_update_metrics (const struct GNUNET_HELLO_Address *address,
330 and if we get metrics for those, they were never known to 352 and if we get metrics for those, they were never known to
331 ATS which means we end up here (however, in this 353 ATS which means we end up here (however, in this
332 case, the address must be an outbound address). */ 354 case, the address must be an outbound address). */
333 GNUNET_break (GNUNET_YES != 355 GNUNET_assert (GNUNET_YES !=
334 GNUNET_HELLO_address_check_option (address, 356 GNUNET_HELLO_address_check_option (address,
335 GNUNET_HELLO_ADDRESS_INFO_INBOUND)); 357 GNUNET_HELLO_ADDRESS_INFO_INBOUND));
336 358
337 return; 359 return;
338 } 360 }
@@ -394,7 +416,7 @@ GST_ats_expire_address (const struct GNUNET_HELLO_Address *address)
394 ai = find_ai (address, NULL); 416 ai = find_ai (address, NULL);
395 if (NULL == ai) 417 if (NULL == ai)
396 { 418 {
397 GNUNET_break (0); 419 GNUNET_assert (0);
398 return; 420 return;
399 } 421 }
400 GNUNET_assert (GNUNET_YES == 422 GNUNET_assert (GNUNET_YES ==