diff options
Diffstat (limited to 'src/fs/gnunet-service-fs_cp.c')
-rw-r--r-- | src/fs/gnunet-service-fs_cp.c | 65 |
1 files changed, 14 insertions, 51 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index f33b97d81..c9e61d5d4 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -25,7 +25,6 @@ | |||
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" | ||
29 | #include "gnunet-service-fs.h" | 28 | #include "gnunet-service-fs.h" |
30 | #include "gnunet-service-fs_cp.h" | 29 | #include "gnunet-service-fs_cp.h" |
31 | #include "gnunet-service-fs_pe.h" | 30 | #include "gnunet-service-fs_pe.h" |
@@ -315,11 +314,6 @@ static struct GNUNET_CONTAINER_MultiHashMap *cp_map; | |||
315 | */ | 314 | */ |
316 | static char *respectDirectory; | 315 | static char *respectDirectory; |
317 | 316 | ||
318 | /** | ||
319 | * Handle to ATS service. | ||
320 | */ | ||
321 | static struct GNUNET_ATS_PerformanceHandle *ats; | ||
322 | |||
323 | 317 | ||
324 | /** | 318 | /** |
325 | * Get the filename under which we would store respect | 319 | * Get the filename under which we would store respect |
@@ -341,39 +335,18 @@ get_respect_filename (const struct GNUNET_PeerIdentity *id) | |||
341 | 335 | ||
342 | 336 | ||
343 | /** | 337 | /** |
344 | * Find latency information in 'atsi'. | 338 | * Update the latency information kept for the given peer. |
345 | * | 339 | * |
346 | * @param atsi performance data | 340 | * @param id peer record to update |
347 | * @param atsi_count number of records in 'atsi' | 341 | * @param latency current latency value |
348 | * @return connection latency | ||
349 | */ | 342 | */ |
350 | static struct GNUNET_TIME_Relative | 343 | void |
351 | get_latency (const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count) | 344 | GSF_update_peer_latency_ (const struct GNUNET_PeerIdentity *id, |
352 | { | 345 | struct GNUNET_TIME_Relative latency) |
353 | unsigned int i; | ||
354 | |||
355 | for (i = 0; i < atsi_count; i++) | ||
356 | if (ntohl (atsi->type) == GNUNET_ATS_QUALITY_NET_DELAY) | ||
357 | return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | ||
358 | ntohl (atsi->value)); | ||
359 | return GNUNET_TIME_UNIT_SECONDS; | ||
360 | } | ||
361 | |||
362 | |||
363 | /** | ||
364 | * Update the performance information kept for the given peer. | ||
365 | * | ||
366 | * @param cp peer record to update | ||
367 | * @param atsi transport performance data | ||
368 | * @param atsi_count number of records in 'atsi' | ||
369 | */ | ||
370 | static void | ||
371 | update_atsi (struct GSF_ConnectedPeer *cp, | ||
372 | const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count) | ||
373 | { | 346 | { |
374 | struct GNUNET_TIME_Relative latency; | 347 | struct GSF_ConnectedPeer *cp; |
375 | 348 | ||
376 | latency = get_latency (atsi, atsi_count); | 349 | cp = GSF_peer_get_ (id); |
377 | GNUNET_LOAD_value_set_decline (cp->ppd.transmission_delay, latency); | 350 | GNUNET_LOAD_value_set_decline (cp->ppd.transmission_delay, latency); |
378 | /* LATER: merge atsi into cp's performance data (if we ever care...) */ | 351 | /* LATER: merge atsi into cp's performance data (if we ever care...) */ |
379 | } | 352 | } |
@@ -439,7 +412,7 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth) | |||
439 | 412 | ||
440 | if (0 != cp->inc_preference) | 413 | if (0 != cp->inc_preference) |
441 | { | 414 | { |
442 | GNUNET_ATS_change_preference (ats, &target, GNUNET_ATS_PREFERENCE_BANDWIDTH, | 415 | GNUNET_ATS_change_preference (GSF_ats, &target, GNUNET_ATS_PREFERENCE_BANDWIDTH, |
443 | (double) cp->inc_preference, | 416 | (double) cp->inc_preference, |
444 | GNUNET_ATS_PREFERENCE_END); | 417 | GNUNET_ATS_PREFERENCE_END); |
445 | cp->inc_preference = 0; | 418 | cp->inc_preference = 0; |
@@ -454,7 +427,7 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth) | |||
454 | /* reservation already done! */ | 427 | /* reservation already done! */ |
455 | pth->was_reserved = GNUNET_YES; | 428 | pth->was_reserved = GNUNET_YES; |
456 | cp->rc = | 429 | cp->rc = |
457 | GNUNET_ATS_reserve_bandwidth (ats, &target, DBLOCK_SIZE, | 430 | GNUNET_ATS_reserve_bandwidth (GSF_ats, &target, DBLOCK_SIZE, |
458 | &ats_reserve_callback, cp); | 431 | &ats_reserve_callback, cp); |
459 | return; | 432 | return; |
460 | } | 433 | } |
@@ -540,8 +513,8 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
540 | GNUNET_PEER_resolve (cp->ppd.pid, &target); | 513 | GNUNET_PEER_resolve (cp->ppd.pid, &target); |
541 | cp->rc_delay_task = GNUNET_SCHEDULER_NO_TASK; | 514 | cp->rc_delay_task = GNUNET_SCHEDULER_NO_TASK; |
542 | cp->rc = | 515 | cp->rc = |
543 | GNUNET_ATS_reserve_bandwidth (ats, &target, DBLOCK_SIZE, | 516 | GNUNET_ATS_reserve_bandwidth (GSF_ats, &target, DBLOCK_SIZE, |
544 | &ats_reserve_callback, cp); | 517 | &ats_reserve_callback, cp); |
545 | } | 518 | } |
546 | 519 | ||
547 | 520 | ||
@@ -595,14 +568,10 @@ ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
595 | * records. | 568 | * records. |
596 | * | 569 | * |
597 | * @param peer identity of peer that connected | 570 | * @param peer identity of peer that connected |
598 | * @param atsi performance data for the connection | ||
599 | * @param atsi_count number of records in 'atsi' | ||
600 | * @return handle to connected peer entry | 571 | * @return handle to connected peer entry |
601 | */ | 572 | */ |
602 | struct GSF_ConnectedPeer * | 573 | struct GSF_ConnectedPeer * |
603 | GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | 574 | GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer) |
604 | const struct GNUNET_ATS_Information *atsi, | ||
605 | unsigned int atsi_count) | ||
606 | { | 575 | { |
607 | struct GSF_ConnectedPeer *cp; | 576 | struct GSF_ConnectedPeer *cp; |
608 | char *fn; | 577 | char *fn; |
@@ -614,7 +583,7 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | |||
614 | cp->ppd.pid = GNUNET_PEER_intern (peer); | 583 | cp->ppd.pid = GNUNET_PEER_intern (peer); |
615 | cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); | 584 | cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); |
616 | cp->rc = | 585 | cp->rc = |
617 | GNUNET_ATS_reserve_bandwidth (ats, peer, DBLOCK_SIZE, | 586 | GNUNET_ATS_reserve_bandwidth (GSF_ats, peer, DBLOCK_SIZE, |
618 | &ats_reserve_callback, cp); | 587 | &ats_reserve_callback, cp); |
619 | fn = get_respect_filename (peer); | 588 | fn = get_respect_filename (peer); |
620 | if ((GNUNET_YES == GNUNET_DISK_file_test (fn)) && | 589 | if ((GNUNET_YES == GNUNET_DISK_file_test (fn)) && |
@@ -630,7 +599,6 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | |||
630 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), | 599 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), |
631 | GNUNET_CONTAINER_multihashmap_size (cp_map), | 600 | GNUNET_CONTAINER_multihashmap_size (cp_map), |
632 | GNUNET_NO); | 601 | GNUNET_NO); |
633 | update_atsi (cp, atsi, atsi_count); | ||
634 | GSF_push_start_ (cp); | 602 | GSF_push_start_ (cp); |
635 | return cp; | 603 | return cp; |
636 | } | 604 | } |
@@ -718,8 +686,6 @@ GSF_handle_p2p_migration_stop_ (void *cls, | |||
718 | cp->mig_revive_task = | 686 | cp->mig_revive_task = |
719 | GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); | 687 | GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); |
720 | } | 688 | } |
721 | fprintf (stderr, "FIX ATS DATA: %s:%u!\n", __FILE__, __LINE__); | ||
722 | update_atsi (cp, NULL, 0); | ||
723 | return GNUNET_OK; | 689 | return GNUNET_OK; |
724 | } | 690 | } |
725 | 691 | ||
@@ -1821,7 +1787,6 @@ void | |||
1821 | GSF_connected_peer_init_ () | 1787 | GSF_connected_peer_init_ () |
1822 | { | 1788 | { |
1823 | cp_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_YES); | 1789 | cp_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_YES); |
1824 | ats = GNUNET_ATS_performance_init (GSF_cfg, NULL, NULL); | ||
1825 | GNUNET_assert (GNUNET_OK == | 1790 | GNUNET_assert (GNUNET_OK == |
1826 | GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs", | 1791 | GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs", |
1827 | "RESPECT", | 1792 | "RESPECT", |
@@ -1860,8 +1825,6 @@ GSF_connected_peer_done_ () | |||
1860 | cp_map = NULL; | 1825 | cp_map = NULL; |
1861 | GNUNET_free (respectDirectory); | 1826 | GNUNET_free (respectDirectory); |
1862 | respectDirectory = NULL; | 1827 | respectDirectory = NULL; |
1863 | GNUNET_ATS_performance_done (ats); | ||
1864 | ats = NULL; | ||
1865 | } | 1828 | } |
1866 | 1829 | ||
1867 | 1830 | ||