aboutsummaryrefslogtreecommitdiff
path: root/src/integration-tests
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-04 15:03:59 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-04 15:03:59 +0000
commite4ecd9c418c7272de727e6ab388c1cfe7584001f (patch)
treeafa0a67583aa7a871cba5bd0d1c93308f2c030cd /src/integration-tests
parent6e86ae790d66d9f6f5c93d16d1b2367b8364d554 (diff)
downloadgnunet-e4ecd9c418c7272de727e6ab388c1cfe7584001f.tar.gz
gnunet-e4ecd9c418c7272de727e6ab388c1cfe7584001f.zip
- consistency check
Diffstat (limited to 'src/integration-tests')
-rw-r--r--src/integration-tests/connection_watchdog.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/src/integration-tests/connection_watchdog.c b/src/integration-tests/connection_watchdog.c
index f83cfccda..82ed56ba9 100644
--- a/src/integration-tests/connection_watchdog.c
+++ b/src/integration-tests/connection_watchdog.c
@@ -34,10 +34,14 @@
34#include "gnunet_transport_service.h" 34#include "gnunet_transport_service.h"
35#include "gnunet_statistics_service.h" 35#include "gnunet_statistics_service.h"
36 36
37
38#define CHECK_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
39
37/** 40/**
38 * Final status code. 41 * Final status code.
39 */ 42 */
40static int ret; 43static int ret;
44static int retry;
41 45
42struct GNUNET_TRANSPORT_Handle *th; 46struct GNUNET_TRANSPORT_Handle *th;
43struct GNUNET_CORE_Handle *ch; 47struct GNUNET_CORE_Handle *ch;
@@ -46,6 +50,7 @@ struct GNUNET_PeerIdentity my_peer_id;
46static unsigned int transport_connections; 50static unsigned int transport_connections;
47static unsigned int core_connections; 51static unsigned int core_connections;
48 52
53static GNUNET_SCHEDULER_TaskIdentifier check_task;
49 54
50 55
51static struct GNUNET_CONTAINER_MultiHashMap *peers; 56static struct GNUNET_CONTAINER_MultiHashMap *peers;
@@ -62,6 +67,7 @@ int map_check_it (void *cls,
62 const GNUNET_HashCode * key, 67 const GNUNET_HashCode * key,
63 void *value) 68 void *value)
64{ 69{
70 int *fail = cls;
65 struct PeerContainer *pc = value; 71 struct PeerContainer *pc = value;
66 if (pc->core_connected != pc->transport_connected) 72 if (pc->core_connected != pc->transport_connected)
67 { 73 {
@@ -70,6 +76,7 @@ int map_check_it (void *cls,
70 GNUNET_i2s (&pc->id), 76 GNUNET_i2s (&pc->id),
71 (GNUNET_YES == pc->transport_connected) ? "YES" : "NO", 77 (GNUNET_YES == pc->transport_connected) ? "YES" : "NO",
72 (GNUNET_YES == pc->core_connected) ? "YES" : "NO"); 78 (GNUNET_YES == pc->core_connected) ? "YES" : "NO");
79 (*fail) ++;
73 } 80 }
74 81
75 return GNUNET_OK; 82 return GNUNET_OK;
@@ -86,10 +93,26 @@ int map_cleanup_it (void *cls,
86 return GNUNET_OK; 93 return GNUNET_OK;
87} 94}
88 95
89static void map_check (void) 96static void
97map_cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
90{ 98{
99 GNUNET_CONTAINER_multihashmap_iterate (peers, &map_cleanup_it, NULL);
100 GNUNET_CONTAINER_multihashmap_destroy(peers);
101}
91 102
92 GNUNET_CONTAINER_multihashmap_iterate (peers, &map_check_it, NULL); 103static void
104map_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
105{
106 int fail = 0;
107 check_task = GNUNET_SCHEDULER_NO_TASK;
108 GNUNET_CONTAINER_multihashmap_iterate (peers, &map_check_it, &fail);
109 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
110 "Inconsistent peers after connection consistency check: %u\n", fail);
111
112 if (NULL != cls)
113 {
114 GNUNET_SCHEDULER_add_now (cls, NULL);
115 }
93} 116}
94 117
95static void 118static void
@@ -111,7 +134,6 @@ map_connect (const struct GNUNET_PeerIdentity *peer, void * source)
111 if (GNUNET_NO == pc->transport_connected) 134 if (GNUNET_NO == pc->transport_connected)
112 { 135 {
113 pc->transport_connected = GNUNET_YES; 136 pc->transport_connected = GNUNET_YES;
114 return;
115 } 137 }
116 else 138 else
117 { 139 {
@@ -128,7 +150,6 @@ map_connect (const struct GNUNET_PeerIdentity *peer, void * source)
128 if (GNUNET_NO == pc->core_connected) 150 if (GNUNET_NO == pc->core_connected)
129 { 151 {
130 pc->core_connected = GNUNET_YES; 152 pc->core_connected = GNUNET_YES;
131 return;
132 } 153 }
133 else 154 else
134 { 155 {
@@ -138,9 +159,11 @@ map_connect (const struct GNUNET_PeerIdentity *peer, void * source)
138 GNUNET_i2s (&pc->id), 159 GNUNET_i2s (&pc->id),
139 "TRANSPORT", (pc->transport_connected == GNUNET_YES) ? "yes" : "no"); 160 "TRANSPORT", (pc->transport_connected == GNUNET_YES) ? "yes" : "no");
140 GNUNET_break (0); 161 GNUNET_break (0);
141 return;
142 } 162 }
143 } 163 }
164 if (GNUNET_SCHEDULER_NO_TASK != check_task)
165 GNUNET_SCHEDULER_cancel(check_task);
166 check_task = GNUNET_SCHEDULER_add_delayed(CHECK_DELAY, &map_check, NULL);
144} 167}
145 168
146 169
@@ -209,6 +232,10 @@ map_disconnect (const struct GNUNET_PeerIdentity * peer, void * source)
209 GNUNET_free (pc); 232 GNUNET_free (pc);
210 } 233 }
211 234
235 if (GNUNET_SCHEDULER_NO_TASK != check_task)
236 GNUNET_SCHEDULER_cancel(check_task);
237 check_task = GNUNET_SCHEDULER_add_delayed(CHECK_DELAY, &map_check, NULL);
238
212} 239}
213 240
214 241
@@ -228,10 +255,12 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
228 ch = NULL; 255 ch = NULL;
229 } 256 }
230 257
231 map_check(); 258 if (GNUNET_SCHEDULER_NO_TASK != check_task)
232 259 {
233 GNUNET_CONTAINER_multihashmap_iterate (peers, &map_cleanup_it, NULL); 260 GNUNET_SCHEDULER_cancel(check_task);
234 GNUNET_CONTAINER_multihashmap_destroy(peers); 261 check_task = GNUNET_SCHEDULER_NO_TASK;
262 }
263 check_task = GNUNET_SCHEDULER_add_now (&map_check, &map_cleanup);
235} 264}
236 265
237void 266void
@@ -349,7 +378,6 @@ run (void *cls, char *const *args, const char *cfgfile,
349 GNUNET_assert (ch != NULL); 378 GNUNET_assert (ch != NULL);
350 379
351 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, NULL); 380 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, NULL);
352
353} 381}
354 382
355 383