diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-24 10:18:09 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-24 10:18:09 +0000 |
commit | e930d9d48fc6e1f97b2cd3202767245f8327319b (patch) | |
tree | 959bcca3e2fd8b263a0f5f2b071e3cb673299b44 /src/ats | |
parent | 90eb0a272087127bac0e6b0e19b59f06e5c9584e (diff) | |
download | gnunet-e930d9d48fc6e1f97b2cd3202767245f8327319b.tar.gz gnunet-e930d9d48fc6e1f97b2cd3202767245f8327319b.zip |
- fixing mantis 2282
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats.c | 6 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 29 |
2 files changed, 33 insertions, 2 deletions
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c index a68ec416b..5e6871096 100644 --- a/src/ats/gnunet-service-ats.c +++ b/src/ats/gnunet-service-ats.c | |||
@@ -39,6 +39,9 @@ | |||
39 | */ | 39 | */ |
40 | struct GNUNET_STATISTICS_Handle *GSA_stats; | 40 | struct GNUNET_STATISTICS_Handle *GSA_stats; |
41 | 41 | ||
42 | static struct GNUNET_SERVER_Handle *GSA_server; | ||
43 | |||
44 | |||
42 | /** | 45 | /** |
43 | * We have received a 'ClientStartMessage' from a client. Find out which | 46 | * We have received a 'ClientStartMessage' from a client. Find out which |
44 | * type of client it is and notify the respective subsystem. | 47 | * type of client it is and notify the respective subsystem. |
@@ -107,6 +110,8 @@ client_disconnect_handler (void *cls, struct GNUNET_SERVER_Client *client) | |||
107 | static void | 110 | static void |
108 | cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 111 | cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
109 | { | 112 | { |
113 | GNUNET_SERVER_destroy (GSA_server); | ||
114 | GSA_server = NULL; | ||
110 | GAS_addresses_done (); | 115 | GAS_addresses_done (); |
111 | GAS_scheduling_done (); | 116 | GAS_scheduling_done (); |
112 | GAS_performance_done (); | 117 | GAS_performance_done (); |
@@ -152,6 +157,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
152 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0}, | 157 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0}, |
153 | {NULL, NULL, 0, 0} | 158 | {NULL, NULL, 0, 0} |
154 | }; | 159 | }; |
160 | GSA_server = server; | ||
155 | GSA_stats = GNUNET_STATISTICS_create ("ats", cfg); | 161 | GSA_stats = GNUNET_STATISTICS_create ("ats", cfg); |
156 | GAS_reservations_init (); | 162 | GAS_reservations_init (); |
157 | GAS_performance_init (server); | 163 | GAS_performance_init (server); |
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index ca161d6b9..f81b4c282 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -66,6 +66,8 @@ static unsigned int active_addr_count; | |||
66 | 66 | ||
67 | static int ats_mode; | 67 | static int ats_mode; |
68 | 68 | ||
69 | static int running; | ||
70 | |||
69 | 71 | ||
70 | static void | 72 | static void |
71 | send_bw_notification (struct ATS_Address *aa) | 73 | send_bw_notification (struct ATS_Address *aa) |
@@ -339,6 +341,11 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer, | |||
339 | struct ATS_Address *old; | 341 | struct ATS_Address *old; |
340 | uint32_t i; | 342 | uint32_t i; |
341 | 343 | ||
344 | if (GNUNET_NO == running) | ||
345 | return; | ||
346 | |||
347 | GNUNET_assert (NULL != addresses); | ||
348 | |||
342 | aa = create_address (peer, | 349 | aa = create_address (peer, |
343 | plugin_name, | 350 | plugin_name, |
344 | plugin_addr, plugin_addr_len, | 351 | plugin_addr, plugin_addr_len, |
@@ -510,6 +517,9 @@ GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer, | |||
510 | { | 517 | { |
511 | struct ATS_Address *aa; | 518 | struct ATS_Address *aa; |
512 | 519 | ||
520 | if (GNUNET_NO == running) | ||
521 | return; | ||
522 | |||
513 | GNUNET_break (0 < strlen (plugin_name)); | 523 | GNUNET_break (0 < strlen (plugin_name)); |
514 | aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, session_id); | 524 | aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len, session_id); |
515 | 525 | ||
@@ -580,6 +590,8 @@ GAS_addresses_in_use (const struct GNUNET_PeerIdentity *peer, | |||
580 | struct ATS_Address *aa; | 590 | struct ATS_Address *aa; |
581 | struct ATS_Address *old; | 591 | struct ATS_Address *old; |
582 | 592 | ||
593 | if (GNUNET_NO == running) | ||
594 | return; | ||
583 | 595 | ||
584 | aa = create_address(peer, plugin_name, plugin_addr, plugin_addr_len, session_id); | 596 | aa = create_address(peer, plugin_name, plugin_addr, plugin_addr_len, session_id); |
585 | old = find_exact_address (peer, aa); | 597 | old = find_exact_address (peer, aa); |
@@ -677,6 +689,9 @@ void request_address_simple (const struct GNUNET_PeerIdentity *peer) | |||
677 | void | 689 | void |
678 | GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) | 690 | GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer) |
679 | { | 691 | { |
692 | if (GNUNET_NO == running) | ||
693 | return; | ||
694 | |||
680 | if (ats_mode == SIMPLE) | 695 | if (ats_mode == SIMPLE) |
681 | { | 696 | { |
682 | request_address_simple (peer); | 697 | request_address_simple (peer); |
@@ -695,6 +710,8 @@ GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer, | |||
695 | enum GNUNET_ATS_PreferenceKind kind, | 710 | enum GNUNET_ATS_PreferenceKind kind, |
696 | float score) | 711 | float score) |
697 | { | 712 | { |
713 | if (GNUNET_NO == running) | ||
714 | return; | ||
698 | #if HAVE_LIBGLPK | 715 | #if HAVE_LIBGLPK |
699 | if (ats_mode == MLP) | 716 | if (ats_mode == MLP) |
700 | GAS_mlp_address_change_preference (mlp, peer, kind, score); | 717 | GAS_mlp_address_change_preference (mlp, peer, kind, score); |
@@ -718,6 +735,11 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
718 | char *quota_wan_in_str; | 735 | char *quota_wan_in_str; |
719 | char *quota_wan_out_str; | 736 | char *quota_wan_out_str; |
720 | 737 | ||
738 | running = GNUNET_NO; | ||
739 | |||
740 | addresses = GNUNET_CONTAINER_multihashmap_create (128); | ||
741 | GNUNET_assert (NULL != addresses); | ||
742 | |||
721 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", "a_wan_in_str)) | 743 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", "a_wan_in_str)) |
722 | { | 744 | { |
723 | if (0 == strcmp(quota_wan_in_str, "unlimited") || | 745 | if (0 == strcmp(quota_wan_in_str, "unlimited") || |
@@ -746,7 +768,6 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
746 | wan_quota_out = (UINT32_MAX) /10; | 768 | wan_quota_out = (UINT32_MAX) /10; |
747 | } | 769 | } |
748 | 770 | ||
749 | |||
750 | mode = GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP"); | 771 | mode = GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP"); |
751 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP mode %u", mode); | 772 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP mode %u", mode); |
752 | switch (mode) | 773 | switch (mode) |
@@ -788,7 +809,7 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
788 | break; | 809 | break; |
789 | } | 810 | } |
790 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started with %s mode\n", (SIMPLE == ats_mode) ? "SIMPLE" : "MLP"); | 811 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started with %s mode\n", (SIMPLE == ats_mode) ? "SIMPLE" : "MLP"); |
791 | addresses = GNUNET_CONTAINER_multihashmap_create (128); | 812 | running = GNUNET_YES; |
792 | } | 813 | } |
793 | 814 | ||
794 | 815 | ||
@@ -813,6 +834,9 @@ free_address_it (void *cls, const GNUNET_HashCode * key, void *value) | |||
813 | void | 834 | void |
814 | GAS_addresses_destroy_all () | 835 | GAS_addresses_destroy_all () |
815 | { | 836 | { |
837 | if (GNUNET_NO == running) | ||
838 | return; | ||
839 | |||
816 | if (addresses != NULL) | 840 | if (addresses != NULL) |
817 | GNUNET_CONTAINER_multihashmap_iterate (addresses, &free_address_it, NULL); | 841 | GNUNET_CONTAINER_multihashmap_iterate (addresses, &free_address_it, NULL); |
818 | GNUNET_assert (active_addr_count == 0); | 842 | GNUNET_assert (active_addr_count == 0); |
@@ -825,6 +849,7 @@ GAS_addresses_destroy_all () | |||
825 | void | 849 | void |
826 | GAS_addresses_done () | 850 | GAS_addresses_done () |
827 | { | 851 | { |
852 | running = GNUNET_NO; | ||
828 | GAS_addresses_destroy_all (); | 853 | GAS_addresses_destroy_all (); |
829 | GNUNET_CONTAINER_multihashmap_destroy (addresses); | 854 | GNUNET_CONTAINER_multihashmap_destroy (addresses); |
830 | addresses = NULL; | 855 | addresses = NULL; |