Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorArt Cancro <ajc@uncensored.citadel.org>
Wed, 6 Jun 2012 22:06:02 +0000 (18:06 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Wed, 6 Jun 2012 22:06:02 +0000 (18:06 -0400)
citadel/housekeeping.c
citadel/modules/smtp/serv_smtpqueue.c

index f4d930d64802631a320086be954b50f409255f58..6eb6440b7e54d7e0cb3bfa582780540f6c627ce6 100644 (file)
@@ -117,9 +117,9 @@ void check_ref_counts(void) {
  * only allow housekeeping to execute once per minute, and we only allow one
  * instance to run at a time.
  */
+static int housekeeping_in_progress = 0;
+static time_t last_timer = 0L;
 void do_housekeeping(void) {
-       static int housekeeping_in_progress = 0;
-       static time_t last_timer = 0L;
        int do_housekeeping_now = 0;
        int do_perminute_housekeeping_now = 0;
        time_t now;
@@ -133,11 +133,6 @@ void do_housekeeping(void) {
        if (housekeeping_in_progress == 0) {
                do_housekeeping_now = 1;
                housekeeping_in_progress = 1;
-               now = time(NULL);
-               if ( (now - last_timer) > (time_t)60 ) {
-                       do_perminute_housekeeping_now = 1;
-                       last_timer = time(NULL);
-               }
        }
        end_critical_section(S_HOUSEKEEPING);
 
@@ -150,6 +145,12 @@ 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);
+       }
+
        /* First, do the "as often as needed" stuff... */
        JournalRunQueue();
        PerformSessionHooks(EVT_HOUSE);
@@ -163,5 +164,7 @@ void do_housekeeping(void) {
        /*
         * All done.
         */
+       begin_critical_section(S_HOUSEKEEPING);
        housekeeping_in_progress = 0;
+       end_critical_section(S_HOUSEKEEPING);
 }
index 2f7c3a5905cbe2a16596f17baeaf161ed26b65e2..b874d1268452870449d405922989cb31d4a4f1b8 100644 (file)
@@ -1003,14 +1003,9 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
  * Run through the queue sending out messages.
  */
 void smtp_do_queue(void) {
-       static int is_running = 0;
        int num_processed = 0;
        int num_activated = 0;
 
-       if (is_running)
-               return; /* Concurrency check - only one can run */
-       is_running = 1;
-
        pthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
        SMTPCM_syslog(LOG_INFO, "processing outbound queue");
 
@@ -1030,8 +1025,6 @@ void smtp_do_queue(void) {
                     "queue run completed; %d messages processed %d activated",
                     num_processed, num_activated);
 
-       run_queue_now = 0;
-       is_running = 0;
 }