Require BDB >= 4.5 for sanity's sake
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 8 Apr 2010 09:33:19 +0000 (12:33 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 8 Apr 2010 09:33:19 +0000 (12:33 +0300)
- replace unused feature tests in configure.ac with a simple version check

configure.ac
lib/backend/db3.c

index 40990df..e5fd6ba 100644 (file)
@@ -310,24 +310,14 @@ esac],
 case "$with_external_db" in
 yes )
   AC_CHECK_HEADERS([db.h],[
-    AC_CHECK_TYPE([db_threadid_t],[],
-      [AC_MSG_WARN([missing type db_threadid_t])],
-      [#include <db.h>])
-    save_LIBS="$LIBS"
-    AC_CHECK_LIB([db],[db_create],[],[
-      AC_MSG_ERROR([missing db_create in libdb])
-      ])
-    AC_CHECK_LIB([db],[db_env_create],[],[
-      AC_MSG_ERROR([missing db_env_create in libdb])
-      ])
-    AC_CHECK_LIB([db],[db_env_set_func_fsync],[],[
-      AC_MSG_ERROR([missing db_env_set_func_fsync in libdb])
-      ])
-    AC_CHECK_LIB([db],[db_strerror],[],[
-      AC_MSG_ERROR([missing db_strerror in libdb])
-      ])
-    WITH_DB_LIB=-ldb
-    LIBS="$save_LIBS"
+    AC_PREPROC_IFELSE([
+       #include <db.h>
+       #if !(DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 5)
+       #error Berkeley DB too old
+       #endif
+    ],[ WITH_DB_LIB=-ldb ], 
+      [ AC_MSG_ERROR([Berkeley DB version >= 4.5 required])
+    ])
   ],[
     AC_MSG_ERROR([missing required header db.h])
   ])
index 549e4cd..0bb6e18 100644 (file)
@@ -68,7 +68,6 @@ static int fsync_disable(int fd)
     return 0;
 }
 
-#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 5)
 /*
  * dbenv->failchk() callback method for determining is the given pid/tid 
  * is alive. We only care about pid's though. 
@@ -88,7 +87,6 @@ static int isalive(DB_ENV *dbenv, pid_t pid, db_threadid_t tid, uint32_t flags)
     
     return alive;
 }
-#endif
 
 static int db_init(dbiIndex dbi, const char * dbhome, DB_ENV ** dbenvp)
 {
@@ -116,14 +114,12 @@ static int db_init(dbiIndex dbi, const char * dbhome, DB_ENV ** dbenvp)
     dbenv->set_errcall(dbenv, NULL);
     dbenv->set_errpfx(dbenv, _errpfx);
 
-#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 5)
     /* 
      * These enable automatic stale lock removal. 
      * thread_count 8 is some kind of "magic minimum" value...
      */
     dbenv->set_thread_count(dbenv, 8);
     dbenv->set_isalive(dbenv, isalive);
-#endif
 
     dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
            (dbi->dbi_verbose & DB_VERB_DEADLOCK));
@@ -152,13 +148,11 @@ static int db_init(dbiIndex dbi, const char * dbhome, DB_ENV ** dbenvp)
     if (rc)
        goto errxit;
 
-#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 5)
     /* stale lock removal */
     rc = dbenv->failchk(dbenv, 0);
     rc = cvtdberr(dbi, "dbenv->failchk", rc, _debug);
     if (rc)
        goto errxit;
-#endif
 
     *dbenvp = dbenv;