From ab68396e62482477b910f532f050558a50ac20cc Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Wed, 3 Apr 2013 21:17:41 +0000 Subject: - reduce open file descriptors in processes started through testing --- src/testing/testing.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'src/testing') diff --git a/src/testing/testing.c b/src/testing/testing.c index c8f857a05..eb039435d 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -91,16 +91,6 @@ struct GNUNET_TESTING_System */ 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 @@ -272,19 +262,15 @@ hostkeys_load (struct GNUNET_TESTING_System *system) GNUNET_free (filename); return GNUNET_SYSERR; } - system->map_fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, - GNUNET_DISK_PERM_NONE); - if (NULL == system->map_fd) + system->hostkeys_data = GNUNET_malloc_large ((size_t) fs); + if (GNUNET_DISK_fn_read (filename, system->hostkeys_data, fs) != (ssize_t) fs) { - 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; } @@ -299,11 +285,7 @@ static void hostkeys_unload (struct GNUNET_TESTING_System *system) { GNUNET_break (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; + GNUNET_free_non_null (system->hostkeys_data); system->hostkeys_data = NULL; system->total_hostkeys = 0; } -- cgit v1.2.3