Somebody broke the build by forgetting to #include "threads.h" in some of
[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 "citadel.h"
32 #include "server.h"
33 #include "citserver.h"
34 #include "database.h"
35 #include "msgbase.h"
36 #include "sysdep_decls.h"
37 #include "config.h"
38 #include "threads.h"
39
40 #include "ctdl_module.h"
41  
42 /*
43  * Main loop for the checkpoint thread.
44  */
45 void *checkpoint_thread(void *arg) {
46         struct CitContext checkpointCC;
47
48         CtdlLogPrintf(CTDL_DEBUG, "checkpoint_thread() initializing\n");
49
50         memset(&checkpointCC, 0, sizeof(struct CitContext));
51         checkpointCC.internal_pgm = 1;
52         checkpointCC.cs_pid = 0;
53         pthread_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 }