gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r31765 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r31765 - gnunet/src/ats
Date: Sun, 29 Dec 2013 02:03:44 +0100

Author: amatus
Date: 2013-12-29 02:03:44 +0100 (Sun, 29 Dec 2013)
New Revision: 31765

Modified:
   gnunet/src/ats/gnunet-service-ats_addresses.c
Log:
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.


Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2013-12-28 20:45:25 UTC 
(rev 31764)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2013-12-29 01:03:44 UTC 
(rev 31765)
@@ -2109,7 +2109,6 @@
   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 @@
     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 @@
     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)))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]