Interrupt the writing thread on failure

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@637881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-03-17 13:32:31 +00:00
parent 5e03394423
commit 4032a01c17
1 changed files with 11 additions and 6 deletions

View File

@ -56,7 +56,7 @@ public class InactivityMonitor extends TransportFilter {
private final AtomicBoolean inReceive = new AtomicBoolean(false); private final AtomicBoolean inReceive = new AtomicBoolean(false);
private SchedulerTimerTask writeCheckerTask; private SchedulerTimerTask writeCheckerTask;
private SchedulerTimerTask readCheckerTask; private SchedulerTimerTask readCheckerTask;
private Thread writeThread;
private long readCheckTime; private long readCheckTime;
private long writeCheckTime; private long writeCheckTime;
@ -154,13 +154,16 @@ public class InactivityMonitor extends TransportFilter {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("No message received since last read check for " + toString() + "! Throwing InactivityIOException."); LOG.debug("No message received since last read check for " + toString() + "! Throwing InactivityIOException.");
} }
// TODO: use a thread pool for this..
ASYNC_TASKS.execute(new Runnable() { ASYNC_TASKS.execute(new Runnable() {
public void run() { public void run() {
Thread t = writeThread;
if (t != null) {
t.interrupt();
}
onException(new InactivityIOException("Channel was inactive for too long: "+next.getRemoteAddress())); onException(new InactivityIOException("Channel was inactive for too long: "+next.getRemoteAddress()));
}; };
}); });
} else { } else {
@ -221,9 +224,11 @@ public class InactivityMonitor extends TransportFilter {
} }
} }
synchronized (writeChecker) { synchronized (writeChecker) {
writeThread=Thread.currentThread();
next.oneway(o); next.oneway(o);
} }
} finally { } finally {
writeThread=null;
commandSent.set(true); commandSent.set(true);
inSend.set(false); inSend.set(false);
} }