From b398b36f59f3f0057c2c8fc42a475216bae152da Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 14 Jul 2009 22:38:23 +0000 Subject: terminate with error if message fails to come back instead of hanging --- src/core/core.h | 4 ++-- src/core/test_core_api.c | 27 ++++++++++++++++++++++++++- src/core/test_core_api_peer1.conf | 4 ++-- src/core/test_core_api_peer2.conf | 4 ++-- 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 @@ /** * General core debugging. */ -#define DEBUG_CORE GNUNET_NO +#define DEBUG_CORE GNUNET_YES /** * Debugging interaction core-clients. */ -#define DEBUG_CORE_CLIENT GNUNET_NO +#define DEBUG_CORE_CLIENT GNUNET_YES /** * 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 @@ #include "gnunet_scheduler_lib.h" #include "gnunet_transport_service.h" -#define VERBOSE GNUNET_NO +#define VERBOSE GNUNET_YES #define START_ARM GNUNET_YES @@ -88,6 +88,20 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } +static void +terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + GNUNET_break (0); + GNUNET_CORE_disconnect (p1.ch); + GNUNET_CORE_disconnect (p2.ch); + GNUNET_TRANSPORT_disconnect (p1.th); + GNUNET_TRANSPORT_disconnect (p2.th); + GNUNET_ARM_stop_service ("core", p1.cfg, sched, TIMEOUT, NULL, NULL); + GNUNET_ARM_stop_service ("core", p2.cfg, sched, TIMEOUT, NULL, NULL); + ok = 42; +} + + static void connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) @@ -143,6 +157,9 @@ outbound_notify (void *cls, } +static GNUNET_SCHEDULER_TaskIdentifier err_task; + + static int process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, @@ -152,6 +169,7 @@ process_mtype (void *cls, "Receiving message from `%4s'.\n", GNUNET_i2s (peer)); GNUNET_assert (ok == 5); OKPP; + GNUNET_SCHEDULER_cancel (sched, err_task); GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, @@ -180,6 +198,13 @@ transmit_ready (void *cls, size_t size, void *buf) m = (struct GNUNET_MessageHeader *) buf; m->type = htons (MTYPE); m->size = htons (sizeof (struct GNUNET_MessageHeader)); + err_task = + GNUNET_SCHEDULER_add_delayed (sched, + GNUNET_NO, + GNUNET_SCHEDULER_PRIORITY_KEEP, + GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_TIME_UNIT_MINUTES, &terminate_task_error, NULL); + return sizeof (struct GNUNET_MessageHeader); } 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 #PREFIX = xterm -T transport1 -e #PREFIX = xterm -T transport1 -e gdb -x cmd --args #PREFIX = xterm -T transport1 -e valgrind --tool=memcheck -#DEBUG = YES +DEBUG = YES [arm] PORT = 12466 @@ -36,7 +36,7 @@ PORT = 12470 #OPTIONS = -l log-core-1 #PREFIX = xterm -T core1 -e gdb -x cmd --args #PREFIX = xterm -T core1 -e -#DEBUG = YES +DEBUG = YES [testing] WEAKRANDOM = 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 PLUGINS = tcp #PREFIX = xterm -T transport2 -e #PREFIX = xterm -T transport2 -e valgrind --tool=memcheck -#DEBUG = YES +DEBUG = YES [arm] PORT = 22466 @@ -33,7 +33,7 @@ PORT = 22469 PORT = 22470 #PREFIX = xterm -T core2 -e #PREFIX = xterm -T core2 -e valgrind --tool=memcheck -#DEBUG = YES +DEBUG = YES [testing] WEAKRANDOM = YES -- cgit v1.2.3