gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r26905 - gnunet/src/testing
Date: Tue, 16 Apr 2013 15:10:36 +0200

Author: harsha
Date: 2013-04-16 15:10:36 +0200 (Tue, 16 Apr 2013)
New Revision: 26905

Modified:
   gnunet/src/testing/testing.c
Log:
- close file fd after mapping the file

Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c        2013-04-16 12:42:44 UTC (rev 26904)
+++ gnunet/src/testing/testing.c        2013-04-16 13:10:36 UTC (rev 26905)
@@ -97,11 +97,6 @@
   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
@@ -243,7 +238,8 @@
   uint64_t fs; 
   char *data_dir;
   char *filename;
-  
+  struct GNUNET_DISK_FileHandle *fd;
+
   GNUNET_assert (NULL == system->hostkeys_data);
   data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
   GNUNET_asprintf (&filename, "%s/testing_hostkeys.ecc", data_dir);
@@ -272,20 +268,23 @@
     GNUNET_free (filename);
     return GNUNET_SYSERR;
   }
-  system->map_fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
+  fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
                                         GNUNET_DISK_PERM_NONE);
-  if (NULL == system->map_fd)
+  if (NULL == fd)
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename);
     GNUNET_free (filename);
     return GNUNET_SYSERR;
   }
-  system->total_hostkeys = fs / GNUNET_TESTING_HOSTKEYFILESIZE;
-  system->hostkeys_data = GNUNET_DISK_file_map (system->map_fd,
+  GNUNET_free (filename);
+  system->hostkeys_data = GNUNET_DISK_file_map (fd,
                                                &system->map,
                                                GNUNET_DISK_MAP_TYPE_READ,
                                                fs);
-  GNUNET_free (filename);
+  GNUNET_DISK_file_close (fd);
+  if (NULL == system->hostkeys_data)
+    return GNUNET_SYSERR;
+  system->total_hostkeys = fs / GNUNET_TESTING_HOSTKEYFILESIZE;
   return GNUNET_OK;
 }
 
@@ -302,8 +301,6 @@
   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]