aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-14 22:38:23 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-14 22:38:23 +0000
commitb398b36f59f3f0057c2c8fc42a475216bae152da (patch)
treecaa2fe0eaff99d5de52e4a9bb1e16ef26dd3e025
parentdecb8865901b54d79846bee36c138cff8c730af9 (diff)
downloadgnunet-b398b36f59f3f0057c2c8fc42a475216bae152da.tar.gz
gnunet-b398b36f59f3f0057c2c8fc42a475216bae152da.zip
terminate with error if message fails to come back instead of hanging
-rw-r--r--src/core/core.h4
-rw-r--r--src/core/test_core_api.c27
-rw-r--r--src/core/test_core_api_peer1.conf4
-rw-r--r--src/core/test_core_api_peer2.conf4
4 files changed, 32 insertions, 7 deletions
diff --git a/src/core/core.h b/src/core/core.h
index 647d18698..19a090ea0 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -29,12 +29,12 @@
29/** 29/**
30 * General core debugging. 30 * General core debugging.
31 */ 31 */
32#define DEBUG_CORE GNUNET_NO 32#define DEBUG_CORE GNUNET_YES
33 33
34/** 34/**
35 * Debugging interaction core-clients. 35 * Debugging interaction core-clients.
36 */ 36 */
37#define DEBUG_CORE_CLIENT GNUNET_NO 37#define DEBUG_CORE_CLIENT GNUNET_YES
38 38
39/** 39/**
40 * Definition of bits in the InitMessage's options field that specify 40 * Definition of bits in the InitMessage's options field that specify
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index 13ccd7a5f..ff565ad02 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -34,7 +34,7 @@
34#include "gnunet_scheduler_lib.h" 34#include "gnunet_scheduler_lib.h"
35#include "gnunet_transport_service.h" 35#include "gnunet_transport_service.h"
36 36
37#define VERBOSE GNUNET_NO 37#define VERBOSE GNUNET_YES
38 38
39#define START_ARM GNUNET_YES 39#define START_ARM GNUNET_YES
40 40
@@ -89,6 +89,20 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
89 89
90 90
91static void 91static void
92terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
93{
94 GNUNET_break (0);
95 GNUNET_CORE_disconnect (p1.ch);
96 GNUNET_CORE_disconnect (p2.ch);
97 GNUNET_TRANSPORT_disconnect (p1.th);
98 GNUNET_TRANSPORT_disconnect (p2.th);
99 GNUNET_ARM_stop_service ("core", p1.cfg, sched, TIMEOUT, NULL, NULL);
100 GNUNET_ARM_stop_service ("core", p2.cfg, sched, TIMEOUT, NULL, NULL);
101 ok = 42;
102}
103
104
105static void
92connect_notify (void *cls, 106connect_notify (void *cls,
93 const struct GNUNET_PeerIdentity *peer) 107 const struct GNUNET_PeerIdentity *peer)
94{ 108{
@@ -143,6 +157,9 @@ outbound_notify (void *cls,
143} 157}
144 158
145 159
160static GNUNET_SCHEDULER_TaskIdentifier err_task;
161
162
146static int 163static int
147process_mtype (void *cls, 164process_mtype (void *cls,
148 const struct GNUNET_PeerIdentity *peer, 165 const struct GNUNET_PeerIdentity *peer,
@@ -152,6 +169,7 @@ process_mtype (void *cls,
152 "Receiving message from `%4s'.\n", GNUNET_i2s (peer)); 169 "Receiving message from `%4s'.\n", GNUNET_i2s (peer));
153 GNUNET_assert (ok == 5); 170 GNUNET_assert (ok == 5);
154 OKPP; 171 OKPP;
172 GNUNET_SCHEDULER_cancel (sched, err_task);
155 GNUNET_SCHEDULER_add_delayed (sched, 173 GNUNET_SCHEDULER_add_delayed (sched,
156 GNUNET_NO, 174 GNUNET_NO,
157 GNUNET_SCHEDULER_PRIORITY_KEEP, 175 GNUNET_SCHEDULER_PRIORITY_KEEP,
@@ -180,6 +198,13 @@ transmit_ready (void *cls, size_t size, void *buf)
180 m = (struct GNUNET_MessageHeader *) buf; 198 m = (struct GNUNET_MessageHeader *) buf;
181 m->type = htons (MTYPE); 199 m->type = htons (MTYPE);
182 m->size = htons (sizeof (struct GNUNET_MessageHeader)); 200 m->size = htons (sizeof (struct GNUNET_MessageHeader));
201 err_task =
202 GNUNET_SCHEDULER_add_delayed (sched,
203 GNUNET_NO,
204 GNUNET_SCHEDULER_PRIORITY_KEEP,
205 GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
206 GNUNET_TIME_UNIT_MINUTES, &terminate_task_error, NULL);
207
183 return sizeof (struct GNUNET_MessageHeader); 208 return sizeof (struct GNUNET_MessageHeader);
184} 209}
185 210
diff --git a/src/core/test_core_api_peer1.conf b/src/core/test_core_api_peer1.conf
index 0cea16038..749bbbeab 100644
--- a/src/core/test_core_api_peer1.conf
+++ b/src/core/test_core_api_peer1.conf
@@ -12,7 +12,7 @@ PLUGINS = tcp
12#PREFIX = xterm -T transport1 -e 12#PREFIX = xterm -T transport1 -e
13#PREFIX = xterm -T transport1 -e gdb -x cmd --args 13#PREFIX = xterm -T transport1 -e gdb -x cmd --args
14#PREFIX = xterm -T transport1 -e valgrind --tool=memcheck 14#PREFIX = xterm -T transport1 -e valgrind --tool=memcheck
15#DEBUG = YES 15DEBUG = YES
16 16
17[arm] 17[arm]
18PORT = 12466 18PORT = 12466
@@ -36,7 +36,7 @@ PORT = 12470
36#OPTIONS = -l log-core-1 36#OPTIONS = -l log-core-1
37#PREFIX = xterm -T core1 -e gdb -x cmd --args 37#PREFIX = xterm -T core1 -e gdb -x cmd --args
38#PREFIX = xterm -T core1 -e 38#PREFIX = xterm -T core1 -e
39#DEBUG = YES 39DEBUG = YES
40 40
41[testing] 41[testing]
42WEAKRANDOM = YES 42WEAKRANDOM = YES
diff --git a/src/core/test_core_api_peer2.conf b/src/core/test_core_api_peer2.conf
index 6e311e1e1..e61537fab 100644
--- a/src/core/test_core_api_peer2.conf
+++ b/src/core/test_core_api_peer2.conf
@@ -11,7 +11,7 @@ PORT = 22465
11PLUGINS = tcp 11PLUGINS = tcp
12#PREFIX = xterm -T transport2 -e 12#PREFIX = xterm -T transport2 -e
13#PREFIX = xterm -T transport2 -e valgrind --tool=memcheck 13#PREFIX = xterm -T transport2 -e valgrind --tool=memcheck
14#DEBUG = YES 14DEBUG = YES
15 15
16[arm] 16[arm]
17PORT = 22466 17PORT = 22466
@@ -33,7 +33,7 @@ PORT = 22469
33PORT = 22470 33PORT = 22470
34#PREFIX = xterm -T core2 -e 34#PREFIX = xterm -T core2 -e
35#PREFIX = xterm -T core2 -e valgrind --tool=memcheck 35#PREFIX = xterm -T core2 -e valgrind --tool=memcheck
36#DEBUG = YES 36DEBUG = YES
37 37
38[testing] 38[testing]
39WEAKRANDOM = YES 39WEAKRANDOM = YES