aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats_mlp.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-12 15:21:12 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-12 15:21:12 +0000
commit5037ac322b2fcfa1bf8beca205173e5c2f6b35b3 (patch)
tree630ec11ec1736c5211e5ae58e61c12c8d4739b8d /src/ats/plugin_ats_mlp.c
parentbd609b6739575ae2bddf2f4b8556282617ba5c7c (diff)
-fix warnings
Diffstat (limited to 'src/ats/plugin_ats_mlp.c')
-rw-r--r--src/ats/plugin_ats_mlp.c163
1 files changed, 83 insertions, 80 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index c2f8530e19..64e07037ed 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -1528,7 +1528,7 @@ mlp_propagate_results (void *cls,
}
-static void
+static void
notify (struct GAS_MLP_Handle *mlp,
enum GAS_Solver_Operation op,
enum GAS_Solver_Status stat,
@@ -1539,7 +1539,7 @@ notify (struct GAS_MLP_Handle *mlp,
}
-static void
+static void
mlp_branch_and_cut_cb (glp_tree *tree, void *info)
{
struct GAS_MLP_Handle *mlp = info;
@@ -2180,77 +2180,11 @@ GAS_mlp_address_change_network (void *solver,
/**
- * Deletes a single address in the MLP problem
- *
- * The MLP problem has to be recreated and the problem has to be resolved
- *
- * @param solver the MLP Handle
- * @param address the address to delete
- * @param session_only delete only session not whole address
- */
-static void
-GAS_mlp_address_delete (void *solver,
- struct ATS_Address *address,
- int session_only)
-{
- struct ATS_Peer *p;
- struct GAS_MLP_Handle *mlp = solver;
- struct MLP_information *mlpi;
- int was_active;
-
- GNUNET_assert (NULL != solver);
- GNUNET_assert (NULL != address);
-
- mlpi = address->solver_information;
- if ((GNUNET_NO == session_only) && (NULL != mlpi))
- {
- /* Remove full address */
- GNUNET_free (mlpi);
- address->solver_information = NULL;
- }
- was_active = address->active;
- address->active = GNUNET_NO;
- address->assigned_bw_in = BANDWIDTH_ZERO;
- address->assigned_bw_out = BANDWIDTH_ZERO;
-
- /* Is this peer included in the problem? */
- if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers,
- &address->peer)))
- {
- LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' without address request \n",
- (session_only == GNUNET_YES) ? "session" : "address",
- GNUNET_i2s(&address->peer));
- return;
- }
- LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' with address request \n",
- (session_only == GNUNET_YES) ? "session" : "address",
- GNUNET_i2s(&address->peer));
-
- /* Problem size changed: new address for peer with pending request */
- mlp->stat_mlp_prob_changed = GNUNET_YES;
- if (GNUNET_YES == mlp->opt_mlp_auto_solve)
- {
- GAS_mlp_solve_problem (solver);
- }
- if (GNUNET_YES == was_active)
- {
- if (NULL == GAS_mlp_get_preferred_address (solver, &address->peer))
- {
- /* No alternative address, disconnecting peer */
- mlp->bw_changed_cb (mlp->bw_changed_cb_cls, address);
- }
- }
-
- return;
-}
-
-
-/**
* Find the active address in the set of addresses of a peer
* @param cls destination
* @param key peer id
* @param value address
- * @return GNUNET_OK
+ * @return #GNUNET_OK
*/
static int
mlp_get_preferred_address_it (void *cls,
@@ -2282,13 +2216,14 @@ mlp_get_preferred_address_it (void *cls,
(*aa)->assigned_bw_out = mlpi->b_out;
return GNUNET_NO;
}
- counter ++;
+ counter++;
return GNUNET_YES;
}
static double
-get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentity *peer)
+get_peer_pref_value (struct GAS_MLP_Handle *mlp,
+ const struct GNUNET_PeerIdentity *peer)
{
double res;
const double *preferences = NULL;
@@ -2309,8 +2244,9 @@ get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentit
res /= (GNUNET_ATS_PreferenceCount -1);
res += 1.0;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Peer preference for peer `%s' == %.2f\n",
- GNUNET_i2s(peer), res);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer preference for peer `%s' == %.2f\n",
+ GNUNET_i2s(peer), res);
return res;
}
@@ -2366,12 +2302,78 @@ GAS_mlp_get_preferred_address (void *solver,
/* Get prefered address */
res = NULL;
GNUNET_CONTAINER_multipeermap_get_multiple (mlp->addresses, peer,
- mlp_get_preferred_address_it, &res);
+ &mlp_get_preferred_address_it, &res);
return res;
}
/**
+ * Deletes a single address in the MLP problem
+ *
+ * The MLP problem has to be recreated and the problem has to be resolved
+ *
+ * @param solver the MLP Handle
+ * @param address the address to delete
+ * @param session_only delete only session not whole address
+ */
+static void
+GAS_mlp_address_delete (void *solver,
+ struct ATS_Address *address,
+ int session_only)
+{
+ struct ATS_Peer *p;
+ struct GAS_MLP_Handle *mlp = solver;
+ struct MLP_information *mlpi;
+ int was_active;
+
+ GNUNET_assert (NULL != solver);
+ GNUNET_assert (NULL != address);
+
+ mlpi = address->solver_information;
+ if ((GNUNET_NO == session_only) && (NULL != mlpi))
+ {
+ /* Remove full address */
+ GNUNET_free (mlpi);
+ address->solver_information = NULL;
+ }
+ was_active = address->active;
+ address->active = GNUNET_NO;
+ address->assigned_bw_in = BANDWIDTH_ZERO;
+ address->assigned_bw_out = BANDWIDTH_ZERO;
+
+ /* Is this peer included in the problem? */
+ if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers,
+ &address->peer)))
+ {
+ LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' without address request \n",
+ (session_only == GNUNET_YES) ? "session" : "address",
+ GNUNET_i2s(&address->peer));
+ return;
+ }
+ LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' with address request \n",
+ (session_only == GNUNET_YES) ? "session" : "address",
+ GNUNET_i2s(&address->peer));
+
+ /* Problem size changed: new address for peer with pending request */
+ mlp->stat_mlp_prob_changed = GNUNET_YES;
+ if (GNUNET_YES == mlp->opt_mlp_auto_solve)
+ {
+ GAS_mlp_solve_problem (solver);
+ }
+ if (GNUNET_YES == was_active)
+ {
+ if (NULL == GAS_mlp_get_preferred_address (solver, &address->peer))
+ {
+ /* No alternative address, disconnecting peer */
+ mlp->bw_changed_cb (mlp->bw_changed_cb_cls, address);
+ }
+ }
+
+ return;
+}
+
+
+/**
* Start a bulk operation
*
* @param solver the solver
@@ -2379,11 +2381,11 @@ GAS_mlp_get_preferred_address (void *solver,
static void
GAS_mlp_bulk_start (void *solver)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Locking solver for bulk operation ...\n");
- struct GAS_MLP_Handle *s = (struct GAS_MLP_Handle *) solver;
+ struct GAS_MLP_Handle *s = solver;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Locking solver for bulk operation ...\n");
GNUNET_assert (NULL != solver);
-
s->stat_bulk_lock ++;
}
@@ -2391,9 +2393,10 @@ GAS_mlp_bulk_start (void *solver)
static void
GAS_mlp_bulk_stop (void *solver)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Unlocking solver from bulk operation ...\n");
+ struct GAS_MLP_Handle *s = solver;
- struct GAS_MLP_Handle *s = (struct GAS_MLP_Handle *) solver;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Unlocking solver from bulk operation ...\n");
GNUNET_assert (NULL != solver);
if (s->stat_bulk_lock < 1)
@@ -2538,7 +2541,7 @@ libgnunet_plugin_ats_mlp_done (void *cls)
struct GAS_MLP_Handle *mlp = cls;
GNUNET_assert (mlp != NULL);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Shutting down mlp solver\n");
mlp_delete_problem (mlp);