From: Bart Polot Date: Mon, 20 Feb 2012 12:28:18 +0000 (+0000) Subject: - Fixed test_monitor testcase crsh X-Git-Tag: initial-import-from-subversion-38251~14799 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f4897d2f8268214a14572bd05c987d1350c302e8;p=oweals%2Fgnunet.git - Fixed test_monitor testcase crsh --- 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; const char *id_origin = "FC74"; const char *id_far = "2UVH"; -unsigned int i_origin; -unsigned int i_far; - struct GNUNET_TESTING_Daemon *d_far; struct GNUNET_TESTING_Daemon *o; @@ -249,7 +246,7 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_h2s_full (&d_far->id.hashPubKey)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: from %s\n", GNUNET_h2s_full (&o->id.hashPubKey)); - get_h_far = GNUNET_DHT_get_start (hs[i_origin], GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ + get_h_far = GNUNET_DHT_get_start (hs[0], GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ GNUNET_BLOCK_TYPE_TEST, /* type */ &d_far->id.hashPubKey, /*key to search */ 4U, /* replication level */ @@ -262,11 +259,23 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } +/** + * Periodic function used to put the ID of the far peer in the DHT. + * + * @param cls Closure (not used). + * @param tc Task context. + */ static void put_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_TESTING_Daemon *d; + if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) + { + put_task = GNUNET_SCHEDULER_NO_TASK; + return; + } + d = GNUNET_TESTING_daemon_get (pg, 4); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: putting into DHT: %s\n", GNUNET_h2s_full (&d->id.hashPubKey)); @@ -327,14 +336,17 @@ monitor_dht_cb (void *cls, /** * peergroup_ready: start test when all peers are connected + * * @param cls closure * @param emsg error message */ static void peergroup_ready (void *cls, const char *emsg) { + struct GNUNET_TESTING_Daemon *d; char *buf; int buf_len; + unsigned int i; if (emsg != NULL) { @@ -372,6 +384,14 @@ peergroup_ready (void *cls, const char *emsg) o = GNUNET_TESTING_daemon_get (pg, 0); d_far = GNUNET_TESTING_daemon_get (pg, 4); + for (i = 0; i < num_peers; i++) + { + d = GNUNET_TESTING_daemon_get (pg, i); + hs[i] = GNUNET_DHT_connect (d->cfg, 32); + mhs[i] = GNUNET_DHT_monitor_start(hs[i], GNUNET_BLOCK_TYPE_ANY, NULL, + &monitor_dht_cb, (void *)(long)i); + } + if ((NULL == o) || (NULL == d_far)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR,