diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_ats.c')
-rw-r--r-- | src/transport/gnunet-service-transport_ats.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c index c6975e526..4fcf7c9dc 100644 --- a/src/transport/gnunet-service-transport_ats.c +++ b/src/transport/gnunet-service-transport_ats.c | |||
@@ -254,11 +254,8 @@ GST_ats_new_session (const struct GNUNET_HELLO_Address *address, | |||
254 | "Telling ATS about new session %p for peer %s\n", | 254 | "Telling ATS about new session %p for peer %s\n", |
255 | session, | 255 | session, |
256 | GNUNET_i2s (&address->peer)); | 256 | GNUNET_i2s (&address->peer)); |
257 | // FIXME: tell ATS API, but not using this call: | 257 | GNUNET_ATS_address_add_session (ai->ar, |
258 | GNUNET_ATS_address_update (ai->ar, | 258 | session); |
259 | session, | ||
260 | NULL, 0); | ||
261 | |||
262 | } | 259 | } |
263 | 260 | ||
264 | 261 | ||
@@ -300,14 +297,12 @@ GST_ats_del_session (const struct GNUNET_HELLO_Address *address, | |||
300 | "Telling ATS to destroy session %p from peer %s\n", | 297 | "Telling ATS to destroy session %p from peer %s\n", |
301 | session, | 298 | session, |
302 | GNUNET_i2s (&address->peer)); | 299 | GNUNET_i2s (&address->peer)); |
303 | /* FIXME: if this was an *inbound* address, destroy it | ||
304 | FULLY here well; but use different API, as looking up | ||
305 | inbound address without session is not great... */ | ||
306 | GNUNET_ATS_address_destroyed (GST_ats, address, session); | ||
307 | if (GNUNET_YES == | 300 | if (GNUNET_YES == |
308 | GNUNET_HELLO_address_check_option (address, | 301 | GNUNET_ATS_address_del_session (ai->ar, session)) |
309 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | 302 | { |
303 | ai->ar = NULL; | ||
310 | GST_ats_expire_address (address); | 304 | GST_ats_expire_address (address); |
305 | } | ||
311 | } | 306 | } |
312 | 307 | ||
313 | 308 | ||
@@ -355,13 +350,36 @@ GST_ats_update_metrics (const struct GNUNET_HELLO_Address *address, | |||
355 | ats, | 350 | ats, |
356 | ats_count); | 351 | ats_count); |
357 | GNUNET_ATS_address_update (ai->ar, | 352 | GNUNET_ATS_address_update (ai->ar, |
358 | session, | ||
359 | ats_new, ats_count); | 353 | ats_new, ats_count); |
360 | GNUNET_free_non_null (ats_new); | 354 | GNUNET_free_non_null (ats_new); |
361 | } | 355 | } |
362 | 356 | ||
363 | 357 | ||
364 | /** | 358 | /** |
359 | * Notify ATS about a new session now being in use (or not). | ||
360 | * | ||
361 | * @param address the address | ||
362 | * @param session the session | ||
363 | * @param in_use #GNUNET_YES or #GNUNET_NO | ||
364 | */ | ||
365 | void | ||
366 | GST_ats_set_in_use (const struct GNUNET_HELLO_Address *address, | ||
367 | struct Session *session, | ||
368 | int in_use) | ||
369 | { | ||
370 | struct AddressInfo *ai; | ||
371 | |||
372 | ai = find_ai (address, session); | ||
373 | if (NULL == ai) | ||
374 | { | ||
375 | GNUNET_break (0); | ||
376 | return; | ||
377 | } | ||
378 | GNUNET_ATS_address_set_in_use (ai->ar, in_use); | ||
379 | } | ||
380 | |||
381 | |||
382 | /** | ||
365 | * Notify ATS that the address has expired and thus cannot | 383 | * Notify ATS that the address has expired and thus cannot |
366 | * be used any longer. This function must only be called | 384 | * be used any longer. This function must only be called |
367 | * if the corresponding session is already gone. | 385 | * if the corresponding session is already gone. |
@@ -388,7 +406,8 @@ GST_ats_expire_address (const struct GNUNET_HELLO_Address *address) | |||
388 | "transport-ats", | 406 | "transport-ats", |
389 | "Telling ATS to destroy address from peer %s\n", | 407 | "Telling ATS to destroy address from peer %s\n", |
390 | GNUNET_i2s (&address->peer)); | 408 | GNUNET_i2s (&address->peer)); |
391 | GNUNET_ATS_address_destroyed (GST_ats, address, NULL); | 409 | if (NULL != ai->ar) |
410 | GNUNET_ATS_address_destroy (ai->ar); | ||
392 | GNUNET_HELLO_address_free (ai->address); | 411 | GNUNET_HELLO_address_free (ai->address); |
393 | GNUNET_free (ai); | 412 | GNUNET_free (ai); |
394 | } | 413 | } |