aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-10 11:06:33 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-10 11:06:33 +0000
commit9767d2478ccb8dcc3152cb617d84cd4cec2097c3 (patch)
tree584adb9bf94ba6d304f400ba350734bd5983898c /src
parent107b3a706cf4d2f0276fb7534a846de5d36a73a9 (diff)
downloadgnunet-9767d2478ccb8dcc3152cb617d84cd4cec2097c3.tar.gz
gnunet-9767d2478ccb8dcc3152cb617d84cd4cec2097c3.zip
renaming in code to use new ATS pref/reservation API
Diffstat (limited to 'src')
-rw-r--r--src/dht/Makefile.am1
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c23
-rw-r--r--src/fs/Makefile.am1
-rw-r--r--src/fs/gnunet-service-fs_cp.c36
4 files changed, 40 insertions, 21 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am
index a88611fb3..ba8b8457c 100644
--- a/src/dht/Makefile.am
+++ b/src/dht/Makefile.am
@@ -44,6 +44,7 @@ gnunet_service_dht_LDADD = \
44 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 44 $(top_builddir)/src/statistics/libgnunetstatistics.la \
45 $(top_builddir)/src/core/libgnunetcore.la \ 45 $(top_builddir)/src/core/libgnunetcore.la \
46 $(top_builddir)/src/nse/libgnunetnse.la \ 46 $(top_builddir)/src/nse/libgnunetnse.la \
47 $(top_builddir)/src/ats/libgnunetats.la \
47 $(top_builddir)/src/transport/libgnunettransport.la \ 48 $(top_builddir)/src/transport/libgnunettransport.la \
48 $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ 49 $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
49 $(top_builddir)/src/hello/libgnunethello.la \ 50 $(top_builddir)/src/hello/libgnunethello.la \
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 0623c0cb1..e1421e0f6 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -32,6 +32,7 @@
32#include "gnunet_constants.h" 32#include "gnunet_constants.h"
33#include "gnunet_protocols.h" 33#include "gnunet_protocols.h"
34#include "gnunet_nse_service.h" 34#include "gnunet_nse_service.h"
35#include "gnunet_ats_service.h"
35#include "gnunet_core_service.h" 36#include "gnunet_core_service.h"
36#include "gnunet_datacache_lib.h" 37#include "gnunet_datacache_lib.h"
37#include "gnunet_transport_service.h" 38#include "gnunet_transport_service.h"
@@ -321,7 +322,7 @@ struct PeerInfo
321 /** 322 /**
322 * Preference update context 323 * Preference update context
323 */ 324 */
324 struct GNUNET_CORE_InformationRequestContext *info_ctx; 325 struct GNUNET_ATS_InformationRequestContext *info_ctx;
325 326
326 /** 327 /**
327 * Task for scheduling preference updates 328 * Task for scheduling preference updates
@@ -407,10 +408,15 @@ static GNUNET_SCHEDULER_TaskIdentifier find_peer_task;
407static struct GNUNET_PeerIdentity my_identity; 408static struct GNUNET_PeerIdentity my_identity;
408 409
409/** 410/**
410 * Handle to GNUnet core. 411 * Handle to CORE.
411 */ 412 */
412static struct GNUNET_CORE_Handle *coreAPI; 413static struct GNUNET_CORE_Handle *coreAPI;
413 414
415/**
416 * Handle to ATS.
417 */
418static struct GNUNET_ATS_Handle *atsAPI;
419
414 420
415 421
416/** 422/**
@@ -514,10 +520,10 @@ update_core_preference (void *cls,
514 gettext_noop ("# Preference updates given to core"), 1, 520 gettext_noop ("# Preference updates given to core"), 1,
515 GNUNET_NO); 521 GNUNET_NO);
516 peer->info_ctx = 522 peer->info_ctx =
517 GNUNET_CORE_peer_change_preference (coreAPI, &peer->id, 523 GNUNET_ATS_peer_change_preference (atsAPI, &peer->id,
518 0, 524 0,
519 preference, 525 preference,
520 &update_core_preference_finish, peer); 526 &update_core_preference_finish, peer);
521} 527}
522 528
523 529
@@ -725,7 +731,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
725 to_remove)); 731 to_remove));
726 if (NULL != to_remove->info_ctx) 732 if (NULL != to_remove->info_ctx)
727 { 733 {
728 GNUNET_CORE_peer_change_preference_cancel (to_remove->info_ctx); 734 GNUNET_ATS_peer_change_preference_cancel (to_remove->info_ctx);
729 to_remove->info_ctx = NULL; 735 to_remove->info_ctx = NULL;
730 } 736 }
731 if (GNUNET_SCHEDULER_NO_TASK != to_remove->preference_task) 737 if (GNUNET_SCHEDULER_NO_TASK != to_remove->preference_task)
@@ -2040,6 +2046,7 @@ GDS_NEIGHBOURS_init ()
2040 GNUNET_CONFIGURATION_get_value_number (GDS_cfg, "DHT", "bucket_size", 2046 GNUNET_CONFIGURATION_get_value_number (GDS_cfg, "DHT", "bucket_size",
2041 &temp_config_num)) 2047 &temp_config_num))
2042 bucket_size = (unsigned int) temp_config_num; 2048 bucket_size = (unsigned int) temp_config_num;
2049 atsAPI = GNUNET_ATS_init (GDS_cfg, NULL, NULL);
2043 coreAPI = GNUNET_CORE_connect (GDS_cfg, 2050 coreAPI = GNUNET_CORE_connect (GDS_cfg,
2044 1, 2051 1,
2045 NULL, 2052 NULL,
@@ -2067,6 +2074,8 @@ GDS_NEIGHBOURS_done ()
2067 return; 2074 return;
2068 GNUNET_CORE_disconnect (coreAPI); 2075 GNUNET_CORE_disconnect (coreAPI);
2069 coreAPI = NULL; 2076 coreAPI = NULL;
2077 GNUNET_ATS_shutdown (atsAPI);
2078 atsAPI = NULL;
2070 GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (all_known_peers)); 2079 GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (all_known_peers));
2071 GNUNET_CONTAINER_multihashmap_destroy (all_known_peers); 2080 GNUNET_CONTAINER_multihashmap_destroy (all_known_peers);
2072 all_known_peers = NULL; 2081 all_known_peers = NULL;
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index ae8d699a1..85e3a4539 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -119,6 +119,7 @@ gnunet_service_fs_LDADD = \
119 $(top_builddir)/src/block/libgnunetblock.la \ 119 $(top_builddir)/src/block/libgnunetblock.la \
120 $(top_builddir)/src/datastore/libgnunetdatastore.la \ 120 $(top_builddir)/src/datastore/libgnunetdatastore.la \
121 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 121 $(top_builddir)/src/statistics/libgnunetstatistics.la \
122 $(top_builddir)/src/ats/libgnunetats.la \
122 $(top_builddir)/src/core/libgnunetcore.la \ 123 $(top_builddir)/src/core/libgnunetcore.la \
123 $(top_builddir)/src/util/libgnunetutil.la \ 124 $(top_builddir)/src/util/libgnunetutil.la \
124 $(GN_LIBINTL) 125 $(GN_LIBINTL)
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index ed855c42e..05e5bedef 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_load_lib.h" 27#include "gnunet_load_lib.h"
28#include "gnunet_ats_service.h"
28#include "gnunet-service-fs.h" 29#include "gnunet-service-fs.h"
29#include "gnunet-service-fs_cp.h" 30#include "gnunet-service-fs_cp.h"
30#include "gnunet-service-fs_pe.h" 31#include "gnunet-service-fs_pe.h"
@@ -240,9 +241,9 @@ struct GSF_ConnectedPeer
240 struct GSF_PeerTransmitHandle *migration_pth; 241 struct GSF_PeerTransmitHandle *migration_pth;
241 242
242 /** 243 /**
243 * Context of our GNUNET_CORE_peer_change_preference call (or NULL). 244 * Context of our GNUNET_ATS_peer_change_preference call (or NULL).
244 */ 245 */
245 struct GNUNET_CORE_InformationRequestContext *irc; 246 struct GNUNET_ATS_InformationRequestContext *irc;
246 247
247 /** 248 /**
248 * Task scheduled if we need to retry bandwidth reservation later. 249 * Task scheduled if we need to retry bandwidth reservation later.
@@ -301,6 +302,10 @@ static struct GNUNET_CONTAINER_MultiHashMap *cp_map;
301 */ 302 */
302static char *trustDirectory; 303static char *trustDirectory;
303 304
305/**
306 * Handle to ATS service.
307 */
308static struct GNUNET_ATS_Handle *ats;
304 309
305/** 310/**
306 * Get the filename under which we would store the GNUNET_HELLO_Message 311 * Get the filename under which we would store the GNUNET_HELLO_Message
@@ -399,7 +404,7 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf);
399 * long should the client wait until re-trying? 404 * long should the client wait until re-trying?
400 */ 405 */
401static void 406static void
402core_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, 407ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
403 int32_t amount, struct GNUNET_TIME_Relative res_delay); 408 int32_t amount, struct GNUNET_TIME_Relative res_delay);
404 409
405 410
@@ -432,9 +437,9 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth)
432 ip = cp->inc_preference; 437 ip = cp->inc_preference;
433 cp->inc_preference = 0; 438 cp->inc_preference = 0;
434 cp->irc = 439 cp->irc =
435 GNUNET_CORE_peer_change_preference (GSF_core, &target, 440 GNUNET_ATS_peer_change_preference (ats, &target,
436 DBLOCK_SIZE, ip, 441 DBLOCK_SIZE, ip,
437 &core_reserve_callback, cp); 442 &ats_reserve_callback, cp);
438 } 443 }
439 GNUNET_assert (pth->cth == NULL); 444 GNUNET_assert (pth->cth == NULL);
440 pth->cth_in_progress++; 445 pth->cth_in_progress++;
@@ -518,9 +523,9 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
518 ip = cp->inc_preference; 523 ip = cp->inc_preference;
519 cp->inc_preference = 0; 524 cp->inc_preference = 0;
520 cp->irc = 525 cp->irc =
521 GNUNET_CORE_peer_change_preference (GSF_core, &target, 526 GNUNET_ATS_peer_change_preference (ats, &target,
522 DBLOCK_SIZE, ip, 527 DBLOCK_SIZE, ip,
523 &core_reserve_callback, cp); 528 &ats_reserve_callback, cp);
524} 529}
525 530
526 531
@@ -535,7 +540,7 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
535 * long should the client wait until re-trying? 540 * long should the client wait until re-trying?
536 */ 541 */
537static void 542static void
538core_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, 543ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
539 int32_t amount, struct GNUNET_TIME_Relative res_delay) 544 int32_t amount, struct GNUNET_TIME_Relative res_delay)
540{ 545{
541 struct GSF_ConnectedPeer *cp = cls; 546 struct GSF_ConnectedPeer *cp = cls;
@@ -584,9 +589,9 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
584 cp->ppd.pid = GNUNET_PEER_intern (peer); 589 cp->ppd.pid = GNUNET_PEER_intern (peer);
585 cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); 590 cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO);
586 cp->irc = 591 cp->irc =
587 GNUNET_CORE_peer_change_preference (GSF_core, peer, 592 GNUNET_ATS_peer_change_preference (ats, peer,
588 DBLOCK_SIZE, 0, 593 DBLOCK_SIZE, 0,
589 &core_reserve_callback, cp); 594 &ats_reserve_callback, cp);
590 fn = get_trust_filename (peer); 595 fn = get_trust_filename (peer);
591 if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && 596 if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) &&
592 (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust)))) 597 (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust))))
@@ -1551,7 +1556,7 @@ GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer)
1551 } 1556 }
1552 if (NULL != cp->irc) 1557 if (NULL != cp->irc)
1553 { 1558 {
1554 GNUNET_CORE_peer_change_preference_cancel (cp->irc); 1559 GNUNET_ATS_peer_change_preference_cancel (cp->irc);
1555 cp->irc = NULL; 1560 cp->irc = NULL;
1556 } 1561 }
1557 if (GNUNET_SCHEDULER_NO_TASK != cp->irc_delay_task) 1562 if (GNUNET_SCHEDULER_NO_TASK != cp->irc_delay_task)
@@ -1825,6 +1830,7 @@ void
1825GSF_connected_peer_init_ () 1830GSF_connected_peer_init_ ()
1826{ 1831{
1827 cp_map = GNUNET_CONTAINER_multihashmap_create (128); 1832 cp_map = GNUNET_CONTAINER_multihashmap_create (128);
1833 ats = GNUNET_ATS_init (GSF_cfg, NULL, NULL);
1828 GNUNET_assert (GNUNET_OK == 1834 GNUNET_assert (GNUNET_OK ==
1829 GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs", 1835 GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs",
1830 "TRUST", 1836 "TRUST",
@@ -1863,6 +1869,8 @@ GSF_connected_peer_done_ ()
1863 cp_map = NULL; 1869 cp_map = NULL;
1864 GNUNET_free (trustDirectory); 1870 GNUNET_free (trustDirectory);
1865 trustDirectory = NULL; 1871 trustDirectory = NULL;
1872 GNUNET_ATS_shutdown (ats);
1873 ats = NULL;
1866} 1874}
1867 1875
1868 1876