aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-19 09:33:57 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-19 09:33:57 +0000
commit891930bd279a11269d8e7443429b7ef604f8691f (patch)
tree9d05719106c362ab390b12df658f54509be9c902 /src/dht
parentc0023ffa9d33f7e0acaa4ab25da1bdc91e5b7d0a (diff)
downloadgnunet-891930bd279a11269d8e7443429b7ef604f8691f.tar.gz
gnunet-891930bd279a11269d8e7443429b7ef604f8691f.zip
-fixing #2397
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/test_dht_monitor.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c
index 4e742a9bd..3d5d8786c 100644
--- a/src/dht/test_dht_monitor.c
+++ b/src/dht/test_dht_monitor.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors) 3 (C) 2011, 2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -107,25 +107,30 @@ static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle;
107 107
108static char *topology_file; 108static char *topology_file;
109 109
110struct GNUNET_TESTING_Daemon *d1; 110static struct GNUNET_TESTING_Daemon *d1;
111 111
112struct GNUNET_TESTING_Daemon *d2; 112static struct GNUNET_TESTING_Daemon *d2;
113 113
114struct GNUNET_DHT_Handle **hs; 114static struct GNUNET_DHT_Handle **hs;
115 115
116struct GNUNET_DHT_MonitorHandle **mhs; 116static struct GNUNET_DHT_MonitorHandle **mhs;
117 117
118struct GNUNET_DHT_GetHandle *get_h_far; 118static struct GNUNET_DHT_GetHandle *get_h_far;
119 119
120const char *id_origin = "FC74"; 120static const char *id_origin = "FC74";
121const char *id_far = "2UVH";
122 121
123struct GNUNET_TESTING_Daemon *d_far; 122static const char *id_far = "2UVH";
124struct GNUNET_TESTING_Daemon *o;
125 123
126unsigned int monitor_counter; 124static struct GNUNET_TESTING_Daemon *d_far;
125
126static struct GNUNET_TESTING_Daemon *o;
127
128static unsigned int monitor_counter;
129
130static unsigned int monitor_expect = UINT_MAX;
131
132static int in_test;
127 133
128int in_test;
129 134
130/** 135/**
131 * Check whether peers successfully shut down. 136 * Check whether peers successfully shut down.
@@ -217,17 +222,15 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: %s\n", 222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: %s\n",
218 GNUNET_i2s (&put_path[i])); 223 GNUNET_i2s (&put_path[i]));
219 } 224 }
220 if (monitor_counter >= get_path_length + put_path_length) 225 monitor_expect = get_path_length + put_path_length;
226 if (monitor_counter >= monitor_expect)
221 { 227 {
222 ok = 0; 228 ok = 0;
223 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "expected at least %u hops, got %u\n", 229 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "expected at least %u hops, got %u\n",
224 get_path_length + put_path_length, monitor_counter); 230 get_path_length + put_path_length, monitor_counter);
231 GNUNET_SCHEDULER_cancel (disconnect_task);
232 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
225 } 233 }
226 else
227 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "expected at least %u hops, got %u\n",
228 get_path_length + put_path_length, monitor_counter);
229 GNUNET_SCHEDULER_cancel (disconnect_task);
230 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
231} 234}
232 235
233 236
@@ -329,7 +332,17 @@ monitor_get_cb (void *cls,
329 i, s_key); 332 i, s_key);
330 333
331 if (strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES) 334 if (strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES)
335 {
332 monitor_counter++; 336 monitor_counter++;
337 if (monitor_counter >= monitor_expect)
338 {
339 ok = 0;
340 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "expected at least %u hops, got %u\n",
341 monitor_expect, monitor_counter);
342 GNUNET_SCHEDULER_cancel (disconnect_task);
343 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
344 }
345 }
333} 346}
334 347
335 348
@@ -531,7 +544,6 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 544 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
532 "test: Problem with new connection (%s)\n", emsg); 545 "test: Problem with new connection (%s)\n", emsg);
533 } 546 }
534
535} 547}
536 548
537 549
@@ -625,7 +637,6 @@ run (void *cls, char *const *args, const char *cfgfile,
625} 637}
626 638
627 639
628
629/** 640/**
630 * test_dht_monitor command line options 641 * test_dht_monitor command line options
631 */ 642 */