* Got the Sleepycat DB back end working, by opening the databases in a non
authorArt Cancro <ajc@citadel.org>
Thu, 30 Nov 2000 03:23:17 +0000 (03:23 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 30 Nov 2000 03:23:17 +0000 (03:23 +0000)
  shared, non threaded mode, and using Citadel's locking to serialize access.

citadel/ChangeLog
citadel/database_sleepycat.c

index caf6c0c3920041a59e8785f7527a1cc938ec612c..d21f132836da333a8dd08abfa64f70f360231978 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 573.36  2000/11/30 03:23:17  ajc
+ * Got the Sleepycat DB back end working, by opening the databases in a non
+   shared, non threaded mode, and using Citadel's locking to serialize access.
+
  Revision 573.35  2000/11/29 05:00:02  ajc
  * I think the db stuff is ok, but my db library is fux0red...
 
@@ -2169,4 +2173,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index dc77215e7a4e8e6f1ed6954db26ed4509ca06fc5..5b790c7462aa022bee3d2a88a2a080ccf46a5254 100644 (file)
@@ -28,18 +28,20 @@ DB *dbp[MAXCDB];
 
 DB_ENV *dbenv;
 
-DBC *cursorz[999];     /* FIXME !! */
+DBC **cursorz = NULL;
+int num_cursorz = 0;
 #define MYCURSOR cursorz[CC->cs_pid]
 
 /*
  * Reclaim unused space in the databases.  We need to do each one of
  * these discretely, rather than in a loop.
+ *
+ * This is a stub function in the Sleepycat DB backend, because there is no
+ * such API call available.
  */
 void defrag_databases(void)
 {
-       /* FIXME ... do we even need this?  If not, we'll just keep it as
-        * a stub function to keep the API consistent.
-        */
+       /* do nothing */
 }
 
 
@@ -67,7 +69,6 @@ void open_databases(void)
                lprintf(1, "db_env_create: %s\n", db_strerror(ret));
                exit(ret);
        }
-       dbenv->set_errfile(dbenv, stderr);  /* FIXME */
        dbenv->set_errpfx(dbenv, "citserver");
 
         /*
@@ -273,14 +274,33 @@ void cdb_free(struct cdbdata *cdb)
 
 
 /* 
- * Prepare for a sequential search of an entire database.  (In the DB model,
- * use per-session key. There is guaranteed to be no more than one traversal in
+ * Prepare for a sequential search of an entire database.
+ * (There is guaranteed to be no more than one traversal in
  * progress per session at any given time.)
  */
 void cdb_rewind(int cdb)
 {
        int ret = 0;
 
+       /*
+        * Make sure we have a cursor allocated for this session
+        */
+
+       if (num_cursorz <= CC->cs_pid) {
+               num_cursorz = CC->cs_pid + 1;
+               if (cursorz == NULL) {
+                       cursorz = (DBC **)
+                           mallok((sizeof(DBC *) * num_cursorz));
+               } else {
+                       cursorz = (DBC **)
+                           reallok(cursorz, (sizeof(DBC *) * num_cursorz));
+               }
+       }
+
+
+       /*
+        * Now initialize the cursor
+        */
        begin_critical_section(S_DATABASE);
        ret = dbp[cdb]->cursor(dbp[cdb], NULL, &MYCURSOR, 0);
        if (ret) {