]> code.citadel.org Git - citadel.git/blobdiff - citadel/database_sleepycat.c
* Variable names, comments, documentation, etc... removed the acronym 'BBS'
[citadel.git] / citadel / database_sleepycat.c
index 5117bb59002db8fbd726aa9efa0127f3872935ac..473071c340e84ab1f3505fa3e04498978c612485 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Sleepycat (Berkeley) DB driver for Citadel/UX
+ * Sleepycat (Berkeley) DB driver for Citadel
  *
  */
 
@@ -273,9 +273,9 @@ static void cdb_checkpoint(void) {
 
 /*
  * 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
- * critical section here, because there aren't any active threads manipulating
- * the database yet -- and besides, it causes problems on BSDI.
+ * does not exist should be created.  Note that we don't need a
+ * critical section here, because there aren't any active threads
+ * manipulating the database yet.
  */
 void open_databases(void)
 {
@@ -305,7 +305,7 @@ void open_databases(void)
          */
        mkdir(dbdirname, 0700);
        chmod(dbdirname, 0700);
-       chown(dbdirname, BBSUID, (-1) );
+       chown(dbdirname, CTDLUID, (-1) );
 
        lprintf(CTDL_DEBUG, "cdb_*: Setting up DB environment\n");
        db_env_set_func_yield(sched_yield);
@@ -366,8 +366,7 @@ void open_databases(void)
                                dbfilename,
                                NULL,
                                DB_BTREE,
-                               DB_CREATE|DB_THREAD
-                               |DB_AUTO_COMMIT
+                               DB_CREATE|DB_AUTO_COMMIT|DB_THREAD
                                ,
                                0600);
                if (ret) {
@@ -394,7 +393,7 @@ void open_databases(void)
                                snprintf(filename, sizeof filename, "%s/%s",
                                        dbdirname, d->d_name);
                                chmod(filename, 0600);
-                               chown(filename, BBSUID, (-1) );
+                               chown(filename, CTDLUID, (-1) );
                        }
                }
                closedir(dp);
@@ -416,16 +415,18 @@ void close_databases(void)
        cdb_free_tsd();
 
        if ((ret = dbenv->txn_checkpoint(dbenv, 0, 0, 0))) {
-               lprintf(CTDL_EMERG, "cdb_*: txn_checkpoint: %s\n", db_strerror(ret));
-               abort();
+               lprintf(CTDL_EMERG,
+                       "cdb_*: txn_checkpoint: %s\n",
+                       db_strerror(ret));
        }
 
        for (a = 0; a < MAXCDB; ++a) {
                lprintf(CTDL_INFO, "cdb_*: Closing database %d\n", a);
                ret = dbp[a]->close(dbp[a], 0);
                if (ret) {
-                       lprintf(CTDL_EMERG, "cdb_*: db_close: %s\n", db_strerror(ret));
-                       abort();
+                       lprintf(CTDL_EMERG,
+                               "cdb_*: db_close: %s\n",
+                               db_strerror(ret));
                }
                
        }
@@ -433,8 +434,9 @@ void close_databases(void)
         /* Close the handle. */
         ret = dbenv->close(dbenv, 0);
        if (ret) {
-                lprintf(CTDL_EMERG, "cdb_*: DBENV->close: %s\n", db_strerror(ret));
-               abort();
+                lprintf(CTDL_EMERG,
+                       "cdb_*: DBENV->close: %s\n",
+                       db_strerror(ret));
         }
 }
 
@@ -466,9 +468,9 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb) {
        uncompressed_data = malloc(zheader.uncompressed_len);
 
        if (uncompress( (Bytef *) uncompressed_data,
-                       &destLen,
-                       compressed_data,
-                       sourceLen
+                       (uLongf *)&destLen,
+                       (const Bytef *)compressed_data,
+                       (uLong)sourceLen
        ) != Z_OK) {
                lprintf(CTDL_EMERG, "uncompress() error\n");
                abort();
@@ -758,8 +760,11 @@ void cdb_rewind(int cdb)
 {
        int ret = 0;
 
-       if (MYCURSORS[cdb] != NULL)
-               cclose(MYCURSORS[cdb]);
+       if (MYCURSORS[cdb] != NULL) {
+               lprintf(CTDL_EMERG, "cdb_rewind: must close cursor on database %d before reopening.\n", cdb);
+               abort();
+               /* cclose(MYCURSORS[cdb]); */
+       }
 
        /*
         * Now initialize the cursor