gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r23649 - gnunet/src/gns


From: gnunet
Subject: [GNUnet-SVN] r23649 - gnunet/src/gns
Date: Wed, 5 Sep 2012 10:28:30 +0200

Author: wachs
Date: 2012-09-05 10:28:30 +0200 (Wed, 05 Sep 2012)
New Revision: 23649

Modified:
   gnunet/src/gns/test_gns_dht_default.conf
   gnunet/src/gns/test_gns_dht_three_peers.c
Log:
do not autostart: I have to copy zonefile



Modified: gnunet/src/gns/test_gns_dht_default.conf
===================================================================
--- gnunet/src/gns/test_gns_dht_default.conf    2012-09-05 08:28:04 UTC (rev 
23648)
+++ gnunet/src/gns/test_gns_dht_default.conf    2012-09-05 08:28:30 UTC (rev 
23649)
@@ -25,7 +25,7 @@
 
 [arm]
 PORT = 22566
-DEFAULTSERVICES = core namestore dht gns
+DEFAULTSERVICES = core dht gns
 UNIXPATH = /tmp/gnunet-default-service-arm.sock
 
 [statistics]

Modified: gnunet/src/gns/test_gns_dht_three_peers.c
===================================================================
--- gnunet/src/gns/test_gns_dht_three_peers.c   2012-09-05 08:28:04 UTC (rev 
23648)
+++ gnunet/src/gns/test_gns_dht_three_peers.c   2012-09-05 08:28:30 UTC (rev 
23649)
@@ -66,14 +66,14 @@
 
 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
 
-const struct GNUNET_CONFIGURATION_Handle *alice_cfg;
-
 struct GNUNET_TESTBED_Peer **cpeers;
 
 struct GNUNET_GNS_Handle *gh;
 
 struct GNUNET_TESTBED_Operation *get_cfg_ops[3];
 struct GNUNET_TESTBED_Operation *connect_ops[3];
