aboutsummaryrefslogtreecommitdiff
path: root/src/datacache
diff options
context:
space:
mode:
Diffstat (limited to 'src/datacache')
-rw-r--r--src/datacache/Makefile.am69
-rw-r--r--src/datacache/Makefile.in337
-rw-r--r--src/datacache/datacache.c74
-rw-r--r--src/datacache/datacache.conf8
-rw-r--r--src/datacache/perf_datacache.c61
-rw-r--r--src/datacache/perf_datacache_data_heap.conf5
-rw-r--r--src/datacache/perf_datacache_data_mysql.conf13
-rw-r--r--src/datacache/plugin_datacache_heap.c441
-rw-r--r--src/datacache/plugin_datacache_mysql.c474
-rw-r--r--src/datacache/plugin_datacache_postgres.c85
-rw-r--r--src/datacache/plugin_datacache_sqlite.c126
-rw-r--r--src/datacache/plugin_datacache_template.c16
-rw-r--r--src/datacache/test_datacache.c68
-rw-r--r--src/datacache/test_datacache_data_heap.conf4
-rw-r--r--src/datacache/test_datacache_data_mysql.conf13
-rw-r--r--src/datacache/test_datacache_quota.c40
16 files changed, 933 insertions, 901 deletions
diff --git a/src/datacache/Makefile.am b/src/datacache/Makefile.am
index d34e6e8..c6c27b3 100644
--- a/src/datacache/Makefile.am
+++ b/src/datacache/Makefile.am
@@ -19,9 +19,6 @@ endif
if HAVE_SQLITE
SQLITE_PLUGIN = libgnunet_plugin_datacache_sqlite.la
endif
-if HAVE_MYSQL
- MYSQL_PLUGIN = libgnunet_plugin_datacache_mysql.la
-endif
if HAVE_POSTGRES
POSTGRES_PLUGIN = libgnunet_plugin_datacache_postgres.la
endif
@@ -42,8 +39,8 @@ libgnunetdatacache_la_LDFLAGS = \
plugin_LTLIBRARIES = \
$(SQLITE_PLUGIN) \
- $(MYSQL_PLUGIN) \
$(POSTGRES_PLUGIN) \
+ libgnunet_plugin_datacache_heap.la \
libgnunet_plugin_datacache_template.la
@@ -51,21 +48,19 @@ libgnunet_plugin_datacache_sqlite_la_SOURCES = \
plugin_datacache_sqlite.c
libgnunet_plugin_datacache_sqlite_la_LIBADD = \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 \
+ $(LTLIBINTL)
libgnunet_plugin_datacache_sqlite_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_datacache_mysql_la_SOURCES = \
- plugin_datacache_mysql.c
-libgnunet_plugin_datacache_mysql_la_LIBADD = \
+libgnunet_plugin_datacache_heap_la_SOURCES = \
+ plugin_datacache_heap.c
+libgnunet_plugin_datacache_heap_la_LIBADD = \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/mysql/libgnunetmysql.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient
-libgnunet_plugin_datacache_mysql_la_CPPFLAGS = \
- $(MYSQL_CPPFLAGS)
-libgnunet_plugin_datacache_mysql_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL)
+libgnunet_plugin_datacache_heap_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
libgnunet_plugin_datacache_postgres_la_SOURCES = \
plugin_datacache_postgres.c
@@ -82,7 +77,8 @@ libgnunet_plugin_datacache_postgres_la_LDFLAGS = \
libgnunet_plugin_datacache_template_la_SOURCES = \
plugin_datacache_template.c
libgnunet_plugin_datacache_template_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS)
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL)
libgnunet_plugin_datacache_template_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
@@ -98,16 +94,14 @@ SQLITE_TESTS = \
$(SQLITE_BENCHMARKS)
endif
-if HAVE_MYSQL
if HAVE_BENCHMARKS
- MYSQL_BENCHMARKS = \
- perf_datacache_mysql
-endif
-MYSQL_TESTS = \
- test_datacache_mysql \
- test_datacache_quota_mysql \
- $(MYSQL_BENCHMARKS)
+ HEAP_BENCHMARKS = \
+ perf_datacache_heap
endif
+HEAP_TESTS = \
+ test_datacache_heap \
+ test_datacache_quota_heap \
+ $(HEAP_BENCHMARKS)
if HAVE_POSTGRES
if HAVE_BENCHMARKS
@@ -122,7 +116,7 @@ endif
check_PROGRAMS = \
$(SQLITE_TESTS) \
- $(MYSQL_TESTS) \
+ $(HEAP_TESTS) \
$(POSTGRES_TESTS)
if ENABLE_TEST_RUN
@@ -132,61 +126,70 @@ endif
test_datacache_sqlite_SOURCES = \
test_datacache.c
test_datacache_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
test_datacache_quota_sqlite_SOURCES = \
test_datacache_quota.c
test_datacache_quota_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
perf_datacache_sqlite_SOURCES = \
perf_datacache.c
perf_datacache_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
-test_datacache_mysql_SOURCES = \
+test_datacache_heap_SOURCES = \
test_datacache.c
-test_datacache_mysql_LDADD = \
+test_datacache_heap_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
-test_datacache_quota_mysql_SOURCES = \
+test_datacache_quota_heap_SOURCES = \
test_datacache_quota.c
-test_datacache_quota_mysql_LDADD = \
+test_datacache_quota_heap_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
-perf_datacache_mysql_SOURCES = \
+perf_datacache_heap_SOURCES = \
perf_datacache.c
-perf_datacache_mysql_LDADD = \
+perf_datacache_heap_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
test_datacache_postgres_SOURCES = \
test_datacache.c
test_datacache_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
test_datacache_quota_postgres_SOURCES = \
test_datacache_quota.c
test_datacache_quota_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
perf_datacache_postgres_SOURCES = \
perf_datacache.c
perf_datacache_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
EXTRA_DIST = \
test_datacache_data_sqlite.conf \
perf_datacache_data_sqlite.conf \
- test_datacache_data_mysql.conf \
- perf_datacache_data_mysql.conf \
+ test_datacache_data_heap.conf \
+ perf_datacache_data_heap.conf \
test_datacache_data_postgres.conf \
perf_datacache_data_postgres.conf
diff --git a/src/datacache/Makefile.in b/src/datacache/Makefile.in
index 2acd972..a564d52 100644
--- a/src/datacache/Makefile.in
+++ b/src/datacache/Makefile.in
@@ -1,9 +1,9 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -17,6 +17,23 @@
VPATH = @srcdir@
+am__make_dryrun = \
+ { \
+ am__dry=no; \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
+ esac; \
+ test $$am__dry = yes; \
+ }
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -43,14 +60,15 @@ DIST_COMMON = $(dist_pkgcfg_DATA) $(srcdir)/Makefile.am \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/absolute-header.m4 \
$(top_srcdir)/m4/align.m4 $(top_srcdir)/m4/argz.m4 \
- $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \
- $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcurl.m4 \
- $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libtool.m4 \
- $(top_srcdir)/m4/libunistring.m4 $(top_srcdir)/m4/ltdl.m4 \
- $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
- $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
- $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
+ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glib-2.0.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libgcrypt.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/libunistring.m4 \
+ $(top_srcdir)/m4/ltdl.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -80,29 +98,31 @@ am__nobase_list = $(am__nobase_strip_setup); \
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(plugindir)" \
"$(DESTDIR)$(pkgcfgdir)"
LTLIBRARIES = $(lib_LTLIBRARIES) $(plugin_LTLIBRARIES)
am__DEPENDENCIES_1 =
-libgnunet_plugin_datacache_mysql_la_DEPENDENCIES = \
+libgnunet_plugin_datacache_heap_la_DEPENDENCIES = \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/mysql/libgnunetmysql.la \
$(top_builddir)/src/util/libgnunetutil.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-am_libgnunet_plugin_datacache_mysql_la_OBJECTS = \
- libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.lo
-libgnunet_plugin_datacache_mysql_la_OBJECTS = \
- $(am_libgnunet_plugin_datacache_mysql_la_OBJECTS)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am_libgnunet_plugin_datacache_heap_la_OBJECTS = \
+ plugin_datacache_heap.lo
+libgnunet_plugin_datacache_heap_la_OBJECTS = \
+ $(am_libgnunet_plugin_datacache_heap_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
-libgnunet_plugin_datacache_mysql_la_LINK = $(LIBTOOL) $(AM_V_lt) \
+libgnunet_plugin_datacache_heap_la_LINK = $(LIBTOOL) $(AM_V_lt) \
--tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
$(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(libgnunet_plugin_datacache_mysql_la_LDFLAGS) $(LDFLAGS) -o \
- $@
-@HAVE_MYSQL_TRUE@am_libgnunet_plugin_datacache_mysql_la_rpath = \
-@HAVE_MYSQL_TRUE@ -rpath $(plugindir)
+ $(libgnunet_plugin_datacache_heap_la_LDFLAGS) $(LDFLAGS) -o $@
libgnunet_plugin_datacache_postgres_la_DEPENDENCIES = \
$(top_builddir)/src/postgres/libgnunetpostgres.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
@@ -121,7 +141,7 @@ libgnunet_plugin_datacache_postgres_la_LINK = $(LIBTOOL) $(AM_V_lt) \
libgnunet_plugin_datacache_sqlite_la_DEPENDENCIES = \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/util/libgnunetutil.la \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am_libgnunet_plugin_datacache_sqlite_la_OBJECTS = \
plugin_datacache_sqlite.lo
libgnunet_plugin_datacache_sqlite_la_OBJECTS = \
@@ -135,7 +155,7 @@ libgnunet_plugin_datacache_sqlite_la_LINK = $(LIBTOOL) $(AM_V_lt) \
@HAVE_SQLITE_TRUE@ -rpath $(plugindir)
libgnunet_plugin_datacache_template_la_DEPENDENCIES = \
$(top_builddir)/src/util/libgnunetutil.la \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am_libgnunet_plugin_datacache_template_la_OBJECTS = \
plugin_datacache_template.lo
libgnunet_plugin_datacache_template_la_OBJECTS = \
@@ -159,46 +179,50 @@ libgnunetdatacache_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
@HAVE_SQLITE_TRUE@am__EXEEXT_2 = test_datacache_sqlite$(EXEEXT) \
@HAVE_SQLITE_TRUE@ test_datacache_quota_sqlite$(EXEEXT) \
@HAVE_SQLITE_TRUE@ $(am__EXEEXT_1)
-@HAVE_BENCHMARKS_TRUE@@HAVE_MYSQL_TRUE@am__EXEEXT_3 = perf_datacache_mysql$(EXEEXT)
-@HAVE_MYSQL_TRUE@am__EXEEXT_4 = test_datacache_mysql$(EXEEXT) \
-@HAVE_MYSQL_TRUE@ test_datacache_quota_mysql$(EXEEXT) \
-@HAVE_MYSQL_TRUE@ $(am__EXEEXT_3)
+@HAVE_BENCHMARKS_TRUE@am__EXEEXT_3 = perf_datacache_heap$(EXEEXT)
+am__EXEEXT_4 = test_datacache_heap$(EXEEXT) \
+ test_datacache_quota_heap$(EXEEXT) $(am__EXEEXT_3)
@HAVE_BENCHMARKS_TRUE@@HAVE_POSTGRES_TRUE@am__EXEEXT_5 = perf_datacache_postgres$(EXEEXT)
@HAVE_POSTGRES_TRUE@am__EXEEXT_6 = test_datacache_postgres$(EXEEXT) \
@HAVE_POSTGRES_TRUE@ test_datacache_quota_postgres$(EXEEXT) \
@HAVE_POSTGRES_TRUE@ $(am__EXEEXT_5)
-am_perf_datacache_mysql_OBJECTS = perf_datacache.$(OBJEXT)
-perf_datacache_mysql_OBJECTS = $(am_perf_datacache_mysql_OBJECTS)
-perf_datacache_mysql_DEPENDENCIES = \
+am_perf_datacache_heap_OBJECTS = perf_datacache.$(OBJEXT)
+perf_datacache_heap_OBJECTS = $(am_perf_datacache_heap_OBJECTS)
+perf_datacache_heap_DEPENDENCIES = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
am_perf_datacache_postgres_OBJECTS = perf_datacache.$(OBJEXT)
perf_datacache_postgres_OBJECTS = \
$(am_perf_datacache_postgres_OBJECTS)
perf_datacache_postgres_DEPENDENCIES = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
am_perf_datacache_sqlite_OBJECTS = perf_datacache.$(OBJEXT)
perf_datacache_sqlite_OBJECTS = $(am_perf_datacache_sqlite_OBJECTS)
perf_datacache_sqlite_DEPENDENCIES = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
-am_test_datacache_mysql_OBJECTS = test_datacache.$(OBJEXT)
-test_datacache_mysql_OBJECTS = $(am_test_datacache_mysql_OBJECTS)
-test_datacache_mysql_DEPENDENCIES = \
+am_test_datacache_heap_OBJECTS = test_datacache.$(OBJEXT)
+test_datacache_heap_OBJECTS = $(am_test_datacache_heap_OBJECTS)
+test_datacache_heap_DEPENDENCIES = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
am_test_datacache_postgres_OBJECTS = test_datacache.$(OBJEXT)
test_datacache_postgres_OBJECTS = \
$(am_test_datacache_postgres_OBJECTS)
test_datacache_postgres_DEPENDENCIES = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
-am_test_datacache_quota_mysql_OBJECTS = \
- test_datacache_quota.$(OBJEXT)
-test_datacache_quota_mysql_OBJECTS = \
- $(am_test_datacache_quota_mysql_OBJECTS)
-test_datacache_quota_mysql_DEPENDENCIES = \
+am_test_datacache_quota_heap_OBJECTS = test_datacache_quota.$(OBJEXT)
+test_datacache_quota_heap_OBJECTS = \
+ $(am_test_datacache_quota_heap_OBJECTS)
+test_datacache_quota_heap_DEPENDENCIES = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
am_test_datacache_quota_postgres_OBJECTS = \
@@ -206,6 +230,7 @@ am_test_datacache_quota_postgres_OBJECTS = \
test_datacache_quota_postgres_OBJECTS = \
$(am_test_datacache_quota_postgres_OBJECTS)
test_datacache_quota_postgres_DEPENDENCIES = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
am_test_datacache_quota_sqlite_OBJECTS = \
@@ -213,11 +238,13 @@ am_test_datacache_quota_sqlite_OBJECTS = \
test_datacache_quota_sqlite_OBJECTS = \
$(am_test_datacache_quota_sqlite_OBJECTS)
test_datacache_quota_sqlite_DEPENDENCIES = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
am_test_datacache_sqlite_OBJECTS = test_datacache.$(OBJEXT)
test_datacache_sqlite_OBJECTS = $(am_test_datacache_sqlite_OBJECTS)
test_datacache_sqlite_DEPENDENCIES = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -230,50 +257,55 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = $(libgnunet_plugin_datacache_mysql_la_SOURCES) \
+SOURCES = $(libgnunet_plugin_datacache_heap_la_SOURCES) \
$(libgnunet_plugin_datacache_postgres_la_SOURCES) \
$(libgnunet_plugin_datacache_sqlite_la_SOURCES) \
$(libgnunet_plugin_datacache_template_la_SOURCES) \
$(libgnunetdatacache_la_SOURCES) \
- $(perf_datacache_mysql_SOURCES) \
+ $(perf_datacache_heap_SOURCES) \
$(perf_datacache_postgres_SOURCES) \
$(perf_datacache_sqlite_SOURCES) \
- $(test_datacache_mysql_SOURCES) \
+ $(test_datacache_heap_SOURCES) \
$(test_datacache_postgres_SOURCES) \
- $(test_datacache_quota_mysql_SOURCES) \
+ $(test_datacache_quota_heap_SOURCES) \
$(test_datacache_quota_postgres_SOURCES) \
$(test_datacache_quota_sqlite_SOURCES) \
$(test_datacache_sqlite_SOURCES)
-DIST_SOURCES = $(libgnunet_plugin_datacache_mysql_la_SOURCES) \
+DIST_SOURCES = $(libgnunet_plugin_datacache_heap_la_SOURCES) \
$(libgnunet_plugin_datacache_postgres_la_SOURCES) \
$(libgnunet_plugin_datacache_sqlite_la_SOURCES) \
$(libgnunet_plugin_datacache_template_la_SOURCES) \
$(libgnunetdatacache_la_SOURCES) \
- $(perf_datacache_mysql_SOURCES) \
+ $(perf_datacache_heap_SOURCES) \
$(perf_datacache_postgres_SOURCES) \
$(perf_datacache_sqlite_SOURCES) \
- $(test_datacache_mysql_SOURCES) \
+ $(test_datacache_heap_SOURCES) \
$(test_datacache_postgres_SOURCES) \
- $(test_datacache_quota_mysql_SOURCES) \
+ $(test_datacache_quota_heap_SOURCES) \
$(test_datacache_quota_postgres_SOURCES) \
$(test_datacache_quota_sqlite_SOURCES) \
$(test_datacache_sqlite_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
DATA = $(dist_pkgcfg_DATA)
ETAGS = etags
CTAGS = ctags
@@ -315,6 +347,10 @@ EXEEXT = @EXEEXT@
EXT_LIBS = @EXT_LIBS@
EXT_LIB_PATH = @EXT_LIB_PATH@
FGREP = @FGREP@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_MKENUMS = @GLIB_MKENUMS@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GNUNETDNS_GROUP = @GNUNETDNS_GROUP@
@@ -325,6 +361,7 @@ GN_LIBINTL = @GN_LIBINTL@
GN_LIB_LDFLAGS = @GN_LIB_LDFLAGS@
GN_PLUGIN_LDFLAGS = @GN_PLUGIN_LDFLAGS@
GN_USER_HOME_DIR = @GN_USER_HOME_DIR@
+GOBJECT_QUERY = @GOBJECT_QUERY@
GREP = @GREP@
HAVE_LIBUNISTRING = @HAVE_LIBUNISTRING@
INCLTDL = @INCLTDL@
@@ -347,6 +384,8 @@ LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
+LIBGTOP_CFLAGS = @LIBGTOP_CFLAGS@
+LIBGTOP_LIBS = @LIBGTOP_LIBS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBLTDL = @LIBLTDL@
@@ -368,6 +407,7 @@ LT_CONFIG_H = @LT_CONFIG_H@
LT_DLLOADERS = @LT_DLLOADERS@
LT_DLPREOPEN = @LT_DLPREOPEN@
MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MONKEYPREFIX = @MONKEYPREFIX@
MSGFMT = @MSGFMT@
@@ -377,6 +417,7 @@ MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
NM = @NM@
NMEDIT = @NMEDIT@
+NSS_DIR = @NSS_DIR@
OBJC = @OBJC@
OBJCDEPMODE = @OBJCDEPMODE@
OBJCFLAGS = @OBJCFLAGS@
@@ -392,6 +433,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
POSTGRES_CPPFLAGS = @POSTGRES_CPPFLAGS@
POSTGRES_LDFLAGS = @POSTGRES_LDFLAGS@
POSUB = @POSUB@
@@ -423,6 +465,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
@@ -445,6 +488,7 @@ datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+gitcommand = @gitcommand@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -458,7 +502,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
ltdl_LIBOBJS = @ltdl_LIBOBJS@
ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@
mandir = @mandir@
@@ -476,6 +519,7 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
subdirs = @subdirs@
+svnversioncommand = @svnversioncommand@
sys_symbol_underscore = @sys_symbol_underscore@
sysconfdir = @sysconfdir@
target = @target@
@@ -496,7 +540,6 @@ dist_pkgcfg_DATA = \
@USE_COVERAGE_TRUE@AM_CFLAGS = --coverage -O0
@USE_COVERAGE_TRUE@XLIBS = -lgcov
@HAVE_SQLITE_TRUE@SQLITE_PLUGIN = libgnunet_plugin_datacache_sqlite.la
-@HAVE_MYSQL_TRUE@MYSQL_PLUGIN = libgnunet_plugin_datacache_mysql.la
@HAVE_POSTGRES_TRUE@POSTGRES_PLUGIN = libgnunet_plugin_datacache_postgres.la
lib_LTLIBRARIES = \
libgnunetdatacache.la
@@ -515,8 +558,8 @@ libgnunetdatacache_la_LDFLAGS = \
plugin_LTLIBRARIES = \
$(SQLITE_PLUGIN) \
- $(MYSQL_PLUGIN) \
$(POSTGRES_PLUGIN) \
+ libgnunet_plugin_datacache_heap.la \
libgnunet_plugin_datacache_template.la
libgnunet_plugin_datacache_sqlite_la_SOURCES = \
@@ -524,25 +567,22 @@ libgnunet_plugin_datacache_sqlite_la_SOURCES = \
libgnunet_plugin_datacache_sqlite_la_LIBADD = \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 \
+ $(LTLIBINTL)
libgnunet_plugin_datacache_sqlite_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_datacache_mysql_la_SOURCES = \
- plugin_datacache_mysql.c
+libgnunet_plugin_datacache_heap_la_SOURCES = \
+ plugin_datacache_heap.c
-libgnunet_plugin_datacache_mysql_la_LIBADD = \
+libgnunet_plugin_datacache_heap_la_LIBADD = \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/mysql/libgnunetmysql.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL)
-libgnunet_plugin_datacache_mysql_la_CPPFLAGS = \
- $(MYSQL_CPPFLAGS)
-
-libgnunet_plugin_datacache_mysql_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient
+libgnunet_plugin_datacache_heap_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
libgnunet_plugin_datacache_postgres_la_SOURCES = \
plugin_datacache_postgres.c
@@ -563,7 +603,8 @@ libgnunet_plugin_datacache_template_la_SOURCES = \
plugin_datacache_template.c
libgnunet_plugin_datacache_template_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS)
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL)
libgnunet_plugin_datacache_template_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
@@ -576,13 +617,13 @@ libgnunet_plugin_datacache_template_la_LDFLAGS = \
@HAVE_SQLITE_TRUE@ test_datacache_quota_sqlite \
@HAVE_SQLITE_TRUE@ $(SQLITE_BENCHMARKS)
-@HAVE_BENCHMARKS_TRUE@@HAVE_MYSQL_TRUE@MYSQL_BENCHMARKS = \
-@HAVE_BENCHMARKS_TRUE@@HAVE_MYSQL_TRUE@ perf_datacache_mysql
+@HAVE_BENCHMARKS_TRUE@HEAP_BENCHMARKS = \
+@HAVE_BENCHMARKS_TRUE@ perf_datacache_heap
-@HAVE_MYSQL_TRUE@MYSQL_TESTS = \
-@HAVE_MYSQL_TRUE@ test_datacache_mysql \
-@HAVE_MYSQL_TRUE@ test_datacache_quota_mysql \
-@HAVE_MYSQL_TRUE@ $(MYSQL_BENCHMARKS)
+HEAP_TESTS = \
+ test_datacache_heap \
+ test_datacache_quota_heap \
+ $(HEAP_BENCHMARKS)
@HAVE_BENCHMARKS_TRUE@@HAVE_POSTGRES_TRUE@POSTGRES_BENCHMARKS = \
@HAVE_BENCHMARKS_TRUE@@HAVE_POSTGRES_TRUE@ perf_datacache_postgres
@@ -597,6 +638,7 @@ test_datacache_sqlite_SOURCES = \
test_datacache.c
test_datacache_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
@@ -604,6 +646,7 @@ test_datacache_quota_sqlite_SOURCES = \
test_datacache_quota.c
test_datacache_quota_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
@@ -611,27 +654,31 @@ perf_datacache_sqlite_SOURCES = \
perf_datacache.c
perf_datacache_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
-test_datacache_mysql_SOURCES = \
+test_datacache_heap_SOURCES = \
test_datacache.c
-test_datacache_mysql_LDADD = \
+test_datacache_heap_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
-test_datacache_quota_mysql_SOURCES = \
+test_datacache_quota_heap_SOURCES = \
test_datacache_quota.c
-test_datacache_quota_mysql_LDADD = \
+test_datacache_quota_heap_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
-perf_datacache_mysql_SOURCES = \
+perf_datacache_heap_SOURCES = \
perf_datacache.c
-perf_datacache_mysql_LDADD = \
+perf_datacache_heap_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
@@ -639,6 +686,7 @@ test_datacache_postgres_SOURCES = \
test_datacache.c
test_datacache_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
@@ -646,6 +694,7 @@ test_datacache_quota_postgres_SOURCES = \
test_datacache_quota.c
test_datacache_quota_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
@@ -653,14 +702,15 @@ perf_datacache_postgres_SOURCES = \
perf_datacache.c
perf_datacache_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/datacache/libgnunetdatacache.la \
$(top_builddir)/src/util/libgnunetutil.la
EXTRA_DIST = \
test_datacache_data_sqlite.conf \
perf_datacache_data_sqlite.conf \
- test_datacache_data_mysql.conf \
- perf_datacache_data_mysql.conf \
+ test_datacache_data_heap.conf \
+ perf_datacache_data_heap.conf \
test_datacache_data_postgres.conf \
perf_datacache_data_postgres.conf
@@ -700,7 +750,6 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
- test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
@@ -708,6 +757,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES)
else :; fi; \
done; \
test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
}
@@ -731,7 +782,6 @@ clean-libLTLIBRARIES:
done
install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
@$(NORMAL_INSTALL)
- test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)"
@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
@@ -739,6 +789,8 @@ install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
else :; fi; \
done; \
test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(plugindir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
}
@@ -760,15 +812,15 @@ clean-pluginLTLIBRARIES:
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
-libgnunet_plugin_datacache_mysql.la: $(libgnunet_plugin_datacache_mysql_la_OBJECTS) $(libgnunet_plugin_datacache_mysql_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libgnunet_plugin_datacache_mysql_la_LINK) $(am_libgnunet_plugin_datacache_mysql_la_rpath) $(libgnunet_plugin_datacache_mysql_la_OBJECTS) $(libgnunet_plugin_datacache_mysql_la_LIBADD) $(LIBS)
-libgnunet_plugin_datacache_postgres.la: $(libgnunet_plugin_datacache_postgres_la_OBJECTS) $(libgnunet_plugin_datacache_postgres_la_DEPENDENCIES)
+libgnunet_plugin_datacache_heap.la: $(libgnunet_plugin_datacache_heap_la_OBJECTS) $(libgnunet_plugin_datacache_heap_la_DEPENDENCIES) $(EXTRA_libgnunet_plugin_datacache_heap_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(libgnunet_plugin_datacache_heap_la_LINK) -rpath $(plugindir) $(libgnunet_plugin_datacache_heap_la_OBJECTS) $(libgnunet_plugin_datacache_heap_la_LIBADD) $(LIBS)
+libgnunet_plugin_datacache_postgres.la: $(libgnunet_plugin_datacache_postgres_la_OBJECTS) $(libgnunet_plugin_datacache_postgres_la_DEPENDENCIES) $(EXTRA_libgnunet_plugin_datacache_postgres_la_DEPENDENCIES)
$(AM_V_CCLD)$(libgnunet_plugin_datacache_postgres_la_LINK) $(am_libgnunet_plugin_datacache_postgres_la_rpath) $(libgnunet_plugin_datacache_postgres_la_OBJECTS) $(libgnunet_plugin_datacache_postgres_la_LIBADD) $(LIBS)
-libgnunet_plugin_datacache_sqlite.la: $(libgnunet_plugin_datacache_sqlite_la_OBJECTS) $(libgnunet_plugin_datacache_sqlite_la_DEPENDENCIES)
+libgnunet_plugin_datacache_sqlite.la: $(libgnunet_plugin_datacache_sqlite_la_OBJECTS) $(libgnunet_plugin_datacache_sqlite_la_DEPENDENCIES) $(EXTRA_libgnunet_plugin_datacache_sqlite_la_DEPENDENCIES)
$(AM_V_CCLD)$(libgnunet_plugin_datacache_sqlite_la_LINK) $(am_libgnunet_plugin_datacache_sqlite_la_rpath) $(libgnunet_plugin_datacache_sqlite_la_OBJECTS) $(libgnunet_plugin_datacache_sqlite_la_LIBADD) $(LIBS)
-libgnunet_plugin_datacache_template.la: $(libgnunet_plugin_datacache_template_la_OBJECTS) $(libgnunet_plugin_datacache_template_la_DEPENDENCIES)
+libgnunet_plugin_datacache_template.la: $(libgnunet_plugin_datacache_template_la_OBJECTS) $(libgnunet_plugin_datacache_template_la_DEPENDENCIES) $(EXTRA_libgnunet_plugin_datacache_template_la_DEPENDENCIES)
$(AM_V_CCLD)$(libgnunet_plugin_datacache_template_la_LINK) -rpath $(plugindir) $(libgnunet_plugin_datacache_template_la_OBJECTS) $(libgnunet_plugin_datacache_template_la_LIBADD) $(LIBS)
-libgnunetdatacache.la: $(libgnunetdatacache_la_OBJECTS) $(libgnunetdatacache_la_DEPENDENCIES)
+libgnunetdatacache.la: $(libgnunetdatacache_la_OBJECTS) $(libgnunetdatacache_la_DEPENDENCIES) $(EXTRA_libgnunetdatacache_la_DEPENDENCIES)
$(AM_V_CCLD)$(libgnunetdatacache_la_LINK) -rpath $(libdir) $(libgnunetdatacache_la_OBJECTS) $(libgnunetdatacache_la_LIBADD) $(LIBS)
clean-checkPROGRAMS:
@@ -779,31 +831,31 @@ clean-checkPROGRAMS:
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
-perf_datacache_mysql$(EXEEXT): $(perf_datacache_mysql_OBJECTS) $(perf_datacache_mysql_DEPENDENCIES)
- @rm -f perf_datacache_mysql$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(perf_datacache_mysql_OBJECTS) $(perf_datacache_mysql_LDADD) $(LIBS)
-perf_datacache_postgres$(EXEEXT): $(perf_datacache_postgres_OBJECTS) $(perf_datacache_postgres_DEPENDENCIES)
+perf_datacache_heap$(EXEEXT): $(perf_datacache_heap_OBJECTS) $(perf_datacache_heap_DEPENDENCIES) $(EXTRA_perf_datacache_heap_DEPENDENCIES)
+ @rm -f perf_datacache_heap$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(perf_datacache_heap_OBJECTS) $(perf_datacache_heap_LDADD) $(LIBS)
+perf_datacache_postgres$(EXEEXT): $(perf_datacache_postgres_OBJECTS) $(perf_datacache_postgres_DEPENDENCIES) $(EXTRA_perf_datacache_postgres_DEPENDENCIES)
@rm -f perf_datacache_postgres$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(perf_datacache_postgres_OBJECTS) $(perf_datacache_postgres_LDADD) $(LIBS)
-perf_datacache_sqlite$(EXEEXT): $(perf_datacache_sqlite_OBJECTS) $(perf_datacache_sqlite_DEPENDENCIES)
+perf_datacache_sqlite$(EXEEXT): $(perf_datacache_sqlite_OBJECTS) $(perf_datacache_sqlite_DEPENDENCIES) $(EXTRA_perf_datacache_sqlite_DEPENDENCIES)
@rm -f perf_datacache_sqlite$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(perf_datacache_sqlite_OBJECTS) $(perf_datacache_sqlite_LDADD) $(LIBS)
-test_datacache_mysql$(EXEEXT): $(test_datacache_mysql_OBJECTS) $(test_datacache_mysql_DEPENDENCIES)
- @rm -f test_datacache_mysql$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(test_datacache_mysql_OBJECTS) $(test_datacache_mysql_LDADD) $(LIBS)
-test_datacache_postgres$(EXEEXT): $(test_datacache_postgres_OBJECTS) $(test_datacache_postgres_DEPENDENCIES)
+test_datacache_heap$(EXEEXT): $(test_datacache_heap_OBJECTS) $(test_datacache_heap_DEPENDENCIES) $(EXTRA_test_datacache_heap_DEPENDENCIES)
+ @rm -f test_datacache_heap$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_datacache_heap_OBJECTS) $(test_datacache_heap_LDADD) $(LIBS)
+test_datacache_postgres$(EXEEXT): $(test_datacache_postgres_OBJECTS) $(test_datacache_postgres_DEPENDENCIES) $(EXTRA_test_datacache_postgres_DEPENDENCIES)
@rm -f test_datacache_postgres$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_datacache_postgres_OBJECTS) $(test_datacache_postgres_LDADD) $(LIBS)
-test_datacache_quota_mysql$(EXEEXT): $(test_datacache_quota_mysql_OBJECTS) $(test_datacache_quota_mysql_DEPENDENCIES)
- @rm -f test_datacache_quota_mysql$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(test_datacache_quota_mysql_OBJECTS) $(test_datacache_quota_mysql_LDADD) $(LIBS)
-test_datacache_quota_postgres$(EXEEXT): $(test_datacache_quota_postgres_OBJECTS) $(test_datacache_quota_postgres_DEPENDENCIES)
+test_datacache_quota_heap$(EXEEXT): $(test_datacache_quota_heap_OBJECTS) $(test_datacache_quota_heap_DEPENDENCIES) $(EXTRA_test_datacache_quota_heap_DEPENDENCIES)
+ @rm -f test_datacache_quota_heap$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(test_datacache_quota_heap_OBJECTS) $(test_datacache_quota_heap_LDADD) $(LIBS)
+test_datacache_quota_postgres$(EXEEXT): $(test_datacache_quota_postgres_OBJECTS) $(test_datacache_quota_postgres_DEPENDENCIES) $(EXTRA_test_datacache_quota_postgres_DEPENDENCIES)
@rm -f test_datacache_quota_postgres$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_datacache_quota_postgres_OBJECTS) $(test_datacache_quota_postgres_LDADD) $(LIBS)
-test_datacache_quota_sqlite$(EXEEXT): $(test_datacache_quota_sqlite_OBJECTS) $(test_datacache_quota_sqlite_DEPENDENCIES)
+test_datacache_quota_sqlite$(EXEEXT): $(test_datacache_quota_sqlite_OBJECTS) $(test_datacache_quota_sqlite_DEPENDENCIES) $(EXTRA_test_datacache_quota_sqlite_DEPENDENCIES)
@rm -f test_datacache_quota_sqlite$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_datacache_quota_sqlite_OBJECTS) $(test_datacache_quota_sqlite_LDADD) $(LIBS)
-test_datacache_sqlite$(EXEEXT): $(test_datacache_sqlite_OBJECTS) $(test_datacache_sqlite_DEPENDENCIES)
+test_datacache_sqlite$(EXEEXT): $(test_datacache_sqlite_OBJECTS) $(test_datacache_sqlite_DEPENDENCIES) $(EXTRA_test_datacache_sqlite_DEPENDENCIES)
@rm -f test_datacache_sqlite$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_datacache_sqlite_OBJECTS) $(test_datacache_sqlite_LDADD) $(LIBS)
@@ -814,9 +866,9 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/datacache.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perf_datacache.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_datacache_heap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_datacache_sqlite.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_datacache_template.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_datacache.Po@am__quote@
@@ -825,42 +877,30 @@ distclean-compile:
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.lo: plugin_datacache_mysql.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgnunet_plugin_datacache_mysql_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.lo -MD -MP -MF $(DEPDIR)/libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.Tpo -c -o libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.lo `test -f 'plugin_datacache_mysql.c' || echo '$(srcdir)/'`plugin_datacache_mysql.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.Tpo $(DEPDIR)/libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='plugin_datacache_mysql.c' object='libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgnunet_plugin_datacache_mysql_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgnunet_plugin_datacache_mysql_la-plugin_datacache_mysql.lo `test -f 'plugin_datacache_mysql.c' || echo '$(srcdir)/'`plugin_datacache_mysql.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.lo: plugin_datacache_postgres.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgnunet_plugin_datacache_postgres_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.lo -MD -MP -MF $(DEPDIR)/libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.Tpo -c -o libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.lo `test -f 'plugin_datacache_postgres.c' || echo '$(srcdir)/'`plugin_datacache_postgres.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.Tpo $(DEPDIR)/libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='plugin_datacache_postgres.c' object='libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugin_datacache_postgres.c' object='libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgnunet_plugin_datacache_postgres_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.lo `test -f 'plugin_datacache_postgres.c' || echo '$(srcdir)/'`plugin_datacache_postgres.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgnunet_plugin_datacache_postgres_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgnunet_plugin_datacache_postgres_la-plugin_datacache_postgres.lo `test -f 'plugin_datacache_postgres.c' || echo '$(srcdir)/'`plugin_datacache_postgres.c
mostlyclean-libtool:
-rm -f *.lo
@@ -869,8 +909,11 @@ clean-libtool:
-rm -rf .libs _libs
install-dist_pkgcfgDATA: $(dist_pkgcfg_DATA)
@$(NORMAL_INSTALL)
- test -z "$(pkgcfgdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgcfgdir)"
@list='$(dist_pkgcfg_DATA)'; test -n "$(pkgcfgdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pkgcfgdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pkgcfgdir)" || exit 1; \
+ fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
@@ -884,9 +927,7 @@ uninstall-dist_pkgcfgDATA:
@$(NORMAL_UNINSTALL)
@list='$(dist_pkgcfg_DATA)'; test -n "$(pkgcfgdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- test -n "$$files" || exit 0; \
- echo " ( cd '$(DESTDIR)$(pkgcfgdir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(pkgcfgdir)" && rm -f $$files
+ dir='$(DESTDIR)$(pkgcfgdir)'; $(am__uninstall_files_from_dir)
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
@@ -1021,14 +1062,15 @@ check-TESTS: $(TESTS)
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
if test "$$failed" -eq 0; then \
- echo "$$grn$$dashes"; \
+ col="$$grn"; \
else \
- echo "$$red$$dashes"; \
+ col="$$red"; \
fi; \
- echo "$$banner"; \
- test -z "$$skipped" || echo "$$skipped"; \
- test -z "$$report" || echo "$$report"; \
- echo "$$dashes$$std"; \
+ echo "$${col}$$dashes$${std}"; \
+ echo "$${col}$$banner$${std}"; \
+ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
+ test -z "$$report" || echo "$${col}$$report$${std}"; \
+ echo "$${col}$$dashes$${std}"; \
test "$$failed" -eq 0; \
else :; fi
@@ -1081,10 +1123,15 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
mostlyclean-generic:
clean-generic:
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index b440af1..0cd6f88 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -103,7 +103,7 @@ struct GNUNET_DATACACHE_Handle
* @param size number of bytes that were made available
*/
static void
-env_delete_notify (void *cls, const GNUNET_HashCode * key, size_t size)
+env_delete_notify (void *cls, const struct GNUNET_HashCode * key, size_t size)
{
struct GNUNET_DATACACHE_Handle *h = cls;
@@ -112,7 +112,9 @@ env_delete_notify (void *cls, const GNUNET_HashCode * key, size_t size)
GNUNET_assert (h->utilization >= size);
h->utilization -= size;
GNUNET_CONTAINER_bloomfilter_remove (h->filter, key);
- GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), -size,
+ GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), - (long long) size,
+ GNUNET_NO);
+ GNUNET_STATISTICS_update (h->stats, gettext_noop ("# items stored"), -1,
GNUNET_NO);
}
@@ -152,22 +154,24 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
bf_size = quota / 32; /* 8 bit per entry, 1 bit per 32 kb in DB */
ret = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_Handle));
- ret->bloom_name = GNUNET_DISK_mktemp ("gnunet-datacachebloom");
- if (NULL != ret->bloom_name)
- {
- ret->filter = GNUNET_CONTAINER_bloomfilter_load (ret->bloom_name, quota / 1024, /* 8 bit per entry in DB, expect 1k entries */
- 5);
- }
- if (NULL == ret->filter)
+
+ if (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF"))
{
- ret->filter = GNUNET_CONTAINER_bloomfilter_init (NULL, bf_size, 5); /* approx. 3% false positives at max use */
- }
- if (NULL == ret->filter)
- {
- GNUNET_free (name);
- GNUNET_free (ret->bloom_name);
- GNUNET_free (ret);
- return NULL;
+ if (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF_RC"))
+ {
+ ret->bloom_name = GNUNET_DISK_mktemp ("gnunet-datacachebloom");
+ }
+ if (NULL != ret->bloom_name)
+ {
+ ret->filter = GNUNET_CONTAINER_bloomfilter_load (ret->bloom_name, quota / 1024, /* 8 bit per entry in DB, expect 1k entries */
+ 5);
+ }
+ if (NULL == ret->filter)
+ {
+ ret->filter = GNUNET_CONTAINER_bloomfilter_init (NULL, bf_size, 5); /* approx. 3% false positives at max use */
+ }
}
ret->stats = GNUNET_STATISTICS_create ("datacache", cfg);
ret->section = GNUNET_strdup (section);
@@ -201,7 +205,7 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
void
GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h)
{
- if (h->filter != NULL)
+ if (NULL != h->filter)
GNUNET_CONTAINER_bloomfilter_free (h->filter);
if (h->api != NULL)
GNUNET_break (NULL == GNUNET_PLUGIN_unload (h->lib_name, h->api));
@@ -229,27 +233,42 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h)
* @param data data to store
* @param type type of the value
* @param discard_time when to discard the value in any case
- * @return GNUNET_OK on success, GNUNET_SYSERR on error (full, etc.)
+ * @param path_info_len number of entries in 'path_info'
+ * @param path_info a path through the network
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error, GNUNET_NO if duplicate
*/
int
GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
- const GNUNET_HashCode * key, size_t size,
+ const struct GNUNET_HashCode * key, size_t size,
const char *data, enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute discard_time)
+ struct GNUNET_TIME_Absolute discard_time,
+ unsigned int path_info_len,
+ const struct GNUNET_PeerIdentity *path_info)
{
- uint32_t used;
+ ssize_t used;
- used = h->api->put (h->api->cls, key, size, data, type, discard_time);
- if (used == 0)
+ used = h->api->put (h->api->cls, key,
+ size, data,
+ type, discard_time,
+ path_info_len, path_info);
+ if (-1 == used)
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
+ if (0 == used)
+ {
+ /* duplicate */
+ return GNUNET_NO;
+ }
LOG (GNUNET_ERROR_TYPE_DEBUG, "Stored data under key `%s' in cache\n",
GNUNET_h2s (key));
GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size,
GNUNET_NO);
- GNUNET_CONTAINER_bloomfilter_add (h->filter, key);
+ GNUNET_STATISTICS_update (h->stats, gettext_noop ("# items stored"), 1,
+ GNUNET_NO);
+ if (NULL != h->filter)
+ GNUNET_CONTAINER_bloomfilter_add (h->filter, key);
while (h->utilization + used > h->env.quota)
GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls));
h->utilization += used;
@@ -270,14 +289,15 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
*/
unsigned int
GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
- const GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type,
+ const struct GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type,
GNUNET_DATACACHE_Iterator iter, void *iter_cls)
{
GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1,
GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for key `%s'\n",
GNUNET_h2s (key));
- if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key))
+ if ( (NULL != h->filter) &&
+ (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key)) )
{
GNUNET_STATISTICS_update (h->stats,
gettext_noop
diff --git a/src/datacache/datacache.conf b/src/datacache/datacache.conf
index 125a4e5..033b56d 100644
--- a/src/datacache/datacache.conf
+++ b/src/datacache/datacache.conf
@@ -1,10 +1,2 @@
-[datacache-mysql]
-DATABASE = gnunet
-CONFIG = ~/.my.cnf
-# USER = gnunet
-# PASSWORD =
-# HOST = localhost
-# PORT = 3306
-
[datacache-postgres]
CONFIG = connect_timeout=10; dbname=gnunet
diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c
index 77edbf9..84775a3 100644
--- a/src/datacache/perf_datacache.c
+++ b/src/datacache/perf_datacache.c
@@ -25,9 +25,9 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_datacache_lib.h"
+#include "gnunet_testing_lib.h"
#include <gauger.h>
-#define VERBOSE GNUNET_NO
#define ASSERT(x) do { if (! (x)) { printf("Error at %s:%d\n", __FILE__, __LINE__); goto FAILURE;} } while (0)
@@ -44,11 +44,14 @@ static const char *plugin_name;
static int
-checkIt (void *cls, struct GNUNET_TIME_Absolute exp,
- const GNUNET_HashCode * key, size_t size, const char *data,
- enum GNUNET_BLOCK_Type type)
+checkIt (void *cls,
+ const struct GNUNET_HashCode * key, size_t size, const char *data,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_TIME_Absolute exp,
+ unsigned int path_len,
+ const struct GNUNET_PeerIdentity *path)
{
- if ((size == sizeof (GNUNET_HashCode)) && (0 == memcmp (data, cls, size)))
+ if ((size == sizeof (struct GNUNET_HashCode)) && (0 == memcmp (data, cls, size)))
found++;
return GNUNET_OK;
}
@@ -59,8 +62,8 @@ run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_DATACACHE_Handle *h;
- GNUNET_HashCode k;
- GNUNET_HashCode n;
+ struct GNUNET_HashCode k;
+ struct GNUNET_HashCode n;
struct GNUNET_TIME_Absolute exp;
struct GNUNET_TIME_Absolute start;
unsigned int i;
@@ -76,41 +79,40 @@ run (void *cls, char *const *args, const char *cfgfile,
}
exp = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS);
start = GNUNET_TIME_absolute_get ();
- memset (&k, 0, sizeof (GNUNET_HashCode));
+ memset (&k, 0, sizeof (struct GNUNET_HashCode));
for (i = 0; i < ITERATIONS; i++)
{
if (0 == i % (ITERATIONS / 80))
FPRINTF (stderr, "%s", ".");
- GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
+ GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
ASSERT (GNUNET_OK ==
- GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode),
- (const char *) &n, 1 + i % 16, exp));
+ GNUNET_DATACACHE_put (h, &k, sizeof (struct GNUNET_HashCode),
+ (const char *) &n, 1 + i % 16, exp,
+ 0, NULL));
k = n;
}
FPRINTF (stderr, "%s", "\n");
- FPRINTF (stdout, "Stored %u items in %llums\n", ITERATIONS,
- (unsigned long long)
- GNUNET_TIME_absolute_get_duration (start).rel_value);
+ FPRINTF (stdout, "Stored %u items in %s\n", ITERATIONS,
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES));
GNUNET_snprintf (gstr, sizeof (gstr), "DATACACHE-%s", plugin_name);
GAUGER (gstr, "Time to PUT item in datacache",
GNUNET_TIME_absolute_get_duration (start).rel_value / ITERATIONS,
"ms/item");
start = GNUNET_TIME_absolute_get ();
- memset (&k, 0, sizeof (GNUNET_HashCode));
+ memset (&k, 0, sizeof (struct GNUNET_HashCode));
for (i = 0; i < ITERATIONS; i++)
{
if (0 == i % (ITERATIONS / 80))
FPRINTF (stderr, "%s", ".");
- GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
+ GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
GNUNET_DATACACHE_get (h, &k, 1 + i % 16, &checkIt, &n);
k = n;
}
FPRINTF (stderr, "%s", "\n");
FPRINTF (stdout,
- "Found %u/%u items in %llums (%u were deleted during storage processing)\n",
+ "Found %u/%u items in %s (%u were deleted during storage processing)\n",
found, ITERATIONS,
- (unsigned long long)
- GNUNET_TIME_absolute_get_duration (start).rel_value,
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES),
ITERATIONS - found);
if (found > 0)
GAUGER (gstr, "Time to GET item from datacache",
@@ -129,16 +131,11 @@ FAILURE:
int
main (int argc, char *argv[])
{
- char *pos;
char cfg_name[128];
-
char *const xargv[] = {
"perf-datacache",
"-c",
cfg_name,
-#if VERBOSE
- "-L", "DEBUG",
-#endif
NULL
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -146,25 +143,11 @@ main (int argc, char *argv[])
};
GNUNET_log_setup ("perf-datacache",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
- /* determine name of plugin to use */
- plugin_name = argv[0];
- while (NULL != (pos = strstr (plugin_name, "_")))
- plugin_name = pos + 1;
- if (NULL != (pos = strstr (plugin_name, ".")))
- pos[0] = 0;
- else
- pos = (char *) plugin_name;
-
+ plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_snprintf (cfg_name, sizeof (cfg_name), "perf_datacache_data_%s.conf",
plugin_name);
- if (pos != plugin_name)
- pos[0] = '.';
GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv,
"perf-datacache", "nohelp", options, &run, NULL);
if (ok != 0)
diff --git a/src/datacache/perf_datacache_data_heap.conf b/src/datacache/perf_datacache_data_heap.conf
new file mode 100644
index 0000000..3680c02
--- /dev/null
+++ b/src/datacache/perf_datacache_data_heap.conf
@@ -0,0 +1,5 @@
+[perfcache]
+QUOTA = 500 KB
+DATABASE = heap
+
+
diff --git a/src/datacache/perf_datacache_data_mysql.conf b/src/datacache/perf_datacache_data_mysql.conf
deleted file mode 100644
index 1760f7d..0000000
--- a/src/datacache/perf_datacache_data_mysql.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-[perfcache]
-QUOTA = 500 KB
-DATABASE = mysql
-
-[datacache-mysql]
-DATABASE = gnunetcheck
-# CONFIG = ~/.my.cnf
-# USER =
-# PASSWORD =
-# HOST =
-# PORT =
-
-
diff --git a/src/datacache/plugin_datacache_heap.c b/src/datacache/plugin_datacache_heap.c
new file mode 100644
index 0000000..41dd089
--- /dev/null
+++ b/src/datacache/plugin_datacache_heap.c
@@ -0,0 +1,441 @@
+/*
+ This file is part of GNUnet
+ (C) 2012 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file datacache/plugin_datacache_heap.c
+ * @brief heap-only implementation of a database backend for the datacache
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_datacache_plugin.h"
+
+#define LOG(kind,...) GNUNET_log_from (kind, "datacache-heap", __VA_ARGS__)
+
+#define LOG_STRERROR_FILE(kind,op,fn) GNUNET_log_from_strerror_file (kind, "datacache-heap", op, fn)
+
+
+
+/**
+ * Context for all functions in this plugin.
+ */
+struct Plugin
+{
+ /**
+ * Our execution environment.
+ */
+ struct GNUNET_DATACACHE_PluginEnvironment *env;
+
+ /**
+ * Our hash map.
+ */
+ struct GNUNET_CONTAINER_MultiHashMap *map;
+
+ /**
+ * Heap for expirations.
+ */
+ struct GNUNET_CONTAINER_Heap *heap;
+
+};
+
+
+/**
+ * Entry in the hash map.
+ */
+struct Value
+{
+ /**
+ * Key for the entry.
+ */
+ struct GNUNET_HashCode key;
+
+ /**
+ * Expiration time.
+ */
+ struct GNUNET_TIME_Absolute discard_time;
+
+ /**
+ * Corresponding node in the heap.
+ */
+ struct GNUNET_CONTAINER_HeapNode *hn;
+
+ /**
+ * Path information.
+ */
+ struct GNUNET_PeerIdentity *path_info;
+
+ /**
+ * Payload (actual payload follows this struct)
+ */
+ size_t size;
+
+ /**
+ * Number of entries in 'path_info'.
+ */
+ unsigned int path_info_len;
+
+ /**
+ * Type of the block.
+ */
+ enum GNUNET_BLOCK_Type type;
+
+};
+
+
+#define OVERHEAD (sizeof (struct Value) + 64)
+
+
+/**
+ * Closure for 'put_cb'.
+ */
+struct PutContext
+{
+ /**
+ * Expiration time for the new value.
+ */
+ struct GNUNET_TIME_Absolute discard_time;
+
+ /**
+ * Data for the new value.
+ */
+ const char *data;
+
+ /**
+ * Heap from the plugin.
+ */
+ struct GNUNET_CONTAINER_Heap *heap;
+
+ /**
+ * Path information.
+ */
+ const struct GNUNET_PeerIdentity *path_info;
+
+ /**
+ * Number of bytes in 'data'.
+ */
+ size_t size;
+
+ /**
+ * Type of the node.
+ */
+ enum GNUNET_BLOCK_Type type;
+
+ /**
+ * Number of entries in 'path_info'.
+ */
+ unsigned int path_info_len;
+
+ /**
+ * Value to set to GNUNET_YES if an equivalent block was found.
+ */
+ int found;
+};
+
+
+/**
+ * Function called during PUT to detect if an equivalent block
+ * already exists.
+ *
+ * @param cls the 'struct PutContext'
+ * @param key the key for the value(s)
+ * @param value an existing value
+ * @return GNUNET_YES if not found (to continue to iterate)
+ */
+static int
+put_cb (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ struct PutContext *put_ctx = cls;
+ struct Value *val = value;
+
+ if ( (val->size == put_ctx->size) &&
+ (val->type == put_ctx->type) &&
+ (0 == memcmp (&val[1], put_ctx->data, put_ctx->size)) )
+ {
+ put_ctx->found = GNUNET_YES;
+ val->discard_time = GNUNET_TIME_absolute_max (val->discard_time,
+ put_ctx->discard_time);
+ /* replace old path with new path */
+ GNUNET_array_grow (val->path_info,
+ val->path_info_len,
+ put_ctx->path_info_len);
+ memcpy (val->path_info,
+ put_ctx->path_info,
+ put_ctx->path_info_len * sizeof (struct GNUNET_PeerIdentity));
+ GNUNET_CONTAINER_heap_update_cost (put_ctx->heap,
+ val->hn,
+ val->discard_time.abs_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got same value for key %s and type %d (size %u vs %u)\n",
+ GNUNET_h2s (key),
+ val->type,
+ (unsigned int) val->size,
+ (unsigned int) put_ctx->size);
+ return GNUNET_NO;
+ }
+ return GNUNET_YES;
+}
+
+
+/**
+ * Store an item in the datastore.
+ *
+ * @param cls closure (our "struct Plugin")
+ * @param key key to store data under
+ * @param size number of bytes in data
+ * @param data data to store
+ * @param type type of the value
+ * @param discard_time when to discard the value in any case
+ * @param path_info_len number of entries in 'path_info'
+ * @param path_info a path through the network
+ * @return 0 if duplicate, -1 on error, number of bytes used otherwise
+ */
+static ssize_t
+heap_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size,
+ const char *data, enum GNUNET_BLOCK_Type type,
+ struct GNUNET_TIME_Absolute discard_time,
+ unsigned int path_info_len,
+ const struct GNUNET_PeerIdentity *path_info)
+{
+ struct Plugin *plugin = cls;
+ struct Value *val;
+ struct PutContext put_ctx;
+
+ put_ctx.found = GNUNET_NO;
+ put_ctx.heap = plugin->heap;
+ put_ctx.data = data;
+ put_ctx.size = size;
+ put_ctx.path_info = path_info;
+ put_ctx.path_info_len = path_info_len;
+ put_ctx.discard_time = discard_time;
+ put_ctx.type = type;
+ GNUNET_CONTAINER_multihashmap_get_multiple (plugin->map,
+ key,
+ put_cb,
+ &put_ctx);
+ if (GNUNET_YES == put_ctx.found)
+ return 0;
+ val = GNUNET_malloc (sizeof (struct Value) + size);
+ memcpy (&val[1], data, size);
+ val->key = *key;
+ val->type = type;
+ val->discard_time = discard_time;
+ val->size = size;
+ GNUNET_array_grow (val->path_info,
+ val->path_info_len,
+ path_info_len);
+ memcpy (val->path_info, path_info,
+ path_info_len * sizeof (struct GNUNET_PeerIdentity));
+ (void) GNUNET_CONTAINER_multihashmap_put (plugin->map,
+ &val->key,
+ val,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ val->hn = GNUNET_CONTAINER_heap_insert (plugin->heap,
+ val,
+ val->discard_time.abs_value);
+ return size + OVERHEAD;
+}
+
+
+/**
+ * Closure for 'get_cb'.
+ */
+struct GetContext
+{
+ /**
+ * Function to call for each result.
+ */
+ GNUNET_DATACACHE_Iterator iter;
+
+ /**
+ * Closure for 'iter'.
+ */
+ void *iter_cls;
+
+ /**
+ * Number of results found.
+ */
+ unsigned int cnt;
+
+ /**
+ * Block type requested.
+ */
+ enum GNUNET_BLOCK_Type type;
+};
+
+
+
+/**
+ * Function called during GET to find matching blocks.
+ * Only matches by type.
+ *
+ * @param cls the 'struct GetContext'
+ * @param key the key for the value(s)
+ * @param value an existing value
+ * @return GNUNET_YES to continue to iterate
+ */
+static int
+get_cb (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ struct GetContext *get_ctx = cls;
+ struct Value *val = value;
+ int ret;
+
+ if ( (get_ctx->type != val->type) &&
+ (GNUNET_BLOCK_TYPE_ANY != get_ctx->type) )
+ return GNUNET_OK;
+ if (NULL != get_ctx->iter)
+ ret = get_ctx->iter (get_ctx->iter_cls,
+ key,
+ val->size,
+ (const char *) &val[1],
+ val->type,
+ val->discard_time,
+ val->path_info_len,
+ val->path_info);
+ else
+ ret = GNUNET_YES;
+ get_ctx->cnt++;
+ return ret;
+}
+
+
+/**
+ * Iterate over the results for a particular key
+ * in the datastore.
+ *
+ * @param cls closure (our "struct Plugin")
+ * @param key
+ * @param type entries of which type are relevant?
+ * @param iter maybe NULL (to just count)
+ * @param iter_cls closure for iter
+ * @return the number of results found
+ */
+static unsigned int
+heap_plugin_get (void *cls, const struct GNUNET_HashCode * key,
+ enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter,
+ void *iter_cls)
+{
+ struct Plugin *plugin = cls;
+ struct GetContext get_ctx;
+
+ get_ctx.type = type;
+ get_ctx.iter = iter;
+ get_ctx.iter_cls = iter_cls;
+ get_ctx.cnt = 0;
+ GNUNET_CONTAINER_multihashmap_get_multiple (plugin->map,
+ key,
+ get_cb,
+ &get_ctx);
+ return get_ctx.cnt;
+}
+
+
+/**
+ * Delete the entry with the lowest expiration value
+ * from the datacache right now.
+ *
+ * @param cls closure (our "struct Plugin")
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ */
+static int
+heap_plugin_del (void *cls)
+{
+ struct Plugin *plugin = cls;
+ struct Value *val;
+
+ val = GNUNET_CONTAINER_heap_remove_root (plugin->heap);
+ if (NULL == val)
+ return GNUNET_SYSERR;
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (plugin->map,
+ &val->key,
+ val));
+ plugin->env->delete_notify (plugin->env->cls,
+ &val->key,
+ val->size + OVERHEAD);
+ GNUNET_free_non_null (val->path_info);
+ GNUNET_free (val);
+ return GNUNET_OK;
+}
+
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls closure (the "struct GNUNET_DATACACHE_PluginEnvironmnet")
+ * @return the plugin's closure (our "struct Plugin")
+ */
+void *
+libgnunet_plugin_datacache_heap_init (void *cls)
+{
+ struct GNUNET_DATACACHE_PluginEnvironment *env = cls;
+ struct GNUNET_DATACACHE_PluginFunctions *api;
+ struct Plugin *plugin;
+
+ plugin = GNUNET_malloc (sizeof (struct Plugin));
+ plugin->map = GNUNET_CONTAINER_multihashmap_create (1024, /* FIXME: base on quota! */
+ GNUNET_YES);
+ plugin->heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+ plugin->env = env;
+ api = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_PluginFunctions));
+ api->cls = plugin;
+ api->get = &heap_plugin_get;
+ api->put = &heap_plugin_put;
+ api->del = &heap_plugin_del;
+ LOG (GNUNET_ERROR_TYPE_INFO, _("Heap datacache running\n"));
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls closure (our "struct Plugin")
+ * @return NULL
+ */
+void *
+libgnunet_plugin_datacache_heap_done (void *cls)
+{
+ struct GNUNET_DATACACHE_PluginFunctions *api = cls;
+ struct Plugin *plugin = api->cls;
+ struct Value *val;
+
+ while (NULL != (val = GNUNET_CONTAINER_heap_remove_root (plugin->heap)))
+ {
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (plugin->map,
+ &val->key,
+ val));
+ GNUNET_free (val);
+ }
+ GNUNET_CONTAINER_heap_destroy (plugin->heap);
+ GNUNET_CONTAINER_multihashmap_destroy (plugin->map);
+ GNUNET_free (plugin);
+ GNUNET_free (api);
+ return NULL;
+}
+
+
+
+/* end of plugin_datacache_heap.c */
diff --git a/src/datacache/plugin_datacache_mysql.c b/src/datacache/plugin_datacache_mysql.c
deleted file mode 100644
index 8103429..0000000
--- a/src/datacache/plugin_datacache_mysql.c
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- This file is part of GNUnet
- (C) 2006, 2009, 2010 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file datacache/plugin_datacache_mysql.c
- * @brief mysql for an implementation of a database backend for the datacache
- * @author Christian Grothoff
- *
- * SETUP INSTRUCTIONS:
- *
- * 1) Access mysql as root,
- * <pre>
- *
- * $ mysql -u root -p
- *
- * </pre>
- * and do the following. [You should replace $USER with the username
- * that will be running the gnunetd process].
- * @verbatim
- CREATE DATABASE gnunet;
- GRANT select,insert,update,delete,create,alter,drop,create temporary tables
- ON gnunet.* TO $USER@localhost;
- SET PASSWORD FOR $USER@localhost=PASSWORD('$the_password_you_like');
- FLUSH PRIVILEGES;
- @endverbatim
- * 2) In the $HOME directory of $USER, create a ".my.cnf" file
- * with the following lines
- * @verbatim
- [client]
- user=$USER
- password=$the_password_you_like
- @endverbatim
- *
- * Thats it -- now you can configure your datastores in GNUnet to
- * use MySQL. Note that .my.cnf file is a security risk unless its on
- * a safe partition etc. The $HOME/.my.cnf can of course be a symbolic
- * link. Even greater security risk can be achieved by setting no
- * password for $USER. Luckily $USER has only priviledges to mess
- * up GNUnet's tables, nothing else (unless you give him more,
- * of course).<p>
- *
- * 3) Still, perhaps you should briefly try if the DB connection
- * works. First, login as $USER. Then use,
- * @verbatim
- $ mysql -u $USER -p $the_password_you_like
- mysql> use gnunet;
- @endverbatim
- *
- * If you get the message &quot;Database changed&quot; it probably works.
- *
- * [If you get &quot;ERROR 2002: Can't connect to local MySQL server
- * through socket '/tmp/mysql.sock' (2)&quot; it may be resolvable by
- * &quot;ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock&quot;
- * so there may be some additional trouble depending on your mysql setup.]
- *
- * PROBLEMS?
- *
- * If you have problems related to the mysql module, your best
- * friend is probably the mysql manual. The first thing to check
- * is that mysql is basically operational, that you can connect
- * to it, create tables, issue queries etc.
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_datacache_plugin.h"
-#include "gnunet_mysql_lib.h"
-#include <mysql/mysql.h>
-
-
-/**
- * Estimate of the per-entry overhead (including indices).
- */
-#define OVERHEAD ((4*2+4*2+8*2+8*2+sizeof(GNUNET_HashCode)*5+8))
-
-/**
- * Die with an error message that indicates
- * a failure of the command 'cmd' with the message given
- * by strerror(errno).
- */
-#define DIE_MYSQL(cmd, dbh) do { GNUNET_log(GNUNET_ERROR_TYPE__ERROR, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); GNUNET_abort(); } while(0);
-
-/**
- * Log an error message at log-level 'level' that indicates
- * a failure of the command 'cmd' on file 'filename'
- * with the message given by strerror(errno).
- */
-#define LOG_MYSQL(level, cmd, dbh) do { GNUNET_log(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); } while(0);
-
-
-/**
- * Context for all functions in this plugin.
- */
-struct Plugin
-{
- /**
- * Our execution environment.
- */
- struct GNUNET_DATACACHE_PluginEnvironment *env;
-
- /**
- * Handle to the mysql database.
- */
- struct GNUNET_MYSQL_Context *mc;
-
-#define SELECT_VALUE_STMT "SELECT value,expire FROM gn080dstore FORCE INDEX (hashidx) WHERE hash=? AND type=? AND expire >= ? LIMIT 1 OFFSET ?"
- struct GNUNET_MYSQL_StatementHandle *select_value;
-
-#define COUNT_VALUE_STMT "SELECT count(*) FROM gn080dstore FORCE INDEX (hashidx) WHERE hash=? AND type=? AND expire >= ?"
- struct GNUNET_MYSQL_StatementHandle *count_value;
-
-#define SELECT_OLD_VALUE_STMT "SELECT hash, vhash, type, value FROM gn080dstore FORCE INDEX (expireidx) ORDER BY puttime ASC LIMIT 1"
- struct GNUNET_MYSQL_StatementHandle *select_old_value;
-
-#define DELETE_VALUE_STMT "DELETE FROM gn080dstore WHERE hash = ? AND vhash = ? AND type = ? AND value = ?"
- struct GNUNET_MYSQL_StatementHandle *delete_value;
-
-#define INSERT_VALUE_STMT "INSERT INTO gn080dstore (type, puttime, expire, hash, vhash, value) "\
- "VALUES (?, ?, ?, ?, ?, ?)"
- struct GNUNET_MYSQL_StatementHandle *insert_value;
-
-#define UPDATE_VALUE_STMT "UPDATE gn080dstore FORCE INDEX (allidx) SET puttime=?, expire=? "\
- "WHERE hash=? AND vhash=? AND type=?"
- struct GNUNET_MYSQL_StatementHandle *update_value;
-
-};
-
-
-/**
- * Create temporary table and prepare statements.
- *
- * @param plugin plugin context
- * @return GNUNET_OK on success
- */
-static int
-itable (struct Plugin *plugin)
-{
-#define MRUNS(a) (GNUNET_OK != GNUNET_MYSQL_statement_run (plugin->mc, a) )
- if (MRUNS
- ("CREATE TEMPORARY TABLE gn080dstore ("
- " type INT(11) UNSIGNED NOT NULL DEFAULT 0,"
- " puttime BIGINT UNSIGNED NOT NULL DEFAULT 0,"
- " expire BIGINT UNSIGNED NOT NULL DEFAULT 0,"
- " hash BINARY(64) NOT NULL DEFAULT '',"
- " vhash BINARY(64) NOT NULL DEFAULT '',"
- " value BLOB NOT NULL DEFAULT '',"
- " INDEX hashidx (hash(64),type,expire),"
- " INDEX allidx (hash(64),vhash(64),type)," " INDEX expireidx (puttime)"
- ") ENGINE=InnoDB") || MRUNS ("SET AUTOCOMMIT = 1"))
- return GNUNET_SYSERR;
-#undef MRUNS
-#define PINIT(a,b) (NULL == (a = GNUNET_MYSQL_statement_prepare (plugin->mc, b)))
- if (PINIT (plugin->select_value, SELECT_VALUE_STMT) ||
- PINIT (plugin->count_value, COUNT_VALUE_STMT) ||
- PINIT (plugin->select_old_value, SELECT_OLD_VALUE_STMT) ||
- PINIT (plugin->delete_value, DELETE_VALUE_STMT) ||
- PINIT (plugin->insert_value, INSERT_VALUE_STMT) ||
- PINIT (plugin->update_value, UPDATE_VALUE_STMT))
- return GNUNET_SYSERR;
-#undef PINIT
- return GNUNET_OK;
-}
-
-
-/**
- * Store an item in the datastore.
- *
- * @param cls closure (our "struct Plugin")
- * @param key key to store data under
- * @param size number of bytes in data
- * @param data data to store
- * @param type type of the value
- * @param discard_time when to discard the value in any case
- * @return 0 on error, number of bytes used otherwise
- */
-static size_t
-mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
- const char *data, enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute discard_time)
-{
- struct Plugin *plugin = cls;
- struct GNUNET_TIME_Absolute now;
- unsigned long k_length;
- unsigned long h_length;
- unsigned long v_length;
- unsigned long long v_now;
- unsigned long long v_discard_time;
- unsigned int v_type;
- GNUNET_HashCode vhash;
- int ret;
-
- if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE)
- return GNUNET_SYSERR;
- GNUNET_CRYPTO_hash (data, size, &vhash);
- now = GNUNET_TIME_absolute_get ();
-
- /* first try UPDATE */
- h_length = sizeof (GNUNET_HashCode);
- k_length = sizeof (GNUNET_HashCode);
- v_length = size;
- v_type = type;
- v_now = (unsigned long long) now.abs_value;
- v_discard_time = (unsigned long long) discard_time.abs_value;
- if (GNUNET_OK ==
- GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->update_value, NULL,
- MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES,
- MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES,
- MYSQL_TYPE_BLOB, key, sizeof (GNUNET_HashCode),
- &k_length, MYSQL_TYPE_BLOB, &vhash,
- sizeof (GNUNET_HashCode), &h_length,
- MYSQL_TYPE_LONG, &v_type, GNUNET_YES, -1))
- return GNUNET_OK;
-
- /* now try INSERT */
- h_length = sizeof (GNUNET_HashCode);
- k_length = sizeof (GNUNET_HashCode);
- v_length = size;
- if (GNUNET_OK !=
- (ret =
- GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->insert_value, NULL,
- MYSQL_TYPE_LONG, &type, GNUNET_YES,
- MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES,
- MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES,
- MYSQL_TYPE_BLOB, key, sizeof (GNUNET_HashCode),
- &k_length, MYSQL_TYPE_BLOB, &vhash,
- sizeof (GNUNET_HashCode), &h_length,
- MYSQL_TYPE_BLOB, data, (unsigned long) size,
- &v_length, -1)))
- {
- if (ret == GNUNET_SYSERR)
- itable (plugin);
- return GNUNET_SYSERR;
- }
- return size + OVERHEAD;
-}
-
-
-static int
-return_ok (void *cls, unsigned int num_values, MYSQL_BIND * values)
-{
- return GNUNET_OK;
-}
-
-
-/**
- * Iterate over the results for a particular key
- * in the datastore.
- *
- * @param cls closure (our "struct Plugin")
- * @param key
- * @param type entries of which type are relevant?
- * @param iter maybe NULL (to just count)
- * @param iter_cls closure for iter
- * @return the number of results found
- */
-static unsigned int
-mysql_plugin_get (void *cls, const GNUNET_HashCode * key,
- enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter,
- void *iter_cls)
-{
- struct Plugin *plugin = cls;
- MYSQL_BIND rbind[3];
- unsigned long h_length;
- unsigned long v_length;
- unsigned long long v_expire;
- struct GNUNET_TIME_Absolute now;
- struct GNUNET_TIME_Absolute expire;
- unsigned int cnt;
- unsigned long long total;
- unsigned long long v_now;
- unsigned int off;
- unsigned int v_type;
- int ret;
- char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE];
-
- now = GNUNET_TIME_absolute_get ();
- h_length = sizeof (GNUNET_HashCode);
- v_length = sizeof (buffer);
- total = -1;
- memset (rbind, 0, sizeof (rbind));
- rbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
- rbind[0].buffer = &total;
- rbind[0].is_unsigned = GNUNET_YES;
- v_type = type;
- v_now = (unsigned long long) now.abs_value;
- if ((GNUNET_OK !=
- (ret =
- GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->count_value, 1, rbind,
- return_ok, NULL, MYSQL_TYPE_BLOB, key,
- sizeof (GNUNET_HashCode), &h_length,
- MYSQL_TYPE_LONG, &v_type, GNUNET_YES,
- MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES,
- -1))) || (-1 == total))
- {
- if (ret == GNUNET_SYSERR)
- itable (plugin);
- return GNUNET_SYSERR;
- }
- if ((iter == NULL) || (total == 0))
- return (int) total;
-
- off = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, total);
- cnt = 0;
- while (cnt < total)
- {
- memset (rbind, 0, sizeof (rbind));
- rbind[0].buffer_type = MYSQL_TYPE_BLOB;
- rbind[0].buffer_length = sizeof (buffer);
- rbind[0].length = &v_length;
- rbind[0].buffer = buffer;
- rbind[1].buffer_type = MYSQL_TYPE_LONGLONG;
- rbind[1].is_unsigned = 1;
- rbind[1].buffer = &v_expire;
- off = (off + 1) % total;
- if (GNUNET_OK !=
- (ret =
- GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->select_value, 2, rbind,
- return_ok, NULL, MYSQL_TYPE_BLOB, key,
- sizeof (GNUNET_HashCode), &h_length,
- MYSQL_TYPE_LONG, &v_type, GNUNET_YES,
- MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES,
- MYSQL_TYPE_LONG, &off, GNUNET_YES, -1)))
- {
- if (ret == GNUNET_SYSERR)
- itable (plugin);
- return GNUNET_SYSERR;
- }
- cnt++;
- expire.abs_value = v_expire;
- if (GNUNET_OK != iter (iter_cls, expire, key, v_length, buffer, type))
- break;
- }
- return cnt;
-}
-
-
-/**
- * Delete the entry with the lowest expiration value
- * from the datacache right now.
- *
- * @param cls closure (our "struct Plugin")
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
- */
-static int
-mysql_plugin_del (void *cls)
-{
- struct Plugin *plugin = cls;
-
- MYSQL_BIND rbind[5];
- unsigned int v_type;
- GNUNET_HashCode v_key;
- GNUNET_HashCode vhash;
- unsigned long k_length;
- unsigned long h_length;
- unsigned long v_length;
- int ret;
- char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE];
-
- k_length = sizeof (GNUNET_HashCode);
- h_length = sizeof (GNUNET_HashCode);
- v_length = sizeof (buffer);
- memset (rbind, 0, sizeof (rbind));
- rbind[0].buffer_type = MYSQL_TYPE_BLOB;
- rbind[0].buffer_length = sizeof (GNUNET_HashCode);
- rbind[0].length = &k_length;
- rbind[0].buffer = &v_key;
- rbind[1].buffer_type = MYSQL_TYPE_BLOB;
- rbind[1].buffer_length = sizeof (GNUNET_HashCode);
- rbind[1].length = &h_length;
- rbind[1].buffer = &vhash;
- rbind[2].buffer_type = MYSQL_TYPE_LONG;
- rbind[2].is_unsigned = 1;
- rbind[2].buffer = &v_type;
- rbind[3].buffer_type = MYSQL_TYPE_BLOB;
- rbind[3].buffer_length = sizeof (buffer);
- rbind[3].length = &v_length;
- rbind[3].buffer = buffer;
- if ((GNUNET_OK !=
- (ret =
- GNUNET_MYSQL_statement_run_prepared_select (plugin->mc, plugin->select_old_value, 4,
- rbind, return_ok, NULL, -1))) ||
- (GNUNET_OK !=
- (ret =
- GNUNET_MYSQL_statement_run_prepared (plugin->mc, plugin->delete_value, NULL,
- MYSQL_TYPE_BLOB, &v_key,
- sizeof (GNUNET_HashCode), &k_length,
- MYSQL_TYPE_BLOB, &vhash,
- sizeof (GNUNET_HashCode), &h_length,
- MYSQL_TYPE_LONG, &v_type, GNUNET_YES,
- MYSQL_TYPE_BLOB, buffer,
- (unsigned long) sizeof (buffer), &v_length,
- -1))))
- {
- if (ret == GNUNET_SYSERR)
- itable (plugin);
- return GNUNET_SYSERR;
- }
- plugin->env->delete_notify (plugin->env->cls, &v_key, v_length + OVERHEAD);
-
- return GNUNET_OK;
-}
-
-
-/**
- * Entry point for the plugin.
- *
- * @param cls closure (the "struct GNUNET_DATACACHE_PluginEnvironmnet")
- * @return the plugin's closure (our "struct Plugin")
- */
-void *
-libgnunet_plugin_datacache_mysql_init (void *cls)
-{
- struct GNUNET_DATACACHE_PluginEnvironment *env = cls;
- struct GNUNET_DATACACHE_PluginFunctions *api;
- struct Plugin *plugin;
-
- plugin = GNUNET_malloc (sizeof (struct Plugin));
- plugin->env = env;
- plugin->mc = GNUNET_MYSQL_context_create (env->cfg, "datacache-mysql");
- if ( (NULL == plugin->mc) ||
- (GNUNET_OK != itable (plugin)) )
- {
- if (NULL != plugin->mc)
- GNUNET_MYSQL_context_destroy (plugin->mc);
- GNUNET_free (plugin);
- return NULL;
- }
- api = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_PluginFunctions));
- api->cls = plugin;
- api->get = &mysql_plugin_get;
- api->put = &mysql_plugin_put;
- api->del = &mysql_plugin_del;
- GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "mysql",
- _("MySQL datacache running\n"));
- return api;
-}
-
-
-/**
- * Exit point from the plugin.
- *
- * @param cls closure (our "struct Plugin")
- * @return NULL
- */
-void *
-libgnunet_plugin_datacache_mysql_done (void *cls)
-{
- struct GNUNET_DATACACHE_PluginFunctions *api = cls;
- struct Plugin *plugin = api->cls;
-
- GNUNET_MYSQL_context_destroy (plugin->mc);
- GNUNET_free (plugin);
- GNUNET_free (api);
- return NULL;
-}
-
-
-/* end of plugin_datacache_mysql.c */
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c
index b40f1fd..e7d2e72 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -34,7 +34,7 @@
/**
* Per-entry overhead estimate
*/
-#define OVERHEAD (sizeof(GNUNET_HashCode) + 24)
+#define OVERHEAD (sizeof(struct GNUNET_HashCode) + 24)
/**
* Context for all functions in this plugin.
@@ -75,13 +75,18 @@ init_connection (struct Plugin *plugin)
" type INTEGER NOT NULL DEFAULT 0,"
" discard_time BIGINT NOT NULL DEFAULT 0,"
" key BYTEA NOT NULL DEFAULT '',"
- " value BYTEA NOT NULL DEFAULT '')" "WITH OIDS");
- if ((ret == NULL) || ((PQresultStatus (ret) != PGRES_COMMAND_OK) && (0 != strcmp ("42P07", /* duplicate table */
- PQresultErrorField
- (ret,
- PG_DIAG_SQLSTATE)))))
+ " value BYTEA NOT NULL DEFAULT '',"
+ " path BYTEA DEFAULT '')"
+ "WITH OIDS");
+ if ( (ret == NULL) ||
+ ((PQresultStatus (ret) != PGRES_COMMAND_OK) &&
+ (0 != strcmp ("42P07", /* duplicate table */
+ PQresultErrorField
+ (ret,
+ PG_DIAG_SQLSTATE)))))
{
- (void) GNUNET_POSTGRES_check_result (plugin->dbh, ret, PGRES_COMMAND_OK, "CREATE TABLE",
+ (void) GNUNET_POSTGRES_check_result (plugin->dbh, ret,
+ PGRES_COMMAND_OK, "CREATE TABLE",
"gn090dc");
PQfinish (plugin->dbh);
plugin->dbh = NULL;
@@ -123,11 +128,11 @@ init_connection (struct Plugin *plugin)
PQclear (ret);
if ((GNUNET_OK !=
GNUNET_POSTGRES_prepare (plugin->dbh, "getkt",
- "SELECT discard_time,type,value FROM gn090dc "
+ "SELECT discard_time,type,value,path FROM gn090dc "
"WHERE key=$1 AND type=$2 ", 2)) ||
(GNUNET_OK !=
GNUNET_POSTGRES_prepare (plugin->dbh, "getk",
- "SELECT discard_time,type,value FROM gn090dc "
+ "SELECT discard_time,type,value,path FROM gn090dc "
"WHERE key=$1", 1)) ||
(GNUNET_OK !=
GNUNET_POSTGRES_prepare (plugin->dbh, "getm",
@@ -137,8 +142,8 @@ init_connection (struct Plugin *plugin)
GNUNET_POSTGRES_prepare (plugin->dbh, "delrow", "DELETE FROM gn090dc WHERE oid=$1", 1)) ||
(GNUNET_OK !=
GNUNET_POSTGRES_prepare (plugin->dbh, "put",
- "INSERT INTO gn090dc (type, discard_time, key, value) "
- "VALUES ($1, $2, $3, $4)", 4)))
+ "INSERT INTO gn090dc (type, discard_time, key, value, path) "
+ "VALUES ($1, $2, $3, $4, $5)", 5)))
{
PQfinish (plugin->dbh);
plugin->dbh = NULL;
@@ -157,12 +162,16 @@ init_connection (struct Plugin *plugin)
* @param data data to store
* @param type type of the value
* @param discard_time when to discard the value in any case
- * @return 0 on error, number of bytes used otherwise
+ * @param path_info_len number of entries in 'path_info'
+ * @param path_info a path through the network
+ * @return 0 if duplicate, -1 on error, number of bytes used otherwise
*/
-static size_t
-postgres_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
+static ssize_t
+postgres_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size,
const char *data, enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute discard_time)
+ struct GNUNET_TIME_Absolute discard_time,
+ unsigned int path_info_len,
+ const struct GNUNET_PeerIdentity *path_info)
{
struct Plugin *plugin = cls;
PGresult *ret;
@@ -173,22 +182,25 @@ postgres_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
(const char *) &btype,
(const char *) &bexpi,
(const char *) key,
- (const char *) data
+ (const char *) data,
+ (const char *) path_info
};
int paramLengths[] = {
sizeof (btype),
sizeof (bexpi),
- sizeof (GNUNET_HashCode),
- size
+ sizeof (struct GNUNET_HashCode),
+ size,
+ path_info_len * sizeof (struct GNUNET_PeerIdentity)
};
- const int paramFormats[] = { 1, 1, 1, 1 };
+ const int paramFormats[] = { 1, 1, 1, 1, 1 };
ret =
- PQexecPrepared (plugin->dbh, "put", 4, paramValues, paramLengths,
+ PQexecPrepared (plugin->dbh, "put", 5, paramValues, paramLengths,
paramFormats, 1);
if (GNUNET_OK !=
- GNUNET_POSTGRES_check_result (plugin->dbh, ret, PGRES_COMMAND_OK, "PQexecPrepared", "put"))
- return GNUNET_SYSERR;
+ GNUNET_POSTGRES_check_result (plugin->dbh, ret,
+ PGRES_COMMAND_OK, "PQexecPrepared", "put"))
+ return -1;
PQclear (ret);
return size + OVERHEAD;
}
@@ -206,7 +218,7 @@ postgres_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
* @return the number of results found
*/
static unsigned int
-postgres_plugin_get (void *cls, const GNUNET_HashCode * key,
+postgres_plugin_get (void *cls, const struct GNUNET_HashCode * key,
enum GNUNET_BLOCK_Type type,
GNUNET_DATACACHE_Iterator iter, void *iter_cls)
{
@@ -218,7 +230,7 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key,
(const char *) &btype,
};
int paramLengths[] = {
- sizeof (GNUNET_HashCode),
+ sizeof (struct GNUNET_HashCode),
sizeof (btype),
};
const int paramFormats[] = { 1, 1 };
@@ -226,6 +238,8 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key,
uint32_t size;
unsigned int cnt;
unsigned int i;
+ unsigned int path_len;
+ const struct GNUNET_PeerIdentity *path;
PGresult *res;
res =
@@ -254,7 +268,7 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key,
PQclear (res);
return cnt;
}
- if ((3 != PQnfields (res)) || (sizeof (uint64_t) != PQfsize (res, 0)) ||
+ if ((4 != PQnfields (res)) || (sizeof (uint64_t) != PQfsize (res, 0)) ||
(sizeof (uint32_t) != PQfsize (res, 1)))
{
GNUNET_break (0);
@@ -267,12 +281,23 @@ postgres_plugin_get (void *cls, const GNUNET_HashCode * key,
GNUNET_ntohll (*(uint64_t *) PQgetvalue (res, i, 0));
type = ntohl (*(uint32_t *) PQgetvalue (res, i, 1));
size = PQgetlength (res, i, 2);
+ path_len = PQgetlength (res, i, 3);
+ if (0 != (path_len % sizeof (struct GNUNET_PeerIdentity)))
+ {
+ GNUNET_break (0);
+ path_len = 0;
+ }
+ path_len %= sizeof (struct GNUNET_PeerIdentity);
+ path = (const struct GNUNET_PeerIdentity *) PQgetvalue (res, i, 3);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found result of size %u bytes and type %u in database\n",
(unsigned int) size, (unsigned int) type);
if (GNUNET_SYSERR ==
- iter (iter_cls, expiration_time, key, size, PQgetvalue (res, i, 2),
- (enum GNUNET_BLOCK_Type) type))
+ iter (iter_cls, key, size, PQgetvalue (res, i, 2),
+ (enum GNUNET_BLOCK_Type) type,
+ expiration_time,
+ path_len,
+ path))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Ending iteration (client error)\n");
@@ -298,7 +323,7 @@ postgres_plugin_del (void *cls)
struct Plugin *plugin = cls;
uint32_t size;
uint32_t oid;
- GNUNET_HashCode key;
+ struct GNUNET_HashCode key;
PGresult *res;
res = PQexecPrepared (plugin->dbh, "getm", 0, NULL, NULL, NULL, 1);
@@ -319,7 +344,7 @@ postgres_plugin_del (void *cls)
}
if ((3 != PQnfields (res)) || (sizeof (size) != PQfsize (res, 0)) ||
(sizeof (oid) != PQfsize (res, 1)) ||
- (sizeof (GNUNET_HashCode) != PQgetlength (res, 0, 2)))
+ (sizeof (struct GNUNET_HashCode) != PQgetlength (res, 0, 2)))
{
GNUNET_break (0);
PQclear (res);
@@ -327,7 +352,7 @@ postgres_plugin_del (void *cls)
}
size = ntohl (*(uint32_t *) PQgetvalue (res, 0, 0));
oid = ntohl (*(uint32_t *) PQgetvalue (res, 0, 1));
- memcpy (&key, PQgetvalue (res, 0, 2), sizeof (GNUNET_HashCode));
+ memcpy (&key, PQgetvalue (res, 0, 2), sizeof (struct GNUNET_HashCode));
PQclear (res);
if (GNUNET_OK != GNUNET_POSTGRES_delete_by_rowid (plugin->dbh, "delrow", oid))
return GNUNET_SYSERR;
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index db27de3..bf76f31 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -37,7 +37,7 @@
* How much overhead do we assume per entry in the
* datacache?
*/
-#define OVERHEAD (sizeof(GNUNET_HashCode) + 32)
+#define OVERHEAD (sizeof(struct GNUNET_HashCode) + 32)
/**
* Context for all functions in this plugin.
@@ -95,52 +95,64 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded
* @param data data to store
* @param type type of the value
* @param discard_time when to discard the value in any case
- * @return 0 on error, number of bytes used otherwise
+ * @param path_info_len number of entries in 'path_info'
+ * @param path_info array of peers that have processed the request
+ * @return 0 if duplicate, -1 on error, number of bytes used otherwise
*/
-static size_t
-sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
- const char *data, enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute discard_time)
+static ssize_t
+sqlite_plugin_put (void *cls,
+ const struct GNUNET_HashCode *key,
+ size_t size, const char *data,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_TIME_Absolute discard_time,
+ unsigned int path_info_len,
+ const struct GNUNET_PeerIdentity *path_info)
{
struct Plugin *plugin = cls;
sqlite3_stmt *stmt;
int64_t dval;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Processing `%s' of %u bytes with key `%4s' and expiration %llums\n",
+ "Processing `%s' of %u bytes with key `%4s' and expiration %s\n",
"PUT", (unsigned int) size, GNUNET_h2s (key),
- (unsigned long long)
- GNUNET_TIME_absolute_get_remaining (discard_time).rel_value);
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (discard_time), GNUNET_YES));
dval = (int64_t) discard_time.abs_value;
if (dval < 0)
dval = INT64_MAX;
if (sq_prepare
(plugin->dbh,
- "INSERT INTO ds090 (type, expire, key, value) VALUES (?, ?, ?, ?)",
+ "INSERT INTO ds090 (type, expire, key, value, path) VALUES (?, ?, ?, ?, ?)",
&stmt) != SQLITE_OK)
{
LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sq_prepare");
- return 0;
+ return -1;
}
if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) ||
(SQLITE_OK != sqlite3_bind_int64 (stmt, 2, dval)) ||
(SQLITE_OK !=
- sqlite3_bind_blob (stmt, 3, key, sizeof (GNUNET_HashCode),
+ sqlite3_bind_blob (stmt, 3,
+ key, sizeof (struct GNUNET_HashCode),
SQLITE_TRANSIENT)) ||
- (SQLITE_OK != sqlite3_bind_blob (stmt, 4, data, size, SQLITE_TRANSIENT)))
+ (SQLITE_OK != sqlite3_bind_blob (stmt, 4,
+ data, size,
+ SQLITE_TRANSIENT)) ||
+ (SQLITE_OK != sqlite3_bind_blob (stmt, 5,
+ path_info,
+ path_info_len * sizeof (struct GNUNET_PeerIdentity),
+ SQLITE_TRANSIENT)))
{
LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_bind_xxx");
sqlite3_finalize (stmt);
- return 0;
+ return -1;
}
if (SQLITE_DONE != sqlite3_step (stmt))
{
LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_step");
sqlite3_finalize (stmt);
- return 0;
+ return -1;
}
if (SQLITE_OK != sqlite3_finalize (stmt))
LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
@@ -161,7 +173,7 @@ sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
* @return the number of results found
*/
static unsigned int
-sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
+sqlite_plugin_get (void *cls, const struct GNUNET_HashCode * key,
enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter,
void *iter_cls)
{
@@ -174,8 +186,10 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
unsigned int cnt;
unsigned int off;
unsigned int total;
+ unsigned int psize;
char scratch[256];
int64_t ntime;
+ const struct GNUNET_PeerIdentity *path;
now = GNUNET_TIME_absolute_get ();
LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' for key `%4s'\n", "GET",
@@ -192,7 +206,7 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
ntime = (int64_t) now.abs_value;
GNUNET_assert (ntime >= 0);
if ((SQLITE_OK !=
- sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode),
+ sqlite3_bind_blob (stmt, 1, key, sizeof (struct GNUNET_HashCode),
SQLITE_TRANSIENT)) ||
(SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
(SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value)))
@@ -230,7 +244,7 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
{
off = (off + 1) % total;
GNUNET_snprintf (scratch, sizeof (scratch),
- "SELECT value,expire FROM ds090 WHERE key=? AND type=? AND expire >= ? LIMIT 1 OFFSET %u",
+ "SELECT value,expire,path FROM ds090 WHERE key=? AND type=? AND expire >= ? LIMIT 1 OFFSET %u",
off);
if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK)
{
@@ -239,7 +253,7 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
return cnt;
}
if ((SQLITE_OK !=
- sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode),
+ sqlite3_bind_blob (stmt, 1, key, sizeof (struct GNUNET_HashCode),
SQLITE_TRANSIENT)) ||
(SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
(SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value)))
@@ -254,6 +268,17 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
size = sqlite3_column_bytes (stmt, 0);
dat = sqlite3_column_blob (stmt, 0);
exp.abs_value = sqlite3_column_int64 (stmt, 1);
+ psize = sqlite3_column_bytes (stmt, 2);
+ if (0 != psize % sizeof (struct GNUNET_PeerIdentity))
+ {
+ GNUNET_break (0);
+ psize = 0;
+ }
+ psize /= sizeof (struct GNUNET_PeerIdentity);
+ if (0 != psize)
+ path = sqlite3_column_blob (stmt, 2);
+ else
+ path = NULL;
ntime = (int64_t) exp.abs_value;
if (ntime == INT64_MAX)
exp = GNUNET_TIME_UNIT_FOREVER_ABS;
@@ -261,7 +286,7 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found %u-byte result when processing `%s' for key `%4s'\n",
(unsigned int) size, "GET", GNUNET_h2s (key));
- if (GNUNET_OK != iter (iter_cls, exp, key, size, dat, type))
+ if (GNUNET_OK != iter (iter_cls, key, size, dat, type, exp, psize, path))
{
sqlite3_finalize (stmt);
break;
@@ -287,7 +312,7 @@ sqlite_plugin_del (void *cls)
unsigned int dsize;
sqlite3_stmt *stmt;
sqlite3_stmt *dstmt;
- GNUNET_HashCode hc;
+ struct GNUNET_HashCode hc;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s'\n", "DEL");
stmt = NULL;
@@ -311,8 +336,8 @@ sqlite_plugin_del (void *cls)
return GNUNET_SYSERR;
}
rowid = sqlite3_column_int64 (stmt, 0);
- GNUNET_assert (sqlite3_column_bytes (stmt, 1) == sizeof (GNUNET_HashCode));
- memcpy (&hc, sqlite3_column_blob (stmt, 1), sizeof (GNUNET_HashCode));
+ GNUNET_assert (sqlite3_column_bytes (stmt, 1) == sizeof (struct GNUNET_HashCode));
+ memcpy (&hc, sqlite3_column_blob (stmt, 1), sizeof (struct GNUNET_HashCode));
dsize = sqlite3_column_bytes (stmt, 2);
if (SQLITE_OK != sqlite3_finalize (stmt))
LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
@@ -365,25 +390,33 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
sqlite3 *dbh;
char *emsg;
- fn = GNUNET_DISK_mktemp ("gnunet-datacache");
- if (fn == NULL)
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+ "datacache-sqlite",
+ "IN_MEMORY"))
{
- GNUNET_break (0);
- return NULL;
+ if (SQLITE_OK != sqlite3_open (":memory:", &dbh))
+ return NULL;
+ fn_utf8 = NULL;
}
-#ifdef ENABLE_NLS
- fn_utf8 = GNUNET_STRINGS_to_utf8 (fn, strlen (fn), nl_langinfo (CODESET));
-#else
- /* good luck */
- fn_utf8 = GNUNET_STRINGS_to_utf8 (fn, strlen (fn), "UTF-8");
-#endif
- if (SQLITE_OK != sqlite3_open (fn_utf8, &dbh))
+ else
{
+ fn = GNUNET_DISK_mktemp ("gnunet-datacache");
+ if (fn == NULL)
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ /* fn should be UTF-8-encoded. If it isn't, it's a bug. */
+ fn_utf8 = GNUNET_strdup (fn);
+ if (SQLITE_OK != sqlite3_open (fn_utf8, &dbh))
+ {
+ GNUNET_free (fn);
+ GNUNET_free (fn_utf8);
+ return NULL;
+ }
GNUNET_free (fn);
- GNUNET_free (fn_utf8);
- return NULL;
}
- GNUNET_free (fn);
SQLITE3_EXEC (dbh, "PRAGMA temp_store=MEMORY");
SQLITE3_EXEC (dbh, "PRAGMA locking_mode=EXCLUSIVE");
@@ -391,11 +424,18 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
SQLITE3_EXEC (dbh, "PRAGMA synchronous=OFF");
SQLITE3_EXEC (dbh, "PRAGMA count_changes=OFF");
SQLITE3_EXEC (dbh, "PRAGMA page_size=4092");
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+ "datacache-sqlite",
+ "IN_MEMORY"))
+ SQLITE3_EXEC (dbh, "PRAGMA sqlite_temp_store=3");
+
SQLITE3_EXEC (dbh,
"CREATE TABLE ds090 (" " type INTEGER NOT NULL DEFAULT 0,"
" expire INTEGER NOT NULL DEFAULT 0,"
" key BLOB NOT NULL DEFAULT '',"
- " value BLOB NOT NULL DEFAULT '')");
+ " value BLOB NOT NULL DEFAULT '',"
+ " path BLOB DEFAULT '')");
SQLITE3_EXEC (dbh, "CREATE INDEX idx_hashidx ON ds090 (key,type,expire)");
SQLITE3_EXEC (dbh, "CREATE INDEX idx_expire ON ds090 (expire)");
plugin = GNUNET_malloc (sizeof (struct Plugin));
@@ -430,9 +470,10 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
#endif
#if !WINDOWS || defined(__CYGWIN__)
- if (0 != UNLINK (plugin->fn))
+ if ( (NULL != plugin->fn) &&
+ (0 != UNLINK (plugin->fn)) )
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", plugin->fn);
- GNUNET_free (plugin->fn);
+ GNUNET_free_non_null (plugin->fn);
#endif
result = sqlite3_close (plugin->dbh);
#if SQLITE_VERSION_NUMBER >= 3007000
@@ -458,9 +499,10 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR, "sqlite3_close");
#if WINDOWS && !defined(__CYGWIN__)
- if (0 != UNLINK (plugin->fn))
+ if ( (NULL != plugin->fn) &&
+ (0 != UNLINK (plugin->fn)) )
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", plugin->fn);
- GNUNET_free (plugin->fn);
+ GNUNET_free_non_null (plugin->fn);
#endif
GNUNET_free (plugin);
GNUNET_free (api);
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c
index 2d3f160..3066155 100644
--- a/src/datacache/plugin_datacache_template.c
+++ b/src/datacache/plugin_datacache_template.c
@@ -49,15 +49,19 @@ struct Plugin
* @param data data to store
* @param type type of the value
* @param discard_time when to discard the value in any case
- * @return 0 on error, number of bytes used otherwise
+ * @param path_info_len number of entries in 'path_info'
+ * @param path_info a path through the network
+ * @return 0 if duplicate, -1 on error, number of bytes used otherwise
*/
-static size_t
-template_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
+static ssize_t
+template_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size,
const char *data, enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute discard_time)
+ struct GNUNET_TIME_Absolute discard_time,
+ unsigned int path_info_len,
+ const struct GNUNET_PeerIdentity *path_info)
{
GNUNET_break (0);
- return 0;
+ return -1;
}
@@ -73,7 +77,7 @@ template_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
* @return the number of results found
*/
static unsigned int
-template_plugin_get (void *cls, const GNUNET_HashCode * key,
+template_plugin_get (void *cls, const struct GNUNET_HashCode * key,
enum GNUNET_BLOCK_Type type,
GNUNET_DATACACHE_Iterator iter, void *iter_cls)
{
diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c
index d8d2f05..8c429cc 100644
--- a/src/datacache/test_datacache.c
+++ b/src/datacache/test_datacache.c
@@ -25,8 +25,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_datacache_lib.h"
-
-#define VERBOSE GNUNET_NO
+#include "gnunet_testing_lib.h"
#define ASSERT(x) do { if (! (x)) { printf("Error at %s:%d\n", __FILE__, __LINE__); goto FAILURE;} } while (0)
@@ -39,18 +38,22 @@ static const char *plugin_name;
static int
-checkIt (void *cls, struct GNUNET_TIME_Absolute exp,
- const GNUNET_HashCode * key, size_t size, const char *data,
- enum GNUNET_BLOCK_Type type)
+checkIt (void *cls,
+ const struct GNUNET_HashCode *key,
+ size_t size, const char *data,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_TIME_Absolute exp,
+ unsigned int path_len,
+ const struct GNUNET_PeerIdentity *path)
{
- if (size != sizeof (GNUNET_HashCode))
+ if (size != sizeof (struct GNUNET_HashCode))
{
- printf ("ERROR: Invalid size\n");
+ GNUNET_break (0);
ok = 2;
}
if (0 != memcmp (data, cls, size))
{
- printf ("ERROR: Invalid data\n");
+ GNUNET_break (0);
ok = 3;
}
return GNUNET_OK;
@@ -62,8 +65,8 @@ run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_DATACACHE_Handle *h;
- GNUNET_HashCode k;
- GNUNET_HashCode n;
+ struct GNUNET_HashCode k;
+ struct GNUNET_HashCode n;
struct GNUNET_TIME_Absolute exp;
unsigned int i;
@@ -78,29 +81,31 @@ run (void *cls, char *const *args, const char *cfgfile,
}
exp = GNUNET_TIME_absolute_get ();
exp.abs_value += 5 * 60 * 1000;
- memset (&k, 0, sizeof (GNUNET_HashCode));
+ memset (&k, 0, sizeof (struct GNUNET_HashCode));
for (i = 0; i < 100; i++)
{
- GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
+ GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
ASSERT (GNUNET_OK ==
- GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode),
- (const char *) &n, 1 + i % 16, exp));
+ GNUNET_DATACACHE_put (h, &k, sizeof (struct GNUNET_HashCode),
+ (const char *) &n, 1 + i % 16, exp,
+ 0, NULL));
k = n;
}
- memset (&k, 0, sizeof (GNUNET_HashCode));
+ memset (&k, 0, sizeof (struct GNUNET_HashCode));
for (i = 0; i < 100; i++)
{
- GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
+ GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
ASSERT (1 == GNUNET_DATACACHE_get (h, &k, 1 + i % 16, &checkIt, &n));
k = n;
}
- memset (&k, 42, sizeof (GNUNET_HashCode));
- GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
+ memset (&k, 42, sizeof (struct GNUNET_HashCode));
+ GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
ASSERT (GNUNET_OK ==
- GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode),
+ GNUNET_DATACACHE_put (h, &k, sizeof (struct GNUNET_HashCode),
(const char *) &n, 792,
- GNUNET_TIME_UNIT_FOREVER_ABS));
+ GNUNET_TIME_UNIT_FOREVER_ABS,
+ 0, NULL));
ASSERT (0 != GNUNET_DATACACHE_get (h, &k, 792, &checkIt, &n));
GNUNET_DATACACHE_destroy (h);
@@ -116,16 +121,11 @@ FAILURE:
int
main (int argc, char *argv[])
{
- char *pos;
char cfg_name[128];
-
char *const xargv[] = {
"test-datacache",
"-c",
cfg_name,
-#if VERBOSE
- "-L", "DEBUG",
-#endif
NULL
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -133,28 +133,14 @@ main (int argc, char *argv[])
};
GNUNET_log_setup ("test-datacache",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
- /* determine name of plugin to use */
- plugin_name = argv[0];
- while (NULL != (pos = strstr (plugin_name, "_")))
- plugin_name = pos + 1;
- if (NULL != (pos = strstr (plugin_name, ".")))
- pos[0] = 0;
- else
- pos = (char *) plugin_name;
-
+ plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datacache_data_%s.conf",
plugin_name);
- if (pos != plugin_name)
- pos[0] = '.';
GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv,
"test-datacache", "nohelp", options, &run, NULL);
- if (ok != 0)
+ if (0 != ok)
FPRINTF (stderr, "Missed some testcases: %d\n", ok);
return ok;
}
diff --git a/src/datacache/test_datacache_data_heap.conf b/src/datacache/test_datacache_data_heap.conf
new file mode 100644
index 0000000..082cf48
--- /dev/null
+++ b/src/datacache/test_datacache_data_heap.conf
@@ -0,0 +1,4 @@
+[testcache]
+QUOTA = 1 MB
+DATABASE = heap
+
diff --git a/src/datacache/test_datacache_data_mysql.conf b/src/datacache/test_datacache_data_mysql.conf
deleted file mode 100644
index bc9daa3..0000000
--- a/src/datacache/test_datacache_data_mysql.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-[testcache]
-QUOTA = 1 MB
-DATABASE = mysql
-
-[datacache-mysql]
-DATABASE = gnunetcheck
-# CONFIG = ~/.my.cnf
-# USER =
-# PASSWORD =
-# HOST =
-# PORT =
-
-
diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c
index cc47bdb..0400b50 100644
--- a/src/datacache/test_datacache_quota.c
+++ b/src/datacache/test_datacache_quota.c
@@ -25,8 +25,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_datacache_lib.h"
-
-#define VERBOSE GNUNET_NO
+#include "gnunet_testing_lib.h"
#define ASSERT(x) do { if (! (x)) { printf("Error at %s:%d\n", __FILE__, __LINE__); goto FAILURE;} } while (0)
@@ -48,8 +47,8 @@ run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_DATACACHE_Handle *h;
- GNUNET_HashCode k;
- GNUNET_HashCode n;
+ struct GNUNET_HashCode k;
+ struct GNUNET_HashCode n;
unsigned int i;
unsigned int j;
char buf[3200];
@@ -65,26 +64,26 @@ run (void *cls, char *const *args, const char *cfgfile,
}
exp = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS);
memset (buf, 1, sizeof (buf));
- memset (&k, 0, sizeof (GNUNET_HashCode));
+ memset (&k, 0, sizeof (struct GNUNET_HashCode));
for (i = 0; i < 10; i++)
{
FPRINTF (stderr, "%s", ".");
- GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
+ GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
for (j = i; j < sizeof (buf); j += 10)
{
exp.abs_value++;
buf[j] = i;
- ASSERT (GNUNET_OK == GNUNET_DATACACHE_put (h, &k, j, buf, 1 + i, exp));
+ ASSERT (GNUNET_OK == GNUNET_DATACACHE_put (h, &k, j, buf, 1 + i, exp, 0, NULL));
ASSERT (0 < GNUNET_DATACACHE_get (h, &k, 1 + i, NULL, NULL));
}
k = n;
}
FPRINTF (stderr, "%s", "\n");
- memset (&k, 0, sizeof (GNUNET_HashCode));
+ memset (&k, 0, sizeof (struct GNUNET_HashCode));
for (i = 0; i < 10; i++)
{
FPRINTF (stderr, "%s", ".");
- GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n);
+ GNUNET_CRYPTO_hash (&k, sizeof (struct GNUNET_HashCode), &n);
if (i < 2)
ASSERT (0 == GNUNET_DATACACHE_get (h, &k, 1 + i, NULL, NULL));
if (i == 9)
@@ -104,16 +103,11 @@ FAILURE:
int
main (int argc, char *argv[])
{
- char *pos;
char cfg_name[128];
-
char *const xargv[] = {
"test-datacache-quota",
"-c",
cfg_name,
-#if VERBOSE
- "-L", "DEBUG",
-#endif
NULL
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -121,29 +115,15 @@ main (int argc, char *argv[])
};
GNUNET_log_setup ("test-datacache-quota",
-#if VERBOSE
- "DEBUG",
-#else
"WARNING",
-#endif
NULL);
- /* determine name of plugin to use */
- plugin_name = argv[0];
- while (NULL != (pos = strstr (plugin_name, "_")))
- plugin_name = pos + 1;
- if (NULL != (pos = strstr (plugin_name, ".")))
- pos[0] = 0;
- else
- pos = (char *) plugin_name;
-
+ plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datacache_data_%s.conf",
plugin_name);
- if (pos != plugin_name)
- pos[0] = '.';
GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv,
"test-datacache-quota", "nohelp", options, &run, NULL);
- if (ok != 0)
+ if (0 != ok)
FPRINTF (stderr, "Missed some testcases: %d\n", ok);
return ok;
}