gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (8e9283304 -> 1eaf5ebe2)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (8e9283304 -> 1eaf5ebe2)
Date: Wed, 28 Nov 2018 00:03:01 +0100

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a change to branch master
in repository gnunet.

    from 8e9283304 REST: Fix oidc client lookup
     new 3cb06d889 RPS tests/profiler: Keep files for dumping internals open
     new a3b65a1c9 RPS sampler: Fix creation of sampler
     new 1eaf5ebe2 RPS profiler: logging, return value

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/rps/gnunet-rps-profiler.c        | 11 +++-
 src/rps/gnunet-service-rps.c         |  1 +
 src/rps/gnunet-service-rps_sampler.c |  1 +
 src/rps/rps-sampler_client.c         |  2 +-
 src/rps/rps-test_util.c              | 99 ++++++++++++++++++++++++++++++++++++
 src/rps/rps-test_util.h              | 40 +++++++++++----
 src/rps/test_rps.c                   |  1 +
 7 files changed, 141 insertions(+), 14 deletions(-)

diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 5ccf1017e..e7759689b 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -1102,6 +1102,7 @@ shutdown_op (void *cls)
   {
     clean_peer (i);
   }
+  close_all_files();
 }
 
 static void
@@ -1127,8 +1128,8 @@ post_test_op (void *cls)
 
   post_test_task = NULL;
   post_test = GNUNET_YES;
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              "Post test task scheduled.\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Executing post test op.\n");
   if (NULL != churn_task)
   {
     GNUNET_SCHEDULER_cancel (churn_task);
@@ -1136,10 +1137,15 @@ post_test_op (void *cls)
   }
   for (i = 0; i < num_peers; i++)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Executing post test op. (peer %" PRIu32 ")\n",
+                rps_peers[i].index);
     if (NULL != rps_peers[i].op)
     {
       GNUNET_TESTBED_operation_done (rps_peers[i].op);
       rps_peers[i].op = NULL;
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Cancelled testbed operation\n");
     }
     if (NULL != cur_test_run.post_test)
     {
@@ -2725,6 +2731,7 @@ test_run (void *cls,
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tnum_peers: %" PRIu32 "\n", 
num_peers);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tpeers: %p\n", peers);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tlinks_succeeded: %u\n", 
links_succeeded);
+    ok = 1;
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 20b314db3..f121db5b8 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -4556,6 +4556,7 @@ shutdown_task (void *cls)
     GNUNET_free (tmp_att_peer);
   }
 #endif /* ENABLE_MALICIOUS */
+  close_all_files();
 }
 
 
diff --git a/src/rps/gnunet-service-rps_sampler.c 
b/src/rps/gnunet-service-rps_sampler.c
index 9629a29a1..dcfef19c6 100644
--- a/src/rps/gnunet-service-rps_sampler.c
+++ b/src/rps/gnunet-service-rps_sampler.c
@@ -204,6 +204,7 @@ RPS_sampler_init (size_t init_size,
 
   #ifdef TO_FILE
   sampler->file_name = create_file ("sampler-");
+  GNUNET_assert (NULL != sampler->file_name);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Initialised sampler %s\n",
diff --git a/src/rps/rps-sampler_client.c b/src/rps/rps-sampler_client.c
index 4904b9d43..fea824cf3 100644
--- a/src/rps/rps-sampler_client.c
+++ b/src/rps/rps-sampler_client.c
@@ -205,7 +205,6 @@ RPS_sampler_mod_init (size_t init_size,
   sampler->get_peers = sampler_mod_get_rand_peer;
   //sampler->sampler_elements = GNUNET_new_array(init_size, struct 
GNUNET_PeerIdentity);
   //GNUNET_array_grow (sampler->sampler_elements, sampler->sampler_size, 
min_size);
-  RPS_sampler_resize (sampler, init_size);
 
   client_get_index = 0;
 
@@ -220,6 +219,7 @@ RPS_sampler_mod_init (size_t init_size,
   to_file (sampler->file_name,
            "This is a modified sampler");
 #endif /* TO_FILE */
+  RPS_sampler_resize (sampler, init_size);
 
   return sampler;
 }
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index a6ea033cd..d0d195229 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -56,6 +56,105 @@ static char buf_unaligned;
  */
 static unsigned num_bits_buf_unaligned;
 
