diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-04-03 21:17:41 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-04-03 21:17:41 +0000 |
commit | ab68396e62482477b910f532f050558a50ac20cc (patch) | |
tree | c7771da2d3a2293e1db52b2f7b889617b3689098 /src/testing | |
parent | 18ac48890771c6ba7f062a0477e7b42e60bdd97d (diff) | |
download | gnunet-ab68396e62482477b910f532f050558a50ac20cc.tar.gz gnunet-ab68396e62482477b910f532f050558a50ac20cc.zip |
- reduce open file descriptors in processes started through testing
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing.c | 28 |
1 files changed, 5 insertions, 23 deletions
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 | |||
@@ -92,16 +92,6 @@ struct GNUNET_TESTING_System | |||
92 | char *hostkeys_data; | 92 | char *hostkeys_data; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * memory map for 'hostkeys_data'. | ||
96 | */ | ||
97 | struct GNUNET_DISK_MapHandle *map; | ||
98 | |||
99 | /** | ||
100 | * File descriptor for the map. | ||
101 | */ | ||
102 | struct GNUNET_DISK_FileHandle *map_fd; | ||
103 | |||
104 | /** | ||
105 | * Bitmap where each TCP port that has already been reserved for | 95 | * Bitmap where each TCP port that has already been reserved for |
106 | * some GNUnet peer is recorded. Note that we additionally need to | 96 | * some GNUnet peer is recorded. Note that we additionally need to |
107 | * test if a port is already in use by non-GNUnet components before | 97 | * test if a port is already in use by non-GNUnet components before |
@@ -272,19 +262,15 @@ hostkeys_load (struct GNUNET_TESTING_System *system) | |||
272 | GNUNET_free (filename); | 262 | GNUNET_free (filename); |
273 | return GNUNET_SYSERR; | 263 | return GNUNET_SYSERR; |
274 | } | 264 | } |
275 | system->map_fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, | 265 | system->hostkeys_data = GNUNET_malloc_large ((size_t) fs); |
276 | GNUNET_DISK_PERM_NONE); | 266 | if (GNUNET_DISK_fn_read (filename, system->hostkeys_data, fs) != (ssize_t) fs) |
277 | if (NULL == system->map_fd) | ||
278 | { | 267 | { |
279 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename); | ||
280 | GNUNET_free (filename); | 268 | GNUNET_free (filename); |
269 | GNUNET_free (system->hostkeys_data); | ||
270 | system->hostkeys_data = NULL; | ||
281 | return GNUNET_SYSERR; | 271 | return GNUNET_SYSERR; |
282 | } | 272 | } |
283 | system->total_hostkeys = fs / GNUNET_TESTING_HOSTKEYFILESIZE; | 273 | system->total_hostkeys = fs / GNUNET_TESTING_HOSTKEYFILESIZE; |
284 | system->hostkeys_data = GNUNET_DISK_file_map (system->map_fd, | ||
285 | &system->map, | ||
286 | GNUNET_DISK_MAP_TYPE_READ, | ||
287 | fs); | ||
288 | GNUNET_free (filename); | 274 | GNUNET_free (filename); |
289 | return GNUNET_OK; | 275 | return GNUNET_OK; |
290 | } | 276 | } |
@@ -299,11 +285,7 @@ static void | |||
299 | hostkeys_unload (struct GNUNET_TESTING_System *system) | 285 | hostkeys_unload (struct GNUNET_TESTING_System *system) |
300 | { | 286 | { |
301 | GNUNET_break (NULL != system->hostkeys_data); | 287 | GNUNET_break (NULL != system->hostkeys_data); |
302 | system->hostkeys_data = NULL; | 288 | GNUNET_free_non_null (system->hostkeys_data); |
303 | GNUNET_DISK_file_unmap (system->map); | ||
304 | system->map = NULL; | ||
305 | GNUNET_DISK_file_close (system->map_fd); | ||
306 | system->map_fd = NULL; | ||
307 | system->hostkeys_data = NULL; | 289 | system->hostkeys_data = NULL; |
308 | system->total_hostkeys = 0; | 290 | system->total_hostkeys = 0; |
309 | } | 291 | } |