Skip to content

Commit

Permalink
Feature lmdb as caching backend (#309)
Browse files Browse the repository at this point in the history
* * first version of lmdb support
* TODOs: remove LMDB=1 from source and set it in configure.ac

* ~ max db size 512MB

* lmdb: move to seperate source file and fix configure
  • Loading branch information
loomy authored and dinhvh committed Nov 3, 2018
1 parent 945f370 commit 7edab14
Show file tree
Hide file tree
Showing 4 changed files with 411 additions and 2 deletions.
16 changes: 15 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,23 @@ DBLINKED=0
DBLIB=""

AC_ARG_ENABLE(db, [AC_HELP_STRING([--disable-db], [disable Berkeley DB (default=try to detect DB)])],[enable_db=$enableval],[enable_db=yes])
AC_ARG_ENABLE(lmdb, [AC_HELP_STRING([--enable-lmdb], [enable lmdb as cache DB instead of BerkeleyDB (default=disable)])],[enable_lmdb=$enableval],[enable_lmdb=no])

if test "x$enable_lmdb" = "xyes"; then
AC_CHECK_HEADER(lmdb.h, [LMDB="yes"])
if test "x$LMDB" = "x"; then
AC_MSG_WARN(lmdb.h not found cache support disabled)
else
AC_CHECK_LIB(lmdb, mdb_env_create, [DBLIB="-llmdb"; DBLINKED=1], [])
if test "$DBLINKED" = 1; then
AC_DEFINE([LMDB], [1], [Enable support for lmdb cache])
enable_db="no"
else
AC_MSG_WARN(liblmdb not found cache support disabled)
fi
fi
dnl Check for a presence of Berkeley DB header
if test "x$enable_db" != "xyes"; then
elif test "x$enable_db" != "xyes"; then
AC_MSG_WARN(cache support disabled)
else
AC_CHECK_HEADER(db.h, [DB_HEADER=1], [DB_HEADER=0])
Expand Down
2 changes: 1 addition & 1 deletion src/data-types/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ libdata_types_la_SOURCES = connect.h connect.c base64.h hmac-md5.h \
mailstream_low.c mailstream.c mailstream_socket.c \
mailstream_ssl.c carray.c clist.c chash.c \
charconv.c maillock.c base64.c mail_cache_db_types.h \
mail_cache_db.h mail_cache_db.c mailsem.c mailsasl.h \
mail_cache_db.h mail_cache_db.c mail_cache_lmdb.c mailsem.c mailsasl.h \
mailsasl.c mailstream_cancel_types.h mailstream_cancel.h \
mailstream_cancel.c timeutils.h timeutils.c \
mmapstring_private.h mailstream_ssl_private.h \
Expand Down
4 changes: 4 additions & 0 deletions src/data-types/mail_cache_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
# include <config.h>
#endif

#ifndef LMDB

#include "mail_cache_db.h"

#include <sys/types.h>
Expand Down Expand Up @@ -498,3 +500,5 @@ int mail_cache_db_get_keys(struct mail_cache_db * cache_db,
return -1;
}
#endif

#endif
Loading

0 comments on commit 7edab14

Please sign in to comment.