]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/smtp/serv_smtpqueue.c
MODULES: add priorities in execution
[citadel.git] / citadel / modules / smtp / serv_smtpqueue.c
index 2f7c3a5905cbe2a16596f17baeaf161ed26b65e2..2430d0db8a76f24f2a2cca9fe0815d2331358c8d 100644 (file)
@@ -94,6 +94,7 @@ struct CitContext smtp_queue_CC;
 pthread_mutex_t ActiveQItemsLock;
 HashList *ActiveQItems  = NULL;
 HashList *QItemHandlers = NULL;
+const unsigned short DefaultMXPort = 25;
 int max_sessions_for_outbound_smtp = 500; /* how many sessions might be active till we stop adding more smtp jobs */
 int ndelay_count = 50; /* every n queued messages we will sleep... */
 int delay_msec = 5000; /* this many seconds. */
@@ -829,7 +830,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                                !IsEmptyStr(Pos)))
                        {
                                StrBufExtract_NextToken(One, All, &Pos, '|');
-                               if (!ParseURL(Url, One, 25)) {
+                               if (!ParseURL(Url, One, DefaultMXPort)) {
                                        SMTPC_syslog(LOG_DEBUG,
                                                     "Failed to parse: %s\n",
                                                     ChrPtr(One));
@@ -857,7 +858,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                                !IsEmptyStr(Pos)))
                        {
                                StrBufExtract_NextToken(One, All, &Pos, '|');
-                               if (!ParseURL(Url, One, 25)) {
+                               if (!ParseURL(Url, One, DefaultMXPort)) {
                                        SMTPC_syslog(LOG_DEBUG,
                                                     "Failed to parse: %s\n",
                                                     ChrPtr(One));
@@ -1003,14 +1004,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 +1026,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;
 }
 
 
@@ -1143,7 +1137,7 @@ CTDL_MODULE_INIT(smtp_queu)
                CtdlRegisterEVCleanupHook(smtp_evq_cleanup);
 
                CtdlRegisterProtoHook(cmd_smtp, "SMTP", "SMTP utility commands");
-               CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER);
+               CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER, PRIO_SEND + 10);
        }
 
        /* return our Subversion id for the Log */