diff options
author | David Barksdale <amatus.amongus@gmail.com> | 2013-12-29 01:03:44 +0000 |
---|---|---|
committer | David Barksdale <amatus.amongus@gmail.com> | 2013-12-29 01:03:44 +0000 |
commit | 120ba95916ae09a62baa52af3e6cd12ef72f5d6d (patch) | |
tree | c93d9c456b95778e391476aab036a67dfb284aa2 /src/ats/gnunet-service-ats_addresses.c | |
parent | 7ff76f7447000b2dacd06882eae64ab301bd8757 (diff) | |
download | gnunet-120ba95916ae09a62baa52af3e6cd12ef72f5d6d.tar.gz gnunet-120ba95916ae09a62baa52af3e6cd12ef72f5d6d.zip |
Load the correct ATS plugin when MODE is unconfigured.
In this case ah->ats_mode was set to MODE_PROPORTIONAL
but plugin_short was not touched. Instead initialize
plugin_short after we are done selecting ah->ats_mode.
This will be less prone to regression when a change
is made to the ats_mode selection code.
Diffstat (limited to 'src/ats/gnunet-service-ats_addresses.c')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 366010afb..a82b21355 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -2109,7 +2109,6 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2109 | GNUNET_assert(NULL != ah->addresses); | 2109 | GNUNET_assert(NULL != ah->addresses); |
2110 | 2110 | ||
2111 | /* Figure out configured solution method */ | 2111 | /* Figure out configured solution method */ |
2112 | plugin_short = NULL; | ||
2113 | if (GNUNET_SYSERR | 2112 | if (GNUNET_SYSERR |
2114 | == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str)) | 2113 | == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str)) |
2115 | { | 2114 | { |
@@ -2122,34 +2121,25 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2122 | for (c = 0; c < strlen (mode_str); c++) | 2121 | for (c = 0; c < strlen (mode_str); c++) |
2123 | mode_str[c] = toupper (mode_str[c]); | 2122 | mode_str[c] = toupper (mode_str[c]); |
2124 | if (0 == strcmp (mode_str, "PROPORTIONAL")) | 2123 | if (0 == strcmp (mode_str, "PROPORTIONAL")) |
2125 | { | ||
2126 | ah->ats_mode = MODE_PROPORTIONAL; | 2124 | ah->ats_mode = MODE_PROPORTIONAL; |
2127 | plugin_short = "proportional"; | ||
2128 | } | ||
2129 | else if (0 == strcmp (mode_str, "MLP")) | 2125 | else if (0 == strcmp (mode_str, "MLP")) |
2130 | { | 2126 | { |
2131 | ah->ats_mode = MODE_MLP; | 2127 | ah->ats_mode = MODE_MLP; |
2132 | plugin_short = "mlp"; | ||
2133 | #if !HAVE_LIBGLPK | 2128 | #if !HAVE_LIBGLPK |
2134 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 2129 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
2135 | "Assignment method `%s' configured, but GLPK is not available, please install \n", | 2130 | "Assignment method `%s' configured, but GLPK is not available, please install \n", |
2136 | mode_str); | 2131 | mode_str); |
2137 | ah->ats_mode = MODE_PROPORTIONAL; | 2132 | ah->ats_mode = MODE_PROPORTIONAL; |
2138 | plugin_short = "proportional"; | ||
2139 | #endif | 2133 | #endif |
2140 | } | 2134 | } |
2141 | else if (0 == strcmp (mode_str, "RIL")) | 2135 | else if (0 == strcmp (mode_str, "RIL")) |
2142 | { | ||
2143 | ah->ats_mode = MODE_RIL; | 2136 | ah->ats_mode = MODE_RIL; |
2144 | plugin_short = "ril"; | ||
2145 | } | ||
2146 | else | 2137 | else |
2147 | { | 2138 | { |
2148 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 2139 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
2149 | "Invalid resource assignment method `%s' configured, using proportional approach\n", | 2140 | "Invalid resource assignment method `%s' configured, using proportional approach\n", |
2150 | mode_str); | 2141 | mode_str); |
2151 | ah->ats_mode = MODE_PROPORTIONAL; | 2142 | ah->ats_mode = MODE_PROPORTIONAL; |
2152 | plugin_short = "proportional"; | ||
2153 | } | 2143 | } |
2154 | GNUNET_free(mode_str); | 2144 | GNUNET_free(mode_str); |
2155 | } | 2145 | } |
@@ -2176,6 +2166,20 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2176 | ah->env.in_quota[c] = quotas_in[c]; | 2166 | ah->env.in_quota[c] = quotas_in[c]; |
2177 | } | 2167 | } |
2178 | 2168 | ||
2169 | switch (ah->ats_mode) { | ||
2170 | case MODE_PROPORTIONAL: | ||
2171 | plugin_short = "proportional"; | ||
2172 | break; | ||
2173 | case MODE_MLP: | ||
2174 | plugin_short = "mlp"; | ||
2175 | break; | ||
2176 | case MODE_RIL: | ||
2177 | plugin_short = "ril"; | ||
2178 | break; | ||
2179 | default: | ||
2180 | plugin_short = NULL; | ||
2181 | break; | ||
2182 | } | ||
2179 | GNUNET_asprintf (&ah->plugin, "libgnunet_plugin_ats_%s", plugin_short); | 2183 | GNUNET_asprintf (&ah->plugin, "libgnunet_plugin_ats_%s", plugin_short); |
2180 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initializing solver `%s '`%s'\n"), plugin_short, ah->plugin); | 2184 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initializing solver `%s '`%s'\n"), plugin_short, ah->plugin); |
2181 | if (NULL == (ah->solver = GNUNET_PLUGIN_load (ah->plugin, &ah->env))) | 2185 | if (NULL == (ah->solver = GNUNET_PLUGIN_load (ah->plugin, &ah->env))) |