From 85a4cfac437eda319682e51b97d4cee5eac9f8da Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 19 Mar 2003 04:04:56 +0000 Subject: [PATCH] * Dropped support for GDBM and for versions of Berkeley DB prior to 4.1 --- citadel/ChangeLog | 4 + citadel/configure.ac | 43 +--- citadel/database.c | 435 ----------------------------------- citadel/database_sleepycat.c | 110 ++------- 4 files changed, 26 insertions(+), 566 deletions(-) delete mode 100644 citadel/database.c diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 66a2f786a..ab3f0c716 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 605.23 2003/03/19 04:04:56 ajc + * Dropped support for GDBM and for versions of Berkeley DB prior to 4.1 + Revision 605.22 2003/03/18 05:15:05 ajc * Applied a patch sent in by Clint Adams to handle building on Debian's unstable with Berkeley DB 4.1, compiled with @@ -4574,3 +4577,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/configure.ac b/citadel/configure.ac index a4ef11f4e..49044a476 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -19,7 +19,6 @@ AC_ARG_ENABLE(threaded-client, [ --disable-threaded-client AC_ARG_WITH(pam, [ --with-pam use PAM if present (see PAM.txt before you try this)]) AC_ARG_WITH(kthread, [ --with-kthread use kernel threads (on FreeBSD) (not recommended yet)]) -AC_ARG_WITH(gdbm, [ --with-gdbm@<:@=DIR@:>@ use GDBM @<:@DIR=/usr/local@:>@]) AC_ARG_WITH(db, [ --with-db@<:@=DIR@:>@ use Sleepycat DB 3.x @<:@DIR=/usr/local/BerkeleyDB.3.@<:@123@:>@@:>@]) AC_ARG_WITH(ssl, [ --with-ssl=PATH Specify path to OpenSSL installation ], @@ -34,27 +33,15 @@ AC_ARG_WITH(ncurses, [ --without-ncurses don't use ncurses]) AC_ARG_WITH(with_zlib, [ --with-zlib use zlib compression if present]) AC_ARG_WITH(with_libical, [ --with-libical use libical calendaring library]) -if test "x$with_gdbm" != xno -a "x$with_gdbm" != xyes -a "$with_gdbm"; then - db_dir="$with_gdbm" - with_gdbm=yes -fi - if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then db_dir="$with_db" with_db=yes else test -f /usr/local/lib/libdb.a -o -f /usr/local/lib/libdb.so \ -o -f /usr/local/lib/libdb4.a -o -f /usr/local/lib/libdb4.so \ - -o -f /usr/local/lib/libdb3.a -o -f /usr/local/lib/libdb3.so && db_dir=/usr/local + && db_dir=/usr/local - test -d /usr/local/BerkeleyDB.3.1 && db_dir=/usr/local/BerkeleyDB.3.1 - test -d /usr/local/BerkeleyDB.3.2 && db_dir=/usr/local/BerkeleyDB.3.2 - test -d /usr/local/BerkeleyDB.3.3 && db_dir=/usr/local/BerkeleyDB.3.3 - test -d /usr/local/BerkeleyDB.4.0 && db_dir=/usr/local/BerkeleyDB.4.0 -fi - -if test "x$with_gdbm" = xyes -a "x$with_db" = xyes; then - AC_MSG_ERROR(can't enable both gdbm and db) + test -d /usr/local/BerkeleyDB.4.1 && db_dir=/usr/local/BerkeleyDB.4.1 fi dnl By default, we only build the client (citadel and whobbs) unless we can @@ -320,7 +307,7 @@ if test "$with_ssl" != "no"; then fi fi -if test "x$with_db" != xno -a "x$with_gdbm" != xyes; then +if test "x$with_db" != xno; then test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib" dblib="" @@ -328,24 +315,17 @@ if test "x$with_db" != xno -a "x$with_gdbm" != xyes; then if test -d "$db_dir/include/db4"; then CPPFLAGS="$CPPFLAGS -I$db_dir/include/db4" dblib="db4" - elif test -d "$db_dir/include/db3"; then - CPPFLAGS="$CPPFLAGS -I$db_dir/include/db3" - dblib="db3" elif test "$db_dir"; then CPPFLAGS="$CPPFLAGS -I$db_dir/include" elif test -d /usr/include/db4; then CPPFLAGS="$CPPFLAGS -I/usr/include/db4" dblib="db4" - elif test -d /usr/include/db3; then - CPPFLAGS="$CPPFLAGS -I/usr/include/db3" - dblib="db3" fi - AC_CHECK_DB([db db-4.1 db-4 db4 db-3.3 db-3.2 db-3.1 db-3 db3], + AC_CHECK_DB([db db-4.1 db-4 db4], [ DATABASE=database_sleepycat.c - with_gdbm=no ], AC_MSG_ERROR([[Can not locate a suitable Berkeley DB library. Use --with-db=PATH to specify @@ -353,19 +333,6 @@ if test "x$with_db" != xno -a "x$with_gdbm" != xyes; then fi -if test "x$with_gdbm" != xno -a "x$with_db" != xyes; then - test -f /usr/local/lib/libgdbm.a -o -f /usr/local/lib/libgdbm.so && db_dir=/usr/local - test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib" - - test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include" - - AC_CHECK_LIB(gdbm, gdbm_open, - [LIBS="-lgdbm $LIBS" - DATABASE=database.c - with_db=no]) -fi - - dnl Checks for the zlib compression library. if test "x$with_zlib" != xno ; then @@ -429,7 +396,7 @@ dnl dnl TODO: for the DB header checks, we should check whether the headers dnl define db_env_create, somehow dnl -AC_CHECK_HEADERS(curses.h dl.h fcntl.h limits.h malloc.h termios.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db3/db.h db4/db.h pthread.h netinet/in.h arpa/nameser.h) +AC_CHECK_HEADERS(curses.h dl.h fcntl.h limits.h malloc.h termios.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db4/db.h pthread.h netinet/in.h arpa/nameser.h) dnl dnl need to check if this is actually compilable, sometimes there are diff --git a/citadel/database.c b/citadel/database.c deleted file mode 100644 index 934cd69e1..000000000 --- a/citadel/database.c +++ /dev/null @@ -1,435 +0,0 @@ -/* - * $Id$ - * - * GDBM database driver for Citadel/UX - * - */ - -/* - * Note that each call to a GDBM function is wrapped in an S_DATABASE critical - * section. This is done because GDBM is not threadsafe. This is the ONLY - * place in the entire Citadel server where any code enters two different - * classes of critical sections at the same time; this is why the GDBM calls - * are *tightly* wrapped in S_DATABASE. Opening multiple concurrent critical - * sections elsewhere in the code can, and probably will, cause deadlock - * conditions to occur. (Deadlock is bad. Eliminate.) - */ - -#ifdef DLL_EXPORT -#define IN_LIBCIT -#endif - -#include "sysdep.h" -#include -#include -#include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#include -#include -#include -#include -#include "citadel.h" -#include "server.h" -#include "database.h" -#include "sysdep_decls.h" - - -/* - * This array holds one gdbm handle for each Citadel database. - */ -GDBM_FILE gdbms[MAXCDB]; - -/* - * We also keep these around, for sequential searches (one per session slot) - */ -int max_keys = 0; -datum *dtkey; - - -/* - * Reclaim unused space in the databases. We need to do each one of - * these discretely, rather than in a loop. - */ -void defrag_databases(void) -{ - - /* defrag the message base */ - lprintf(7, "Defragmenting message base\n"); - begin_critical_section(S_DATABASE); - gdbm_reorganize(gdbms[CDB_MSGMAIN]); - end_critical_section(S_DATABASE); - - /* defrag the user file, mailboxes, and user/room relationships */ - lprintf(7, "Defragmenting user file\n"); - begin_critical_section(S_USERSUPP); - begin_critical_section(S_DATABASE); - gdbm_reorganize(gdbms[CDB_USERSUPP]); - gdbm_reorganize(gdbms[CDB_VISIT]); - end_critical_section(S_DATABASE); - end_critical_section(S_USERSUPP); - - /* defrag the room files and message lists */ - lprintf(7, "Defragmenting room files and message lists\n"); - begin_critical_section(S_QUICKROOM); - begin_critical_section(S_DATABASE); - gdbm_reorganize(gdbms[CDB_QUICKROOM]); - gdbm_reorganize(gdbms[CDB_MSGLISTS]); - end_critical_section(S_DATABASE); - end_critical_section(S_QUICKROOM); - - /* defrag the floor table */ - lprintf(7, "Defragmenting floor table\n"); - begin_critical_section(S_FLOORTAB); - begin_critical_section(S_DATABASE); - gdbm_reorganize(gdbms[CDB_FLOORTAB]); - end_critical_section(S_DATABASE); - end_critical_section(S_FLOORTAB); - - /* defrag the directory */ - lprintf(7, "Defragmenting the directory\n"); - begin_critical_section(S_DIRECTORY); - gdbm_reorganize(gdbms[CDB_DIRECTORY]); - end_critical_section(S_DIRECTORY); - - /* defrag the use table */ - lprintf(7, "Defragmenting the use table\n"); - gdbm_reorganize(gdbms[CDB_USETABLE]); -} - - -/* - * Open the various gdbm databases we'll be using. Any database which - * does not exist should be created. - */ -void open_databases(void) -{ - lprintf(7, "%s\n", gdbm_version); - - /* - * Silently try to create the database subdirectory. If it's - * already there, no problem. - */ - system("exec mkdir data 2>/dev/null"); - - /* a critical section is unnecessary, as this function is called before - any other threads are created. and it causes problems on BSDI. - - begin_critical_section(S_DATABASE); - - */ - - gdbms[CDB_MSGMAIN] = gdbm_open("data/msgmain.gdbm", 8192, - GDBM_WRCREAT, 0600, NULL); - if (gdbms[CDB_MSGMAIN] == NULL) { - lprintf(2, "Cannot open msgmain: %s\n", - gdbm_strerror(gdbm_errno)); - exit(1); - } - gdbms[CDB_USERSUPP] = gdbm_open("data/usersupp.gdbm", 0, - GDBM_WRCREAT, 0600, NULL); - if (gdbms[CDB_USERSUPP] == NULL) { - lprintf(2, "Cannot open usersupp: %s\n", - gdbm_strerror(gdbm_errno)); - exit(1); - } - gdbms[CDB_VISIT] = gdbm_open("data/visit.gdbm", 0, - GDBM_WRCREAT, 0600, NULL); - if (gdbms[CDB_VISIT] == NULL) { - lprintf(2, "Cannot open visit file: %s\n", - gdbm_strerror(gdbm_errno)); - exit(1); - } - gdbms[CDB_QUICKROOM] = gdbm_open("data/quickroom.gdbm", 0, - GDBM_WRCREAT, 0600, NULL); - if (gdbms[CDB_QUICKROOM] == NULL) { - lprintf(2, "Cannot open quickroom: %s\n", - gdbm_strerror(gdbm_errno)); - exit(1); - } - gdbms[CDB_FLOORTAB] = gdbm_open("data/floortab.gdbm", 0, - GDBM_WRCREAT, 0600, NULL); - if (gdbms[CDB_FLOORTAB] == NULL) { - lprintf(2, "Cannot open floortab: %s\n", - gdbm_strerror(gdbm_errno)); - exit(1); - } - gdbms[CDB_MSGLISTS] = gdbm_open("data/msglists.gdbm", 0, - GDBM_WRCREAT, 0600, NULL); - if (gdbms[CDB_MSGLISTS] == NULL) { - lprintf(2, "Cannot open msglists: %s\n", - gdbm_strerror(gdbm_errno)); - exit(1); - } - gdbms[CDB_DIRECTORY] = gdbm_open("data/directory.gdbm", 0, - GDBM_WRCREAT, 0600, NULL); - if (gdbms[CDB_DIRECTORY] == NULL) { - lprintf(2, "Cannot open directory: %s\n", - gdbm_strerror(gdbm_errno)); - exit(1); - } - gdbms[CDB_USETABLE] = gdbm_open("data/usetable.gdbm", 0, - GDBM_WRCREAT, 0600, NULL); - if (gdbms[CDB_USETABLE] == NULL) { - lprintf(2, "Cannot open use table: %s\n", - gdbm_strerror(gdbm_errno)); - exit(1); - } - - /* - end_critical_section(S_DATABASE); - */ - -} - - -/* - * Close all of the gdbm database files we've opened. This can be done - * in a loop, since it's just a bunch of closes. - */ -void close_databases(void) -{ - int a; - - begin_critical_section(S_DATABASE); - for (a = 0; a < MAXCDB; ++a) { - lprintf(7, "Closing database %d\n", a); - gdbm_close(gdbms[a]); - } - end_critical_section(S_DATABASE); - - for (a = 0; a < max_keys; ++a) { - if (dtkey[a].dptr != NULL) { - phree(dtkey[a].dptr); - } - } - -} - - -/* - * Store a piece of data. Returns 0 if the operation was successful. If a - * datum already exists it should be overwritten. - */ -int cdb_store(int cdb, - void *key, int keylen, - void *data, int datalen) -{ - - datum dkey, ddata; - int retval; - - dkey.dsize = keylen; - dkey.dptr = key; - ddata.dsize = datalen; - ddata.dptr = data; - - begin_critical_section(S_DATABASE); - retval = gdbm_store(gdbms[cdb], dkey, ddata, GDBM_REPLACE); - end_critical_section(S_DATABASE); - if (retval < 0) { - lprintf(2, "gdbm error: %s\n", gdbm_strerror(gdbm_errno)); - return (-1); - } - return (0); -} - - -/* - * Delete a piece of data. Returns 0 if the operation was successful. - */ -int cdb_delete(int cdb, void *key, int keylen) -{ - - datum dkey; - int retval; - - dkey.dsize = keylen; - dkey.dptr = key; - - begin_critical_section(S_DATABASE); - retval = gdbm_delete(gdbms[cdb], dkey); - end_critical_section(S_DATABASE); - return (retval); - -} - - - - -/* - * Fetch a piece of data. If not found, returns NULL. Otherwise, it returns - * a struct cdbdata which it is the caller's responsibility to free later on - * using the cdb_free() routine. - */ -struct cdbdata *cdb_fetch(int cdb, void *key, int keylen) -{ - - struct cdbdata *tempcdb; - datum dkey, dret; - - dkey.dsize = keylen; - dkey.dptr = key; - - begin_critical_section(S_DATABASE); - dret = gdbm_fetch(gdbms[cdb], dkey); - end_critical_section(S_DATABASE); - if (dret.dptr == NULL) { - return NULL; - } - tempcdb = (struct cdbdata *) mallok(sizeof(struct cdbdata)); - if (tempcdb == NULL) { - lprintf(2, "Cannot allocate memory!\n"); - } - tempcdb->len = dret.dsize; - tempcdb->ptr = dret.dptr; - return (tempcdb); -} - - -/* - * Free a cdbdata item (ok, this is really no big deal, but we might need to do - * more complex stuff with other database managers in the future). - */ -void cdb_free(struct cdbdata *cdb) -{ - phree(cdb->ptr); - phree(cdb); -} - -void cdb_close_cursor(cdb) -{ - while (max_keys <= CC->cs_pid) { - ++max_keys; - if (dtkey == NULL) { - dtkey = (datum *) - mallok((sizeof(datum) * max_keys)); - } else { - dtkey = (datum *) - reallok(dtkey, (sizeof(datum) * max_keys)); - } - dtkey[max_keys - 1].dsize = 0; - dtkey[max_keys - 1].dptr = NULL; - } - - if (dtkey[CC->cs_pid].dptr != NULL) { - phree(dtkey[CC->cs_pid].dptr); - } - dtkey[CC->cs_pid].dptr = NULL; - dtkey[CC->cs_pid].dsize = 0; -} - - -/* - * Prepare for a sequential search of an entire database. (In the gdbm model, - * we do this by keeping an array dtkey[] of "the next" key for each session - * that is open. There is guaranteed to be no more than one traversal in - * progress per session at any given time.) - */ -void cdb_rewind(int cdb) -{ - - while (max_keys <= CC->cs_pid) { - ++max_keys; - if (dtkey == NULL) { - dtkey = (datum *) - mallok((sizeof(datum) * max_keys)); - } else { - dtkey = (datum *) - reallok(dtkey, (sizeof(datum) * max_keys)); - } - dtkey[max_keys - 1].dsize = 0; - dtkey[max_keys - 1].dptr = NULL; - } - - if (dtkey[CC->cs_pid].dptr != NULL) { - phree(dtkey[CC->cs_pid].dptr); - } - begin_critical_section(S_DATABASE); - dtkey[CC->cs_pid] = gdbm_firstkey(gdbms[cdb]); - end_critical_section(S_DATABASE); -} - - -/* - * Fetch the next item in a sequential search. Returns a pointer to a - * cdbdata structure, or NULL if we've hit the end. - */ -struct cdbdata *cdb_next_item(int cdb) -{ - datum dret; - struct cdbdata *cdbret; - void *ptr = NULL; - - - if (dtkey[CC->cs_pid].dptr == NULL) { /* end of file */ - return NULL; - } - begin_critical_section(S_DATABASE); - dret = gdbm_fetch(gdbms[cdb], dtkey[CC->cs_pid]); - end_critical_section(S_DATABASE); - if (dret.dptr == NULL) { /* bad read */ - phree(dtkey[CC->cs_pid].dptr); - return NULL; - } - cdbret = (struct cdbdata *) mallok(sizeof(struct cdbdata)); - cdbret->len = dret.dsize; - cdbret->ptr = dret.dptr; - - ptr = dtkey[CC->cs_pid].dptr; - begin_critical_section(S_DATABASE); - dtkey[CC->cs_pid] = gdbm_nextkey(gdbms[cdb], dtkey[CC->cs_pid]); - end_critical_section(S_DATABASE); - - if (ptr != NULL) { /* Free the previous key. */ - free(ptr); - } - - return (cdbret); -} - - -/* - * Truncate (delete every record) - */ -void cdb_trunc(int cdb) { - datum key; - - begin_critical_section(S_DATABASE); - key = gdbm_firstkey (gdbms[cdb]); - while (key = gdbm_firstkey(gdbms[cdb], key.dptr) { - gdbm_delete(gdbms[cdb], key); - } - end_critical_section(S_DATABASE); -} - - - -/* - * empty functions because GDBM doesn't have transaction support - */ - -void cdb_begin_transaction(void) { -} - -void cdb_end_transaction(void) { -} - -void cdb_allocate_tsd(void) { -} - -void cdb_free_tsd(void) { -} - -void cdb_check_handles(void) { -} diff --git a/citadel/database_sleepycat.c b/citadel/database_sleepycat.c index a0f132016..5df1e6e3c 100644 --- a/citadel/database_sleepycat.c +++ b/citadel/database_sleepycat.c @@ -37,12 +37,16 @@ #include #elif defined(HAVE_DB4_DB_H) #include -#elif defined(HAVE_DB3_DB_H) -#include #else -#error Neither nor was found by configure. Install db3-devel. +#error Neither nor was found by configure. Install db4-devel. #endif + +#if DB_VERSION_MAJOR < 4 || DB_VERSION_MINOR < 1 +#error Citadel requires Berkeley DB v4.1 or newer. Please upgrade. +#endif + + #include #include "citadel.h" #include "server.h" @@ -71,7 +75,9 @@ static pthread_key_t tsdkey; /* just a little helper function */ static void txabort(DB_TXN *tid) { - int ret = tid->abort(tid); + int ret; + + ret = tid->abort(tid); if (ret) { lprintf(1, "cdb_*: txn_abort: %s\n", db_strerror(ret)); @@ -81,7 +87,9 @@ static void txabort(DB_TXN *tid) { /* this one is even more helpful than the last. */ static void txcommit(DB_TXN *tid) { - int ret = tid->commit(tid, 0); + int ret; + + ret = tid->commit(tid, 0); if (ret) { lprintf(1, "cdb_*: txn_commit: %s\n", db_strerror(ret)); @@ -91,7 +99,9 @@ static void txcommit(DB_TXN *tid) { /* are you sensing a pattern yet? */ static void txbegin(DB_TXN **tid) { - int ret = dbenv->txn_begin(dbenv, NULL, tid, 0); + int ret; + + ret = dbenv->txn_begin(dbenv, NULL, tid, 0); if (ret) { lprintf(1, "cdb_*: txn_begin: %s\n", db_strerror(ret)); @@ -199,13 +209,7 @@ static void cdb_cull_logs(void) { flags = DB_ARCH_ABS; /* Get the list of names. */ -#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR < 3 - if ((ret = log_archive(dbenv, &list, flags, NULL)) != 0) { -#elif DB_VERSION_MAJOR >= 4 if ((ret = dbenv->log_archive(dbenv, &list, flags)) != 0) { -#else - if ((ret = log_archive(dbenv, &list, flags)) != 0) { -#endif lprintf(1, "cdb_cull_logs: %s\n", db_strerror(ret)); return; } @@ -242,35 +246,16 @@ static void cdb_checkpoint(void) { int ret; static time_t last_cull = 0L; -#if DB_VERSION_MAJOR >= 4 ret = dbenv->txn_checkpoint(dbenv, -#else - ret = txn_checkpoint(dbenv, -#endif 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)); - 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) { @@ -357,16 +342,12 @@ 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 + NULL, dbfilename, NULL, DB_BTREE, DB_CREATE|DB_THREAD -#if DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 1 |DB_AUTO_COMMIT -#endif , 0600); if (ret) { @@ -397,11 +378,7 @@ void close_databases(void) cdb_free_tsd(); -#if DB_VERSION_MAJOR >= 4 if ((ret = dbenv->txn_checkpoint(dbenv, 0, 0, 0))) { -#else - if ((ret = txn_checkpoint(dbenv, 0, 0, 0))) { -#endif lprintf(1, "cdb_*: txn_checkpoint: %s\n", db_strerror(ret)); abort(); } @@ -848,9 +825,7 @@ void cdb_trunc(int cdb) { DB_TXN *tid; int ret; -#if DB_VERSION_MAJOR > 3 || DB_VERSION_MINOR > 2 u_int32_t count; -#endif if (MYTID != NULL) { @@ -861,56 +836,6 @@ void cdb_trunc(int cdb) { bailIfCursor(MYCURSORS, "attempt to write during r/o cursor"); -#if DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR < 3 - for (;;) - { - DBT key, data; - - /* Initialize the key/data pair so the flags aren't set. */ - memset(&key, 0, sizeof(key)); - memset(&data, 0, sizeof(data)); - - txbegin(&tid); - - ret = dbp[cdb]->cursor(dbp[cdb], tid, &MYCURSORS[cdb], 0); - if (ret) - { - lprintf(1, "cdb_trunc: db_cursor: %s\n", db_strerror(ret)); - abort(); - } - - ret = MYCURSORS[cdb]->c_get(MYCURSORS[cdb], - &key, &data, DB_NEXT); - if (ret) - { - cclose(MYCURSORS[cdb]); - txabort(tid); - if (ret == DB_LOCK_DEADLOCK) - continue; - - if (ret == DB_NOTFOUND) - break; - - lprintf(1, "cdb_trunc: c_get: %s\n", db_strerror(ret)); - abort(); - } - - ret = MYCURSORS[cdb]->c_del(MYCURSORS[cdb], 0); - if (ret) - { - cclose(MYCURSORS[cdb]); - txabort(tid); - if (ret == DB_LOCK_DEADLOCK) - continue; - - lprintf(1, "cdb_trunc: c_del: %s\n", db_strerror(ret)); - abort(); - } - - cclose(MYCURSORS[cdb]); - txcommit(tid); - } -#else retry: txbegin(&tid); @@ -935,6 +860,5 @@ void cdb_trunc(int cdb) { txcommit(tid); } -#endif } } -- 2.39.2