+static struct GNUNET_CONTAINER_MultiHashMap *open_files;
+
+
+
+/**
+ * @brief Get file handle
+ *
+ * If necessary, create file handle and store it with the other file handles.
+ *
+ * @param name Name of the file
+ *
+ * @return File handle
+ */
+struct GNUNET_DISK_FileHandle *
+get_file_handle (const char *name)
+{
+  struct GNUNET_HashCode hash;
+  struct GNUNET_DISK_FileHandle *fh;
+
+  if (NULL == open_files)
+  {
+    open_files = GNUNET_CONTAINER_multihashmap_create (16,
+        GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+  }
+  GNUNET_CRYPTO_hash (name,
+                      strnlen (name,
+                               512),
+                      &hash);
+  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (open_files,
+                                                           &hash))
+  {
+    fh = GNUNET_DISK_file_open (name,
+                                GNUNET_DISK_OPEN_APPEND,
+                                GNUNET_DISK_PERM_USER_READ |
+                                GNUNET_DISK_PERM_USER_WRITE |
+                                GNUNET_DISK_PERM_GROUP_READ);
+    GNUNET_CONTAINER_multihashmap_put (open_files,
+                                       &hash,
+                                       fh,
+                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+    return fh;
+  }
+  else
+  {
+    fh = GNUNET_CONTAINER_multihashmap_get (open_files,
+                                            &hash);
+    return fh;
+  }
+}
+
+
+/**
+ * @brief Closes the file of the current entry
+ *
+ * Implements #GNUNET_CONTAINER_HashMapIterator
+ *
+ * @param cls unused
+ * @param key unused
+ * @param value the file handle
+ *
+ * @return #GNUNET_YES if we should continue to
+ *         iterate,
+ *         #GNUNET_NO if not.
+ */
+int
+close_files_iter (void *cls,
+                  const struct GNUNET_HashCode *key,
+                  void *value)
+{
+  (void) cls;
+  (void) key;
+  struct GNUNET_DISK_FileHandle *fh = value;
+
+  if (NULL != fh)
+  {
+    GNUNET_DISK_file_close (fh);
+  }
+  return GNUNET_YES;
+}
+
+
+/**
+ * @brief Close all files that were opened with #get_file_handle
+ *
+ * @return Success of iterating over files
+ */
+int
+close_all_files ()
+{
+  int ret;
+
+  ret = GNUNET_CONTAINER_multihashmap_iterate (open_files,
+                                               close_files_iter,
+                                               NULL);
+  GNUNET_CONTAINER_multihashmap_destroy (open_files);
+  return ret;
+}
+
+
 
 void
 to_file_raw (const char *file_name, const char *buf, size_t size_buf)
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index a806f11cd..5dfcc5f6a 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -39,23 +39,43 @@ char *
 create_file (const char *name);
 
 /**
+ * @brief Get file handle
+ *
+ * If necessary, create file handle and store it with the other file handles.
+ *
+ * @param name Name of the file
+ *
+ * @return File handle
+ */
+struct GNUNET_DISK_FileHandle *
+get_file_handle (const char *name);
+
+/**
+ * @brief Close all files that were opened with #get_file_handle
+ *
+ * @return Success of iterating over files
+ */
+int
+close_all_files ();
+
+/**
  * This function is used to facilitate writing important information to disk
  */
 #ifdef TO_FILE
-#  define to_file(file_name, ...) do {char tmp_buf[512] = "";\
+#define to_file(file_name, ...) do {GNUNET_assert (NULL != file_name);\
+    char tmp_buf[512] = "";\
     int size;\
     size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
     if (0 > size)\
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
            "Failed to create tmp_buf\n");\
     else\
-      GNUNET_DISK_fn_write(file_name, tmp_buf, strnlen(tmp_buf, 512),\
-                            GNUNET_DISK_PERM_USER_READ |\
-                            GNUNET_DISK_PERM_USER_WRITE |\
-                            GNUNET_DISK_PERM_GROUP_READ |\
-                            GNUNET_DISK_PERM_OTHER_READ);\
+      GNUNET_DISK_file_write (get_file_handle (file_name),\
+                              tmp_buf,\
+                              strnlen (tmp_buf, 512));\
   } while (0);
 
+
 #define to_file_w_len(file_name, len, ...) do {char tmp_buf[len];\
     int size;\
     memset (tmp_buf, 0, len);\
@@ -64,11 +84,9 @@ create_file (const char *name);
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
            "Failed to create tmp_buf\n");\
     else\
-      GNUNET_DISK_fn_write(file_name, tmp_buf, strnlen(tmp_buf, len), \
-                            GNUNET_DISK_PERM_USER_READ |\
-                            GNUNET_DISK_PERM_USER_WRITE |\
-                            GNUNET_DISK_PERM_GROUP_READ |\
-                            GNUNET_DISK_PERM_OTHER_READ);\
+      GNUNET_DISK_file_write (get_file_handle (file_name),\
+                              tmp_buf,\
+                              strnlen (tmp_buf, 512));\
   } while (0);
 #else /* TO_FILE */
 #  define to_file(file_name, ...)
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 63a6007ae..72dc90b17 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -806,6 +806,7 @@ shutdown_op (void *cls)
       GNUNET_TESTBED_operation_done (rps_peers[i].op);
     }
   }
+  close_all_files();
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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