aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-08 18:13:10 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-08 18:13:10 +0000
commited8beb3bda5f3b1d2bf31f57f077bf90e40af812 (patch)
tree4ee276dfc49030a79cd7a8c5b26ab08a6aaffde2 /src
parente1669fabbcb9f21c509e03811fe2d8b5b568b15c (diff)
downloadgnunet-ed8beb3bda5f3b1d2bf31f57f077bf90e40af812.tar.gz
gnunet-ed8beb3bda5f3b1d2bf31f57f077bf90e40af812.zip
changing s_get API to return void instead of address, have plugin use existing mechanism to signal address activation
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-ats-solver-eval.c20
-rw-r--r--src/ats/gnunet-service-ats_plugins.c29
-rw-r--r--src/ats/plugin_ats_mlp.c24
-rw-r--r--src/ats/plugin_ats_proportional.c27
-rw-r--r--src/ats/plugin_ats_ril.c7
-rw-r--r--src/include/gnunet_ats_plugin.h2
6 files changed, 41 insertions, 68 deletions
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c
index a10d745fd..8cf4b115b 100644
--- a/src/ats/gnunet-ats-solver-eval.c
+++ b/src/ats/gnunet-ats-solver-eval.c
@@ -2382,7 +2382,6 @@ static void
2382enforce_start_request (struct GNUNET_ATS_TEST_Operation *op) 2382enforce_start_request (struct GNUNET_ATS_TEST_Operation *op)
2383{ 2383{
2384 struct TestPeer *p; 2384 struct TestPeer *p;
2385 const struct ATS_Address *res;
2386 2385
2387 if (NULL == (p = find_peer_by_id (op->peer_id))) 2386 if (NULL == (p = find_peer_by_id (op->peer_id)))
2388 { 2387 {
@@ -2396,18 +2395,10 @@ enforce_start_request (struct GNUNET_ATS_TEST_Operation *op)
2396 op->peer_id); 2395 op->peer_id);
2397 p->is_requested = GNUNET_YES; 2396 p->is_requested = GNUNET_YES;
2398 2397
2399 res = sh->sf->s_get (sh->sf->cls, &p->peer_id); 2398 sh->sf->s_get (sh->sf->cls, &p->peer_id);
2400 if (NULL != res)
2401 {
2402 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Suggested address for peer %u: %llu %llu\n",
2403 op->peer_id,
2404 res->assigned_bw_in,
2405 res->assigned_bw_out);
2406 if (NULL != l)
2407 GNUNET_ATS_solver_logging_now (l);
2408 }
2409} 2399}
2410 2400
2401
2411static void 2402static void
2412enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op) 2403enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op)
2413{ 2404{
@@ -2421,10 +2412,9 @@ enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op)
2421 return; 2412 return;
2422 } 2413 }
2423 2414
2424 2415 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2425 2416 "Stop requesting address for peer %u\n",
2426 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop requesting address for peer %u\n", 2417 op->peer_id);
2427 op->peer_id);
2428 p->is_requested = GNUNET_NO; 2418 p->is_requested = GNUNET_NO;
2429 p->assigned_bw_in = 0; 2419 p->assigned_bw_in = 0;
2430 p->assigned_bw_out = 0; 2420 p->assigned_bw_out = 0;
diff --git a/src/ats/gnunet-service-ats_plugins.c b/src/ats/gnunet-service-ats_plugins.c
index 712f927b5..131d8d634 100644
--- a/src/ats/gnunet-service-ats_plugins.c
+++ b/src/ats/gnunet-service-ats_plugins.c
@@ -246,11 +246,11 @@ bandwidth_changed_cb (void *cls,
246 (diff_in < htonl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) ) 246 (diff_in < htonl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) )
247 return; 247 return;
248 248
249 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 249 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
250 "Sending bandwidth update for peer `%s': %u/%u\n", 250 "Sending bandwidth update for peer `%s': %u/%u\n",
251 GNUNET_i2s (&address->peer), 251 GNUNET_i2s (&address->peer),
252 address->assigned_bw_out, 252 address->assigned_bw_out,
253 address->assigned_bw_out); 253 address->assigned_bw_out);
254 254
255 /* *Notify scheduling clients about suggestion */ 255 /* *Notify scheduling clients about suggestion */
256 GAS_scheduling_transmit_address_suggestion (&address->peer, 256 GAS_scheduling_transmit_address_suggestion (&address->peer,
@@ -555,24 +555,7 @@ GAS_plugin_solver_unlock ()
555void 555void
556GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid) 556GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid)
557{ 557{
558 const struct ATS_Address *aa; 558 sf->s_get (sf->cls, pid);
559
560 aa = sf->s_get (sf->cls, pid);
561 if (NULL == aa)
562 {
563 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
564 "Cannot suggest address for peer `%s'\n",
565 GNUNET_i2s (pid));
566 return;
567 }
568 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
569 "Suggesting address %p for peer `%s'\n",
570 aa,
571 GNUNET_i2s (pid));
572 GAS_scheduling_transmit_address_suggestion (pid,
573 aa->session_id,
574 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_out),
575 GNUNET_BANDWIDTH_value_init (aa->assigned_bw_in));
576} 559}
577 560
578 561
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index 900a07fa5..b97261d46 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -2063,9 +2063,8 @@ get_peer_pref_value (struct GAS_MLP_Handle *mlp,
2063 * 2063 *
2064 * @param solver the MLP Handle 2064 * @param solver the MLP Handle
2065 * @param peer the peer 2065 * @param peer the peer
2066 * @return suggested address
2067 */ 2066 */
2068static const struct ATS_Address * 2067static void
2069GAS_mlp_get_preferred_address (void *solver, 2068GAS_mlp_get_preferred_address (void *solver,
2070 const struct GNUNET_PeerIdentity *peer) 2069 const struct GNUNET_PeerIdentity *peer)
2071{ 2070{
@@ -2073,11 +2072,9 @@ GAS_mlp_get_preferred_address (void *solver,
2073 struct ATS_Peer *p; 2072 struct ATS_Peer *p;
2074 struct ATS_Address *res; 2073 struct ATS_Address *res;
2075 2074
2076 GNUNET_assert (NULL != solver); 2075 LOG (GNUNET_ERROR_TYPE_DEBUG,
2077 GNUNET_assert (NULL != peer); 2076 "Getting preferred address for `%s'\n",
2078 2077 GNUNET_i2s (peer));
2079 LOG (GNUNET_ERROR_TYPE_DEBUG, "Getting preferred address for `%s'\n",
2080 GNUNET_i2s (peer));
2081 2078
2082 /* Is this peer included in the problem? */ 2079 /* Is this peer included in the problem? */
2083 if (NULL == 2080 if (NULL ==
@@ -2110,7 +2107,9 @@ GAS_mlp_get_preferred_address (void *solver,
2110 res = NULL; 2107 res = NULL;
2111 GNUNET_CONTAINER_multipeermap_get_multiple (mlp->env->addresses, peer, 2108 GNUNET_CONTAINER_multipeermap_get_multiple (mlp->env->addresses, peer,
2112 &mlp_get_preferred_address_it, &res); 2109 &mlp_get_preferred_address_it, &res);
2113 return res; 2110 if (NULL != res)
2111 mlp->env->bandwidth_changed_cb (mlp->env->cls,
2112 res);
2114} 2113}
2115 2114
2116 2115
@@ -2128,6 +2127,7 @@ GAS_mlp_address_delete (void *solver,
2128{ 2127{
2129 struct GAS_MLP_Handle *mlp = solver; 2128 struct GAS_MLP_Handle *mlp = solver;
2130 struct MLP_information *mlpi; 2129 struct MLP_information *mlpi;
2130 struct ATS_Address *res;
2131 int was_active; 2131 int was_active;
2132 2132
2133 mlpi = address->solver_information; 2133 mlpi = address->solver_information;
@@ -2164,7 +2164,13 @@ GAS_mlp_address_delete (void *solver,
2164 } 2164 }
2165 if (GNUNET_YES == was_active) 2165 if (GNUNET_YES == was_active)
2166 { 2166 {
2167 if (NULL == GAS_mlp_get_preferred_address (solver, &address->peer)) 2167 GAS_mlp_get_preferred_address (solver, &address->peer);
2168 res = NULL;
2169 GNUNET_CONTAINER_multipeermap_get_multiple (mlp->env->addresses,
2170 &address->peer,
2171 &mlp_get_preferred_address_it,
2172 &res);
2173 if (NULL == res)
2168 { 2174 {
2169 /* No alternative address, disconnecting peer */ 2175 /* No alternative address, disconnecting peer */
2170 mlp->env->bandwidth_changed_cb (mlp->env->cls, address); 2176 mlp->env->bandwidth_changed_cb (mlp->env->cls, address);
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c
index 7f0fcd042..70c3d4771 100644
--- a/src/ats/plugin_ats_proportional.c
+++ b/src/ats/plugin_ats_proportional.c
@@ -929,26 +929,15 @@ update_active_address (struct GAS_PROPORTIONAL_Handle *s,
929 struct AddressWrapper *asi; 929 struct AddressWrapper *asi;
930 struct Network *net; 930 struct Network *net;
931 931
932 LOG (GNUNET_ERROR_TYPE_INFO,
933 "Updating active address for peer `%s'\n",
934 GNUNET_i2s (peer));
935
936 /* Find active address */
937 current_address = get_active_address (s, 932 current_address = get_active_address (s,
938 peer); 933 peer);
939
940 LOG (GNUNET_ERROR_TYPE_INFO,
941 "Peer `%s' has active address %p\n",
942 GNUNET_i2s (peer),
943 current_address);
944
945 /* Find best address */
946 best_address = get_best_address (s, 934 best_address = get_best_address (s,
947 s->env->addresses, 935 s->env->addresses,
948 peer); 936 peer);
949 LOG (GNUNET_ERROR_TYPE_INFO, 937 LOG (GNUNET_ERROR_TYPE_INFO,
950 "Peer `%s' has best address %p\n", 938 "Peer `%s' has active address %p and best address %p\n",
951 GNUNET_i2s (peer), 939 GNUNET_i2s (peer),
940 current_address,
952 best_address); 941 best_address);
953 942
954 if (NULL != current_address) 943 if (NULL != current_address)
@@ -1106,19 +1095,21 @@ GAS_proportional_address_preference_feedback (void *solver,
1106 * 1095 *
1107 * @param solver the solver handle 1096 * @param solver the solver handle
1108 * @param peer the identity of the peer 1097 * @param peer the identity of the peer
1109 * @return best address
1110 */ 1098 */
1111static const struct ATS_Address * 1099static void
1112GAS_proportional_get_preferred_address (void *solver, 1100GAS_proportional_get_preferred_address (void *solver,
1113 const struct GNUNET_PeerIdentity *peer) 1101 const struct GNUNET_PeerIdentity *peer)
1114{ 1102{
1115 struct GAS_PROPORTIONAL_Handle *s = solver; 1103 struct GAS_PROPORTIONAL_Handle *s = solver;
1116 const struct ATS_Address *best_address; 1104 struct ATS_Address *best_address;
1117 1105
1118 best_address = update_active_address (s, peer); 1106 best_address = update_active_address (s, peer);
1107 if (NULL == best_address)
1108 return;
1119 if (s->bulk_lock > 0) 1109 if (s->bulk_lock > 0)
1120 return NULL; 1110 return;
1121 return best_address; 1111 s->env->bandwidth_changed_cb (s->env->cls,
1112 best_address);
1122} 1113}
1123 1114
1124 1115
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c
index cd867b95c..78f58e609 100644
--- a/src/ats/plugin_ats_ril.c
+++ b/src/ats/plugin_ats_ril.c
@@ -2484,7 +2484,7 @@ GAS_ril_bulk_stop (void *solver)
2484 * @param solver the solver handle 2484 * @param solver the solver handle
2485 * @param peer the identity of the peer 2485 * @param peer the identity of the peer
2486 */ 2486 */
2487static const struct ATS_Address * 2487static void
2488GAS_ril_get_preferred_address (void *solver, 2488GAS_ril_get_preferred_address (void *solver,
2489 const struct GNUNET_PeerIdentity *peer) 2489 const struct GNUNET_PeerIdentity *peer)
2490{ 2490{
@@ -2514,9 +2514,12 @@ GAS_ril_get_preferred_address (void *solver,
2514 s->parameters.temperature = s->parameters.temperature_init; 2514 s->parameters.temperature = s->parameters.temperature_init;
2515 s->parameters.epsilon = s->parameters.epsilon_init; 2515 s->parameters.epsilon = s->parameters.epsilon_init;
2516 } 2516 }
2517 return agent->address_inuse; 2517 if (NULL != agent->address_inuse)
2518 s->env->bandwidth_changed_cb (s->env->cls,
2519 agent->address_inuse);
2518} 2520}
2519 2521
2522
2520/** 2523/**
2521 * Tell solver stop notifying ATS about changes for this peers 2524 * Tell solver stop notifying ATS about changes for this peers
2522 * 2525 *
diff --git a/src/include/gnunet_ats_plugin.h b/src/include/gnunet_ats_plugin.h
index c33ad61e9..4d6fa43f4 100644
--- a/src/include/gnunet_ats_plugin.h
+++ b/src/include/gnunet_ats_plugin.h
@@ -143,7 +143,7 @@ typedef void
143 * @param solver the solver to use 143 * @param solver the solver to use
144 * @param peer the peer 144 * @param peer the peer
145 */ 145 */
146typedef const struct ATS_Address * 146typedef void
147(*GAS_solver_get_preferred_address) (void *solver, 147(*GAS_solver_get_preferred_address) (void *solver,
148 const struct GNUNET_PeerIdentity *peer); 148 const struct GNUNET_PeerIdentity *peer);
149 149