aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-04-16 12:42:44 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-04-16 12:42:44 +0000
commitead89b2005376011111abab67088ed5cb475e200 (patch)
tree15e4a06e56e5ef1c20e379948cb7d0b18818ea57 /src/testing
parente3eafec912a3b75fdfed15053d66c14ccc72dd2a (diff)
downloadgnunet-ead89b2005376011111abab67088ed5cb475e200.tar.gz
gnunet-ead89b2005376011111abab67088ed5cb475e200.zip
- revert to using memory mapped host keys file
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 909a28750..14e660358 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -92,6 +92,16 @@ 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 /**
95 * Bitmap where each TCP port that has already been reserved for 105 * Bitmap where each TCP port that has already been reserved for
96 * some GNUnet peer is recorded. Note that we additionally need to 106 * some GNUnet peer is recorded. Note that we additionally need to
97 * test if a port is already in use by non-GNUnet components before 107 * test if a port is already in use by non-GNUnet components before
@@ -262,15 +272,19 @@ hostkeys_load (struct GNUNET_TESTING_System *system)
262 GNUNET_free (filename); 272 GNUNET_free (filename);
263 return GNUNET_SYSERR; 273 return GNUNET_SYSERR;
264 } 274 }
265 system->hostkeys_data = GNUNET_malloc_large ((size_t) fs); 275 system->map_fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
266 if (GNUNET_DISK_fn_read (filename, system->hostkeys_data, fs) != (ssize_t) fs) 276 GNUNET_DISK_PERM_NONE);
277 if (NULL == system->map_fd)
267 { 278 {
279 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename);
268 GNUNET_free (filename); 280 GNUNET_free (filename);
269 GNUNET_free (system->hostkeys_data);
270 system->hostkeys_data = NULL;
271 return GNUNET_SYSERR; 281 return GNUNET_SYSERR;
272 } 282 }
273 system->total_hostkeys = fs / GNUNET_TESTING_HOSTKEYFILESIZE; 283 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);
274 GNUNET_free (filename); 288 GNUNET_free (filename);
275 return GNUNET_OK; 289 return GNUNET_OK;
276} 290}
@@ -285,7 +299,11 @@ static void
285hostkeys_unload (struct GNUNET_TESTING_System *system) 299hostkeys_unload (struct GNUNET_TESTING_System *system)
286{ 300{
287 GNUNET_break (NULL != system->hostkeys_data); 301 GNUNET_break (NULL != system->hostkeys_data);
288 GNUNET_free_non_null (system->hostkeys_data); 302 system->hostkeys_data = NULL;
303 GNUNET_DISK_file_unmap (system->map);
304 system->map = NULL;
305 GNUNET_DISK_file_close (system->map_fd);
306 system->map_fd = NULL;
289 system->hostkeys_data = NULL; 307 system->hostkeys_data = NULL;
290 system->total_hostkeys = 0; 308 system->total_hostkeys = 0;
291} 309}