gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r26904 - gnunet/src/testing


From: gnunet
Subject: [GNUnet-SVN] r26904 - gnunet/src/testing
Date: Tue, 16 Apr 2013 14:42:44 +0200

Author: harsha
Date: 2013-04-16 14:42:44 +0200 (Tue, 16 Apr 2013)
New Revision: 26904

Modified:
   gnunet/src/testing/testing.c
Log:
- revert to using memory mapped host keys file

Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c        2013-04-16 11:38:14 UTC (rev 26903)
+++ gnunet/src/testing/testing.c        2013-04-16 12:42:44 UTC (rev 26904)
@@ -92,6 +92,16 @@
   char *hostkeys_data;
 
   /**
+   * memory map for 'hostkeys_data'.
+   */
+  struct GNUNET_DISK_MapHandle *map;
+
+  /**
+   * File descriptor for the map.
+   */
+  struct GNUNET_DISK_FileHandle *map_fd;
+
+  /**
    * Bitmap where each TCP port that has already been reserved for
    * some GNUnet peer is recorded.  Note that we additionally need to
    * test if a port is already in use by non-GNUnet components before
@@ -262,15 +272,19 @@
     GNUNET_free (filename);
     return GNUNET_SYSERR;
   }
-  system->hostkeys_data = GNUNET_malloc_large ((size_t) fs);
-  if (GNUNET_DISK_fn_read (filename, system->hostkeys_data, fs) != (ssize_t) 
fs)
+  system->map_fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
+                                        GNUNET_DISK_PERM_NONE);
+  if (NULL == system->map_fd)
   {
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename);
     GNUNET_free (filename);
-    GNUNET_free (system->hostkeys_data);
-    system->hostkeys_data = NULL;
     return GNUNET_SYSERR;
   }
   system->total_hostkeys = fs / GNUNET_TESTING_HOSTKEYFILESIZE;
+  system->hostkeys_data = GNUNET_DISK_file_map (system->map_fd,
+                                               &system->map,
+                                               GNUNET_DISK_MAP_TYPE_READ,
+                                               fs);
   GNUNET_free (filename);
   return GNUNET_OK;
 }
@@ -285,8 +299,12 @@
 hostkeys_unload (struct GNUNET_TESTING_System *system)
 {
   GNUNET_break (NULL != system->hostkeys_data);
-  GNUNET_free_non_null (system->hostkeys_data);
   system->hostkeys_data = NULL;
+  GNUNET_DISK_file_unmap (system->map);
+  system->map = NULL;
+  GNUNET_DISK_file_close (system->map_fd);
+  system->map_fd = NULL;
+  system->hostkeys_data = NULL;
   system->total_hostkeys = 0;
 }
 




reply via email to

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