- read unique peer-ids from testbed
authorSree Harsha Totakura <totakura@in.tum.de>
Thu, 28 Mar 2013 09:09:12 +0000 (09:09 +0000)
committerSree Harsha Totakura <totakura@in.tum.de>
Thu, 28 Mar 2013 09:09:12 +0000 (09:09 +0000)
src/nse/gnunet-nse-profiler.c
src/nse/gnunet-service-nse.c

index 7fe803673682b720874105546d107252ea7dacd2..9ed998c84df637a8fea5988ccee8113df677a3c6 100644 (file)
  *        Generally, the profiler starts a given number of peers,
  *        then churns some off, waits a certain amount of time, then
  *        churns again, and repeats.
- *
- * TODO:
- * - need to check for leaks (especially FD leaks)
- * - need to TEST
+ * @author Christian Grothoff
+ * @author Nathan Evans
+ * @author Sree Harsha Totakura
  */
+
 #include "platform.h"
 #include "gnunet_testbed_service.h"
 #include "gnunet_nse_service.h"
@@ -303,9 +303,16 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_TESTBED_operation_done (get_stats_op);
     get_stats_op = NULL;
   }
-  // FIXME: what about closing other files!?  
   if (NULL != data_file)
+  {
     GNUNET_DISK_file_close (data_file);
+    data_file = NULL;
+  }
+  if (NULL != output_file)
+  {
+    GNUNET_DISK_file_close (output_file);
+    output_file = NULL;
+  }
   if (NULL != testing_cfg)
     GNUNET_CONFIGURATION_destroy (testing_cfg);
   testing_cfg = NULL;
index aa90572fd450245fc6c17395e7987fb5d0ecb6e9..2b7b3f8ee1b8992d339b1899f9aa13ea4f4015bd 100644 (file)
@@ -1456,18 +1456,27 @@ key_generation_cb (void *cls,
   {
     char *hostname;
     char *hgram_file;
-
-    hostname = GNUNET_malloc (GNUNET_OS_get_hostname_max_length ());
-    if (0 == gethostname (hostname, HOST_NAME_MAX))
+    unsigned long long peer_id;
+    
+    hgram_file = NULL;
+    if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED",
+                                                            "PEERID", &peer_id))
+      (void) GNUNET_asprintf (&hgram_file, "%s/%llu.hist", proof, peer_id);
+    else  
+    {
+      hostname = GNUNET_malloc (GNUNET_OS_get_hostname_max_length ());
+      if (0 == gethostname (hostname, HOST_NAME_MAX))
+        (void) GNUNET_asprintf (&hgram_file, "%s/%s_%jd.hist", 
+                                proof, hostname, (intmax_t) getpid());
+      else
+        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "gethostname");    
+      GNUNET_free (hostname);
+    }
+    if (NULL != hgram_file)
     {
-      (void) GNUNET_asprintf (&hgram_file, "%s/%s_%jd.hist", 
-                              proof, hostname, (intmax_t) getpid());
       wh = GNUNET_BIO_write_open (hgram_file);
       GNUNET_free (hgram_file);
     }
-    else
-      GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "gethostname");    
-    GNUNET_free (hostname);
     GNUNET_free (proof);
   }
 #endif