diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-02-20 12:28:18 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-02-20 12:28:18 +0000 |
commit | f4897d2f8268214a14572bd05c987d1350c302e8 (patch) | |
tree | aeef633248a8ae717cccc16683e7ae64244498fd /src/dht/test_dht_monitor.c | |
parent | 0f73a5434770a20429816e8b6adafcffa98a7f46 (diff) | |
download | gnunet-f4897d2f8268214a14572bd05c987d1350c302e8.tar.gz gnunet-f4897d2f8268214a14572bd05c987d1350c302e8.zip |
- Fixed test_monitor testcase crsh
Diffstat (limited to 'src/dht/test_dht_monitor.c')
-rw-r--r-- | src/dht/test_dht_monitor.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index 06489ff15..8e3bd95ef 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c | |||
@@ -122,9 +122,6 @@ struct GNUNET_DHT_GetHandle *get_h_far; | |||
122 | const char *id_origin = "FC74"; | 122 | const char *id_origin = "FC74"; |
123 | const char *id_far = "2UVH"; | 123 | const char *id_far = "2UVH"; |
124 | 124 | ||
125 | unsigned int i_origin; | ||
126 | unsigned int i_far; | ||
127 | |||
128 | struct GNUNET_TESTING_Daemon *d_far; | 125 | struct GNUNET_TESTING_Daemon *d_far; |
129 | struct GNUNET_TESTING_Daemon *o; | 126 | struct GNUNET_TESTING_Daemon *o; |
130 | 127 | ||
@@ -249,7 +246,7 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
249 | GNUNET_h2s_full (&d_far->id.hashPubKey)); | 246 | GNUNET_h2s_full (&d_far->id.hashPubKey)); |
250 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: from %s\n", | 247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: from %s\n", |
251 | GNUNET_h2s_full (&o->id.hashPubKey)); | 248 | GNUNET_h2s_full (&o->id.hashPubKey)); |
252 | get_h_far = GNUNET_DHT_get_start (hs[i_origin], GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ | 249 | get_h_far = GNUNET_DHT_get_start (hs[0], GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ |
253 | GNUNET_BLOCK_TYPE_TEST, /* type */ | 250 | GNUNET_BLOCK_TYPE_TEST, /* type */ |
254 | &d_far->id.hashPubKey, /*key to search */ | 251 | &d_far->id.hashPubKey, /*key to search */ |
255 | 4U, /* replication level */ | 252 | 4U, /* replication level */ |
@@ -262,11 +259,23 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
262 | } | 259 | } |
263 | 260 | ||
264 | 261 | ||
262 | /** | ||
263 | * Periodic function used to put the ID of the far peer in the DHT. | ||
264 | * | ||
265 | * @param cls Closure (not used). | ||
266 | * @param tc Task context. | ||
267 | */ | ||
265 | static void | 268 | static void |
266 | put_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 269 | put_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
267 | { | 270 | { |
268 | struct GNUNET_TESTING_Daemon *d; | 271 | struct GNUNET_TESTING_Daemon *d; |
269 | 272 | ||
273 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
274 | { | ||
275 | put_task = GNUNET_SCHEDULER_NO_TASK; | ||
276 | return; | ||
277 | } | ||
278 | |||
270 | d = GNUNET_TESTING_daemon_get (pg, 4); | 279 | d = GNUNET_TESTING_daemon_get (pg, 4); |
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: putting into DHT: %s\n", | 280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: putting into DHT: %s\n", |
272 | GNUNET_h2s_full (&d->id.hashPubKey)); | 281 | GNUNET_h2s_full (&d->id.hashPubKey)); |
@@ -327,14 +336,17 @@ monitor_dht_cb (void *cls, | |||
327 | 336 | ||
328 | /** | 337 | /** |
329 | * peergroup_ready: start test when all peers are connected | 338 | * peergroup_ready: start test when all peers are connected |
339 | * | ||
330 | * @param cls closure | 340 | * @param cls closure |
331 | * @param emsg error message | 341 | * @param emsg error message |
332 | */ | 342 | */ |
333 | static void | 343 | static void |
334 | peergroup_ready (void *cls, const char *emsg) | 344 | peergroup_ready (void *cls, const char *emsg) |
335 | { | 345 | { |
346 | struct GNUNET_TESTING_Daemon *d; | ||
336 | char *buf; | 347 | char *buf; |
337 | int buf_len; | 348 | int buf_len; |
349 | unsigned int i; | ||
338 | 350 | ||
339 | if (emsg != NULL) | 351 | if (emsg != NULL) |
340 | { | 352 | { |
@@ -372,6 +384,14 @@ peergroup_ready (void *cls, const char *emsg) | |||
372 | o = GNUNET_TESTING_daemon_get (pg, 0); | 384 | o = GNUNET_TESTING_daemon_get (pg, 0); |
373 | d_far = GNUNET_TESTING_daemon_get (pg, 4); | 385 | d_far = GNUNET_TESTING_daemon_get (pg, 4); |
374 | 386 | ||
387 | for (i = 0; i < num_peers; i++) | ||
388 | { | ||
389 | d = GNUNET_TESTING_daemon_get (pg, i); | ||
390 | hs[i] = GNUNET_DHT_connect (d->cfg, 32); | ||
391 | mhs[i] = GNUNET_DHT_monitor_start(hs[i], GNUNET_BLOCK_TYPE_ANY, NULL, | ||
392 | &monitor_dht_cb, (void *)(long)i); | ||
393 | } | ||
394 | |||
375 | if ((NULL == o) || (NULL == d_far)) | 395 | if ((NULL == o) || (NULL == d_far)) |
376 | { | 396 | { |
377 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 397 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |