Revision: 325
Author: mmo...@tildeslash.com
Date: Fri Feb 18 08:59:50 2011
Log: * Randomize the mail message id to prevent duplicates in the case, that
  the same hostname is used on multiple hosts running monit and messages
  are generated in the same second in parallel. Thanks to Sergey B
  Kirpichev.



http://code.google.com/p/monit/source/detail?r=325

Modified:
 /trunk/CHANGES.txt
 /trunk/sendmail.c

=======================================
--- /trunk/CHANGES.txt  Fri Feb 18 08:15:27 2011
+++ /trunk/CHANGES.txt  Fri Feb 18 08:59:50 2011
@@ -38,6 +38,11 @@

 * Spelling fixes. Thanks to Sergey B Kirpichev.

+* Randomize the mail message id to prevent duplicates in the case, that
+  the same hostname is used on multiple hosts running monit and messages
+  are generated in the same second in parallel. Thanks to Sergey B
+  Kirpichev.
+


 Version 5.2.3
=======================================
--- /trunk/sendmail.c   Wed Jan 19 10:40:32 2011
+++ /trunk/sendmail.c   Fri Feb 18 08:59:50 2011
@@ -174,6 +174,7 @@
   }

   for(i = 0, m= mail; m; m= m->next, i++) {
+    srandom(time(NULL) + getpid() + i);
     do_send(&S, "MAIL FROM: <%s>\r\n", m->from);
     do_status(&S);
     do_send(&S, "RCPT TO: <%s>\r\n", m->to);
@@ -190,7 +191,7 @@
     do_send(&S, "Mime-Version: 1.0\r\n");
     do_send(&S, "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n");
     do_send(&S, "Content-Transfer-Encoding: 8bit\r\n");
-    do_send(&S, "Message-id: <%ld.%d@%s>\r\n", time(NULL), i, S.localhost);
+ do_send(&S, "Message-id: <%ld.%lu@%s>\r\n", time(NULL), random(), S.localhost);
     do_send(&S, "\r\n");
     do_send(&S, "%s\r\n", m->message);
     do_send(&S, ".\r\n");

_______________________________________________
monit-dev mailing list
monit-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/monit-dev

Reply via email to