int GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx);
+
static void
mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GAS_mlp_solve_problem(mlp, &ctx);
}
+
/**
* Solves the MLP problem
*
GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx)
{
int res;
+ /* Check if solving is already running */
+ if (GNUNET_YES == mlp->semaphore)
+ {
+ if (mlp->mlp_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel(mlp->mlp_task);
+ mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp);
+ return GNUNET_SYSERR;
+ }
+ mlp->semaphore = GNUNET_YES;
+
mlp->last_execution = GNUNET_TIME_absolute_get ();
ctx->lp_result = GNUNET_SYSERR;
if (res != GNUNET_OK)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "LP Problem solving failed\n");
+ mlp->semaphore = GNUNET_NO;
return GNUNET_SYSERR;
}
if (res != GNUNET_OK)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP Problem solving failed\n");
+ mlp->semaphore = GNUNET_NO;
return GNUNET_SYSERR;
}
#if WRITE_MLP
GNUNET_SCHEDULER_cancel(mlp->mlp_task);
mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
}
- //mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp);
+ mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp);
+ mlp->semaphore = GNUNET_NO;
return res;
}
mlp->b_min = b_min;
mlp->n_min = n_min;
mlp->m_q = GNUNET_ATS_QualityPropertiesCount;
-
+ mlp->semaphore = GNUNET_NO;
return mlp;
}
*/
int auto_solve;
+ int semaphore;
+
/* state information */
/**
static unsigned int peers;
static unsigned int addresses;
static unsigned int numeric;
+static unsigned int updates;
static int start;
static int end;
#endif
struct ATS_Address addr[10];
struct ATS_PreferedAddress *res[10];
+ struct GAS_MLP_SolutionContext ctx;
stats = GNUNET_STATISTICS_create("ats", cfg);
GAS_mlp_address_update (mlp, addresses, &addr[2]);
GNUNET_assert (mlp->addr_in_problem == 3);
- GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp));
+ GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx));
+ GNUNET_assert (GNUNET_OK == ctx.lp_result);
+ GNUNET_assert (GNUNET_OK == ctx.mlp_result);
res[0] = GAS_mlp_get_preferred_address(mlp, addresses, &p[0]);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s' outbound bandwidth: %u Bps\n",res[0]->address->plugin, res[0]->bandwidth_out);
struct ATS_Address addr[10];
struct ATS_PreferedAddress *res[10];
struct MLP_information *mlpi;
+ struct GAS_MLP_SolutionContext ctx;
stats = GNUNET_STATISTICS_create("ats", cfg);
GNUNET_assert (mlp->addr_in_problem == 1);
- GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp));
+ GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx));
+ GNUNET_assert (GNUNET_OK == ctx.lp_result);
+ GNUNET_assert (GNUNET_OK == ctx.mlp_result);
res[0] = GAS_mlp_get_preferred_address(mlp, addresses, &p[0]);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s' outbound bandwidth: %u Bps\n",res[0]->address->plugin, res[0]->bandwidth_out);