aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-02-20 12:28:18 +0000
committerBart Polot <bart@net.in.tum.de>2012-02-20 12:28:18 +0000
commitf4897d2f8268214a14572bd05c987d1350c302e8 (patch)
treeaeef633248a8ae717cccc16683e7ae64244498fd /src/dht
parent0f73a5434770a20429816e8b6adafcffa98a7f46 (diff)
downloadgnunet-f4897d2f8268214a14572bd05c987d1350c302e8.tar.gz
gnunet-f4897d2f8268214a14572bd05c987d1350c302e8.zip
- Fixed test_monitor testcase crsh
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/test_dht_monitor.c28
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;
122const char *id_origin = "FC74"; 122const char *id_origin = "FC74";
123const char *id_far = "2UVH"; 123const char *id_far = "2UVH";
124 124
125unsigned int i_origin;
126unsigned int i_far;
127
128struct GNUNET_TESTING_Daemon *d_far; 125struct GNUNET_TESTING_Daemon *d_far;
129struct GNUNET_TESTING_Daemon *o; 126struct 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 */
265static void 268static void
266put_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 269put_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 */
333static void 343static void
334peergroup_ready (void *cls, const char *emsg) 344peergroup_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,