]> git.ipfire.org Git - people/ms/dma.git/commitdiff
Apply the fix from rev. 3165 - fix my own queue display patch to
authorPeter Pentchev <roam@ringlet.net>
Tue, 24 Mar 2009 14:17:24 +0000 (14:17 +0000)
committerPeter Pentchev <roam@ringlet.net>
Tue, 24 Mar 2009 14:17:24 +0000 (14:17 +0000)
only display once messages with multiple recipients.

changelog
patches/08-queue-list-all.patch

index 7dfd048b0a80bb5990bed99350ed08a5bcb1a667..13a764470f4c1b3c55402f8fa8c5f6cf581af306 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,10 @@
+dma (0.0.2009.02.11-1~6) unstable; urgency=low
+
+  * Fix my own queue display patch - if a message has multiple recipients,
+    only display it once :)
+
+ -- Peter Pentchev <roam@ringlet.net>  Tue, 24 Mar 2009 16:06:57 +0200
+
 dma (0.0.2009.02.11-1~5) unstable; urgency=low
 
   * Add a new patch to implement sendmail's -t command-line option:
index 8440a4c44ed969de2456f09e0698dfb04485a912..1d517ef0c8fbd1f8fc17899987bb306b83769e46 100644 (file)
@@ -4,28 +4,104 @@ the queue ID.
 
 --- a/dma.c
 +++ b/dma.c
-@@ -667,7 +667,7 @@
+@@ -73,6 +73,7 @@
+ struct authusers authusers = LIST_HEAD_INITIALIZER(authusers);
+ static int daemonize = 1;
+ struct config *config;
++static struct strlist seenmsg[16][16];
+ static int open_locked(const char *, int);
+@@ -666,8 +667,66 @@
+       /* NOTREACHED */
  }
  
++static int
++c2x(char c)
++{
++      if (c <= '9')
++              return (c - '0');
++      else if (c <= 'F')
++              return (c - 'A' + 10);
++      else
++              return (c - 'a' + 10);
++}
++
  static void
 -load_queue(struct queue *queue)
++seen_init(void)
++{
++      int i, j;
++
++      for (i = 0; i < 16; i++)
++              for (j = 0; j < 16; j++)
++                      SLIST_INIT(&seenmsg[i][j]);
++}
++
++static int
++seen(const char *msgid)
++{
++      const char *p;
++      size_t len;
++      int i, j;
++      struct stritem *t;
++
++      p = strchr(msgid, '.');
++      if (p == NULL)
++              return (0);
++      len = p - msgid;
++      if (len >= 2) {
++              i = c2x(msgid[len - 2]);
++              j = c2x(msgid[len - 1]);
++      } else if (len == 1) {
++              i = c2x(msgid[0]);
++              j = 0;
++      } else {
++              i = j = 0;
++      }
++      if (i < 0 || i >= 16 || j < 0 || j >= 16)
++              errx(1, "INTERNAL ERROR: bad seen code for msgid %s", msgid);
++      SLIST_FOREACH(t, &seenmsg[i][j], next)
++              if (!strncmp(t->str, msgid, len))
++                      return (1);
++      t = malloc(sizeof(*t));
++      if (t == NULL)
++              errx(1, "Could not allocate %lu bytes",
++                  (unsigned long)(sizeof(*t)));
++      t->str = strdup(msgid);
++      if (t->str == NULL)
++              errx(1, "Could not duplicate msgid %s", msgid);
++      SLIST_INSERT_HEAD(&seenmsg[i][j], t, next);
++      return (0);
++}
++
++static void
 +load_queue(struct queue *queue, int nolock)
  {
        struct stat st;
        struct qitem *it;
-@@ -683,7 +683,7 @@
+@@ -683,7 +742,7 @@
        char *queueid;
        char *queuefn;
        off_t hdrlen;
 -      int fd;
-+      int fd, locked;
++      int fd, locked, seenit;
  
        LIST_INIT(&queue->queue);
  
-@@ -705,12 +705,18 @@
+@@ -691,6 +750,7 @@
+       if (spooldir == NULL)
+               err(1, "reading queue");
++      seen_init();
+       while ((de = readdir(spooldir)) != NULL) {
+               sender = NULL;
+               queuef = NULL;
+@@ -705,12 +765,19 @@
                        continue;
                if (asprintf(&queuefn, "%s/%s", config->spooldir, de->d_name) < 0)
                        goto fail;
++              seenit = seen(de->d_name);
 +              locked = 0;
                fd = open_locked(queuefn, O_RDONLY|O_NONBLOCK);
                if (fd < 0) {
@@ -33,7 +109,7 @@ the queue ID.
 -                      if (errno == EWOULDBLOCK)
 +                      if (errno != EWOULDBLOCK)
 +                              goto skip_item;
-+                      if (!nolock)
++                      if (!nolock || seenit)
                                continue;
 -                      goto skip_item;
 +                      fd = open(queuefn, O_RDONLY);
@@ -43,7 +119,7 @@ the queue ID.
                }
  
                queuef = fdopen(fd, "r");
-@@ -751,6 +757,7 @@
+@@ -751,6 +818,7 @@
                        it->queuef = queuef;
                        it->queueid = queueid;
                        it->queuefn = fn;
@@ -51,7 +127,7 @@ the queue ID.
                        fn = NULL;
                }
                if (LIST_EMPTY(&itmqueue.queue)) {
-@@ -810,9 +817,9 @@
+@@ -810,9 +878,9 @@
  
        LIST_FOREACH(it, &queue->queue, next) {
                printf("\
@@ -63,7 +139,7 @@ the queue ID.
        }
  }
  
-@@ -914,7 +921,7 @@
+@@ -914,7 +982,7 @@
                if (argc != 0)
                        errx(1, "sending mail and displaying queue is"
                                " mutually exclusive");
@@ -72,7 +148,7 @@ the queue ID.
                show_queue(&lqueue);
                return (0);
        }
-@@ -922,7 +929,7 @@
+@@ -922,7 +990,7 @@
        if (doqueue) {
                if (argc != 0)
                        errx(1, "sending mail and queue pickup is mutually exclusive");