diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-06-29 10:18:44 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-06-29 10:18:44 +0200 |
commit | e96e9584f2ca6797552fc46bb83e3d10827fad49 (patch) | |
tree | 2690a245a593114276918b6226bead748ceb8fcd /src/namestore | |
parent | 3ddd3e7aaa16e086136f64881bc9d403b87a61ec (diff) | |
download | gnunet-e96e9584f2ca6797552fc46bb83e3d10827fad49.tar.gz gnunet-e96e9584f2ca6797552fc46bb83e3d10827fad49.zip |
use mmap() instead of malloc, rename heap->flat as database is persisted in flat file
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/.gitignore | 36 | ||||
-rw-r--r-- | src/namestore/Makefile.am | 124 | ||||
-rw-r--r-- | src/namestore/perf_namestore_api_flat.conf (renamed from src/namestore/perf_namestore_api_heap.conf) | 2 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_flat.c (renamed from src/namestore/plugin_namestore_heap.c) | 273 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_flat.conf (renamed from src/namestore/test_namestore_api_heap.conf) | 2 | ||||
-rw-r--r-- | src/namestore/test_plugin_namestore_flat.conf (renamed from src/namestore/test_plugin_namestore_heap.conf) | 2 |
6 files changed, 229 insertions, 210 deletions
diff --git a/src/namestore/.gitignore b/src/namestore/.gitignore index 5a59afd24..f159cdaff 100644 --- a/src/namestore/.gitignore +++ b/src/namestore/.gitignore | |||
@@ -68,21 +68,21 @@ test_namestore_api_zone_iteration_stop_sqlite | |||
68 | test_namestore_api_zone_to_name_flat | 68 | test_namestore_api_zone_to_name_flat |
69 | test_namestore_api_zone_to_name_postgres | 69 | test_namestore_api_zone_to_name_postgres |
70 | test_namestore_api_zone_to_name_sqlite | 70 | test_namestore_api_zone_to_name_sqlite |
71 | test_namestore_api_lookup_nick_heap | 71 | test_namestore_api_lookup_nick_flat |
72 | test_namestore_api_lookup_private_heap | 72 | test_namestore_api_lookup_private_flat |
73 | test_namestore_api_lookup_public_heap | 73 | test_namestore_api_lookup_public_flat |
74 | test_namestore_api_lookup_shadow_filter_heap | 74 | test_namestore_api_lookup_shadow_filter_flat |
75 | test_namestore_api_lookup_shadow_heap | 75 | test_namestore_api_lookup_shadow_flat |
76 | test_namestore_api_monitoring_existing_heap | 76 | test_namestore_api_monitoring_existing_flat |
77 | test_namestore_api_monitoring_heap | 77 | test_namestore_api_monitoring_flat |
78 | test_namestore_api_remove_heap | 78 | test_namestore_api_remove_flat |
79 | test_namestore_api_remove_not_existing_record_heap | 79 | test_namestore_api_remove_not_existing_record_flat |
80 | test_namestore_api_store_heap | 80 | test_namestore_api_store_flat |
81 | test_namestore_api_store_update_heap | 81 | test_namestore_api_store_update_flat |
82 | test_namestore_api_zone_iteration_heap | 82 | test_namestore_api_zone_iteration_flat |
83 | test_namestore_api_zone_iteration_nick_heap | 83 | test_namestore_api_zone_iteration_nick_flat |
84 | test_namestore_api_zone_iteration_specific_zone_heap | 84 | test_namestore_api_zone_iteration_specific_zone_flat |
85 | test_namestore_api_zone_iteration_stop_heap | 85 | test_namestore_api_zone_iteration_stop_flat |
86 | test_namestore_api_zone_to_name_heap | 86 | test_namestore_api_zone_to_name_flat |
87 | test_plugin_namestore_heap | 87 | test_plugin_namestore_flat |
88 | perf_namestore_api_zone_iteration_heap | 88 | perf_namestore_api_zone_iteration_flat |
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 25941b4fb..e95add6c7 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am | |||
@@ -20,26 +20,26 @@ if USE_COVERAGE | |||
20 | XLIBS = -lgcov | 20 | XLIBS = -lgcov |
21 | endif | 21 | endif |
22 | 22 | ||
23 | HEAP_PLUGIN = libgnunet_plugin_namestore_heap.la | 23 | HEAP_PLUGIN = libgnunet_plugin_namestore_flat.la |
24 | if HAVE_TESTING | 24 | if HAVE_TESTING |
25 | HEAP_TESTS = test_plugin_namestore_heap \ | 25 | HEAP_TESTS = test_plugin_namestore_flat \ |
26 | test_namestore_api_store_heap \ | 26 | test_namestore_api_store_flat \ |
27 | test_namestore_api_store_update_heap \ | 27 | test_namestore_api_store_update_flat \ |
28 | test_namestore_api_remove_heap \ | 28 | test_namestore_api_remove_flat \ |
29 | test_namestore_api_zone_iteration_heap \ | 29 | test_namestore_api_zone_iteration_flat \ |
30 | test_namestore_api_lookup_nick_heap \ | 30 | test_namestore_api_lookup_nick_flat \ |
31 | test_namestore_api_monitoring_heap \ | 31 | test_namestore_api_monitoring_flat \ |
32 | test_namestore_api_lookup_public_heap \ | 32 | test_namestore_api_lookup_public_flat \ |
33 | test_namestore_api_lookup_private_heap \ | 33 | test_namestore_api_lookup_private_flat \ |
34 | test_namestore_api_lookup_shadow_heap \ | 34 | test_namestore_api_lookup_shadow_flat \ |
35 | test_namestore_api_lookup_shadow_filter_heap \ | 35 | test_namestore_api_lookup_shadow_filter_flat \ |
36 | test_namestore_api_remove_not_existing_record_heap \ | 36 | test_namestore_api_remove_not_existing_record_flat \ |
37 | test_namestore_api_zone_iteration_nick_heap \ | 37 | test_namestore_api_zone_iteration_nick_flat \ |
38 | test_namestore_api_zone_iteration_specific_zone_heap \ | 38 | test_namestore_api_zone_iteration_specific_zone_flat \ |
39 | test_namestore_api_zone_iteration_stop_heap \ | 39 | test_namestore_api_zone_iteration_stop_flat \ |
40 | test_namestore_api_monitoring_existing_heap \ | 40 | test_namestore_api_monitoring_existing_flat \ |
41 | test_namestore_api_zone_to_name_heap \ | 41 | test_namestore_api_zone_to_name_flat \ |
42 | perf_namestore_api_zone_iteration_heap | 42 | perf_namestore_api_zone_iteration_flat |
43 | endif | 43 | endif |
44 | 44 | ||
45 | if HAVE_SQLITE | 45 | if HAVE_SQLITE |
@@ -206,14 +206,14 @@ gnunet_service_namestore_LDADD = \ | |||
206 | 206 | ||
207 | 207 | ||
208 | 208 | ||
209 | libgnunet_plugin_namestore_heap_la_SOURCES = \ | 209 | libgnunet_plugin_namestore_flat_la_SOURCES = \ |
210 | plugin_namestore_heap.c | 210 | plugin_namestore_flat.c |
211 | libgnunet_plugin_namestore_heap_la_LIBADD = \ | 211 | libgnunet_plugin_namestore_flat_la_LIBADD = \ |
212 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 212 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
213 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 213 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
214 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ | 214 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ |
215 | $(LTLIBINTL) | 215 | $(LTLIBINTL) |
216 | libgnunet_plugin_namestore_heap_la_LDFLAGS = \ | 216 | libgnunet_plugin_namestore_flat_la_LDFLAGS = \ |
217 | $(GN_PLUGIN_LDFLAGS) | 217 | $(GN_PLUGIN_LDFLAGS) |
218 | 218 | ||
219 | 219 | ||
@@ -239,9 +239,9 @@ libgnunet_plugin_namestore_postgres_la_LIBADD = \ | |||
239 | libgnunet_plugin_namestore_postgres_la_LDFLAGS = \ | 239 | libgnunet_plugin_namestore_postgres_la_LDFLAGS = \ |
240 | $(GN_PLUGIN_LDFLAGS) $(POSTGRESQL_LDFLAGS) | 240 | $(GN_PLUGIN_LDFLAGS) $(POSTGRESQL_LDFLAGS) |
241 | 241 | ||
242 | test_namestore_api_store_heap_SOURCES = \ | 242 | test_namestore_api_store_flat_SOURCES = \ |
243 | test_namestore_api_store.c | 243 | test_namestore_api_store.c |
244 | test_namestore_api_store_heap_LDADD = \ | 244 | test_namestore_api_store_flat_LDADD = \ |
245 | $(top_builddir)/src/testing/libgnunettesting.la \ | 245 | $(top_builddir)/src/testing/libgnunettesting.la \ |
246 | $(top_builddir)/src/util/libgnunetutil.la \ | 246 | $(top_builddir)/src/util/libgnunetutil.la \ |
247 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 247 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -263,9 +263,9 @@ test_namestore_api_store_postgres_LDADD = \ | |||
263 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 263 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
264 | libgnunetnamestore.la | 264 | libgnunetnamestore.la |
265 | 265 | ||
266 | test_namestore_api_store_update_heap_SOURCES = \ | 266 | test_namestore_api_store_update_flat_SOURCES = \ |
267 | test_namestore_api_store_update.c | 267 | test_namestore_api_store_update.c |
268 | test_namestore_api_store_update_heap_LDADD = \ | 268 | test_namestore_api_store_update_flat_LDADD = \ |
269 | $(top_builddir)/src/testing/libgnunettesting.la \ | 269 | $(top_builddir)/src/testing/libgnunettesting.la \ |
270 | $(top_builddir)/src/util/libgnunetutil.la \ | 270 | $(top_builddir)/src/util/libgnunetutil.la \ |
271 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 271 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -290,9 +290,9 @@ test_namestore_api_store_update_postgres_LDADD = \ | |||
290 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 290 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
291 | libgnunetnamestore.la | 291 | libgnunetnamestore.la |
292 | 292 | ||
293 | test_namestore_api_lookup_public_heap_SOURCES = \ | 293 | test_namestore_api_lookup_public_flat_SOURCES = \ |
294 | test_namestore_api_lookup_public.c | 294 | test_namestore_api_lookup_public.c |
295 | test_namestore_api_lookup_public_heap_LDADD = \ | 295 | test_namestore_api_lookup_public_flat_LDADD = \ |
296 | $(top_builddir)/src/testing/libgnunettesting.la \ | 296 | $(top_builddir)/src/testing/libgnunettesting.la \ |
297 | $(top_builddir)/src/util/libgnunetutil.la \ | 297 | $(top_builddir)/src/util/libgnunetutil.la \ |
298 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 298 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -335,18 +335,18 @@ test_namestore_api_lookup_nick_postgres_LDADD = \ | |||
335 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 335 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
336 | libgnunetnamestore.la | 336 | libgnunetnamestore.la |
337 | 337 | ||
338 | test_namestore_api_lookup_nick_heap_SOURCES = \ | 338 | test_namestore_api_lookup_nick_flat_SOURCES = \ |
339 | test_namestore_api_lookup_nick.c | 339 | test_namestore_api_lookup_nick.c |
340 | test_namestore_api_lookup_nick_heap_LDADD = \ | 340 | test_namestore_api_lookup_nick_flat_LDADD = \ |
341 | $(top_builddir)/src/testing/libgnunettesting.la \ | 341 | $(top_builddir)/src/testing/libgnunettesting.la \ |
342 | $(top_builddir)/src/util/libgnunetutil.la \ | 342 | $(top_builddir)/src/util/libgnunetutil.la \ |
343 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 343 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
344 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 344 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
345 | libgnunetnamestore.la | 345 | libgnunetnamestore.la |
346 | 346 | ||
347 | test_namestore_api_lookup_private_heap_SOURCES = \ | 347 | test_namestore_api_lookup_private_flat_SOURCES = \ |
348 | test_namestore_api_lookup_private.c | 348 | test_namestore_api_lookup_private.c |
349 | test_namestore_api_lookup_private_heap_LDADD = \ | 349 | test_namestore_api_lookup_private_flat_LDADD = \ |
350 | $(top_builddir)/src/testing/libgnunettesting.la \ | 350 | $(top_builddir)/src/testing/libgnunettesting.la \ |
351 | $(top_builddir)/src/util/libgnunetutil.la \ | 351 | $(top_builddir)/src/util/libgnunetutil.la \ |
352 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 352 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -371,9 +371,9 @@ test_namestore_api_lookup_private_postgres_LDADD = \ | |||
371 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 371 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
372 | libgnunetnamestore.la | 372 | libgnunetnamestore.la |
373 | 373 | ||
374 | test_namestore_api_lookup_shadow_heap_SOURCES = \ | 374 | test_namestore_api_lookup_shadow_flat_SOURCES = \ |
375 | test_namestore_api_lookup_shadow.c | 375 | test_namestore_api_lookup_shadow.c |
376 | test_namestore_api_lookup_shadow_heap_LDADD = \ | 376 | test_namestore_api_lookup_shadow_flat_LDADD = \ |
377 | $(top_builddir)/src/testing/libgnunettesting.la \ | 377 | $(top_builddir)/src/testing/libgnunettesting.la \ |
378 | $(top_builddir)/src/util/libgnunetutil.la \ | 378 | $(top_builddir)/src/util/libgnunetutil.la \ |
379 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 379 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -398,9 +398,9 @@ test_namestore_api_lookup_shadow_postgres_LDADD = \ | |||
398 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ | 398 | $(top_builddir)/src/namecache/libgnunetnamecache.la \ |
399 | libgnunetnamestore.la | 399 | libgnunetnamestore.la |
400 | 400 | ||
401 | test_namestore_api_lookup_shadow_filter_heap_SOURCES = \ | 401 | test_namestore_api_lookup_shadow_filter_flat_SOURCES = \ |
402 | test_namestore_api_lookup_shadow_filter.c | 402 | test_namestore_api_lookup_shadow_filter.c |
403 | test_namestore_api_lookup_shadow_filter_heap_LDADD = \ | 403 | test_namestore_api_lookup_shadow_filter_flat_LDADD = \ |
404 | $(top_builddir)/src/testing/libgnunettesting.la \ | 404 | $(top_builddir)/src/testing/libgnunettesting.la \ |
405 | $(top_builddir)/src/util/libgnunetutil.la \ | 405 | $(top_builddir)/src/util/libgnunetutil.la \ |
406 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 406 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -440,17 +440,17 @@ test_namestore_api_remove_postgres_LDADD = \ | |||
440 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 440 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
441 | libgnunetnamestore.la | 441 | libgnunetnamestore.la |
442 | 442 | ||
443 | test_namestore_api_remove_heap_SOURCES = \ | 443 | test_namestore_api_remove_flat_SOURCES = \ |
444 | test_namestore_api_remove.c | 444 | test_namestore_api_remove.c |
445 | test_namestore_api_remove_heap_LDADD = \ | 445 | test_namestore_api_remove_flat_LDADD = \ |
446 | $(top_builddir)/src/testing/libgnunettesting.la \ | 446 | $(top_builddir)/src/testing/libgnunettesting.la \ |
447 | $(top_builddir)/src/util/libgnunetutil.la \ | 447 | $(top_builddir)/src/util/libgnunetutil.la \ |
448 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 448 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
449 | libgnunetnamestore.la | 449 | libgnunetnamestore.la |
450 | 450 | ||
451 | test_namestore_api_remove_not_existing_record_heap_SOURCES = \ | 451 | test_namestore_api_remove_not_existing_record_flat_SOURCES = \ |
452 | test_namestore_api_remove_not_existing_record.c | 452 | test_namestore_api_remove_not_existing_record.c |
453 | test_namestore_api_remove_not_existing_record_heap_LDADD = \ | 453 | test_namestore_api_remove_not_existing_record_flat_LDADD = \ |
454 | $(top_builddir)/src/testing/libgnunettesting.la \ | 454 | $(top_builddir)/src/testing/libgnunettesting.la \ |
455 | $(top_builddir)/src/util/libgnunetutil.la \ | 455 | $(top_builddir)/src/util/libgnunetutil.la \ |
456 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 456 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -472,9 +472,9 @@ test_namestore_api_remove_not_existing_record_postgres_LDADD = \ | |||
472 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 472 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
473 | libgnunetnamestore.la | 473 | libgnunetnamestore.la |
474 | 474 | ||
475 | test_namestore_api_zone_to_name_heap_SOURCES = \ | 475 | test_namestore_api_zone_to_name_flat_SOURCES = \ |
476 | test_namestore_api_zone_to_name.c | 476 | test_namestore_api_zone_to_name.c |
477 | test_namestore_api_zone_to_name_heap_LDADD = \ | 477 | test_namestore_api_zone_to_name_flat_LDADD = \ |
478 | $(top_builddir)/src/testing/libgnunettesting.la \ | 478 | $(top_builddir)/src/testing/libgnunettesting.la \ |
479 | $(top_builddir)/src/util/libgnunetutil.la \ | 479 | $(top_builddir)/src/util/libgnunetutil.la \ |
480 | libgnunetnamestore.la | 480 | libgnunetnamestore.la |
@@ -493,9 +493,9 @@ test_namestore_api_zone_to_name_postgres_LDADD = \ | |||
493 | $(top_builddir)/src/util/libgnunetutil.la \ | 493 | $(top_builddir)/src/util/libgnunetutil.la \ |
494 | libgnunetnamestore.la | 494 | libgnunetnamestore.la |
495 | 495 | ||
496 | test_namestore_api_monitoring_heap_SOURCES = \ | 496 | test_namestore_api_monitoring_flat_SOURCES = \ |
497 | test_namestore_api_monitoring.c | 497 | test_namestore_api_monitoring.c |
498 | test_namestore_api_monitoring_heap_LDADD = \ | 498 | test_namestore_api_monitoring_flat_LDADD = \ |
499 | $(top_builddir)/src/testing/libgnunettesting.la \ | 499 | $(top_builddir)/src/testing/libgnunettesting.la \ |
500 | libgnunetnamestore.la \ | 500 | libgnunetnamestore.la \ |
501 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 501 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -517,9 +517,9 @@ test_namestore_api_monitoring_postgres_LDADD = \ | |||
517 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 517 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
518 | $(top_builddir)/src/util/libgnunetutil.la | 518 | $(top_builddir)/src/util/libgnunetutil.la |
519 | 519 | ||
520 | test_namestore_api_monitoring_existing_heap_SOURCES = \ | 520 | test_namestore_api_monitoring_existing_flat_SOURCES = \ |
521 | test_namestore_api_monitoring_existing.c | 521 | test_namestore_api_monitoring_existing.c |
522 | test_namestore_api_monitoring_existing_heap_LDADD = \ | 522 | test_namestore_api_monitoring_existing_flat_LDADD = \ |
523 | $(top_builddir)/src/testing/libgnunettesting.la \ | 523 | $(top_builddir)/src/testing/libgnunettesting.la \ |
524 | libgnunetnamestore.la \ | 524 | libgnunetnamestore.la \ |
525 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 525 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -541,9 +541,9 @@ test_namestore_api_monitoring_existing_postgres_LDADD = \ | |||
541 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 541 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
542 | $(top_builddir)/src/util/libgnunetutil.la | 542 | $(top_builddir)/src/util/libgnunetutil.la |
543 | 543 | ||
544 | test_namestore_api_zone_iteration_heap_SOURCES = \ | 544 | test_namestore_api_zone_iteration_flat_SOURCES = \ |
545 | test_namestore_api_zone_iteration.c | 545 | test_namestore_api_zone_iteration.c |
546 | test_namestore_api_zone_iteration_heap_LDADD = \ | 546 | test_namestore_api_zone_iteration_flat_LDADD = \ |
547 | $(top_builddir)/src/testing/libgnunettesting.la \ | 547 | $(top_builddir)/src/testing/libgnunettesting.la \ |
548 | $(top_builddir)/src/util/libgnunetutil.la \ | 548 | $(top_builddir)/src/util/libgnunetutil.la \ |
549 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 549 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -581,17 +581,17 @@ perf_namestore_api_zone_iteration_sqlite_LDADD = \ | |||
581 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 581 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
582 | libgnunetnamestore.la | 582 | libgnunetnamestore.la |
583 | 583 | ||
584 | perf_namestore_api_zone_iteration_heap_SOURCES = \ | 584 | perf_namestore_api_zone_iteration_flat_SOURCES = \ |
585 | perf_namestore_api_zone_iteration.c | 585 | perf_namestore_api_zone_iteration.c |
586 | perf_namestore_api_zone_iteration_heap_LDADD = \ | 586 | perf_namestore_api_zone_iteration_flat_LDADD = \ |
587 | $(top_builddir)/src/testing/libgnunettesting.la \ | 587 | $(top_builddir)/src/testing/libgnunettesting.la \ |
588 | $(top_builddir)/src/util/libgnunetutil.la \ | 588 | $(top_builddir)/src/util/libgnunetutil.la \ |
589 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 589 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
590 | libgnunetnamestore.la | 590 | libgnunetnamestore.la |
591 | 591 | ||
592 | test_namestore_api_zone_iteration_nick_heap_SOURCES = \ | 592 | test_namestore_api_zone_iteration_nick_flat_SOURCES = \ |
593 | test_namestore_api_zone_iteration_nick.c | 593 | test_namestore_api_zone_iteration_nick.c |
594 | test_namestore_api_zone_iteration_nick_heap_LDADD = \ | 594 | test_namestore_api_zone_iteration_nick_flat_LDADD = \ |
595 | $(top_builddir)/src/testing/libgnunettesting.la \ | 595 | $(top_builddir)/src/testing/libgnunettesting.la \ |
596 | $(top_builddir)/src/util/libgnunetutil.la \ | 596 | $(top_builddir)/src/util/libgnunetutil.la \ |
597 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 597 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -613,9 +613,9 @@ test_namestore_api_zone_iteration_nick_postgres_LDADD = \ | |||
613 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 613 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
614 | libgnunetnamestore.la | 614 | libgnunetnamestore.la |
615 | 615 | ||
616 | test_namestore_api_zone_iteration_specific_zone_heap_SOURCES = \ | 616 | test_namestore_api_zone_iteration_specific_zone_flat_SOURCES = \ |
617 | test_namestore_api_zone_iteration_specific_zone.c | 617 | test_namestore_api_zone_iteration_specific_zone.c |
618 | test_namestore_api_zone_iteration_specific_zone_heap_LDADD = \ | 618 | test_namestore_api_zone_iteration_specific_zone_flat_LDADD = \ |
619 | $(top_builddir)/src/testing/libgnunettesting.la \ | 619 | $(top_builddir)/src/testing/libgnunettesting.la \ |
620 | $(top_builddir)/src/util/libgnunetutil.la \ | 620 | $(top_builddir)/src/util/libgnunetutil.la \ |
621 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 621 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -637,9 +637,9 @@ test_namestore_api_zone_iteration_specific_zone_postgres_LDADD = \ | |||
637 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 637 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
638 | libgnunetnamestore.la | 638 | libgnunetnamestore.la |
639 | 639 | ||
640 | test_namestore_api_zone_iteration_stop_heap_SOURCES = \ | 640 | test_namestore_api_zone_iteration_stop_flat_SOURCES = \ |
641 | test_namestore_api_zone_iteration_stop.c | 641 | test_namestore_api_zone_iteration_stop.c |
642 | test_namestore_api_zone_iteration_stop_heap_LDADD = \ | 642 | test_namestore_api_zone_iteration_stop_flat_LDADD = \ |
643 | $(top_builddir)/src/testing/libgnunettesting.la \ | 643 | $(top_builddir)/src/testing/libgnunettesting.la \ |
644 | $(top_builddir)/src/util/libgnunetutil.la \ | 644 | $(top_builddir)/src/util/libgnunetutil.la \ |
645 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 645 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
@@ -661,9 +661,9 @@ test_namestore_api_zone_iteration_stop_postgres_LDADD = \ | |||
661 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 661 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
662 | libgnunetnamestore.la | 662 | libgnunetnamestore.la |
663 | 663 | ||
664 | test_plugin_namestore_heap_SOURCES = \ | 664 | test_plugin_namestore_flat_SOURCES = \ |
665 | test_plugin_namestore.c | 665 | test_plugin_namestore.c |
666 | test_plugin_namestore_heap_LDADD = \ | 666 | test_plugin_namestore_flat_LDADD = \ |
667 | $(top_builddir)/src/testing/libgnunettesting.la \ | 667 | $(top_builddir)/src/testing/libgnunettesting.la \ |
668 | $(top_builddir)/src/util/libgnunetutil.la | 668 | $(top_builddir)/src/util/libgnunetutil.la |
669 | 669 | ||
@@ -689,13 +689,13 @@ EXTRA_DIST = \ | |||
689 | test_namestore_api.conf \ | 689 | test_namestore_api.conf \ |
690 | test_namestore_api_postgres.conf \ | 690 | test_namestore_api_postgres.conf \ |
691 | test_namestore_api_sqlite.conf \ | 691 | test_namestore_api_sqlite.conf \ |
692 | test_namestore_api_heap.conf \ | 692 | test_namestore_api_flat.conf \ |
693 | perf_namestore_api_postgres.conf \ | 693 | perf_namestore_api_postgres.conf \ |
694 | perf_namestore_api_sqlite.conf \ | 694 | perf_namestore_api_sqlite.conf \ |
695 | perf_namestore_api_heap.conf \ | 695 | perf_namestore_api_flat.conf \ |
696 | test_plugin_namestore_sqlite.conf \ | 696 | test_plugin_namestore_sqlite.conf \ |
697 | test_plugin_namestore_postgres.conf \ | 697 | test_plugin_namestore_postgres.conf \ |
698 | test_plugin_namestore_heap.conf \ | 698 | test_plugin_namestore_flat.conf \ |
699 | test_hostkey \ | 699 | test_hostkey \ |
700 | zonefiles/S5I9DSGQVAB5FVV16T3B3CC5H1B2JGL3Q412JBKURME8EKU0600G.zkey \ | 700 | zonefiles/S5I9DSGQVAB5FVV16T3B3CC5H1B2JGL3Q412JBKURME8EKU0600G.zkey \ |
701 | zonefiles/AQ835GVL939H4O8QJQ7GBLPTQC0QAAO91BN7QK01BA63MDSK6I4G.zkey \ | 701 | zonefiles/AQ835GVL939H4O8QJQ7GBLPTQC0QAAO91BN7QK01BA63MDSK6I4G.zkey \ |
diff --git a/src/namestore/perf_namestore_api_heap.conf b/src/namestore/perf_namestore_api_flat.conf index a12761a7f..30759ce7a 100644 --- a/src/namestore/perf_namestore_api_heap.conf +++ b/src/namestore/perf_namestore_api_flat.conf | |||
@@ -1,7 +1,7 @@ | |||
1 | @INLINE@ test_namestore_api.conf | 1 | @INLINE@ test_namestore_api.conf |
2 | 2 | ||
3 | [namestore] | 3 | [namestore] |
4 | DATABASE = heap | 4 | DATABASE = flat |
5 | 5 | ||
6 | [namecache] | 6 | [namecache] |
7 | DISABLE = YES | 7 | DISABLE = YES |
diff --git a/src/namestore/plugin_namestore_heap.c b/src/namestore/plugin_namestore_flat.c index 2a72c0e51..4e1d33907 100644 --- a/src/namestore/plugin_namestore_heap.c +++ b/src/namestore/plugin_namestore_flat.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of GNUnet | 2 | * This file is part of GNUnet |
3 | * Copyright (C) 2009-2015, 2018 GNUnet e.V. | 3 | * Copyright (C) 2009-2015, 2018, 2019 GNUnet e.V. |
4 | * | 4 | * |
5 | * GNUnet is free software: you can redistribute it and/or modify it | 5 | * GNUnet is free software: you can redistribute it and/or modify it |
6 | * under the terms of the GNU Affero General Public License as published | 6 | * under the terms of the GNU Affero General Public License as published |
@@ -17,9 +17,8 @@ | |||
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file namestore/plugin_namestore_heap.c | 21 | * @file namestore/plugin_namestore_flat.c |
23 | * @brief file-based namestore backend | 22 | * @brief file-based namestore backend |
24 | * @author Martin Schanzenbach | 23 | * @author Martin Schanzenbach |
25 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
@@ -125,7 +124,7 @@ hash_pkey_and_label (const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | |||
125 | static int | 124 | static int |
126 | database_setup (struct Plugin *plugin) | 125 | database_setup (struct Plugin *plugin) |
127 | { | 126 | { |
128 | char *afsdir; | 127 | char *flatdbfile; |
129 | char *record_data; | 128 | char *record_data; |
130 | char *zone_private_key; | 129 | char *zone_private_key; |
131 | char *record_data_b64; | 130 | char *record_data_b64; |
@@ -139,36 +138,37 @@ database_setup (struct Plugin *plugin) | |||
139 | struct GNUNET_HashCode hkey; | 138 | struct GNUNET_HashCode hkey; |
140 | struct GNUNET_DISK_FileHandle *fh; | 139 | struct GNUNET_DISK_FileHandle *fh; |
141 | struct FlatFileEntry *entry; | 140 | struct FlatFileEntry *entry; |
141 | struct GNUNET_DISK_MapHandle *mh; | ||
142 | 142 | ||
143 | if (GNUNET_OK != | 143 | if (GNUNET_OK != |
144 | GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, | 144 | GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, |
145 | "namestore-heap", | 145 | "namestore-flat", |
146 | "FILENAME", | 146 | "FILENAME", |
147 | &afsdir)) | 147 | &flatdbfile)) |
148 | { | 148 | { |
149 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 149 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
150 | "namestore-heap", | 150 | "namestore-flat", |
151 | "FILENAME"); | 151 | "FILENAME"); |
152 | return GNUNET_SYSERR; | 152 | return GNUNET_SYSERR; |
153 | } | 153 | } |
154 | if (GNUNET_OK != | 154 | if (GNUNET_OK != |
155 | GNUNET_DISK_file_test (afsdir)) | 155 | GNUNET_DISK_file_test (flatdbfile)) |
156 | { | 156 | { |
157 | if (GNUNET_OK != | 157 | if (GNUNET_OK != |
158 | GNUNET_DISK_directory_create_for_file (afsdir)) | 158 | GNUNET_DISK_directory_create_for_file (flatdbfile)) |
159 | { | 159 | { |
160 | GNUNET_break (0); | 160 | GNUNET_break (0); |
161 | GNUNET_free (afsdir); | 161 | GNUNET_free (flatdbfile); |
162 | return GNUNET_SYSERR; | 162 | return GNUNET_SYSERR; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | /* afsdir should be UTF-8-encoded. If it isn't, it's a bug */ | 165 | /* flatdbfile should be UTF-8-encoded. If it isn't, it's a bug */ |
166 | plugin->fn = afsdir; | 166 | plugin->fn = flatdbfile; |
167 | 167 | ||
168 | /* Load data from file into hashmap */ | 168 | /* Load data from file into hashmap */ |
169 | plugin->hm = GNUNET_CONTAINER_multihashmap_create (10, | 169 | plugin->hm = GNUNET_CONTAINER_multihashmap_create (10, |
170 | GNUNET_NO); | 170 | GNUNET_NO); |
171 | fh = GNUNET_DISK_file_open (afsdir, | 171 | fh = GNUNET_DISK_file_open (flatdbfile, |
172 | GNUNET_DISK_OPEN_CREATE | | 172 | GNUNET_DISK_OPEN_CREATE | |
173 | GNUNET_DISK_OPEN_READWRITE, | 173 | GNUNET_DISK_OPEN_READWRITE, |
174 | GNUNET_DISK_PERM_USER_WRITE | | 174 | GNUNET_DISK_PERM_USER_WRITE | |
@@ -177,137 +177,152 @@ database_setup (struct Plugin *plugin) | |||
177 | { | 177 | { |
178 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 178 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
179 | _("Unable to initialize file: %s.\n"), | 179 | _("Unable to initialize file: %s.\n"), |
180 | afsdir); | 180 | flatdbfile); |
181 | return GNUNET_SYSERR; | 181 | return GNUNET_SYSERR; |
182 | } | 182 | } |
183 | if (GNUNET_SYSERR == | 183 | if (GNUNET_SYSERR == |
184 | GNUNET_DISK_file_size (afsdir, | 184 | GNUNET_DISK_file_size (flatdbfile, |
185 | &size, | 185 | &size, |
186 | GNUNET_YES, | 186 | GNUNET_YES, |
187 | GNUNET_YES)) | 187 | GNUNET_YES)) |
188 | { | 188 | { |
189 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 189 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
190 | _("Unable to get filesize: %s.\n"), | 190 | _("Unable to get filesize: %s.\n"), |
191 | afsdir); | 191 | flatdbfile); |
192 | GNUNET_DISK_file_close (fh); | 192 | GNUNET_DISK_file_close (fh); |
193 | return GNUNET_SYSERR; | 193 | return GNUNET_SYSERR; |
194 | } | 194 | } |
195 | 195 | if (size > SIZE_MAX) | |
196 | buffer = GNUNET_malloc_large (size + 1); | ||
197 | if (GNUNET_SYSERR == | ||
198 | GNUNET_DISK_file_read (fh, | ||
199 | buffer, | ||
200 | size)) | ||
201 | { | 196 | { |
202 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 197 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
203 | _("Unable to read file: %s.\n"), | 198 | _("File too big to map: %llu bytes.\n"), |
204 | afsdir); | 199 | (unsigned long long) size); |
205 | GNUNET_free (buffer); | 200 | GNUNET_DISK_file_close (fh); |
201 | return GNUNET_SYSERR; | ||
202 | } | ||
203 | if (0 == size) | ||
204 | { | ||
205 | GNUNET_DISK_file_close (fh); | ||
206 | return GNUNET_OK; | ||
207 | } | ||
208 | buffer = GNUNET_DISK_file_map (fh, | ||
209 | &mh, | ||
210 | GNUNET_DISK_MAP_TYPE_READ, | ||
211 | size); | ||
212 | if (NULL == buffer) | ||
213 | { | ||
214 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
215 | "mmap"); | ||
216 | GNUNET_DISK_file_close (fh); | ||
217 | return GNUNET_SYSERR; | ||
218 | } | ||
219 | if ('\0' != buffer[size-1]) | ||
220 | { | ||
221 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
222 | _("Namestore database file `%s' malformed\n"), | ||
223 | flatdbfile); | ||
224 | GNUNET_DISK_file_unmap (mh); | ||
206 | GNUNET_DISK_file_close (fh); | 225 | GNUNET_DISK_file_close (fh); |
207 | return GNUNET_SYSERR; | 226 | return GNUNET_SYSERR; |
208 | } | 227 | } |
209 | buffer[size] = '\0'; | ||
210 | GNUNET_DISK_file_close (fh); | ||
211 | 228 | ||
212 | if (0 < size) | 229 | line = strtok (buffer, "\n"); |
230 | while (NULL != line) | ||
213 | { | 231 | { |
214 | line = strtok (buffer, "\n"); | 232 | zone_private_key = strtok (line, ","); |
215 | while (line != NULL) | 233 | if (NULL == zone_private_key) |
234 | break; | ||
235 | rvalue = strtok (NULL, ","); | ||
236 | if (NULL == rvalue) | ||
237 | break; | ||
238 | record_count = strtok (NULL, ","); | ||
239 | if (NULL == record_count) | ||
240 | break; | ||
241 | record_data_b64 = strtok (NULL, ","); | ||
242 | if (NULL == record_data_b64) | ||
243 | break; | ||
244 | label = strtok (NULL, ","); | ||
245 | if (NULL == label) | ||
246 | break; | ||
247 | line = strtok (NULL, "\n"); | ||
248 | entry = GNUNET_new (struct FlatFileEntry); | ||
216 | { | 249 | { |
217 | zone_private_key = strtok (line, ","); | 250 | unsigned long long ll; |
218 | if (NULL == zone_private_key) | 251 | |
219 | break; | 252 | if (1 != sscanf (rvalue, |
220 | rvalue = strtok (NULL, ","); | 253 | "%llu", |
221 | if (NULL == rvalue) | 254 | &ll)) |
222 | break; | ||
223 | record_count = strtok (NULL, ","); | ||
224 | if (NULL == record_count) | ||
225 | break; | ||
226 | record_data_b64 = strtok (NULL, ","); | ||
227 | if (NULL == record_data_b64) | ||
228 | break; | ||
229 | label = strtok (NULL, ","); | ||
230 | if (NULL == label) | ||
231 | break; | ||
232 | line = strtok (NULL, "\n"); | ||
233 | entry = GNUNET_new (struct FlatFileEntry); | ||
234 | { | ||
235 | unsigned long long ll; | ||
236 | |||
237 | if (1 != sscanf (rvalue, | ||
238 | "%llu", | ||
239 | &ll)) | ||
240 | { | ||
241 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
242 | "Error parsing entry\n"); | ||
243 | GNUNET_free (entry); | ||
244 | break; | ||
245 | } | ||
246 | entry->rvalue = (uint64_t) ll; | ||
247 | } | ||
248 | { | ||
249 | unsigned int ui; | ||
250 | |||
251 | if (1 != sscanf (record_count, | ||
252 | "%u", | ||
253 | &ui)) | ||
254 | { | ||
255 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
256 | "Error parsing entry\n"); | ||
257 | GNUNET_free (entry); | ||
258 | break; | ||
259 | } | ||
260 | entry->record_count = (uint32_t) ui; | ||
261 | } | ||
262 | entry->label = GNUNET_strdup (label); | ||
263 | record_data_size | ||
264 | = GNUNET_STRINGS_base64_decode (record_data_b64, | ||
265 | strlen (record_data_b64), | ||
266 | (void **) &record_data); | ||
267 | entry->record_data = | ||
268 | GNUNET_new_array (entry->record_count, | ||
269 | struct GNUNET_GNSRECORD_Data); | ||
270 | if (GNUNET_OK != | ||
271 | GNUNET_GNSRECORD_records_deserialize (record_data_size, | ||
272 | record_data, | ||
273 | entry->record_count, | ||
274 | entry->record_data)) | ||
275 | { | 255 | { |
276 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 256 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
277 | "Unable to deserialize record %s\n", | 257 | "Error parsing entry\n"); |
278 | label); | ||
279 | GNUNET_free (entry->label); | ||
280 | GNUNET_free (entry); | 258 | GNUNET_free (entry); |
281 | GNUNET_free (record_data); | ||
282 | break; | 259 | break; |
283 | } | 260 | } |
284 | GNUNET_free (record_data); | 261 | entry->rvalue = (uint64_t) ll; |
285 | 262 | } | |
286 | { | 263 | { |
287 | struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key; | 264 | unsigned int ui; |
288 | |||
289 | GNUNET_STRINGS_base64_decode (zone_private_key, | ||
290 | strlen (zone_private_key), | ||
291 | (void**)&private_key); | ||
292 | entry->private_key = *private_key; | ||
293 | GNUNET_free (private_key); | ||
294 | } | ||
295 | 265 | ||
296 | hash_pkey_and_label (&entry->private_key, | 266 | if (1 != sscanf (record_count, |
297 | label, | 267 | "%u", |
298 | &hkey); | 268 | &ui)) |
299 | if (GNUNET_OK != | ||
300 | GNUNET_CONTAINER_multihashmap_put (plugin->hm, | ||
301 | &hkey, | ||
302 | entry, | ||
303 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | ||
304 | { | 269 | { |
270 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
271 | "Error parsing entry\n"); | ||
305 | GNUNET_free (entry); | 272 | GNUNET_free (entry); |
306 | GNUNET_break (0); | 273 | break; |
307 | } | 274 | } |
275 | entry->record_count = (uint32_t) ui; | ||
276 | } | ||
277 | entry->label = GNUNET_strdup (label); | ||
278 | record_data_size | ||
279 | = GNUNET_STRINGS_base64_decode (record_data_b64, | ||
280 | strlen (record_data_b64), | ||
281 | (void **) &record_data); | ||
282 | entry->record_data = | ||
283 | GNUNET_new_array (entry->record_count, | ||
284 | struct GNUNET_GNSRECORD_Data); | ||
285 | if (GNUNET_OK != | ||
286 | GNUNET_GNSRECORD_records_deserialize (record_data_size, | ||
287 | record_data, | ||
288 | entry->record_count, | ||
289 | entry->record_data)) | ||
290 | { | ||
291 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
292 | "Unable to deserialize record %s\n", | ||
293 | label); | ||
294 | GNUNET_free (entry->label); | ||
295 | GNUNET_free (entry); | ||
296 | GNUNET_free (record_data); | ||
297 | break; | ||
298 | } | ||
299 | GNUNET_free (record_data); | ||
300 | |||
301 | { | ||
302 | struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key; | ||
303 | |||
304 | GNUNET_STRINGS_base64_decode (zone_private_key, | ||
305 | strlen (zone_private_key), | ||
306 | (void**)&private_key); | ||
307 | entry->private_key = *private_key; | ||
308 | GNUNET_free (private_key); | ||
309 | } | ||
310 | |||
311 | hash_pkey_and_label (&entry->private_key, | ||
312 | label, | ||
313 | &hkey); | ||
314 | if (GNUNET_OK != | ||
315 | GNUNET_CONTAINER_multihashmap_put (plugin->hm, | ||
316 | &hkey, | ||
317 | entry, | ||
318 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | ||
319 | { | ||
320 | GNUNET_free (entry); | ||
321 | GNUNET_break (0); | ||
308 | } | 322 | } |
309 | } | 323 | } |
310 | GNUNET_free (buffer); | 324 | GNUNET_DISK_file_unmap (mh); |
325 | GNUNET_DISK_file_close (fh); | ||
311 | return GNUNET_OK; | 326 | return GNUNET_OK; |
312 | } | 327 | } |
313 | 328 | ||
@@ -418,6 +433,10 @@ database_shutdown (struct Plugin *plugin) | |||
418 | &store_and_free_entries, | 433 | &store_and_free_entries, |
419 | fh); | 434 | fh); |
420 | GNUNET_CONTAINER_multihashmap_destroy (plugin->hm); | 435 | GNUNET_CONTAINER_multihashmap_destroy (plugin->hm); |
436 | /* append 0-terminator */ | ||
437 | GNUNET_DISK_file_write (fh, | ||
438 | "", | ||
439 | 1); | ||
421 | GNUNET_DISK_file_close (fh); | 440 | GNUNET_DISK_file_close (fh); |
422 | } | 441 | } |
423 | 442 | ||
@@ -434,7 +453,7 @@ database_shutdown (struct Plugin *plugin) | |||
434 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 453 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
435 | */ | 454 | */ |
436 | static int | 455 | static int |
437 | namestore_heap_store_records (void *cls, | 456 | namestore_flat_store_records (void *cls, |
438 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 457 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
439 | const char *label, | 458 | const char *label, |
440 | unsigned int rd_count, | 459 | unsigned int rd_count, |
@@ -499,7 +518,7 @@ namestore_heap_store_records (void *cls, | |||
499 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | 518 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR |
500 | */ | 519 | */ |
501 | static int | 520 | static int |
502 | namestore_heap_lookup_records (void *cls, | 521 | namestore_flat_lookup_records (void *cls, |
503 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 522 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
504 | const char *label, | 523 | const char *label, |
505 | GNUNET_NAMESTORE_RecordIterator iter, | 524 | GNUNET_NAMESTORE_RecordIterator iter, |
@@ -573,7 +592,7 @@ struct IterateContext | |||
573 | 592 | ||
574 | 593 | ||
575 | /** | 594 | /** |
576 | * Helper function for #namestore_heap_iterate_records(). | 595 | * Helper function for #namestore_flat_iterate_records(). |
577 | * | 596 | * |
578 | * @param cls a `struct IterateContext` | 597 | * @param cls a `struct IterateContext` |
579 | * @param key unused | 598 | * @param key unused |
@@ -629,7 +648,7 @@ iterate_zones (void *cls, | |||
629 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error | 648 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error |
630 | */ | 649 | */ |
631 | static int | 650 | static int |
632 | namestore_heap_iterate_records (void *cls, | 651 | namestore_flat_iterate_records (void *cls, |
633 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 652 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
634 | uint64_t serial, | 653 | uint64_t serial, |
635 | uint64_t limit, | 654 | uint64_t limit, |
@@ -712,7 +731,7 @@ zone_to_name (void *cls, | |||
712 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error | 731 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error |
713 | */ | 732 | */ |
714 | static int | 733 | static int |
715 | namestore_heap_zone_to_name (void *cls, | 734 | namestore_flat_zone_to_name (void *cls, |
716 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 735 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
717 | const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, | 736 | const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, |
718 | GNUNET_NAMESTORE_RecordIterator iter, | 737 | GNUNET_NAMESTORE_RecordIterator iter, |
@@ -744,7 +763,7 @@ namestore_heap_zone_to_name (void *cls, | |||
744 | * @return NULL on error, otherwise the plugin context | 763 | * @return NULL on error, otherwise the plugin context |
745 | */ | 764 | */ |
746 | void * | 765 | void * |
747 | libgnunet_plugin_namestore_heap_init (void *cls) | 766 | libgnunet_plugin_namestore_flat_init (void *cls) |
748 | { | 767 | { |
749 | static struct Plugin plugin; | 768 | static struct Plugin plugin; |
750 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 769 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
@@ -763,12 +782,12 @@ libgnunet_plugin_namestore_heap_init (void *cls) | |||
763 | } | 782 | } |
764 | api = GNUNET_new (struct GNUNET_NAMESTORE_PluginFunctions); | 783 | api = GNUNET_new (struct GNUNET_NAMESTORE_PluginFunctions); |
765 | api->cls = &plugin; | 784 | api->cls = &plugin; |
766 | api->store_records = &namestore_heap_store_records; | 785 | api->store_records = &namestore_flat_store_records; |
767 | api->iterate_records = &namestore_heap_iterate_records; | 786 | api->iterate_records = &namestore_flat_iterate_records; |
768 | api->zone_to_name = &namestore_heap_zone_to_name; | 787 | api->zone_to_name = &namestore_flat_zone_to_name; |
769 | api->lookup_records = &namestore_heap_lookup_records; | 788 | api->lookup_records = &namestore_flat_lookup_records; |
770 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 789 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
771 | _("heap file database running\n")); | 790 | _("Flat file database running\n")); |
772 | return api; | 791 | return api; |
773 | } | 792 | } |
774 | 793 | ||
@@ -780,7 +799,7 @@ libgnunet_plugin_namestore_heap_init (void *cls) | |||
780 | * @return always NULL | 799 | * @return always NULL |
781 | */ | 800 | */ |
782 | void * | 801 | void * |
783 | libgnunet_plugin_namestore_heap_done (void *cls) | 802 | libgnunet_plugin_namestore_flat_done (void *cls) |
784 | { | 803 | { |
785 | struct GNUNET_NAMESTORE_PluginFunctions *api = cls; | 804 | struct GNUNET_NAMESTORE_PluginFunctions *api = cls; |
786 | struct Plugin *plugin = api->cls; | 805 | struct Plugin *plugin = api->cls; |
@@ -789,8 +808,8 @@ libgnunet_plugin_namestore_heap_done (void *cls) | |||
789 | plugin->cfg = NULL; | 808 | plugin->cfg = NULL; |
790 | GNUNET_free (api); | 809 | GNUNET_free (api); |
791 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 810 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
792 | "heap file plugin is finished\n"); | 811 | "Flat file plugin is finished\n"); |
793 | return NULL; | 812 | return NULL; |
794 | } | 813 | } |
795 | 814 | ||
796 | /* end of plugin_namestore_heap.c */ | 815 | /* end of plugin_namestore_flat.c */ |
diff --git a/src/namestore/test_namestore_api_heap.conf b/src/namestore/test_namestore_api_flat.conf index 1d6173e74..8460d143c 100644 --- a/src/namestore/test_namestore_api_heap.conf +++ b/src/namestore/test_namestore_api_flat.conf | |||
@@ -1,7 +1,7 @@ | |||
1 | @INLINE@ test_namestore_api.conf | 1 | @INLINE@ test_namestore_api.conf |
2 | 2 | ||
3 | [namestore] | 3 | [namestore] |
4 | DATABASE = heap | 4 | DATABASE = flat |
5 | 5 | ||
6 | [namestore-heap] | 6 | [namestore-heap] |
7 | FILENAME = $GNUNET_TEST_HOME/namestore/flat.db | 7 | FILENAME = $GNUNET_TEST_HOME/namestore/flat.db |
diff --git a/src/namestore/test_plugin_namestore_heap.conf b/src/namestore/test_plugin_namestore_flat.conf index 94f79b9aa..5c632f0d1 100644 --- a/src/namestore/test_plugin_namestore_heap.conf +++ b/src/namestore/test_plugin_namestore_flat.conf | |||
@@ -1,2 +1,2 @@ | |||
1 | [namestore-heap] | 1 | [namestore-flat] |
2 | FILENAME = $GNUNET_TMP/gnunet-test-plugin-namestore-flat/flatdb | 2 | FILENAME = $GNUNET_TMP/gnunet-test-plugin-namestore-flat/flatdb |