diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-14 08:34:07 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-14 08:34:07 +0000 |
commit | 41cff0bca30e6c1e891bcdabc50a4ab4c20e805b (patch) | |
tree | d8d136cc5d1f85c9b31c51d2bcda0fd52ff1e1d4 /src/ats/plugin_ats_proportional.c | |
parent | 4cb749c370a4fd93a00734c5692a6e3664a5d67f (diff) | |
download | gnunet-41cff0bca30e6c1e891bcdabc50a4ab4c20e805b.tar.gz gnunet-41cff0bca30e6c1e891bcdabc50a4ab4c20e805b.zip |
use cfg function in solvers
Diffstat (limited to 'src/ats/plugin_ats_proportional.c')
-rw-r--r-- | src/ats/plugin_ats_proportional.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c index 6def592e2..8206d19c4 100644 --- a/src/ats/plugin_ats_proportional.c +++ b/src/ats/plugin_ats_proportional.c | |||
@@ -408,8 +408,7 @@ libgnunet_plugin_ats_proportional_init (void *cls) | |||
408 | struct GAS_PROPORTIONAL_Handle *s; | 408 | struct GAS_PROPORTIONAL_Handle *s; |
409 | struct Network * cur; | 409 | struct Network * cur; |
410 | char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString; | 410 | char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString; |
411 | unsigned long long prop_factor; | 411 | float f_tmp; |
412 | unsigned long long stability_factor; | ||
413 | int c; | 412 | int c; |
414 | 413 | ||
415 | GNUNET_assert (NULL != env); | 414 | GNUNET_assert (NULL != env); |
@@ -450,43 +449,39 @@ libgnunet_plugin_ats_proportional_init (void *cls) | |||
450 | s->addresses = env->addresses; | 449 | s->addresses = env->addresses; |
451 | s->requests = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); | 450 | s->requests = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
452 | 451 | ||
453 | if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number(s->env->cfg, "ats", | 452 | s->stability_factor = PROP_STABILITY_FACTOR; |
454 | "PROP_STABILITY_FACTOR", &stability_factor)) | 453 | if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats", |
454 | "PROP_STABILITY_FACTOR", &f_tmp)) | ||
455 | { | 455 | { |
456 | if ((stability_factor >= 100) && (stability_factor <= 200)) | 456 | if ((f_tmp < 1.0) || (f_tmp > 2.0)) |
457 | { | 457 | { |
458 | s->stability_factor = ((double) stability_factor) / 100; | 458 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"), |
459 | "PROP_STABILITY_FACTOR", f_tmp); | ||
459 | } | 460 | } |
460 | else | 461 | else |
461 | { | 462 | { |
462 | GNUNET_break (0); | 463 | s->stability_factor = f_tmp; |
463 | s->stability_factor = PROP_STABILITY_FACTOR; | 464 | LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n", |
465 | "PROP_STABILITY_FACTOR", f_tmp); | ||
464 | } | 466 | } |
465 | } | 467 | } |
466 | else | ||
467 | { | ||
468 | GNUNET_break (0); | ||
469 | s->stability_factor = PROP_STABILITY_FACTOR; | ||
470 | } | ||
471 | LOG (GNUNET_ERROR_TYPE_INFO, "Using stability factor %.3f\n", | ||
472 | s->stability_factor); | ||
473 | 468 | ||
474 | if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number(s->env->cfg, "ats", | 469 | s->prop_factor = PROPORTIONALITY_FACTOR; |
475 | "PROP_PROPORTIONALITY_FACTOR", &prop_factor)) | 470 | if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats", |
471 | "PROP_STABILITY_FACTOR", &f_tmp)) | ||
476 | { | 472 | { |
477 | if (prop_factor >= 100) | 473 | if (f_tmp < 1.0) |
478 | s->prop_factor = ((double) prop_factor) / 100; | 474 | { |
475 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"), | ||
476 | "PROP_PROPORTIONALITY_FACTOR", f_tmp); | ||
477 | } | ||
479 | else | 478 | else |
480 | { | 479 | { |
481 | GNUNET_break (0); | 480 | s->prop_factor = f_tmp; |
482 | s->prop_factor = PROPORTIONALITY_FACTOR; | 481 | LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n", |
482 | "PROP_PROPORTIONALITY_FACTOR", f_tmp); | ||
483 | } | 483 | } |
484 | } | 484 | } |
485 | else | ||
486 | s->prop_factor = PROPORTIONALITY_FACTOR; | ||
487 | LOG (GNUNET_ERROR_TYPE_INFO, "Using proportionality factor %.3f\n", | ||
488 | s->prop_factor); | ||
489 | |||
490 | 485 | ||
491 | for (c = 0; c < env->network_count; c++) | 486 | for (c = 0; c < env->network_count; c++) |
492 | { | 487 | { |