[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19207 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19207 - gnunet/src/ats |
Date: |
Tue, 17 Jan 2012 17:44:03 +0100 |
Author: wachs
Date: 2012-01-17 17:44:03 +0100 (Tue, 17 Jan 2012)
New Revision: 19207
Modified:
gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
Log:
- changes
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-01-17 16:17:14 UTC
(rev 19206)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-01-17 16:44:03 UTC
(rev 19207)
@@ -33,6 +33,8 @@
#include "glpk.h"
#endif
+#define DEBUG_ATS GNUNET_YES
+
/**
* Translate glpk solver error codes to text
* @param retcode return code
@@ -165,7 +167,6 @@
* @param mlp the MLP handle
* @return GNUNET_OK or GNUNET_SYSERR
*/
-
static int
mlp_create_problem (struct GAS_MLP_Handle *mlp)
{
@@ -395,6 +396,26 @@
return GNUNET_OK;
}
+int mlp_solve_problem (struct GAS_MLP_Handle *mlp);
+
+static void
+mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GAS_MLP_Handle *mlp = cls;
+
+ mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
+
+ if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+ return;
+
+#if DEBUG_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n");
+#endif
+ if (mlp->addr_in_problem != 0)
+ mlp_solve_problem(mlp);
+}
+
+
/**
* Solves the MLP problem
*
@@ -409,6 +430,12 @@
res = mlp_solve_lp_problem (mlp);
if (res == GNUNET_OK)
res = mlp_solve_mlp_problem (mlp);
+ 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 res;
}
@@ -434,6 +461,7 @@
long long unsigned int tmp;
unsigned int b_min;
unsigned int n_min;
+ struct GNUNET_TIME_Relative i_exec;
/* Init GLPK environment */
GNUNET_assert (glp_init_env() == 0);
@@ -514,6 +542,14 @@
else
n_min = 4;
+ /* Get minimum number of connections from configuration */
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (cfg, "ats",
+ "ATS_EXEC_INTERVAL",
+ &i_exec))
+ mlp->exec_interval = i_exec;
+ else
+ mlp->exec_interval =
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30);
+
mlp->stats = (struct GNUNET_STATISTICS_Handle *) stats;
mlp->max_iterations = max_iterations;
mlp->max_exec_duration = max_duration;
@@ -610,6 +646,9 @@
glp_set_obj_coef (mlp->prob, mlpi->c_n, 0);
/* Add */
+
+
+ mlp->addr_in_problem ++;
}
else
new = GNUNET_NO;
@@ -641,6 +680,8 @@
{
GNUNET_free (address->mlp_information);
address->mlp_information = NULL;
+
+ mlp->addr_in_problem --;
}
/* Update problem */
@@ -670,6 +711,12 @@
void
GAS_mlp_done (struct GAS_MLP_Handle *mlp)
{
+ if (mlp->mlp_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel(mlp->mlp_task);
+ mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+
if (mlp != NULL)
glp_delete_prob(mlp->prob);
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-01-17 16:17:14 UTC
(rev 19206)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-01-17 16:44:03 UTC
(rev 19207)
@@ -70,6 +70,16 @@
glp_iocp control_param_mlp;
/**
+ * Solves the task in an regular interval
+ */
+ GNUNET_SCHEDULER_TaskIdentifier mlp_task;
+
+ /**
+ * Interval between scheduled problem solving
+ */
+ struct GNUNET_TIME_Relative exec_interval;
+
+ /**
* Maximum execution time per problem solving
*/
struct GNUNET_TIME_Relative max_exec_duration;
@@ -121,6 +131,8 @@
*/
uint64_t mlp_total_duration;
+ unsigned int addr_in_problem;
+
/* Information about the problem */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19207 - gnunet/src/ats,
gnunet <=