System users (SYS_*) now have proper user numbers.
[citadel.git] / citadel / modules / checkpoint / serv_checkpoint.c
1 /*
2  * $Id: serv_checkpoint.c 5756 2007-11-16 17:15:22Z ajc $
3  *
4  * checkpointing module for the database
5  */
6  
7 #include "sysdep.h"
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <stdio.h>
11 #include <ctype.h>
12 #include <string.h>
13 #include <errno.h>
14 #include <sys/types.h>
15 #include <sys/stat.h>
16 #include <dirent.h>
17
18 #ifdef HAVE_DB_H
19 #include <db.h>
20 #elif defined(HAVE_DB4_DB_H)
21 #include <db4/db.h>
22 #else
23 #error Neither <db.h> nor <db4/db.h> was found by configure. Install db4-devel.
24 #endif
25
26
27 #if DB_VERSION_MAJOR < 4 || DB_VERSION_MINOR < 1
28 #error Citadel requires Berkeley DB v4.1 or newer.  Please upgrade.
29 #endif
30
31 #include <libcitadel.h>
32
33 #include "citadel.h"
34 #include "server.h"
35 #include "citserver.h"
36 #include "database.h"
37 #include "msgbase.h"
38 #include "sysdep_decls.h"
39 #include "config.h"
40 #include "threads.h"
41
42 #include "ctdl_module.h"
43  
44 /*
45  * Main loop for the checkpoint thread.
46  */
47 void *checkpoint_thread(void *arg) {
48         struct CitContext checkpointCC;
49
50         CtdlLogPrintf(CTDL_DEBUG, "checkpoint_thread() initializing\n");
51
52         CtdlFillSystemContext(&checkpointCC, "checkpoint");
53         citthread_setspecific(MyConKey, (void *)&checkpointCC );
54
55         while (!CtdlThreadCheckStop()) {
56                 cdb_checkpoint();
57                 CtdlThreadSleep(60);
58         }
59
60         CtdlLogPrintf(CTDL_DEBUG, "checkpoint_thread() exiting\n");
61         return NULL;
62 }
63
64
65 CTDL_MODULE_INIT(checkpoint) {
66         if (threading)
67         {
68                 CtdlThreadCreate ("checkpoint", CTDLTHREAD_BIGSTACK, checkpoint_thread, NULL);
69         }
70         /* return our Subversion id for the Log */
71         return "$Id: serv_autocompletion.c 5756 2007-11-16 17:15:22Z ajc $";
72 }