#define LIBCITADEL_MIN 951 // Minimum required version of libcitadel
#define SERVER_TYPE 0 // zero for stock Citadel; other developers please obtain SERVER_TYPE codes for your implementations
-#define TRACE syslog(LOG_DEBUG, "\033[7m Checkpoint: %s : %d \033[0m", __FILE__, __LINE__)
+#define TRACE syslog(LOG_DEBUG, "\033[7m Checkpoint: %p : %s : %d \033[0m", CC, __FILE__, __LINE__)
#ifndef LONG_MAX
#define LONG_MAX 2147483647L
int do_perminute_housekeeping_now = 0;
time_t now;
- if (housekeeping_disabled) {
+ if ( (housekeeping_disabled) || (housekeeping_in_progress) ) {
return;
}
return;
}
+ if (!do_housekeeping_now) {
+ return;
+ }
+
// Ok, at this point we've made the decision to run the housekeeping
// loop. Everything below this point is real work.
int i;
time_t last_update = 0;
+ cdb_begin_transaction();
for (i=0; i<65536; ++i) {
if ((time(NULL) - last_update) >= 10) {
syslog(LOG_INFO, "fulltext: flushing index cache to disk (%d%% complete)", (i * 100 / 65536));
ftc_msgs[i] = NULL;
}
}
+ cdb_end_transaction();
syslog(LOG_INFO, "fulltext: flushed index cache to disk (100%% complete)");
}
// FIXME
// There is something in this module that fux0rs the new backend, causing it to deadlock.
- // syslog(LOG_DEBUG, "extensions: init %s", ctdl_module_init_fulltext());
+ syslog(LOG_DEBUG, "extensions: init %s", ctdl_module_init_fulltext());
syslog(LOG_DEBUG, "extensions: init %s", ctdl_module_init_image());
syslog(LOG_DEBUG, "extensions: init %s", ctdl_module_init_imap());
}
// Now begin the traversal.
- if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) {
+ if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) if (msglist[a] > 0) {
// If the caller is looking for a specific MIME type, filter
// out all messages which are not of the type requested.
}
end_critical_section(S_SESSION_TABLE);
- if (bind_me) {
- goto SKIP_SELECT;
+ if (bind_me) { // don't search for a session to bind to.
+ goto SKIP_SELECT; // we already found one.
}
// If we got this far, it means that there are no sessions
}
// If control reaches this point, the server is shutting down
- while(1) {
- sleep(1); // wait to die
- }
- //pthread_mutex_lock(&ThreadCountMutex);
- //--num_workers;
- //pthread_mutex_unlock(&ThreadCountMutex);
- //return(NULL);
+ return(NULL);
}
pthread_mutex_t Critters[MAX_SEMAPHORES]; // Things needing locking
int server_shutting_down = 0; // set to nonzero during shutdown
pthread_mutex_t ThreadCountMutex;
-char locks[MAX_SEMAPHORES+1];
void InitializeSemaphores(void) {
int i;
// Set up a bunch of semaphores to be used for critical sections
for (i=0; i<MAX_SEMAPHORES; ++i) {
pthread_mutex_init(&Critters[i], NULL);
- locks[i] = ' ';
}
- locks[MAX_SEMAPHORES] = 0;
}
// For all types of critical sections except those listed here,
// ensure nobody ever tries to do a critical section within a
// transaction; this could lead to deadlock.
- if ( (which_one != S_FLOORCACHE)
- && (which_one != S_NETCONFIGS)
- ) {
+ if ((which_one != S_FLOORCACHE) && (which_one != S_NETCONFIGS)) {
cdb_check_handles();
}
- //syslog(LOG_ERR, "\033[3%dm lock(%14p, %2d, %s)\033[0m", (which_one%6)+1, pthread_self(), which_one, locks);
pthread_mutex_lock(&Critters[which_one]);
- //if (locks[which_one] != 'X') {
- //syslog(LOG_ERR, "\033[31mThread %p had to wait to get a lock on %d\033[0m", pthread_self(), which_one);
- //}
- locks[which_one] = 'X';
}
// Release a semaphore lock to end a critical section.
void end_critical_section(int which_one) {
- locks[which_one] = '_';
- //syslog(LOG_ERR, "\033[3%dmunlock(%14p, %2d, %s)\033[0m", (which_one%6)+1, pthread_self(), which_one, locks);
pthread_mutex_unlock(&Critters[which_one]);
}