+struct GNUNET_CONFIGURATION_Handle *cfg_handles[3];
+struct GNUNET_NAMESTORE_Handle *nh[3];
 
 /**
  * Check if the get_handle is being used, if so stop the request.  Either
@@ -94,6 +94,11 @@
 
   for (c = 0; c < 3; c++)
   {
+    if (NULL != nh[c])
+    {
+      GNUNET_NAMESTORE_disconnect(nh[c]);
+      nh[c] = NULL;
+    }
     if (NULL != get_cfg_ops[c])
     {
         GNUNET_TESTBED_operation_cancel(get_cfg_ops[c]);
@@ -104,6 +109,11 @@
         GNUNET_TESTBED_operation_cancel(connect_ops[c]);
         connect_ops[c] = NULL;
     }
+    if (NULL != cfg_handles[c])
+    {
+      GNUNET_CONFIGURATION_destroy (cfg_handles[c]);
+      cfg_handles[c] = NULL;
+    }
   }
 
   if (NULL != gh)
@@ -121,12 +131,27 @@
 static void
 end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  int c;
   if (GNUNET_SCHEDULER_NO_TASK != die_task)
   {
       GNUNET_SCHEDULER_cancel (die_task);
       die_task = GNUNET_SCHEDULER_NO_TASK;
   }
 
+  for (c = 0; c < 3; c++)
+  {
+    if (NULL != nh[c])
+    {
+      GNUNET_NAMESTORE_disconnect(nh[c]);
+      nh[c] = NULL;
+    }
+    if (NULL != cfg_handles[c])
+    {
+      GNUNET_CONFIGURATION_destroy (cfg_handles[c]);
+      cfg_handles[c] = NULL;
+    }
+  }
+
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test successful \n");
   GNUNET_break (0);
   GNUNET_SCHEDULER_shutdown ();
@@ -143,7 +168,14 @@
 static void
 disconnect_ns (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+
   GNUNET_NAMESTORE_disconnect (cls);
+  if (cls == nh[0])
+    nh[0] = NULL;
+  if (cls == nh[1])
+    nh[1] = NULL;
+  if (cls == nh[2])
+    nh[2] = NULL;
 }
 
 
@@ -197,8 +229,6 @@
   {
     fprintf (stderr, "\n");
     wait_task = GNUNET_SCHEDULER_NO_TASK;
-    gh = GNUNET_GNS_connect(alice_cfg);
-
     GNUNET_GNS_lookup(gh, TEST_DOMAIN, GNUNET_GNS_RECORD_A,
                       GNUNET_NO,
                       NULL,
@@ -248,7 +278,6 @@
 static int
 setup_dave (const struct GNUNET_CONFIGURATION_Handle * cfg)
 {
-  struct GNUNET_NAMESTORE_Handle *ns;
   char* keyfile;
   char* source;
   struct GNUNET_CRYPTO_RsaPrivateKey *key;
@@ -257,8 +286,9 @@
   struct GNUNET_NAMESTORE_RecordData rd;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up dave\n");
-  GNUNET_assert (NULL != cfg);
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+  cfg_handles[0] = GNUNET_CONFIGURATION_dup (cfg);
+  GNUNET_assert (NULL != cfg_handles[0]);
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg_handles[0], 
"gns",
                                                             "ZONEKEY",
                                                             &keyfile))
   {
@@ -267,6 +297,8 @@
   }
 
   GNUNET_asprintf (&source, "zonefiles%s%s", DIR_SEPARATOR_STR, 
"test_zonekey");
+  GNUNET_break (GNUNET_OK == GNUNET_DISK_file_test (source));
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Copy `%s' to `%s'\n", source, keyfile);
   GNUNET_break (GNUNET_OK == GNUNET_DISK_file_copy (source, keyfile));
   GNUNET_free (source);
 
@@ -279,8 +311,8 @@
     return GNUNET_SYSERR;
   }
 
-  ns = GNUNET_NAMESTORE_connect (cfg);
-  if (NULL == ns)
+  nh[0] = GNUNET_NAMESTORE_connect (cfg_handles[0]);
+  if (NULL == nh[0])
   {
     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n");
     GNUNET_CRYPTO_rsa_key_free (key);
@@ -298,25 +330,25 @@
   rd.record_type = GNUNET_GNS_RECORD_A;
   rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
 
-  GNUNET_NAMESTORE_record_create (ns, key, "www", &rd, NULL, NULL);
+  GNUNET_NAMESTORE_record_create (nh[0], key, "www", &rd, NULL, NULL);
 
   rd.data_size = strlen(TEST_DAVE_PSEU);
   rd.data = TEST_DAVE_PSEU;
   rd.record_type = GNUNET_GNS_RECORD_PSEU;
 
-  GNUNET_NAMESTORE_record_create (ns, key, "+", &rd, &cont_ns, ns);
+  GNUNET_NAMESTORE_record_create (nh[0], key, "+", &rd, &cont_ns, nh[0]);
 
   GNUNET_CRYPTO_rsa_key_free(key);
   GNUNET_free(keyfile);
   GNUNET_free(web);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up dave done\n");
+  //GNUNET_TESTBED_operation_done (get_cfg_ops[0]);
   return GNUNET_OK;
 }
 
 static int
 setup_bob (const struct GNUNET_CONFIGURATION_Handle * cfg)
 {
-  struct GNUNET_NAMESTORE_Handle *ns;
   char* keyfile;
   char* source;
   struct GNUNET_CRYPTO_RsaPrivateKey *key;
@@ -325,7 +357,8 @@
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up bob\n");
   GNUNET_assert (NULL != cfg);
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+  cfg_handles[1] = GNUNET_CONFIGURATION_dup (cfg);
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg_handles[1], 
"gns",
                                                             "ZONEKEY",
                                                             &keyfile))
   {
@@ -334,6 +367,8 @@
   }
 
   GNUNET_asprintf (&source, "zonefiles%s%s", DIR_SEPARATOR_STR, 
"OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey");
+  GNUNET_break (GNUNET_OK == GNUNET_DISK_file_test (source));
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Copy `%s' to `%s'\n", source, keyfile);
   GNUNET_break (GNUNET_OK == GNUNET_DISK_file_copy (source, keyfile));
   GNUNET_free (source);
 
@@ -346,8 +381,8 @@
     return GNUNET_SYSERR;
   }
 
-  ns = GNUNET_NAMESTORE_connect (cfg);
-  if (NULL == ns)
+  nh[1] = GNUNET_NAMESTORE_connect (cfg_handles[1]);
+  if (NULL == nh[1])
   {
     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n");
     GNUNET_CRYPTO_rsa_key_free (key);
@@ -363,18 +398,18 @@
   rd.record_type = GNUNET_GNS_RECORD_PKEY;
   rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
 
-  GNUNET_NAMESTORE_record_create (ns, key, "buddy", &rd, &cont_ns, ns);
+  GNUNET_NAMESTORE_record_create (nh[1], key, "buddy", &rd, &cont_ns, nh[1]);
 
   GNUNET_CRYPTO_rsa_key_free(key);
   GNUNET_free(keyfile);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up bob done\n");
+  //GNUNET_TESTBED_operation_done (get_cfg_ops[1]);
   return GNUNET_OK;
 }
 
 static int
 setup_alice (const struct GNUNET_CONFIGURATION_Handle * cfg)
 {
-  struct GNUNET_NAMESTORE_Handle *ns;
   char* keyfile;
   char* source;
   struct GNUNET_CRYPTO_RsaPrivateKey *key;
@@ -382,8 +417,8 @@
 
 
   GNUNET_assert (NULL != cfg);
-  alice_cfg = cfg;
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
+  cfg_handles[2] = GNUNET_CONFIGURATION_dup (cfg);
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg_handles[2], 
"gns",
                                                             "ZONEKEY",
                                                             &keyfile))
   {
@@ -392,6 +427,8 @@
   }
 
   GNUNET_asprintf (&source, "zonefiles%s%s", DIR_SEPARATOR_STR, 
"188JSUMKEF25GVU8TTV0PBNNN8JVCPUEDFV1UHJJU884JD25V0T0.zkey");
+  GNUNET_break (GNUNET_OK == GNUNET_DISK_file_test (source));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Copy `%s' to `%s'\n", source, keyfile);
   GNUNET_break (GNUNET_OK == GNUNET_DISK_file_copy (source, keyfile));
   GNUNET_free (source);
 
@@ -404,8 +441,8 @@
     return GNUNET_SYSERR;
   }
 
-  ns = GNUNET_NAMESTORE_connect (cfg);
-  if (NULL == ns)
+  nh[2] = GNUNET_NAMESTORE_connect (cfg_handles[2]);
+  if (NULL == nh[2])
   {
     GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n");
     GNUNET_CRYPTO_rsa_key_free (key);
@@ -418,11 +455,21 @@
   rd.record_type = GNUNET_GNS_RECORD_PKEY;
   rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
 
-  GNUNET_NAMESTORE_record_create (ns, key, "bob", &rd, &cont_ns, ns);
+  GNUNET_NAMESTORE_record_create (nh[2], key, "bob", &rd, &cont_ns, nh[2]);
 
+  gh = GNUNET_GNS_connect(cfg_handles[2]);
+  if (NULL == gh)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to connect to namestore\n");
+    GNUNET_CRYPTO_rsa_key_free (key);
+    GNUNET_free (keyfile);
+    return GNUNET_SYSERR;
+  }
+
   GNUNET_CRYPTO_rsa_key_free (key);
   GNUNET_free (keyfile);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up alice  done\n");
+  //GNUNET_TESTBED_operation_done (get_cfg_ops[2]);
   return GNUNET_OK;
 }
 
@@ -512,8 +559,11 @@
       if (connections == 3)
       {
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers connected\n");
+          GNUNET_TESTBED_operation_done (connect_ops[0]);
           connect_ops[0] = NULL;
+          GNUNET_TESTBED_operation_done (connect_ops[1]);
           connect_ops[1] = NULL;
+          GNUNET_TESTBED_operation_done (connect_ops[2]);
           connect_ops[2] = NULL;
           all_connected ();
       }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]