various fixes
authorChristian Grothoff <christian@grothoff.org>
Sat, 31 Oct 2009 21:19:37 +0000 (21:19 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 31 Oct 2009 21:19:37 +0000 (21:19 +0000)
src/testing/Makefile.am
src/testing/test_testing_connect.c
src/testing/test_testing_connect_peer1.conf
src/testing/test_testing_connect_peer2.conf
src/testing/test_testing_data.conf
src/testing/testing.c

index 58e0f9e474801b3cb7af830071f2b41ca15fca09..e62795a92f9c9f0e189f8d469430d6ff689cea66 100644 (file)
@@ -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
index 4e048851b01f924b25e292f4230c54757078c91d..b6a2d859a7e03cd80c6224d976386c9e965361b6 100644 (file)
@@ -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);
index fd1baecb7727dad804ffd7348da64ab074854ce6..020504728415af1d854168a83748e1e0cc54bfe7 100644 (file)
@@ -22,7 +22,7 @@ DEFAULTSERVICES = peerinfo transport core
 PORT = 12567
 HOSTNAME = localhost
 
-[tcp]
+[transport-tcp]
 PORT = 12568
 
 [peerinfo]
index 44ba43a9d31b020c6e75967e4f6d78d847f3983a..196e96a845e223d268fd80ccb858e2bfada9130b 100644 (file)
@@ -22,7 +22,7 @@ HOSTNAME = localhost
 PORT = 22567
 HOSTNAME = localhost
 
-[tcp]
+[transport-tcp]
 PORT = 22568
 
 [peerinfo]
index f314028d4838fe3581554300b3d56cb07ac7cdc4..8af5d1a14916b0c2770704c0d750c9792c4b89cd 100644 (file)
@@ -18,7 +18,7 @@ DEFAULTSERVICES = peerinfo transport core
 [statistics]
 PORT = 2567
 
-[tcp]
+[transport-tcp]
 PORT = 2568
 
 [peerinfo]
index 0119e580f08e5b52a2dc1552fe3ee6388ad8a711..b4d305e9e6c20b4328c2cd77ba73e64e916f0b7e 100644 (file)
@@ -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,
+                                    &notify_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);