#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
+#include <syslog.h>
#include <sys/syslog.h>
#if TIME_WITH_SYS_TIME
#endif
#include "citadel.h"
#include "server.h"
-#include "serv_extensions.h"
#include "sysdep_decls.h"
#include "citserver.h"
#include "support.h"
#include "database.h"
#include "housekeeping.h"
#include "tools.h"
-#include "serv_crypto.h"
-#include "serv_fulltext.h"
+#include "modules/crypto/serv_crypto.h" /* Needed for init_ssl, client_write_ssl, client_read_ssl, destruct_ssl */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
time_t last_purge = 0; /* Last dead session purge */
static int num_threads = 0; /* Current number of threads */
int num_sessions = 0; /* Current number of sessions */
-pthread_t indexer_thread_tid;
-pthread_t checkpoint_thread_tid;
int syslog_facility = LOG_DAEMON;
int enable_syslog = 0;
-extern int running_as_daemon;
void DestroyWorkerList(void);
volatile int time_to_die = 0;
volatile int shutdown_and_halt = 0;
+volatile int restart_server = 0;
+volatile int running_as_daemon = 0;
static RETSIGTYPE signal_cleanup(int signum) {
lprintf(CTDL_DEBUG, "Caught signal %d; shutting down.\n", signum);
sin.sin_addr.s_addr = inet_addr(ip_addr);
}
- if (sin.sin_addr.s_addr == INADDR_NONE) {
+ if (sin.sin_addr.s_addr == !INADDR_ANY) {
sin.sin_addr.s_addr = INADDR_ANY;
}
/* Strip the trailing LF, and the trailing CR if present.
*/
buf[i] = 0;
- while ( (strlen(buf) > 0) && ((buf[strlen(buf)-1]==10) || (buf[strlen(buf)-1] == 13)) ) {
+ while ( (!IsEmptyStr(buf)) && ((buf[strlen(buf)-1]==10) || (buf[strlen(buf)-1] == 13)) ) {
buf[strlen(buf)-1] = 0;
}
if (retval < 0) safestrncpy(buf, "000", bufsize);
else {
fp = fopen(file_pid_file, "w");
if (fp != NULL) {
- fprintf(fp, "%d\n", child);
+ fprintf(fp, ""F_PID_T"\n", child);
fclose(fp);
}
waitpid(current_child, &status, 0);
}
/*
- * Create the indexer thread and begin its operation.
- * Then create the checkpoint thread and begin its operation.
+ * Create the maintenance threads and begin their operation.
*/
void create_maintenance_threads(void) {
int ret;
pthread_attr_destroy(&attr);
return;
}
+
+ struct MaintenanceThreadHook *fcn;
- if ((ret = pthread_create(&indexer_thread_tid, &attr, indexer_thread, NULL) != 0)) {
- lprintf(CTDL_ALERT, "Can't create thread: %s\n", strerror(ret));
- }
+ lprintf(CTDL_DEBUG, "Performing startup of maintenance thread hooks\n");
- if ((ret = pthread_create(&checkpoint_thread_tid, &attr, checkpoint_thread, NULL) != 0)) {
- lprintf(CTDL_ALERT, "Can't create thread: %s\n", strerror(ret));
+ for (fcn = MaintenanceThreadHookTable; fcn != NULL; fcn = fcn->next) {
+ if ((ret = pthread_create(&(fcn->MaintenanceThread_tid), &attr, fcn->fcn_ptr, NULL) != 0)) {
+ lprintf(CTDL_ALERT, "Can't create thread: %s\n", strerror(ret));
+ }
+ else
+ {
+ lprintf(CTDL_NOTICE, "Spawned a new maintenance thread \"%s\" (%ld). \n", fcn->name,
+ fcn->MaintenanceThread_tid);
+ }
}
+
pthread_attr_destroy(&attr);
}