Author: remy.maucherat(a)jboss.com
Date: 2012-11-14 10:10:19 -0500 (Wed, 14 Nov 2012)
New Revision: 2123
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/connector/Request.java
branches/7.2.x/src/main/java/org/apache/coyote/ActionCode.java
branches/7.2.x/src/main/java/org/apache/coyote/ajp/AjpAprProcessor.java
branches/7.2.x/src/main/java/org/apache/coyote/ajp/AjpProcessor.java
branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java
branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11Processor.java
Log:
- AS7-5840: the clarification seems to lean towards destroying async listeners on
recycle.
- Add a separate event for resuming async, since it enabled the read polling flag
[probably not too problematic, but most certainly useless].
Modified: branches/7.2.x/src/main/java/org/apache/catalina/connector/Request.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/connector/Request.java 2012-11-14
14:08:45 UTC (rev 2122)
+++ branches/7.2.x/src/main/java/org/apache/catalina/connector/Request.java 2012-11-14
15:10:19 UTC (rev 2123)
@@ -37,6 +37,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
@@ -474,7 +475,13 @@
* Random generator.
*/
protected Random random = null;
+
+ /**
+ * Async listener instances.
+ */
+ protected LinkedList<AsyncListener> asyncListenerInstances = new
LinkedList<AsyncListener>();
+
// --------------------------------------------------------- Public Methods
@@ -485,6 +492,17 @@
*/
public void recycle() {
+ if (asyncContext != null && context != null) {
+ for (AsyncListener listener : asyncListenerInstances) {
+ try {
+ context.getInstanceManager().destroyInstance(listener);
+ } catch (Throwable t) {
+ context.getLogger().error(MESSAGES.preDestroyException(), t);
+ }
+ }
+ asyncListenerInstances.clear();
+ }
+
context = null;
wrapper = null;
@@ -2553,6 +2571,11 @@
}
+ public void wakeup() {
+ coyoteRequest.action(ActionCode.ACTION_EVENT_WAKEUP, null);
+ }
+
+
public void suspend() {
coyoteRequest.action(ActionCode.ACTION_EVENT_SUSPEND, null);
}
@@ -3324,7 +3347,7 @@
public void complete() {
setEventMode(false);
- resume();
+ wakeup();
}
public void dispatch() {
@@ -3342,21 +3365,21 @@
throw MESSAGES.cannotFindDispatchContext(requestURI);
}
}
- resume();
+ wakeup();
}
public void dispatch(String path) {
this.servletContext = null;
this.path = path;
useAttributes = true;
- resume();
+ wakeup();
}
public void dispatch(ServletContext servletContext, String path) {
this.servletContext = servletContext;
this.path = path;
useAttributes = true;
- resume();
+ wakeup();
}
public ServletRequest getRequest() {
@@ -3381,7 +3404,7 @@
public void start(Runnable runnable) {
this.runnable = runnable;
- resume();
+ wakeup();
}
public boolean isReady() {
@@ -3457,6 +3480,7 @@
} catch (Exception e) {
throw new
ServletException(MESSAGES.listenerCreationFailed(clazz.getName()), e);
}
+ asyncListenerInstances.add(listenerInstance);
return listenerInstance;
}
Modified: branches/7.2.x/src/main/java/org/apache/coyote/ActionCode.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/coyote/ActionCode.java 2012-11-14 14:08:45 UTC
(rev 2122)
+++ branches/7.2.x/src/main/java/org/apache/coyote/ActionCode.java 2012-11-14 15:10:19 UTC
(rev 2123)
@@ -176,6 +176,11 @@
*/
public static final ActionCode UPGRADE = new ActionCode(28);
+ /**
+ * Ask for a callback event without reenabling read events
+ */
+ public static final ActionCode ACTION_EVENT_WAKEUP = new ActionCode(29);
+
// ----------------------------------------------------------- Constructors
int code;
Modified: branches/7.2.x/src/main/java/org/apache/coyote/ajp/AjpAprProcessor.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/coyote/ajp/AjpAprProcessor.java 2012-11-14
14:08:45 UTC (rev 2122)
+++ branches/7.2.x/src/main/java/org/apache/coyote/ajp/AjpAprProcessor.java 2012-11-14
15:10:19 UTC (rev 2123)
@@ -652,7 +652,7 @@
event = false;
} else if (actionCode == ActionCode.ACTION_EVENT_SUSPEND) {
// No action needed
- } else if (actionCode == ActionCode.ACTION_EVENT_RESUME) {
+ } else if (actionCode == ActionCode.ACTION_EVENT_WAKEUP) {
// An event is being processed already: adding for resume will be done
// when the socket gets back to the poller
if (!eventProcessing && !resumeNotification) {
Modified: branches/7.2.x/src/main/java/org/apache/coyote/ajp/AjpProcessor.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/coyote/ajp/AjpProcessor.java 2012-11-14
14:08:45 UTC (rev 2122)
+++ branches/7.2.x/src/main/java/org/apache/coyote/ajp/AjpProcessor.java 2012-11-14
15:10:19 UTC (rev 2123)
@@ -666,7 +666,7 @@
event = false;
} else if (actionCode == ActionCode.ACTION_EVENT_SUSPEND) {
// No action needed
- } else if (actionCode == ActionCode.ACTION_EVENT_RESUME) {
+ } else if (actionCode == ActionCode.ACTION_EVENT_WAKEUP) {
// An event is being processed already: adding for resume will be done
// when the socket gets back to the poller
if (!eventProcessing && !resumeNotification) {
Modified: branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java 2012-11-14
14:08:45 UTC (rev 2122)
+++
branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java 2012-11-14
15:10:19 UTC (rev 2123)
@@ -1271,6 +1271,13 @@
endpoint.getEventPoller().add(socket, timeout, false, false, true,
true);
}
resumeNotification = true;
+ } else if (actionCode == ActionCode.ACTION_EVENT_WAKEUP) {
+ // An event is being processed already: adding for resume will be done
+ // when the socket gets back to the poller
+ if (!eventProcessing && !resumeNotification) {
+ endpoint.getEventPoller().add(socket, timeout, false, false, true,
true);
+ }
+ resumeNotification = true;
} else if (actionCode == ActionCode.ACTION_EVENT_WRITE) {
// An event is being processed already: adding for write will be done
// when the socket gets back to the poller
Modified: branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java 2012-11-14
14:08:45 UTC (rev 2122)
+++
branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java 2012-11-14
15:10:19 UTC (rev 2123)
@@ -730,8 +730,10 @@
* @param param
* the vent parameter
*/
- private void resumeEvent(Object param) {
- readNotifications = true;
+ private void resumeEvent(Object param, boolean read) {
+ if (read) {
+ readNotifications = true;
+ }
// An event is being processed already: adding for resume will be
// done
// when the channel gets back to the poller
@@ -843,7 +845,10 @@
suspendEvent();
} else if (actionCode == ActionCode.ACTION_EVENT_RESUME) {
// Resume event
- resumeEvent(param);
+ resumeEvent(param, true);
+ } else if (actionCode == ActionCode.ACTION_EVENT_WAKEUP) {
+ // Resume event
+ resumeEvent(param, false);
} else if (actionCode == ActionCode.ACTION_EVENT_WRITE) {
// Write event
writeEvent(param);
Modified: branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11Processor.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11Processor.java 2012-11-14
14:08:45 UTC (rev 2122)
+++ branches/7.2.x/src/main/java/org/apache/coyote/http11/Http11Processor.java 2012-11-14
15:10:19 UTC (rev 2123)
@@ -1144,7 +1144,7 @@
event = false;
} else if (actionCode == ActionCode.ACTION_EVENT_SUSPEND) {
// No action needed
- } else if (actionCode == ActionCode.ACTION_EVENT_RESUME) {
+ } else if (actionCode == ActionCode.ACTION_EVENT_WAKEUP) {
// An event is being processed already: adding for resume will be done
// when the socket gets back to the poller
if (!eventProcessing && !resumeNotification) {