]> code.citadel.org Git - citadel.git/blobdiff - citadel/database_sleepycat.c
* The size constant "256" which shows up everywhere as a buffer size has now
[citadel.git] / citadel / database_sleepycat.c
index 10be08d7891f5cd3bc91a2e1fe6ada71769fe9a3..f522fd1aec5adbe61478db19bf5f6d95d68e5b85 100644 (file)
@@ -5,22 +5,6 @@
  *
  */
 
-/*****************************************************************************
-       Tunable configuration parameters for the Sleepycat DB back end
- *****************************************************************************/
-
-/* Set to 1 for transaction-based database logging.  This is recommended for
- * safe recovery in the event of system or application failure.
- */
-#define TRANSACTION_BASED      1
-
-/* Citadel will checkpoint the db at the end of every session, but only if
- * the specified number of kilobytes has been written, or if the specified
- * number of minutes has passed, since the last checkpoint.
- */
-#define MAX_CHECKPOINT_KBYTES  0
-#define MAX_CHECKPOINT_MINUTES 15
-
 /*****************************************************************************/
 
 #include "sysdep.h"
@@ -31,6 +15,8 @@
 #include <ctype.h>
 #include <string.h>
 #include <errno.h>
+#include <sys/types.h>
+#include <signal.h>
 #include <db.h>
 #include "citadel.h"
 #include "server.h"
@@ -44,18 +30,18 @@ DB_ENV *dbenv;                      /* The DB environment (global) */
 
 struct cdbssd {                        /* Session-specific DB stuff */
        DBC *cursor;            /* Cursor, for traversals... */
-       DB_TXN *tid;            /* Transaction ID */
 };
 
 struct cdbssd *ssd_arr = NULL;
 int num_ssd = 0;
+
 #define MYCURSOR       ssd_arr[CC->cs_pid].cursor
-#define MYTID          ssd_arr[CC->cs_pid].tid
+#define MYTID          NULL
 
 /*
  * Ensure that we have enough space for session-specific data.  We don't
  * put anything in here that Citadel cares about; this is just database
- * related stuff like cursors and transactions.
+ * related stuff like cursors.
  */
 void cdb_allocate_ssd(void) {
        /*
@@ -91,22 +77,6 @@ void defrag_databases(void)
 
 
 
-/*
- * Request a checkpoint of the database.
- */
-void cdb_checkpoint(void) {
-       int ret;
-
-       ret = txn_checkpoint(dbenv,
-                               MAX_CHECKPOINT_KBYTES,
-                               MAX_CHECKPOINT_MINUTES,
-                               0);
-       if (ret) {
-               lprintf(1, "txn_checkpoint: %s\n", db_strerror(ret));
-       }
-}
-
-
 /*
  * Open the various databases we'll be using.  Any database which
  * does not exist should be created.  Note that we don't need an S_DATABASE
@@ -117,9 +87,10 @@ void open_databases(void)
 {
        int ret;
        int i;
-       char dbfilename[256];
+       char dbfilename[SIZ];
        u_int32_t flags = 0;
 
+       lprintf(9, "open_databases() starting\n");
         /*
          * Silently try to create the database subdirectory.  If it's
          * already there, no problem.
@@ -152,11 +123,8 @@ void open_databases(void)
         * is serialized already, so don't bother the database manager with
         * it.  Besides, it locks up when we do it that way.
          */
-#ifdef TRANSACTION_BASED
-        flags = DB_CREATE|DB_RECOVER|DB_INIT_MPOOL|DB_PRIVATE|DB_INIT_TXN;
-#else
-        flags = DB_CREATE|DB_RECOVER|DB_INIT_MPOOL|DB_PRIVATE;
-#endif
+        flags = DB_CREATE|DB_RECOVER|DB_INIT_MPOOL|DB_PRIVATE|DB_INIT_LOG;
+       /* flags |= DB_INIT_LOCK | DB_THREAD; */
         ret = dbenv->open(dbenv, "./data", flags, 0);
        if (ret) {
                lprintf(1, "dbenv->open: %s\n", db_strerror(ret));
@@ -195,9 +163,7 @@ void open_databases(void)
 
        cdb_allocate_ssd();
        CtdlRegisterSessionHook(cdb_allocate_ssd, EVT_START);
-#ifdef TRANSACTION_BASED
-       CtdlRegisterSessionHook(cdb_checkpoint, EVT_TIMER);
-#endif
+       lprintf(9, "open_databases() finished\n");
 }
 
 
@@ -386,27 +352,3 @@ struct cdbdata *cdb_next_item(int cdb)
        return (cdbret);
 }
 
-
-/*
- * Transaction-based stuff.  I'm writing this as I bake cookies...
- */
-
-void cdb_begin_transaction(void) {
-
-#ifdef TRANSACTION_BASED
-       begin_critical_section(S_DATABASE);
-       txn_begin(dbenv, NULL, &MYTID, 0);
-       end_critical_section(S_DATABASE);
-#else
-       MYTID = NULL;
-#endif
-}
-
-void cdb_end_transaction(void) {
-#ifdef TRANSACTION_BASED
-       begin_critical_section(S_DATABASE);
-       if (MYTID == NULL) lprintf(1, "WARNING: txn_commit(NULL) !!\n");
-       txn_commit(MYTID, 0);
-       end_critical_section(S_DATABASE);
-#endif
-}