From 6019e8ac2cf304b65e2defc658987211d71d4644 Mon Sep 17 00:00:00 2001 From: adam Date: Sat, 1 Mar 2008 06:01:27 +0000 Subject: [PATCH] add delayed retry for SMTP darcs-hash:20080301060127-5007d-e11089dc22906e76adf872a6fe4746d805fc5d96.gz --- src/org/ibex/mail/SMTP.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/org/ibex/mail/SMTP.java b/src/org/ibex/mail/SMTP.java index 64677a0..cf86164 100644 --- a/src/org/ibex/mail/SMTP.java +++ b/src/org/ibex/mail/SMTP.java @@ -53,6 +53,8 @@ public class SMTP { public static final int GRAYLIST_MINWAIT = 1000 * 60 * 60; // one hour public static final int GRAYLIST_MAXWAIT = 1000 * 60 * 60 * 24 * 5; // five days + public static final int RETRY_TIME = 1000 * 60 * 30; + public static final Graylist graylist; public static final Whitelist whitelist; static { @@ -444,6 +446,8 @@ public class SMTP { private int serial = serials++; private Mailbox.Iterator it; + private static Map nextTry = Collections.synchronizedMap(new HashMap()); + public Outgoing() { synchronized(Outgoing.class) { threads.add(this); @@ -468,7 +472,12 @@ public class SMTP { } if (!good) break; try { - if (attempt(it.cur())) it.delete(); + String messageid = it.cur().messageid; + if (nextTry.get(messageid) == null || System.currentTimeMillis() > nextTry.get(messageid)) { + boolean ok = attempt(it.cur()); + if (ok) it.delete(); + else nextTry.put(messageid, System.currentTimeMillis() + RETRY_TIME); + } } catch (Exception e) { Log.error(SMTP.Outgoing.class, e); } -- 1.7.10.4