diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-16 10:10:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-16 10:10:59 +0000 |
commit | 1eef01cd60f92a3d77061d655c0217bd6f9ffce4 (patch) | |
tree | db83ba950eb0ece1efb9b682e379ccd1d0dd4b72 /src/testbed | |
parent | c1d89ed3cf92fa2492a5639e725aadd74742f135 (diff) | |
download | gnunet-1eef01cd60f92a3d77061d655c0217bd6f9ffce4.tar.gz gnunet-1eef01cd60f92a3d77061d655c0217bd6f9ffce4.zip |
notify performance monitors about destroyed addresses (for #3406)
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/gnunet-daemon-latency-logger.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/testbed/gnunet-daemon-latency-logger.c b/src/testbed/gnunet-daemon-latency-logger.c index 774b5dd4d..a33d00e92 100644 --- a/src/testbed/gnunet-daemon-latency-logger.c +++ b/src/testbed/gnunet-daemon-latency-logger.c | |||
@@ -21,7 +21,7 @@ | |||
21 | /** | 21 | /** |
22 | * @file testbed/gnunet-daemon-latency-logger.c | 22 | * @file testbed/gnunet-daemon-latency-logger.c |
23 | * @brief log latency values from neighbour connections into an SQLite database | 23 | * @brief log latency values from neighbour connections into an SQLite database |
24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | 24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
@@ -71,7 +71,7 @@ struct Entry | |||
71 | * The last known value for latency | 71 | * The last known value for latency |
72 | */ | 72 | */ |
73 | unsigned int latency; | 73 | unsigned int latency; |
74 | 74 | ||
75 | }; | 75 | }; |
76 | 76 | ||
77 | 77 | ||
@@ -119,7 +119,7 @@ free_iterator (void *cls, | |||
119 | { | 119 | { |
120 | struct Entry *e = cls; | 120 | struct Entry *e = cls; |
121 | 121 | ||
122 | GNUNET_assert (GNUNET_YES == | 122 | GNUNET_assert (GNUNET_YES == |
123 | GNUNET_CONTAINER_multipeermap_remove (map, key, e)); | 123 | GNUNET_CONTAINER_multipeermap_remove (map, key, e)); |
124 | GNUNET_free (e); | 124 | GNUNET_free (e); |
125 | return GNUNET_YES; | 125 | return GNUNET_YES; |
@@ -131,7 +131,7 @@ free_iterator (void *cls, | |||
131 | * | 131 | * |
132 | * @param cls NULL | 132 | * @param cls NULL |
133 | * @param tc task context from scheduler | 133 | * @param tc task context from scheduler |
134 | * @return | 134 | * @return |
135 | */ | 135 | */ |
136 | static void | 136 | static void |
137 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 137 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -148,7 +148,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
148 | db = NULL; | 148 | db = NULL; |
149 | if (NULL != map) | 149 | if (NULL != map) |
150 | { | 150 | { |
151 | GNUNET_assert (GNUNET_SYSERR != | 151 | GNUNET_assert (GNUNET_SYSERR != |
152 | GNUNET_CONTAINER_multipeermap_iterate (map, free_iterator, NULL)); | 152 | GNUNET_CONTAINER_multipeermap_iterate (map, free_iterator, NULL)); |
153 | GNUNET_CONTAINER_multipeermap_destroy (map); | 153 | GNUNET_CONTAINER_multipeermap_destroy (map); |
154 | map = NULL; | 154 | map = NULL; |
@@ -160,8 +160,10 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
160 | * | 160 | * |
161 | * @param cls closure | 161 | * @param cls closure |
162 | * @param address the address | 162 | * @param address the address |
163 | * @param address_active is this address actively used to maintain a connection | 163 | * @param address_active #GNUNET_YES if this address is actively used |
164 | * to a peer | 164 | * to maintain a connection to a peer; |
165 | * #GNUNET_NO if the address is not actively used; | ||
166 | * #GNUNET_SYSERR if this address is no longer available for ATS | ||
165 | * @param bandwidth_out assigned outbound bandwidth for the connection | 167 | * @param bandwidth_out assigned outbound bandwidth for the connection |
166 | * @param bandwidth_in assigned inbound bandwidth for the connection | 168 | * @param bandwidth_in assigned inbound bandwidth for the connection |
167 | * @param ats performance data for the address (as far as known) | 169 | * @param ats performance data for the address (as far as known) |
@@ -197,7 +199,7 @@ addr_info_cb (void *cls, | |||
197 | } | 199 | } |
198 | 200 | ||
199 | GNUNET_assert (NULL != db); | 201 | GNUNET_assert (NULL != db); |
200 | if (GNUNET_NO == address_active) | 202 | if (GNUNET_YES != address_active) |
201 | return; | 203 | return; |
202 | for (cnt = 0; cnt < ats_count; cnt++) | 204 | for (cnt = 0; cnt < ats_count; cnt++) |
203 | { | 205 | { |
@@ -248,13 +250,13 @@ addr_info_cb (void *cls, | |||
248 | { | 250 | { |
249 | entry = GNUNET_new (struct Entry); | 251 | entry = GNUNET_new (struct Entry); |
250 | entry->id = address->peer; | 252 | entry->id = address->peer; |
251 | GNUNET_CONTAINER_multipeermap_put (map, | 253 | GNUNET_CONTAINER_multipeermap_put (map, |
252 | &entry->id, entry, | 254 | &entry->id, entry, |
253 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 255 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
254 | } | 256 | } |
255 | entry->latency = latency; | 257 | entry->latency = latency; |
256 | return; | 258 | return; |
257 | 259 | ||
258 | err_shutdown: | 260 | err_shutdown: |
259 | GNUNET_SCHEDULER_shutdown (); | 261 | GNUNET_SCHEDULER_shutdown (); |
260 | } | 262 | } |
@@ -272,7 +274,7 @@ static void | |||
272 | run (void *cls, char *const *args, const char *cfgfile, | 274 | run (void *cls, char *const *args, const char *cfgfile, |
273 | const struct GNUNET_CONFIGURATION_Handle *c) | 275 | const struct GNUNET_CONFIGURATION_Handle *c) |
274 | { | 276 | { |
275 | const char *query_create = | 277 | const char *query_create = |
276 | "CREATE TABLE ats_info (" | 278 | "CREATE TABLE ats_info (" |
277 | "id TEXT," | 279 | "id TEXT," |
278 | "val INTEGER," | 280 | "val INTEGER," |
@@ -303,9 +305,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
303 | DEBUG ("SQLite Error: %d. Perhaps the database `%s' already exits.\n", | 305 | DEBUG ("SQLite Error: %d. Perhaps the database `%s' already exits.\n", |
304 | sqlite3_errcode (db), dbfile); | 306 | sqlite3_errcode (db), dbfile); |
305 | DEBUG ("Opened database %s\n", dbfile); | 307 | DEBUG ("Opened database %s\n", dbfile); |
306 | GNUNET_free (dbfile); | 308 | GNUNET_free (dbfile); |
307 | dbfile = NULL; | 309 | dbfile = NULL; |
308 | ats = GNUNET_ATS_performance_init (c, addr_info_cb, NULL); | 310 | ats = GNUNET_ATS_performance_init (c, &addr_info_cb, NULL); |
309 | map = GNUNET_CONTAINER_multipeermap_create (30, GNUNET_YES); | 311 | map = GNUNET_CONTAINER_multipeermap_create (30, GNUNET_YES); |
310 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 312 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
311 | &do_shutdown, NULL); | 313 | &do_shutdown, NULL); |