From: Christian Grothoff Date: Sat, 31 Oct 2009 21:19:37 +0000 (+0000) Subject: various fixes X-Git-Tag: initial-import-from-subversion-38251~23190 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bfc865c4521d83f0bf4043017350ec4c8f65a34f;p=oweals%2Fgnunet.git various fixes --- diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 58e0f9e47..e62795a92 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am @@ -24,8 +24,7 @@ check_PROGRAMS = \ test_testing \ test_testing_connect -TESTS = test_testing -# $(check_PROGRAMS) +TESTS = $(check_PROGRAMS) test_testing_SOURCES = \ test_testing.c diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c index 4e048851b..b6a2d859a 100644 --- a/src/testing/test_testing_connect.c +++ b/src/testing/test_testing_connect.c @@ -57,7 +57,7 @@ static void end2_cb(void *cls, } static void end1_cb(void *cls, - const char *emsg) + const char *emsg) { GNUNET_assert (emsg == NULL); GNUNET_TESTING_daemon_stop (d2, &end2_cb, NULL); diff --git a/src/testing/test_testing_connect_peer1.conf b/src/testing/test_testing_connect_peer1.conf index fd1baecb7..020504728 100644 --- a/src/testing/test_testing_connect_peer1.conf +++ b/src/testing/test_testing_connect_peer1.conf @@ -22,7 +22,7 @@ DEFAULTSERVICES = peerinfo transport core PORT = 12567 HOSTNAME = localhost -[tcp] +[transport-tcp] PORT = 12568 [peerinfo] diff --git a/src/testing/test_testing_connect_peer2.conf b/src/testing/test_testing_connect_peer2.conf index 44ba43a9d..196e96a84 100644 --- a/src/testing/test_testing_connect_peer2.conf +++ b/src/testing/test_testing_connect_peer2.conf @@ -22,7 +22,7 @@ HOSTNAME = localhost PORT = 22567 HOSTNAME = localhost -[tcp] +[transport-tcp] PORT = 22568 [peerinfo] diff --git a/src/testing/test_testing_data.conf b/src/testing/test_testing_data.conf index f314028d4..8af5d1a14 100644 --- a/src/testing/test_testing_data.conf +++ b/src/testing/test_testing_data.conf @@ -18,7 +18,7 @@ DEFAULTSERVICES = peerinfo transport core [statistics] PORT = 2567 -[tcp] +[transport-tcp] PORT = 2568 [peerinfo] diff --git a/src/testing/testing.c b/src/testing/testing.c index 0119e580f..b4d305e9e 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -40,7 +40,7 @@ #include "gnunet_testing_lib.h" #include "gnunet_transport_service.h" -#define DEBUG_TESTING GNUNET_NO +#define DEBUG_TESTING GNUNET_YES /** * How long do we wait after starting gnunet-service-arm @@ -790,6 +790,7 @@ void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, return; } GNUNET_CONFIGURATION_destroy (d->cfg); + GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (d->cfgfile)); GNUNET_free (d->cfgfile); GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->username); @@ -914,12 +915,6 @@ struct ConnectContext */ struct GNUNET_TRANSPORT_Handle *d2th; - /** - * When should this operation be complete (or we must trigger - * a timeout). - */ - struct GNUNET_TIME_Absolute timeout; - /** * Function to call once we are done (or have timed out). */ @@ -929,9 +924,46 @@ struct ConnectContext * Closure for "nb". */ void *cb_cls; + + /** + * Transmit handle for our request for transmission + * (as given to d2 asking to talk to d1). + */ + struct GNUNET_CORE_TransmitHandle *ntr; + + /** + * When should this operation be complete (or we must trigger + * a timeout). + */ + struct GNUNET_TIME_Absolute timeout; + }; +/** + * Notify callback about success or failure of the attempt + * to connect the two peers + * + * @param cls our "struct ConnectContext" (freed) + * @param tc reason tells us if we succeeded or failed + */ +static void +notify_connect_result (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct ConnectContext *ctx = cls; + + if (ctx->cb != NULL) + { + if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0) + ctx->cb (ctx->cb_cls, _("Peers failed to connect")); + else + ctx->cb (ctx->cb_cls, NULL); + } + GNUNET_free (ctx); +} + + /** * Success, connection is up. Signal client our success. * @@ -945,16 +977,22 @@ transmit_ready (void *cls, size_t size, void *buf) { struct ConnectContext *ctx = cls; +#if DEBUG_TESTING + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Core notified us about readiness to transmit message, connection must be up!\n"); +#endif + ctx->ntr = NULL; GNUNET_TRANSPORT_disconnect (ctx->d1th); + ctx->d1th = NULL; GNUNET_TRANSPORT_disconnect (ctx->d2th); - if (NULL != ctx->cb) - { - if (buf == NULL) - ctx->cb (ctx->cb_cls, _("Peers failed to connect")); - else - ctx->cb (ctx->cb_cls, NULL); - } - GNUNET_free (ctx); + ctx->d2th = NULL; + GNUNET_SCHEDULER_add_continuation (ctx->d1->sched, + GNUNET_NO, + ¬ify_connect_result, + ctx, + (buf == NULL) ? + GNUNET_SCHEDULER_REASON_TIMEOUT : + GNUNET_SCHEDULER_REASON_PREREQ_DONE); return 0; } @@ -987,17 +1025,20 @@ process_hello (void *cls, GNUNET_free (ctx); return; } +#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' from transport service of `%4s'\n", "HELLO", GNUNET_i2s (peer)); +#endif GNUNET_assert (message != NULL); GNUNET_TRANSPORT_offer_hello (ctx->d2th, message); - GNUNET_CORE_notify_transmit_ready (ctx->d2->server, - 0, - GNUNET_TIME_absolute_get_remaining (ctx->timeout), - &ctx->d1->id, - sizeof (struct GNUNET_MessageHeader), - &transmit_ready, ctx); + ctx->ntr + = GNUNET_CORE_notify_transmit_ready (ctx->d2->server, + 0, + GNUNET_TIME_absolute_get_remaining (ctx->timeout), + &ctx->d1->id, + sizeof (struct GNUNET_MessageHeader), + &transmit_ready, ctx); } @@ -1032,7 +1073,10 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); ctx->cb = cb; ctx->cb_cls = cb_cls; - ctx->d1th = GNUNET_TRANSPORT_connect (d1->sched, d1->cfg, d1, NULL, NULL, NULL); + ctx->d1th = GNUNET_TRANSPORT_connect (d1->sched, + d1->cfg, + d1, + NULL, NULL, NULL); if (ctx->d1th == NULL) { GNUNET_free (ctx); @@ -1040,7 +1084,10 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, cb (cb_cls, _("Failed to connect to transport service!\n")); return; } - ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, d2->cfg, d2, NULL, NULL, NULL); + ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, + d2->cfg, + d2, + NULL, NULL, NULL); if (ctx->d2th == NULL) { GNUNET_TRANSPORT_disconnect (ctx->d1th);