Log.setThreadAnnotation("[outgoing smtp] ");
Log.info(SMTP.Outgoing.class, "outgoing thread started; " + spool.count(Query.all()) + " messages to send");
while(true) {
+ if (Thread.currentThread().isInterrupted()) throw new InterruptedException();
for(Mailbox.Iterator it = spool.iterator(); it.next(); ) {
- try { if (attempt(it.cur())) it.delete(); }
- catch (Exception e) { Log.error(SMTP.Outgoing.class, e); }
+ try {
+ if (Thread.currentThread().isInterrupted()) throw new InterruptedException();
+ if (attempt(it.cur())) it.delete();
+ } catch (Exception e) {
+ if (e instanceof InterruptedException) throw e;
+ Log.error(SMTP.Outgoing.class, e);
+ }
}
synchronized(Outgoing.class) {
+ if (Thread.currentThread().isInterrupted()) throw new InterruptedException();
Log.info(SMTP.Outgoing.class, "outgoing thread going to sleep");
Outgoing.class.wait(5 * 60 * 1000);
deadHosts.clear();
Log.info(SMTP.Outgoing.class,"outgoing thread woke up; "+spool.count(Query.all())+" messages in queue");
}
}
- } catch (Exception e) { Log.error(SMTP.Outgoing.class, e); }
+ } catch (Exception e) {
+ Log.error(SMTP.Outgoing.class, "outgoing thread killed by exception: " + e);
+ Log.error(SMTP.Outgoing.class, e);
+ }
}
}