keep track of last_queue_job_submitted
authorArt Cancro <ajc@citadel.org>
Wed, 8 Feb 2023 04:07:36 +0000 (23:07 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 8 Feb 2023 04:07:36 +0000 (23:07 -0500)
citadel/server/modules/smtp/serv_smtpclient.c
citadel/server/msgbase.c

index 26cb4dcffc9846fd7d230f27d7284b0ff97e55f5..a968cb719118cacd1557b3d242a90a913d033422 100644 (file)
@@ -32,6 +32,8 @@
 #include "../../citadel_dirs.h"
 #include "../smtp/smtp_util.h"
 
+long last_queue_job_submitted = 0;
+
 struct smtpmsgsrc {            // Data passed in and out of libcurl for message upload
        StrBuf *TheMessage;
        int bytes_total;
@@ -106,7 +108,7 @@ int smtp_aftersave(struct CtdlMessage *msg, struct recptypes *recps) {
                CM_SetField(imsg, eAuthor, HKEY("Citadel"));
                CM_SetField(imsg, eJournal, HKEY("do not journal"));
                CM_SetAsFieldSB(imsg, eMesageText, &SpoolMsg);
-               CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM);
+               last_queue_job_submitted = CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM);
                CM_Free(imsg);
        }
        return 0;
@@ -500,12 +502,12 @@ enum {
        QUICK_QUEUE_RUN         // only process jobs in the queue that have not been tried yet
 };
 
+
 // Run through the queue sending out messages.
-void smtp_do_queue(void) {
+void smtp_do_queue(int type_of_queue_run) {
        static int doing_smtpclient = 0;
        static long last_queue_msg_processed = 0;
        int i = 0;
-       int type_of_queue_run = FULL_QUEUE_RUN;
 
        // This is a concurrency check to make sure only one smtpclient run is done at a time.
        begin_critical_section(S_SMTPQUEUE);
@@ -516,7 +518,7 @@ void smtp_do_queue(void) {
        doing_smtpclient = 1;
        end_critical_section(S_SMTPQUEUE);
 
-       syslog(LOG_DEBUG, "smtpclient: start queue run - last_queue_msg_processed=%ld", last_queue_msg_processed);
+       syslog(LOG_DEBUG, "smtpclient: start queue run , last_queue_msg_processed=%ld , last_queue_job_submitted=%ld", last_queue_msg_processed, last_queue_job_submitted);
 
        if (CtdlGetRoom(&CC->room, SMTP_SPOOLOUT_ROOM) != 0) {
                syslog(LOG_WARNING, "smtpclient: cannot find room <%s>", SMTP_SPOOLOUT_ROOM);
@@ -553,7 +555,17 @@ void smtp_do_queue(void) {
 
        array_free(smtp_queue);
        doing_smtpclient = 0;
-       syslog(LOG_DEBUG, "smtpclient: end queue run - last_queue_msg_processed=%ld", last_queue_msg_processed);
+       syslog(LOG_DEBUG, "smtpclient: end queue run , last_queue_msg_processed=%ld , last_queue_job_submitted=%ld", last_queue_msg_processed, last_queue_job_submitted);
+}
+
+
+void smtp_do_queue_full(void) {
+       smtp_do_queue(FULL_QUEUE_RUN);
+}
+
+
+void smtp_do_queue_quick(void) {
+       smtp_do_queue(QUICK_QUEUE_RUN);
 }
 
 
@@ -561,7 +573,7 @@ void smtp_do_queue(void) {
 char *ctdl_module_init_smtpclient(void) {
        if (!threading) {
                CtdlRegisterMessageHook(smtp_aftersave, EVT_AFTERSAVE);
-               CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER, PRIO_AGGR + 51);
+               CtdlRegisterSessionHook(smtp_do_queue_full, EVT_TIMER, PRIO_AGGR + 51);
                smtp_init_spoolout();
        }
 
index bf24b4148946299ca9c3cce4dcb05930d281671e..bf6bb4056e622723310c64c6a6eda23779ecaaf1 100644 (file)
@@ -1,6 +1,6 @@
 // Implements the message store.
 //
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
 //
 // This program is open source software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License version 3.