You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2008/01/17 14:15:34 UTC
svn commit: r612809 - in
/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor:
AbstractMultiworkerIOReactor.java DefaultConnectingIOReactor.java
DefaultListeningIOReactor.java ListenerEndpointImpl.java
Author: olegk
Date: Thu Jan 17 05:15:00 2008
New Revision: 612809
URL: http://svn.apache.org/viewvc?rev=612809&view=rev
Log:
Fixed problem with the default I/O reactor impls not canceling pending requests upon shutdown
Modified:
httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java
Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java?rev=612809&r1=612808&r2=612809&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java Thu Jan 17 05:15:00 2008
@@ -117,6 +117,7 @@
}
protected abstract void processEvents(int count) throws IOReactorException;
+ protected abstract void cancelRequests() throws IOReactorException;
public void execute(
final IOEventDispatch eventDispatch) throws InterruptedIOException, IOReactorException {
@@ -191,7 +192,8 @@
if (this.status.compareTo(IOReactorStatus.ACTIVE) > 0) {
return;
}
- this.status = IOReactorStatus.SHUTTING_DOWN;
+ this.status = IOReactorStatus.SHUTTING_DOWN;
+ cancelRequests();
this.selector.wakeup();
// Close out all channels
Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java?rev=612809&r1=612808&r2=612809&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java Thu Jan 17 05:15:00 2008
@@ -74,6 +74,17 @@
this(workerCount, null, params);
}
+ @Override
+ protected void cancelRequests() throws IOReactorException {
+ SessionRequestImpl request;
+ while ((request = this.requestQueue.poll()) != null) {
+ if (!request.isCompleted()) {
+ request.cancel();
+ }
+ }
+ }
+
+ @Override
protected void processEvents(int readyCount) throws IOReactorException {
processSessionRequests();
Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java?rev=612809&r1=612808&r2=612809&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java Thu Jan 17 05:15:00 2008
@@ -73,6 +73,16 @@
this(workerCount, null, params);
}
+
+ @Override
+ protected void cancelRequests() throws IOReactorException {
+ ListenerEndpointImpl request;
+ while ((request = this.requestQueue.poll()) != null) {
+ request.cancel();
+ }
+ }
+
+ @Override
protected void processEvents(int readyCount) throws IOReactorException {
processSessionRequests();
Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java?rev=612809&r1=612808&r2=612809&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java Thu Jan 17 05:15:00 2008
@@ -1,7 +1,7 @@
/*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
+ * $HeadURL$
+ * $Revision$
+ * $Date$
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@@ -104,6 +104,16 @@
this.completed = true;
synchronized (this) {
this.exception = exception;
+ notifyAll();
+ }
+ }
+
+ public void cancel() {
+ if (this.completed) {
+ return;
+ }
+ this.completed = true;
+ synchronized (this) {
notifyAll();
}
}