diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-12 15:21:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-12 15:21:12 +0000 |
commit | 5037ac322b2fcfa1bf8beca205173e5c2f6b35b3 (patch) | |
tree | 630ec11ec1736c5211e5ae58e61c12c8d4739b8d /src/ats | |
parent | bd609b6739575ae2bddf2f4b8556282617ba5c7c (diff) | |
download | gnunet-5037ac322b2fcfa1bf8beca205173e5c2f6b35b3.tar.gz gnunet-5037ac322b2fcfa1bf8beca205173e5c2f6b35b3.zip |
-fix warnings
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/plugin_ats_mlp.c | 163 |
1 files changed, 83 insertions, 80 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c index c2f8530e1..64e07037e 100644 --- a/src/ats/plugin_ats_mlp.c +++ b/src/ats/plugin_ats_mlp.c | |||
@@ -1528,7 +1528,7 @@ mlp_propagate_results (void *cls, | |||
1528 | } | 1528 | } |
1529 | 1529 | ||
1530 | 1530 | ||
1531 | static void | 1531 | static void |
1532 | notify (struct GAS_MLP_Handle *mlp, | 1532 | notify (struct GAS_MLP_Handle *mlp, |
1533 | enum GAS_Solver_Operation op, | 1533 | enum GAS_Solver_Operation op, |
1534 | enum GAS_Solver_Status stat, | 1534 | enum GAS_Solver_Status stat, |
@@ -1539,7 +1539,7 @@ notify (struct GAS_MLP_Handle *mlp, | |||
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | 1541 | ||
1542 | static void | 1542 | static void |
1543 | mlp_branch_and_cut_cb (glp_tree *tree, void *info) | 1543 | mlp_branch_and_cut_cb (glp_tree *tree, void *info) |
1544 | { | 1544 | { |
1545 | struct GAS_MLP_Handle *mlp = info; | 1545 | struct GAS_MLP_Handle *mlp = info; |
@@ -2180,77 +2180,11 @@ GAS_mlp_address_change_network (void *solver, | |||
2180 | 2180 | ||
2181 | 2181 | ||
2182 | /** | 2182 | /** |
2183 | * Deletes a single address in the MLP problem | ||
2184 | * | ||
2185 | * The MLP problem has to be recreated and the problem has to be resolved | ||
2186 | * | ||
2187 | * @param solver the MLP Handle | ||
2188 | * @param address the address to delete | ||
2189 | * @param session_only delete only session not whole address | ||
2190 | */ | ||
2191 | static void | ||
2192 | GAS_mlp_address_delete (void *solver, | ||
2193 | struct ATS_Address *address, | ||
2194 | int session_only) | ||
2195 | { | ||
2196 | struct ATS_Peer *p; | ||
2197 | struct GAS_MLP_Handle *mlp = solver; | ||
2198 | struct MLP_information *mlpi; | ||
2199 | int was_active; | ||
2200 | |||
2201 | GNUNET_assert (NULL != solver); | ||
2202 | GNUNET_assert (NULL != address); | ||
2203 | |||
2204 | mlpi = address->solver_information; | ||
2205 | if ((GNUNET_NO == session_only) && (NULL != mlpi)) | ||
2206 | { | ||
2207 | /* Remove full address */ | ||
2208 | GNUNET_free (mlpi); | ||
2209 | address->solver_information = NULL; | ||
2210 | } | ||
2211 | was_active = address->active; | ||
2212 | address->active = GNUNET_NO; | ||
2213 | address->assigned_bw_in = BANDWIDTH_ZERO; | ||
2214 | address->assigned_bw_out = BANDWIDTH_ZERO; | ||
2215 | |||
2216 | /* Is this peer included in the problem? */ | ||
2217 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, | ||
2218 | &address->peer))) | ||
2219 | { | ||
2220 | LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' without address request \n", | ||
2221 | (session_only == GNUNET_YES) ? "session" : "address", | ||
2222 | GNUNET_i2s(&address->peer)); | ||
2223 | return; | ||
2224 | } | ||
2225 | LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' with address request \n", | ||
2226 | (session_only == GNUNET_YES) ? "session" : "address", | ||
2227 | GNUNET_i2s(&address->peer)); | ||
2228 | |||
2229 | /* Problem size changed: new address for peer with pending request */ | ||
2230 | mlp->stat_mlp_prob_changed = GNUNET_YES; | ||
2231 | if (GNUNET_YES == mlp->opt_mlp_auto_solve) | ||
2232 | { | ||
2233 | GAS_mlp_solve_problem (solver); | ||
2234 | } | ||
2235 | if (GNUNET_YES == was_active) | ||
2236 | { | ||
2237 | if (NULL == GAS_mlp_get_preferred_address (solver, &address->peer)) | ||
2238 | { | ||
2239 | /* No alternative address, disconnecting peer */ | ||
2240 | mlp->bw_changed_cb (mlp->bw_changed_cb_cls, address); | ||
2241 | } | ||
2242 | } | ||
2243 | |||
2244 | return; | ||
2245 | } | ||
2246 | |||
2247 | |||
2248 | /** | ||
2249 | * Find the active address in the set of addresses of a peer | 2183 | * Find the active address in the set of addresses of a peer |
2250 | * @param cls destination | 2184 | * @param cls destination |
2251 | * @param key peer id | 2185 | * @param key peer id |
2252 | * @param value address | 2186 | * @param value address |
2253 | * @return GNUNET_OK | 2187 | * @return #GNUNET_OK |
2254 | */ | 2188 | */ |
2255 | static int | 2189 | static int |
2256 | mlp_get_preferred_address_it (void *cls, | 2190 | mlp_get_preferred_address_it (void *cls, |
@@ -2282,13 +2216,14 @@ mlp_get_preferred_address_it (void *cls, | |||
2282 | (*aa)->assigned_bw_out = mlpi->b_out; | 2216 | (*aa)->assigned_bw_out = mlpi->b_out; |
2283 | return GNUNET_NO; | 2217 | return GNUNET_NO; |
2284 | } | 2218 | } |
2285 | counter ++; | 2219 | counter++; |
2286 | return GNUNET_YES; | 2220 | return GNUNET_YES; |
2287 | } | 2221 | } |
2288 | 2222 | ||
2289 | 2223 | ||
2290 | static double | 2224 | static double |
2291 | get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentity *peer) | 2225 | get_peer_pref_value (struct GAS_MLP_Handle *mlp, |
2226 | const struct GNUNET_PeerIdentity *peer) | ||
2292 | { | 2227 | { |
2293 | double res; | 2228 | double res; |
2294 | const double *preferences = NULL; | 2229 | const double *preferences = NULL; |
@@ -2309,8 +2244,9 @@ get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentit | |||
2309 | res /= (GNUNET_ATS_PreferenceCount -1); | 2244 | res /= (GNUNET_ATS_PreferenceCount -1); |
2310 | res += 1.0; | 2245 | res += 1.0; |
2311 | 2246 | ||
2312 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peer preference for peer `%s' == %.2f\n", | 2247 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2313 | GNUNET_i2s(peer), res); | 2248 | "Peer preference for peer `%s' == %.2f\n", |
2249 | GNUNET_i2s(peer), res); | ||
2314 | 2250 | ||
2315 | return res; | 2251 | return res; |
2316 | } | 2252 | } |
@@ -2366,12 +2302,78 @@ GAS_mlp_get_preferred_address (void *solver, | |||
2366 | /* Get prefered address */ | 2302 | /* Get prefered address */ |
2367 | res = NULL; | 2303 | res = NULL; |
2368 | GNUNET_CONTAINER_multipeermap_get_multiple (mlp->addresses, peer, | 2304 | GNUNET_CONTAINER_multipeermap_get_multiple (mlp->addresses, peer, |
2369 | mlp_get_preferred_address_it, &res); | 2305 | &mlp_get_preferred_address_it, &res); |
2370 | return res; | 2306 | return res; |
2371 | } | 2307 | } |
2372 | 2308 | ||
2373 | 2309 | ||
2374 | /** | 2310 | /** |
2311 | * Deletes a single address in the MLP problem | ||
2312 | * | ||
2313 | * The MLP problem has to be recreated and the problem has to be resolved | ||
2314 | * | ||
2315 | * @param solver the MLP Handle | ||
2316 | * @param address the address to delete | ||
2317 | * @param session_only delete only session not whole address | ||
2318 | */ | ||
2319 | static void | ||
2320 | GAS_mlp_address_delete (void *solver, | ||
2321 | struct ATS_Address *address, | ||
2322 | int session_only) | ||
2323 | { | ||
2324 | struct ATS_Peer *p; | ||
2325 | struct GAS_MLP_Handle *mlp = solver; | ||
2326 | struct MLP_information *mlpi; | ||
2327 | int was_active; | ||
2328 | |||
2329 | GNUNET_assert (NULL != solver); | ||
2330 | GNUNET_assert (NULL != address); | ||
2331 | |||
2332 | mlpi = address->solver_information; | ||
2333 | if ((GNUNET_NO == session_only) && (NULL != mlpi)) | ||
2334 | { | ||
2335 | /* Remove full address */ | ||
2336 | GNUNET_free (mlpi); | ||
2337 | address->solver_information = NULL; | ||
2338 | } | ||
2339 | was_active = address->active; | ||
2340 | address->active = GNUNET_NO; | ||
2341 | address->assigned_bw_in = BANDWIDTH_ZERO; | ||
2342 | address->assigned_bw_out = BANDWIDTH_ZERO; | ||
2343 | |||
2344 | /* Is this peer included in the problem? */ | ||
2345 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, | ||
2346 | &address->peer))) | ||
2347 | { | ||
2348 | LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' without address request \n", | ||
2349 | (session_only == GNUNET_YES) ? "session" : "address", | ||
2350 | GNUNET_i2s(&address->peer)); | ||
2351 | return; | ||
2352 | } | ||
2353 | LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' with address request \n", | ||
2354 | (session_only == GNUNET_YES) ? "session" : "address", | ||
2355 | GNUNET_i2s(&address->peer)); | ||
2356 | |||
2357 | /* Problem size changed: new address for peer with pending request */ | ||
2358 | mlp->stat_mlp_prob_changed = GNUNET_YES; | ||
2359 | if (GNUNET_YES == mlp->opt_mlp_auto_solve) | ||
2360 | { | ||
2361 | GAS_mlp_solve_problem (solver); | ||
2362 | } | ||
2363 | if (GNUNET_YES == was_active) | ||
2364 | { | ||
2365 | if (NULL == GAS_mlp_get_preferred_address (solver, &address->peer)) | ||
2366 | { | ||
2367 | /* No alternative address, disconnecting peer */ | ||
2368 | mlp->bw_changed_cb (mlp->bw_changed_cb_cls, address); | ||
2369 | } | ||
2370 | } | ||
2371 | |||
2372 | return; | ||
2373 | } | ||
2374 | |||
2375 | |||
2376 | /** | ||
2375 | * Start a bulk operation | 2377 | * Start a bulk operation |
2376 | * | 2378 | * |
2377 | * @param solver the solver | 2379 | * @param solver the solver |
@@ -2379,11 +2381,11 @@ GAS_mlp_get_preferred_address (void *solver, | |||
2379 | static void | 2381 | static void |
2380 | GAS_mlp_bulk_start (void *solver) | 2382 | GAS_mlp_bulk_start (void *solver) |
2381 | { | 2383 | { |
2382 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Locking solver for bulk operation ...\n"); | 2384 | struct GAS_MLP_Handle *s = solver; |
2383 | struct GAS_MLP_Handle *s = (struct GAS_MLP_Handle *) solver; | ||
2384 | 2385 | ||
2386 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2387 | "Locking solver for bulk operation ...\n"); | ||
2385 | GNUNET_assert (NULL != solver); | 2388 | GNUNET_assert (NULL != solver); |
2386 | |||
2387 | s->stat_bulk_lock ++; | 2389 | s->stat_bulk_lock ++; |
2388 | } | 2390 | } |
2389 | 2391 | ||
@@ -2391,9 +2393,10 @@ GAS_mlp_bulk_start (void *solver) | |||
2391 | static void | 2393 | static void |
2392 | GAS_mlp_bulk_stop (void *solver) | 2394 | GAS_mlp_bulk_stop (void *solver) |
2393 | { | 2395 | { |
2394 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Unlocking solver from bulk operation ...\n"); | 2396 | struct GAS_MLP_Handle *s = solver; |
2395 | 2397 | ||
2396 | struct GAS_MLP_Handle *s = (struct GAS_MLP_Handle *) solver; | 2398 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2399 | "Unlocking solver from bulk operation ...\n"); | ||
2397 | GNUNET_assert (NULL != solver); | 2400 | GNUNET_assert (NULL != solver); |
2398 | 2401 | ||
2399 | if (s->stat_bulk_lock < 1) | 2402 | if (s->stat_bulk_lock < 1) |
@@ -2538,7 +2541,7 @@ libgnunet_plugin_ats_mlp_done (void *cls) | |||
2538 | struct GAS_MLP_Handle *mlp = cls; | 2541 | struct GAS_MLP_Handle *mlp = cls; |
2539 | GNUNET_assert (mlp != NULL); | 2542 | GNUNET_assert (mlp != NULL); |
2540 | 2543 | ||
2541 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2544 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2542 | "Shutting down mlp solver\n"); | 2545 | "Shutting down mlp solver\n"); |
2543 | mlp_delete_problem (mlp); | 2546 | mlp_delete_problem (mlp); |
2544 | 2547 | ||