]> code.citadel.org Git - citadel.git/commitdiff
* Stabilize, dammit!!
authorArt Cancro <ajc@citadel.org>
Tue, 12 Dec 2000 06:19:56 +0000 (06:19 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 12 Dec 2000 06:19:56 +0000 (06:19 +0000)
citadel/ChangeLog
citadel/citserver.c
citadel/database_sleepycat.c
citadel/dynloader.c
citadel/sysdep.c

index 52d3d74128478fda023b2316c20250d83b4385de..b2d123ab79295f5e8502b61eb8be507c68d774ef 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 573.49  2000/12/12 06:19:55  ajc
+ * Stabilize, dammit!!
+
  Revision 573.48  2000/12/12 04:20:03  ajc
  * Made the transaction open/close a global thing, in a frantic attempt to get
    Uncensored to stop crashing.  More fixes on the way...
@@ -2216,3 +2219,4 @@ 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 1882aa8937aeb9355b96163a2b12ea8e63e51297..24f106b4607deb4d57c8dc2fa715d8c9f2202416 100644 (file)
@@ -54,6 +54,7 @@ int do_defrag = 0;
 void master_startup(void) {
        struct timeval tv;
        
+       lprintf(9, "master_startup() started\n");
        lprintf(7, "Opening databases\n");
        open_databases();
        cdb_begin_transaction();
@@ -73,6 +74,7 @@ void master_startup(void) {
        lprintf(7, "Seeding the pseudo-random number generator...\n");
        gettimeofday(&tv, NULL);
        srand(tv.tv_usec);
+       lprintf(9, "master_startup() finished\n");
 }
 
 
@@ -108,7 +110,7 @@ void master_cleanup(void) {
        lprintf(3, "citserver: exiting.\n");
        fflush(stdout); fflush(stderr);
        exit(0);
-       }
+}
 
 
 /*
index 8d67f9b68cb6d7aa7274dbeaf3f2f7471af0a356..cb31b8dd3191c7a5722d4e47d88aea053526d9a0 100644 (file)
@@ -9,11 +9,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.
@@ -31,6 +26,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"
 
 DB *dbp[MAXCDB];               /* One DB handle for each Citadel database */
 DB_ENV *dbenv;                 /* The DB environment (global) */
+DB_TXN *MYTID;
 
 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 */
-DB_TXN *MYTID;
 
 /*
  * Ensure that we have enough space for session-specific data.  We don't
@@ -121,6 +117,7 @@ void open_databases(void)
        char dbfilename[256];
        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.
@@ -153,11 +150,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_INIT_LOCK | DB_THREAD; */
         ret = dbenv->open(dbenv, "./data", flags, 0);
        if (ret) {
                lprintf(1, "dbenv->open: %s\n", db_strerror(ret));
@@ -196,9 +190,8 @@ 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");
 }
 
 
@@ -394,20 +387,21 @@ struct cdbdata *cdb_next_item(int cdb)
 
 void cdb_begin_transaction(void) {
 
-#ifdef TRANSACTION_BASED
        begin_critical_section(S_DATABASE);
-       txn_begin(dbenv, NULL, &MYTID, 0);
+
+       if (MYTID != NULL) {    /* FIXME this slows it down, take it out */
+               lprintf(1, "ERROR: thread %d is opening a new transaction with one already open!\n", getpid());
+       }
+       else {
+               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);
+       if (MYTID == NULL) lprintf(1, "ERROR: txn_commit(NULL) !!\n");
+       else txn_commit(MYTID, 0);
+       MYTID = NULL;   /* FIXME take out */
        end_critical_section(S_DATABASE);
-#endif
 }
index 585b4ff3d52b78f6b24e48c93ce4026cf82263d8..1087be5c5a02ba15468098e9c78210df9ce20d80 100644 (file)
@@ -102,6 +102,7 @@ void DLoader_Init(char *pathname)
                        continue;
 
                snprintf(pathbuf, PATH_MAX, "%s/%s", pathname, dptr->d_name);
+               lprintf(7, "Initializing %s...\n", pathbuf);
 
 #ifdef RTLD_LAZY
                if (!(fcn_handle = dlopen(pathbuf, RTLD_LAZY)))
index 338b30091da8cebf9dcb4e81f4faf6f51d9bef40..2b6cb68009ed39650390e8c93a8ef56323875fe6 100644 (file)
@@ -995,7 +995,7 @@ int main(int argc, char **argv)
 
        /* We want to check for idle sessions once per minute */
        CtdlRegisterSessionHook(terminate_idle_sessions, EVT_TIMER);
-
+       
        /*
         * Now create a bunch of worker threads.
         */
@@ -1009,6 +1009,7 @@ int main(int argc, char **argv)
                }
        }
 
+
        /* Now this thread can become a worker as well. */
        worker_thread();
 
@@ -1191,7 +1192,6 @@ SETUP_FD: memcpy(&readfds, &masterfds, sizeof masterfds);
                }
 
                check_sched_shutdown();
-
        }
 
        /* If control reaches this point, the server is shutting down */