aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_addresses_mlp.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-19 15:11:54 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-19 15:11:54 +0000
commit20f538f06d2852ddaad7f6f631eede8c39234da4 (patch)
tree0a0d743950b130d972f4f734d80f5307198e5547 /src/ats/gnunet-service-ats_addresses_mlp.c
parent9dfda11d4fba38cbf2cf23c9acdf2c31eebbc72e (diff)
downloadgnunet-20f538f06d2852ddaad7f6f631eede8c39234da4.tar.gz
gnunet-20f538f06d2852ddaad7f6f631eede8c39234da4.zip
- fixes
Diffstat (limited to 'src/ats/gnunet-service-ats_addresses_mlp.c')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index 85113ea8e..512d5fb39 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -976,6 +976,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContex
976 976
977int GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx); 977int GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx);
978 978
979
979static void 980static void
980mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 981mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
981{ 982{
@@ -993,6 +994,7 @@ mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
993 GAS_mlp_solve_problem(mlp, &ctx); 994 GAS_mlp_solve_problem(mlp, &ctx);
994} 995}
995 996
997
996/** 998/**
997 * Solves the MLP problem 999 * Solves the MLP problem
998 * 1000 *
@@ -1003,6 +1005,19 @@ int
1003GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx) 1005GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx)
1004{ 1006{
1005 int res; 1007 int res;
1008 /* Check if solving is already running */
1009 if (GNUNET_YES == mlp->semaphore)
1010 {
1011 if (mlp->mlp_task != GNUNET_SCHEDULER_NO_TASK)
1012 {
1013 GNUNET_SCHEDULER_cancel(mlp->mlp_task);
1014 mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
1015 }
1016 mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp);
1017 return GNUNET_SYSERR;
1018 }
1019 mlp->semaphore = GNUNET_YES;
1020
1006 mlp->last_execution = GNUNET_TIME_absolute_get (); 1021 mlp->last_execution = GNUNET_TIME_absolute_get ();
1007 1022
1008 ctx->lp_result = GNUNET_SYSERR; 1023 ctx->lp_result = GNUNET_SYSERR;
@@ -1025,6 +1040,7 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContex
1025 if (res != GNUNET_OK) 1040 if (res != GNUNET_OK)
1026 { 1041 {
1027 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "LP Problem solving failed\n"); 1042 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "LP Problem solving failed\n");
1043 mlp->semaphore = GNUNET_NO;
1028 return GNUNET_SYSERR; 1044 return GNUNET_SYSERR;
1029 } 1045 }
1030 1046
@@ -1041,6 +1057,7 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContex
1041 if (res != GNUNET_OK) 1057 if (res != GNUNET_OK)
1042 { 1058 {
1043 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP Problem solving failed\n"); 1059 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP Problem solving failed\n");
1060 mlp->semaphore = GNUNET_NO;
1044 return GNUNET_SYSERR; 1061 return GNUNET_SYSERR;
1045 } 1062 }
1046#if WRITE_MLP 1063#if WRITE_MLP
@@ -1085,7 +1102,8 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContex
1085 GNUNET_SCHEDULER_cancel(mlp->mlp_task); 1102 GNUNET_SCHEDULER_cancel(mlp->mlp_task);
1086 mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK; 1103 mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
1087 } 1104 }
1088 //mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp); 1105 mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp);
1106 mlp->semaphore = GNUNET_NO;
1089 return res; 1107 return res;
1090} 1108}
1091 1109
@@ -1360,7 +1378,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1360 mlp->b_min = b_min; 1378 mlp->b_min = b_min;
1361 mlp->n_min = n_min; 1379 mlp->n_min = n_min;
1362 mlp->m_q = GNUNET_ATS_QualityPropertiesCount; 1380 mlp->m_q = GNUNET_ATS_QualityPropertiesCount;
1363 1381 mlp->semaphore = GNUNET_NO;
1364 return mlp; 1382 return mlp;
1365} 1383}
1366 1384