diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-22 23:04:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-22 23:04:40 +0000 |
commit | a57305cef1ec471aea627810955e6f6cec36d847 (patch) | |
tree | 475a79a451277b60033a9919fb2499c197cc77ab /src/ats/gnunet-service-ats_performance.c | |
parent | 78b8e1c2a54c44992a16b65cdf67fea973e2cad0 (diff) | |
download | gnunet-a57305cef1ec471aea627810955e6f6cec36d847.tar.gz gnunet-a57305cef1ec471aea627810955e6f6cec36d847.zip |
use statics instead of singleton struct, simplify internal APIs
Diffstat (limited to 'src/ats/gnunet-service-ats_performance.c')
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 2e205b982..e0a5cbdae 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -60,11 +60,6 @@ struct PerformanceClient | |||
60 | 60 | ||
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Address handle | ||
64 | */ | ||
65 | static struct GAS_Addresses_Handle *GSA_addresses; | ||
66 | |||
67 | /** | ||
68 | * Head of linked list of all clients to this service. | 63 | * Head of linked list of all clients to this service. |
69 | */ | 64 | */ |
70 | static struct PerformanceClient *pc_head; | 65 | static struct PerformanceClient *pc_head; |
@@ -113,7 +108,7 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client) | |||
113 | if (NULL == pc) | 108 | if (NULL == pc) |
114 | return; | 109 | return; |
115 | GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); | 110 | GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); |
116 | GAS_addresses_preference_client_disconnect (GSA_addresses, client); | 111 | GAS_addresses_preference_client_disconnect (client); |
117 | GNUNET_free (pc); | 112 | GNUNET_free (pc); |
118 | } | 113 | } |
119 | 114 | ||
@@ -314,8 +309,7 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client, | |||
314 | GNUNET_CONTAINER_DLL_insert (pc_head, | 309 | GNUNET_CONTAINER_DLL_insert (pc_head, |
315 | pc_tail, | 310 | pc_tail, |
316 | pc); | 311 | pc); |
317 | GAS_addresses_get_peer_info (GSA_addresses, | 312 | GAS_addresses_get_peer_info (NULL, |
318 | NULL, | ||
319 | &peerinfo_it, | 313 | &peerinfo_it, |
320 | pc); | 314 | pc); |
321 | } | 315 | } |
@@ -528,16 +522,14 @@ GAS_handle_request_address_list (void *cls, | |||
528 | sizeof (struct GNUNET_PeerIdentity))) | 522 | sizeof (struct GNUNET_PeerIdentity))) |
529 | { | 523 | { |
530 | /* Return addresses for all peers */ | 524 | /* Return addresses for all peers */ |
531 | GAS_addresses_get_peer_info (GSA_addresses, | 525 | GAS_addresses_get_peer_info (NULL, |
532 | NULL, | ||
533 | &req_addr_peerinfo_it, | 526 | &req_addr_peerinfo_it, |
534 | &ai); | 527 | &ai); |
535 | } | 528 | } |
536 | else | 529 | else |
537 | { | 530 | { |
538 | /* Return addresses for a specific peer */ | 531 | /* Return addresses for a specific peer */ |
539 | GAS_addresses_get_peer_info (GSA_addresses, | 532 | GAS_addresses_get_peer_info (&alrm->peer, |
540 | &alrm->peer, | ||
541 | &req_addr_peerinfo_it, | 533 | &req_addr_peerinfo_it, |
542 | &ai); | 534 | &ai); |
543 | } | 535 | } |
@@ -644,8 +636,7 @@ GAS_handle_preference_change (void *cls, | |||
644 | 1, GNUNET_NO); | 636 | 1, GNUNET_NO); |
645 | pi = (const struct PreferenceInformation *) &msg[1]; | 637 | pi = (const struct PreferenceInformation *) &msg[1]; |
646 | for (i = 0; i < nump; i++) | 638 | for (i = 0; i < nump; i++) |
647 | GAS_addresses_preference_change (GSA_addresses, | 639 | GAS_addresses_preference_change (client, |
648 | client, | ||
649 | &msg->peer, | 640 | &msg->peer, |
650 | (enum GNUNET_ATS_PreferenceKind) | 641 | (enum GNUNET_ATS_PreferenceKind) |
651 | ntohl (pi[i].preference_kind), | 642 | ntohl (pi[i].preference_kind), |
@@ -697,18 +688,16 @@ GAS_handle_preference_feedback (void *cls, | |||
697 | 1, GNUNET_NO); | 688 | 1, GNUNET_NO); |
698 | pi = (const struct PreferenceInformation *) &msg[1]; | 689 | pi = (const struct PreferenceInformation *) &msg[1]; |
699 | for (i = 0; i < nump; i++) | 690 | for (i = 0; i < nump; i++) |
700 | GAS_addresses_preference_feedback (GSA_addresses, | 691 | GAS_addresses_preference_feedback (client, |
701 | client, | 692 | &msg->peer, |
702 | &msg->peer, | 693 | GNUNET_TIME_relative_ntoh(msg->scope), |
703 | GNUNET_TIME_relative_ntoh(msg->scope), | 694 | (enum GNUNET_ATS_PreferenceKind) |
704 | (enum GNUNET_ATS_PreferenceKind) | 695 | ntohl (pi[i].preference_kind), |
705 | ntohl (pi[i].preference_kind), | 696 | pi[i].preference_value); |
706 | pi[i].preference_value); | ||
707 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 697 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
708 | } | 698 | } |
709 | 699 | ||
710 | 700 | ||
711 | |||
712 | /** | 701 | /** |
713 | * Initialize performance subsystem. | 702 | * Initialize performance subsystem. |
714 | * | 703 | * |
@@ -716,10 +705,8 @@ GAS_handle_preference_feedback (void *cls, | |||
716 | * @param addresses the address handle to use | 705 | * @param addresses the address handle to use |
717 | */ | 706 | */ |
718 | void | 707 | void |
719 | GAS_performance_init (struct GNUNET_SERVER_Handle *server, | 708 | GAS_performance_init (struct GNUNET_SERVER_Handle *server) |
720 | struct GAS_Addresses_Handle *addresses) | ||
721 | { | 709 | { |
722 | GSA_addresses = addresses; | ||
723 | nc = GNUNET_SERVER_notification_context_create (server, 128); | 710 | nc = GNUNET_SERVER_notification_context_create (server, 128); |
724 | } | 711 | } |
725 | 712 | ||