aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport_ats.c38
-rw-r--r--src/transport/gnunet-service-transport_ats.h11
2 files changed, 39 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,
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 *
@@ -170,10 +187,6 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
170 { 187 {
171 GNUNET_break (NULL != session); 188 GNUNET_break (NULL != session);
172 } 189 }
173 else
174 {
175 GNUNET_break (NULL == session);
176 }
177 ai = find_ai (address, session); 190 ai = find_ai (address, session);
178 if (NULL != ai) 191 if (NULL != ai)
179 { 192 {
@@ -183,7 +196,7 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
183 if (NULL == (papi = GST_plugins_find (address->transport_name))) 196 if (NULL == (papi = GST_plugins_find (address->transport_name)))
184 { 197 {
185 /* we don't have the plugin for this address */ 198 /* we don't have the plugin for this address */
186 GNUNET_break(0); 199 GNUNET_assert (0);
187 return; 200 return;
188 } 201 }
189 if (NULL != session) 202 if (NULL != session)
@@ -244,7 +257,12 @@ GST_ats_new_session (const struct GNUNET_HELLO_Address *address,
244 ai = find_ai (address, NULL); 257 ai = find_ai (address, NULL);
245 if (NULL == ai) 258 if (NULL == ai)
246 { 259 {
247 GNUNET_break (NULL != (find_ai (address, session))); 260 /* We may already be aware of the session, even if some other part
261 of the code could not tell if it just created a new session or
262 just got one recycled from the plugin; hence, we may be called
263 with "new" session even for an "old" session; in that case,
264 check that this is the case, but just ignore it. */
265 GNUNET_assert (NULL != (find_ai (address, session)));
248 return; 266 return;
249 } 267 }
250 GNUNET_break (NULL == ai->session); 268 GNUNET_break (NULL == ai->session);
@@ -330,9 +348,9 @@ GST_ats_update_metrics (const struct GNUNET_HELLO_Address *address,
330 and if we get metrics for those, they were never known to 348 and if we get metrics for those, they were never known to
331 ATS which means we end up here (however, in this 349 ATS which means we end up here (however, in this
332 case, the address must be an outbound address). */ 350 case, the address must be an outbound address). */
333 GNUNET_break (GNUNET_YES != 351 GNUNET_assert (GNUNET_YES !=
334 GNUNET_HELLO_address_check_option (address, 352 GNUNET_HELLO_address_check_option (address,
335 GNUNET_HELLO_ADDRESS_INFO_INBOUND)); 353 GNUNET_HELLO_ADDRESS_INFO_INBOUND));
336 354
337 return; 355 return;
338 } 356 }
@@ -394,7 +412,7 @@ GST_ats_expire_address (const struct GNUNET_HELLO_Address *address)
394 ai = find_ai (address, NULL); 412 ai = find_ai (address, NULL);
395 if (NULL == ai) 413 if (NULL == ai)
396 { 414 {
397 GNUNET_break (0); 415 GNUNET_assert (0);
398 return; 416 return;
399 } 417 }
400 GNUNET_assert (GNUNET_YES == 418 GNUNET_assert (GNUNET_YES ==
diff --git a/src/transport/gnunet-service-transport_ats.h b/src/transport/gnunet-service-transport_ats.h
index b066ad74f..b203cc323 100644
--- a/src/transport/gnunet-service-transport_ats.h
+++ b/src/transport/gnunet-service-transport_ats.h
@@ -51,6 +51,17 @@ GST_ats_done (void);
51 51
52 52
53/** 53/**
54 * Test if ATS knows about this address.
55 *
56 * @param address the address
57 * @param session the session
58 * @return #GNUNET_YES if address is known, #GNUNET_NO if not.
59 */
60int
61GST_ats_is_known (const struct GNUNET_HELLO_Address *address,
62 struct Session *session);
63
64/**
54 * Notify ATS about the new address including the network this address is 65 * Notify ATS about the new address including the network this address is
55 * located in. 66 * located in.
56 * 67 *