]> code.citadel.org Git - citadel.git/blobdiff - citadel/database_sleepycat.c
* Renamed "dynloader" to "serv_extensions" globally. We don't want people
[citadel.git] / citadel / database_sleepycat.c
index ae63d5e9ae38b9301e38d3854f7fc2effb1a5bd6..df38f880d9a4665f4aff1fea391bdf6b5d5f69e6 100644 (file)
@@ -46,7 +46,7 @@
 #include <pthread.h>
 #include "citadel.h"
 #include "server.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
 #include "citserver.h"
 #include "database.h"
 #include "msgbase.h"
@@ -154,7 +154,7 @@ void cdb_allocate_tsd(void) {
        if (pthread_getspecific(tsdkey) != NULL)
                return;
 
-       tsd = mallok(sizeof *tsd);
+       tsd = mallok(sizeof(struct cdbtsd));
 
        tsd->tid = NULL;
 
@@ -250,14 +250,27 @@ static void cdb_checkpoint(void) {
                                MAX_CHECKPOINT_KBYTES,
                                MAX_CHECKPOINT_MINUTES,
                                0);
+
+/* The DB_INCOMPLETE error is no longer possible (or even defined) as of
+ * Berkeley DB v4.1.  When we get to the point where v4.0 and earlier are no
+ * longer supported, we can remove this ifdef.
+ */
+#ifdef DB_INCOMPLETE
        if ( (ret != 0) && (ret != DB_INCOMPLETE) ) {
-               lprintf(1, "cdb_checkpoint: txn_checkpoint: %s\n", db_strerror(ret));
+               lprintf(1, "cdb_checkpoint: txn_checkpoint: %s\n",
+                       db_strerror(ret));
                abort();
        }
-
        if (ret == DB_INCOMPLETE) {
                lprintf(3, "WARNING: txn_checkpoint: %s\n", db_strerror(ret));
        }
+#else /* DB_INCOMPLETE */
+       if (ret != 0) {
+               lprintf(1, "cdb_checkpoint: txn_checkpoint: %s\n",
+                       db_strerror(ret));
+               abort();
+       }
+#endif /* DB_INCOMPLETE */
 
        /* Cull the logs if we haven't done so for 24 hours */
        if ((time(NULL) - last_cull) > 86400L) {
@@ -344,10 +357,17 @@ void open_databases(void)
                snprintf(dbfilename, sizeof dbfilename, "cdb.%02x", i);
 
                ret = dbp[i]->open(dbp[i],
+#if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 1
+                               NULL,                   /* new parameter */
+#endif
                                dbfilename,
                                NULL,
                                DB_BTREE,
-                               DB_CREATE|DB_THREAD,
+                               DB_CREATE|DB_THREAD
+#if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 1
+                               |DB_AUTO_COMMIT
+#endif
+                               ,
                                0600);
                if (ret) {
                        lprintf(1, "cdb_*: db_open[%d]: %s\n", i, db_strerror(ret));