Fix queue_run_in_order to ignore the PID portion of the message ID
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 12 Oct 2017 13:03:08 +0000 (14:03 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Thu, 12 Oct 2017 15:34:21 +0000 (16:34 +0100)
doc/doc-txt/ChangeLog
src/src/queue.c
src/src/receive.c

index 74a492686330f1f4b1e7084899a95da7a22bf1cd..73c86a9ce9b6386660f4a8cbb7f750bbf9ec6d9a 100644 (file)
@@ -50,6 +50,10 @@ JH/15 Fix a crash in the smtp transport caused when two hosts in succession
       are unsuable for non-message-specific reasons - eg. connection timeout,
       banner-time rejection.
 
+JH/29 Fix queue_run_in_order to ignore the PID portion of the message ID.  This
+      matters on fast-turnover and PID-randomising systems, which were getting
+      out-of-order delivery.
+
 
 Exim version 4.89
 -----------------
index 50e4aaef34667e03f2cd4707058e6c1bfd0b3283..8db4094fdf6a1544cbb65996f79ee2d9afe7ac48 100644 (file)
@@ -80,7 +80,11 @@ queue_filename *first = NULL;
 queue_filename **append = &first;
 
 while (a && b)
-  if (Ustrcmp(a->text, b->text) < 0)
+  {
+  int d;
+  if ((d = Ustrncmp(a->text, b->text, 6)) == 0)
+    d = Ustrcmp(a->text + 14, b->text + 14);
+  if (d < 0)
     {
     *append = a;
     append= &a->next;
@@ -92,6 +96,7 @@ while (a && b)
     append= &b->next;
     b = b->next;
     }
+  }
 
 *append = a ? a : b;
 return first;
@@ -278,7 +283,7 @@ for (; i <= *subcount; i++)
           if (root[j])
             {
             next = merge_queue_lists(next, root[j]);
-            root[j] = (j == LOG2_MAXNODES - 1)? next : NULL;
+            root[j] = j == LOG2_MAXNODES - 1 ? next : NULL;
             }
           else
             {
@@ -460,8 +465,8 @@ subsequent iterations.
 When the first argument of queue_get_spool_list() is -1 (for queue_run_in_
 order), it scans all directories and makes a single message list. */
 
-for (i  = (queue_run_in_order? -1 : 0);
-     i <= (queue_run_in_order? -1 : subcount);
+for (i = queue_run_in_order ? -1 : 0;
+     i <= (queue_run_in_order ? -1 : subcount);
      i++)
   {
   queue_filename *f;
index 7980c324fc1d42c1bca0462928e4cecb89782d00..95cf13e12a4449709781e93bf1489c4cde58b820 100644 (file)
@@ -2582,8 +2582,9 @@ letter and it is not used internally.
 NOTE: If ever the format of message ids is changed, the regular expression for
 checking that a string is in this format must be updated in a corresponding
 way. It appears in the initializing code in exim.c. The macro MESSAGE_ID_LENGTH
-must also be changed to reflect the correct string length. Then, of course,
-other programs that rely on the message id format will need updating too. */
+must also be changed to reflect the correct string length. The queue-sort code
+needs to know the layout. Then, of course, other programs that rely on the
+message id format will need updating too. */
 
 Ustrncpy(message_id, string_base62((long int)(message_id_tv.tv_sec)), 6);
 message_id[6] = '-';