Simple concurrency lock to prevent multiple citservers running at the same time
[citadel.git] / citadel / database.c
index fd7730d42aaee22cdc46922467a35e802c899bd6..dbfac8dd54ebc1522ea588b2d87c483457183794 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This is a data store backend for the Citadel server which uses Berkeley DB.
  *
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2016 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 3.
 #ifdef HAVE_DB_H
 #include <db.h>
 #elif defined(HAVE_DB4_DB_H)
-#include <db4/db.h>
+#include <db5/db.h>
 #else
-#error Neither <db.h> nor <db4/db.h> was found by configure. Install db4-devel.
+#error Neither <db.h> nor <db5/db.h> was found by configure. Install db5-devel.
 #endif
 
-
-#if DB_VERSION_MAJOR < 4 || DB_VERSION_MINOR < 1
-#error Citadel requires Berkeley DB v4.1 or newer.  Please upgrade.
+#if DB_VERSION_MAJOR < 5
+#error Citadel requires Berkeley DB v5.0 or newer.  Please upgrade.
 #endif
 
-
 #include <libcitadel.h>
 
 #include "ctdl_module.h"
@@ -52,7 +50,6 @@
 #include "citserver.h"
 #include "config.h"
 
-
 static DB *dbp[MAXCDB];                /* One DB handle for each Citadel database */
 static DB_ENV *dbenv;          /* The DB environment (global) */
 
@@ -215,7 +212,7 @@ void cdb_checkpoint(void)
 {
        int ret;
 
-       syslog(LOG_DEBUG, "-- db checkpoint --");
+       MARKM_syslog(LOG_DEBUG, "-- db checkpoint --");
        ret = dbenv->txn_checkpoint(dbenv, MAX_CHECKPOINT_KBYTES, MAX_CHECKPOINT_MINUTES, 0);
 
        if (ret != 0) {
@@ -281,9 +278,7 @@ void open_databases(void)
        dbenv->set_paniccall(dbenv, dbpanic);
        dbenv->set_errcall(dbenv, cdb_verbose_err);
        dbenv->set_errpfx(dbenv, "ctdl");
-#if (DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR >= 3)
        dbenv->set_msgcall(dbenv, cdb_verbose_log);
-#endif
        dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK, 1);
        dbenv->set_verbose(dbenv, DB_VERB_RECOVERY, 1);
 
@@ -916,8 +911,10 @@ time_t CheckIfAlreadySeen(const char *Facility,
                else
                {
                        if (cdbut) cdb_free(cdbut);
-
+                       
                        SEENM_syslog(LOG_DEBUG, "not Found");
+                       if (cType == eCheckUpdate)
+                               return 0;
                }
 
                if (cType == eCheckExist)