From 120ba95916ae09a62baa52af3e6cd12ef72f5d6d Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Sun, 29 Dec 2013 01:03:44 +0000 Subject: 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. --- src/ats/gnunet-service-ats_addresses.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/ats/gnunet-service-ats_addresses.c') 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, GNUNET_assert(NULL != ah->addresses); /* Figure out configured solution method */ - plugin_short = NULL; if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str)) { @@ -2122,34 +2121,25 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, for (c = 0; c < strlen (mode_str); c++) mode_str[c] = toupper (mode_str[c]); if (0 == strcmp (mode_str, "PROPORTIONAL")) - { ah->ats_mode = MODE_PROPORTIONAL; - plugin_short = "proportional"; - } else if (0 == strcmp (mode_str, "MLP")) { ah->ats_mode = MODE_MLP; - plugin_short = "mlp"; #if !HAVE_LIBGLPK GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Assignment method `%s' configured, but GLPK is not available, please install \n", mode_str); ah->ats_mode = MODE_PROPORTIONAL; - plugin_short = "proportional"; #endif } else if (0 == strcmp (mode_str, "RIL")) - { ah->ats_mode = MODE_RIL; - plugin_short = "ril"; - } else { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Invalid resource assignment method `%s' configured, using proportional approach\n", mode_str); ah->ats_mode = MODE_PROPORTIONAL; - plugin_short = "proportional"; } GNUNET_free(mode_str); } @@ -2176,6 +2166,20 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, ah->env.in_quota[c] = quotas_in[c]; } + switch (ah->ats_mode) { + case MODE_PROPORTIONAL: + plugin_short = "proportional"; + break; + case MODE_MLP: + plugin_short = "mlp"; + break; + case MODE_RIL: + plugin_short = "ril"; + break; + default: + plugin_short = NULL; + break; + } GNUNET_asprintf (&ah->plugin, "libgnunet_plugin_ats_%s", plugin_short); GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initializing solver `%s '`%s'\n"), plugin_short, ah->plugin); if (NULL == (ah->solver = GNUNET_PLUGIN_load (ah->plugin, &ah->env))) -- cgit v1.2.3