silenced a silly little compiler warning
[citadel.git] / citadel / housekeeping.c
index 139ada05ee63915e6716285c2f2d7791e8df2e69..ea87c91bb8654f078032df5daaf406795edd42c4 100644 (file)
@@ -19,7 +19,9 @@
 #include "serv_extensions.h"
 #include "room_ops.h"
 #include "internet_addressing.h"
+#include "config.h"
 #include "journaling.h"
+#include "citadel_ldap.h"
 
 void check_sched_shutdown(void) {
        if ((ScheduledShutdown == 1) && (ContextList == NULL)) {
@@ -98,7 +100,14 @@ void do_housekeeping(void) {
        }
        end_critical_section(S_HOUSEKEEPING);
 
+       now = time(NULL);
        if (do_housekeeping_now == 0) {
+               if ( (now - last_timer) > (time_t)300 ) {
+                       syslog(LOG_WARNING,
+                               "housekeeping: WARNING: housekeeping loop has not run for %ld minutes.  Is something stuck?",
+                               ((now - last_timer) / 60)
+                       );
+               }
                return;
        }
 
@@ -107,7 +116,6 @@ void do_housekeeping(void) {
         * loop.  Everything below this point is real work.
         */
 
-       now = time(NULL);
        if ( (now - last_timer) > (time_t)60 ) {
                do_perminute_housekeeping_now = 1;
                last_timer = time(NULL);
@@ -119,8 +127,17 @@ void do_housekeeping(void) {
 
        /* Then, do the "once per minute" stuff... */
        if (do_perminute_housekeeping_now) {
-               cdb_check_handles();                    /* suggested by Justin Case */
-               PerformSessionHooks(EVT_TIMER);         /* Run any timer hooks */
+               cdb_check_handles();
+               PerformSessionHooks(EVT_TIMER);         // Run all registered TIMER hooks
+
+#ifdef HAVE_LDAP                                       // LDAP sync isn't in a module so we can put it here
+               static time_t last_ldap_sync = 0L;
+               if ( (now - last_ldap_sync) > (time_t)CtdlGetConfigLong("c_ldap_sync_freq") ) {
+                       CtdlSynchronizeUsersFromLDAP();
+                       last_ldap_sync = time(NULL);
+               }
+#endif
+
        }
 
        /*
@@ -164,7 +181,7 @@ retry_wait_for_contexts:
        {
                for (i=0; i<nContexts; i++) 
                {
-                       if ((nptr[i].state != CON_SYS) || (nptr[i].IO == NULL) || (nptr[i].lastcmd == 0))
+                       if ((nptr[i].state != CON_SYS) || (nptr[i].lastcmd == 0))
                                continue;
                        ActiveBackgroundJobs ++;
                        syslog(LOG_INFO, "jousekeeping: job CC[%d] active; use TERM if you don't want to wait for it", nptr[i].cs_pid);