]> code.citadel.org Git - citadel.git/blobdiff - citadel/housekeeping.c
* Wrap txn_begin and txn_end in S_DATABASE mutex
[citadel.git] / citadel / housekeeping.c
index fc878b499280850cebfb204abd76c50071de5777..15f43df16fd8a1efbb3dbb2b394f4cc241151525 100644 (file)
@@ -1,8 +1,9 @@
 /*
+ * $Id$
+ *
  * This file contains housekeeping tasks which periodically
  * need to be executed.  It keeps a nice little queue...
  *
- * $Id$
  */
 
 #include "sysdep.h"
@@ -28,6 +29,7 @@
 #include "housekeeping.h"
 #include "sysdep_decls.h"
 #include "room_ops.h"
+#include "database.h"
 
 
 int housepipe[2];      /* This is the queue for housekeeping tasks */
@@ -111,6 +113,7 @@ void housekeeping_loop(void) {
                        }
 
                        extract(cmd, house_cmd, 0);
+                       cdb_begin_transaction();
 
                        /* Do whatever this cmd requires */
 
@@ -129,6 +132,8 @@ void housekeeping_loop(void) {
                                lprintf(7, "Unknown housekeeping command\n");
                        }
 
+                       cdb_end_transaction();
+
                } while (did_something);
        }
 }
@@ -164,19 +169,20 @@ void check_ref_counts_backend(struct quickroom *qrbuf, void *data) {
        ++flbuf.f_ref_count;
        flbuf.f_flags = flbuf.f_flags | QR_INUSE;
        putfloor(&flbuf, qrbuf->QRfloor);
-       }
+}
 
 void check_ref_counts(void) {
        struct floor flbuf;
        int a;
 
+       lprintf(7, "Checking floor reference counts\n");
        for (a=0; a<MAXFLOORS; ++a) {
                getfloor(&flbuf, a);
                flbuf.f_ref_count = 0;
                flbuf.f_flags = flbuf.f_flags & ~QR_INUSE;
                putfloor(&flbuf, a);
-               }
+       }
 
        ForEachRoom(check_ref_counts_backend, NULL);
-       }       
+}