aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-22 20:54:15 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-22 20:54:15 +0000
commit9750132ba19a96ab1756de15e91c62405a1918fb (patch)
tree41312f4ff3224895507e127f712ffd9271a19cea /src/transport
parent7701720d1410c40923749c53b96ccb5770e1be09 (diff)
downloadgnunet-9750132ba19a96ab1756de15e91c62405a1918fb.tar.gz
gnunet-9750132ba19a96ab1756de15e91c62405a1918fb.zip
towards a cleaner ATS scheduling API
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport_ats.c45
-rw-r--r--src/transport/gnunet-service-transport_ats.h13
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c22
3 files changed, 57 insertions, 23 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 */
365void
366GST_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}
diff --git a/src/transport/gnunet-service-transport_ats.h b/src/transport/gnunet-service-transport_ats.h
index c7b826484..b066ad74f 100644
--- a/src/transport/gnunet-service-transport_ats.h
+++ b/src/transport/gnunet-service-transport_ats.h
@@ -79,6 +79,19 @@ GST_ats_new_session (const struct GNUNET_HELLO_Address *address,
79 79
80 80
81/** 81/**
82 * Notify ATS about a new session now being in use (or not).
83 *
84 * @param address the address
85 * @param session the session
86 * @param in_use #GNUNET_YES or #GNUNET_NO
87 */
88void
89GST_ats_set_in_use (const struct GNUNET_HELLO_Address *address,
90 struct Session *session,
91 int in_use);
92
93
94/**
82 * Notify ATS about property changes to an address 95 * Notify ATS about property changes to an address
83 * 96 *
84 * @param address the address 97 * @param address the address
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 40bad6d75..aca86535f 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -631,8 +631,12 @@ free_address (struct NeighbourAddress *na)
631{ 631{
632 if (GNUNET_YES == na->ats_active) 632 if (GNUNET_YES == na->ats_active)
633 { 633 {
634 GST_validation_set_address_use (na->address, na->session, GNUNET_NO); 634 GST_validation_set_address_use (na->address,
635 GNUNET_ATS_address_in_use (GST_ats, na->address, na->session, GNUNET_NO); 635 na->session,
636 GNUNET_NO);
637 GST_ats_set_in_use (na->address,
638 na->session,
639 GNUNET_NO);
636 } 640 }
637 641
638 na->bandwidth_in = GNUNET_BANDWIDTH_value_init (0); 642 na->bandwidth_in = GNUNET_BANDWIDTH_value_init (0);
@@ -816,10 +820,9 @@ set_primary_address (struct NeighbourMapEntry *n,
816 if (is_active != n->primary_address.ats_active) 820 if (is_active != n->primary_address.ats_active)
817 { 821 {
818 n->primary_address.ats_active = is_active; 822 n->primary_address.ats_active = is_active;
819 GNUNET_ATS_address_in_use (GST_ats, 823 GST_ats_set_in_use (n->primary_address.address,
820 n->primary_address.address, 824 n->primary_address.session,
821 n->primary_address.session, 825 is_active);
822 is_active);
823 GST_validation_set_address_use (n->primary_address.address, 826 GST_validation_set_address_use (n->primary_address.address,
824 n->primary_address.session, 827 n->primary_address.session,
825 is_active); 828 is_active);
@@ -855,10 +858,9 @@ set_primary_address (struct NeighbourMapEntry *n,
855 if (GNUNET_YES == is_active) 858 if (GNUNET_YES == is_active)
856 { 859 {
857 /* Telling ATS about new session */ 860 /* Telling ATS about new session */
858 GNUNET_ATS_address_in_use (GST_ats, 861 GST_ats_set_in_use (n->primary_address.address,
859 n->primary_address.address, 862 n->primary_address.session,
860 n->primary_address.session, 863 GNUNET_YES);
861 GNUNET_YES);
862 GST_validation_set_address_use (n->primary_address.address, 864 GST_validation_set_address_use (n->primary_address.address,
863 n->primary_address.session, 865 n->primary_address.session,
864 GNUNET_YES); 866 GNUNET_YES);