*
*/
-/*****************************************************************************
- 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"
#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"
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) {
/*
-/*
- * 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
{
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.
* 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));
cdb_allocate_ssd();
CtdlRegisterSessionHook(cdb_allocate_ssd, EVT_START);
-#ifdef TRANSACTION_BASED
- CtdlRegisterSessionHook(cdb_checkpoint, EVT_TIMER);
-#endif
+ lprintf(9, "open_databases() finished\n");
}
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
-}