JBossWeb SVN: r979 - in trunk: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-02 12:17:25 -0400 (Thu, 02 Apr 2009)
New Revision: 979
Modified:
trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
trunk/webapps/docs/changelog.xml
Log:
- Fix timeout handling after the code changes for values <= 0.
Modified: trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2009-04-02 01:12:31 UTC (rev 978)
+++ trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2009-04-02 16:17:25 UTC (rev 979)
@@ -1396,10 +1396,6 @@
// Adjust poller size so that it won't reach the limit
actualPollerSize = 1024;
}
- int timeout = keepAliveTimeout;
- if (timeout < 0) {
- timeout = soTimeout;
- }
// At the moment, setting the timeout is useless, but it could get used
// again as the normal poller could be faster using maintain. It might not
@@ -1486,6 +1482,10 @@
if (timeout < 0) {
timeout = soTimeout;
}
+ if (timeout <= 0) {
+ // Always put a timeout in
+ timeout = Integer.MAX_VALUE;
+ }
boolean ok = false;
synchronized (this) {
// Add socket to the list. Newly added sockets will wait
@@ -1522,6 +1522,10 @@
if (timeout < 0) {
timeout = soTimeout;
}
+ if (timeout <= 0) {
+ // Always put a timeout in
+ timeout = Integer.MAX_VALUE;
+ }
boolean ok = false;
synchronized (this) {
// Add socket to the list. Newly added sockets will wait
Modified: trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java 2009-04-02 01:12:31 UTC (rev 978)
+++ trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java 2009-04-02 16:17:25 UTC (rev 979)
@@ -691,6 +691,10 @@
if (timeout < 0) {
timeout = soTimeout;
}
+ if (timeout <= 0) {
+ // Always put a timeout in
+ timeout = Integer.MAX_VALUE;
+ }
boolean ok = false;
synchronized (this) {
// Add socket to the list. Newly added sockets will wait
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-04-02 01:12:31 UTC (rev 978)
+++ trunk/webapps/docs/changelog.xml 2009-04-02 16:17:25 UTC (rev 979)
@@ -57,6 +57,9 @@
<update>
Add support for non IO events in all connectors. (remm)
</update>
+ <fix>
+ Fix handling of timeout values <= 0 with the poller refactoring. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
16 years, 7 months
JBossWeb SVN: r978 - in trunk/java/org/apache/catalina: core and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-01 21:12:31 -0400 (Wed, 01 Apr 2009)
New Revision: 978
Modified:
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
Log:
- Implement in real conditions the fixme comments.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-02 00:48:01 UTC (rev 977)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-02 01:12:31 UTC (rev 978)
@@ -2824,7 +2824,7 @@
// ------------------------------------------ AsyncContextImpl Inner Class
- protected class AsyncContextImpl implements AsyncContext {
+ public class AsyncContextImpl implements AsyncContext {
protected ServletRequest request = null;
protected ServletResponse response = null;
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-02 00:48:01 UTC (rev 977)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-02 01:12:31 UTC (rev 978)
@@ -28,7 +28,6 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import javax.servlet.AsyncContext;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
@@ -45,6 +44,7 @@
import org.apache.tomcat.util.log.SystemLogHandler;
import org.jboss.servlet.http.HttpEvent;
import org.jboss.servlet.http.HttpEventServlet;
+import org.jboss.servlet.http.HttpEvent.EventType;
/**
* Valve that implements the default basic behavior for the
@@ -305,7 +305,7 @@
// Release the filter chain (if any) for this request
if (filterChain != null) {
- if (request.isEventMode()) {
+ if (request.isEventMode() && !request.isAsyncStarted()) {
// If this is a event request, then the same chain will be used for the
// processing of all subsequent events.
filterChain.reuse();
@@ -421,19 +421,30 @@
(ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
requestPathMB);
- // FIXME: Implement async mode, which means invoking listeners or the Servlet
- // FIXME: Some async mode need creating a new filter chain
+ // FIXME: Implement async mode, which means invoking listeners or the Servlet, etc
+ Request.AsyncContextImpl asyncContext = (Request.AsyncContextImpl) request.getAsyncContext();
+ if (asyncContext != null) {
+ if (event.getType() == EventType.END || event.getType() == EventType.ERROR) {
+ // Invoke the listeners with onComplete
+ // FIXME
+ } else if (event.getType() == EventType.TIMEOUT) {
+ // Invoke the listeners with onTimeout
+ // FIXME
+ } else if (asyncContext.getRunnable() != null) {
+ // Execute the runnable
+ // FIXME
+ } else if (asyncContext.getPath() != null) {
+ // Remap the request, set the dispatch attributes, create the filter chain
+ // and invoke the Servlet
+ // FIXME: Also check how cross context works, but it is be ok to do from here
+ // (or do another distpatcher object similar to the current request dispatcher)
+ } else {
+ // Create the filter chain and reinvoke the same Servlet
+ // FIXME
+ }
+ return; // FIXME
+ }
- /* FIXME:
- * - If async context has path: remap and invoke Servlet
- * - If async context has runnable, invoke runnable
- * - If no path, reinvoke servlet with current filters
- * - If no event mode (and end event) invoke listeners
- * - If timeout, invoke listeners
- * - If error ?
- */
- AsyncContext asyncContext = request.getAsyncContext();
-
// Get the current (unchanged) filter chain for this request
ApplicationFilterChain filterChain =
(ApplicationFilterChain) request.getFilterChain();
@@ -500,7 +511,11 @@
// Release the filter chain (if any) for this request
if (filterChain != null) {
- filterChain.reuse();
+ if (asyncContext != null) {
+ filterChain.release();
+ } else {
+ filterChain.reuse();
+ }
}
// Deallocate the allocated servlet instance
16 years, 7 months
JBossWeb SVN: r977 - in trunk: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-01 20:48:01 -0400 (Wed, 01 Apr 2009)
New Revision: 977
Modified:
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
trunk/webapps/docs/sysprops.xml
Log:
- Ok, so 5 (now 6) volatile were used to track rather useless stats, and I had forgotten about it.
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-01 17:42:19 UTC (rev 976)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-02 00:48:01 UTC (rev 977)
@@ -28,6 +28,7 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import javax.servlet.AsyncContext;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
@@ -56,6 +57,12 @@
final class StandardWrapperValve
extends ValveBase {
+
+ protected static final boolean SERVLET_STATS =
+ Globals.STRICT_SERVLET_COMPLIANCE
+ || Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardWrapperValve.SERVLET_STATS", "false")).booleanValue();
+
+
// ----------------------------------------------------- Instance Variables
@@ -65,6 +72,7 @@
private volatile long processingTime;
private volatile long maxTime;
private volatile long minTime = Long.MAX_VALUE;
+ private volatile int eventCount;
private volatile int requestCount;
private volatile int errorCount;
@@ -97,8 +105,11 @@
boolean unavailable = false;
Throwable throwable = null;
// This should be a Request attribute...
- long t1=System.currentTimeMillis();
- requestCount++;
+ long t1 = 0;
+ if (SERVLET_STATS) {
+ t1 = System.currentTimeMillis();
+ requestCount++;
+ }
StandardWrapper wrapper = (StandardWrapper) getContainer();
Servlet servlet = null;
Context context = (Context) wrapper.getParent();
@@ -332,12 +343,17 @@
exception(request, response, e);
}
}
- long t2=System.currentTimeMillis();
- long time=t2-t1;
- processingTime += time;
- if( time > maxTime) maxTime=time;
- if( time < minTime) minTime=time;
+ if (SERVLET_STATS) {
+ long time = System.currentTimeMillis() - t1;
+ processingTime += time;
+ if (time > maxTime) {
+ maxTime = time;
+ }
+ if (time < minTime) {
+ minTime = time;
+ }
+ }
}
@@ -361,8 +377,11 @@
// Initialize local variables we may need
Throwable throwable = null;
// This should be a Request attribute...
- long t1=System.currentTimeMillis();
- // FIXME: Add a flag to count the total amount of events processed ? requestCount++;
+ long t1 = 0;
+ if (SERVLET_STATS) {
+ t1 = System.currentTimeMillis();
+ eventCount++;
+ }
StandardWrapper wrapper = (StandardWrapper) getContainer();
Servlet servlet = null;
Context context = (Context) wrapper.getParent();
@@ -413,6 +432,7 @@
* - If timeout, invoke listeners
* - If error ?
*/
+ AsyncContext asyncContext = request.getAsyncContext();
// Get the current (unchanged) filter chain for this request
ApplicationFilterChain filterChain =
@@ -513,13 +533,17 @@
}
}
- long t2=System.currentTimeMillis();
+ if (SERVLET_STATS) {
+ long time = System.currentTimeMillis() - t1;
+ processingTime += time;
+ if (time > maxTime) {
+ maxTime = time;
+ }
+ if (time < minTime) {
+ minTime = time;
+ }
+ }
- long time=t2-t1;
- processingTime += time;
- if( time > maxTime) maxTime=time;
- if( time < minTime) minTime=time;
-
}
@@ -584,6 +608,14 @@
this.errorCount = errorCount;
}
+ public int getEventCount() {
+ return eventCount;
+ }
+
+ public void setEventCount(int eventCount) {
+ this.eventCount = eventCount;
+ }
+
// Don't register in JMX
public ObjectName createObjectName(String domain, ObjectName parent)
Modified: trunk/webapps/docs/sysprops.xml
===================================================================
--- trunk/webapps/docs/sysprops.xml 2009-04-01 17:42:19 UTC (rev 976)
+++ trunk/webapps/docs/sysprops.xml 2009-04-02 00:48:01 UTC (rev 977)
@@ -99,6 +99,7 @@
<p>The size of the cache to use parsed and formatted date value. If not
specified, the default value of <code>1000</code> will be used.</p>
</property>
+
<property name="org.apache.catalina.core. StandardService.DELAY_CONNECTOR_STARTUP">
<p>If <code>true</code>, the connector startup will not be done automatically. Useful
in embedded mode.</p>
@@ -304,6 +305,14 @@
</p>
</property>
+ <property name="org.apache.catalina.core. StandardWrapperValve.SERVLET_STATS">
+ <p>If <code>true</code> or if
+ <code>org.apache.catalina.STRICT_SERVLET_COMPLIANCE</code> is
+ <code>true</code>, the wrapper will collect the JSR-77 statistics for
+ individual servlets. If not specified, the
+ default value of <code>false</code> will be used.</p>
+ </property>
+
<property
name="org.apache.catalina.session. StandardSession.ACTIVITY_CHECK">
<p>If this is <code>true</code> or if
16 years, 7 months
JBossWeb SVN: r976 - in trunk/java/org/apache/catalina: core and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-01 13:42:19 -0400 (Wed, 01 Apr 2009)
New Revision: 976
Modified:
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
Log:
- Move the fixmes and add getters.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-01 17:08:09 UTC (rev 975)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-01 17:42:19 UTC (rev 976)
@@ -2840,20 +2840,17 @@
public void complete() {
setEventMode(false);
- // FIXME: Probably needs to set the context as the "current" one
resume();
}
public void dispatch() {
- // FIXME: the SWrapperValve will invoke the current Servlet again if it supports async
resume();
}
public void dispatch(ServletContext servletContext, String path) {
this.servletContext = servletContext;
this.path = path;
- // FIXME: No idea what the servletContext means right now ;)
- // FIXME: the SWrapperValve will map the path and run the Servlet if it supports async
+ // FIXME: No idea what the servletContext means right now
resume();
}
@@ -2871,10 +2868,21 @@
public void start(Runnable runnable) {
this.runnable = runnable;
- // FIXME: the SWrapperValve will run the runnable rather than a Servlet
resume();
}
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public Runnable getRunnable() {
+ return runnable;
+ }
+
}
}
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-01 17:08:09 UTC (rev 975)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-01 17:42:19 UTC (rev 976)
@@ -1,18 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
@@ -400,6 +405,15 @@
// FIXME: Implement async mode, which means invoking listeners or the Servlet
// FIXME: Some async mode need creating a new filter chain
+ /* FIXME:
+ * - If async context has path: remap and invoke Servlet
+ * - If async context has runnable, invoke runnable
+ * - If no path, reinvoke servlet with current filters
+ * - If no event mode (and end event) invoke listeners
+ * - If timeout, invoke listeners
+ * - If error ?
+ */
+
// Get the current (unchanged) filter chain for this request
ApplicationFilterChain filterChain =
(ApplicationFilterChain) request.getFilterChain();
16 years, 7 months
JBossWeb SVN: r975 - trunk/java/org/apache/catalina/connector.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-01 13:08:09 -0400 (Wed, 01 Apr 2009)
New Revision: 975
Modified:
trunk/java/org/apache/catalina/connector/Request.java
Log:
- More details about async implementation. Async redispatch seems to have three main code paths which will need
to be added in StandardWrapperValve.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-03-31 18:16:24 UTC (rev 974)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-01 17:08:09 UTC (rev 975)
@@ -1,18 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
@@ -48,6 +53,7 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.catalina.Container;
@@ -199,9 +205,10 @@
/**
- * Servlet 3.0 asynchronous mode flag
+ * Servlet 3.0 asynchronous mode context (also used as a flag - when not null,
+ * we're in asynchronous mode).
*/
- protected boolean asyncMode = false;
+ protected AsyncContextImpl asyncContext = null;
/**
@@ -399,13 +406,13 @@
dispatcherType = null;
requestDispatcherPath = null;
- asyncMode = false;
eventMode = false;
if (event != null) {
event.clear();
event = null;
}
+ asyncContext = null;
authType = null;
inputBuffer.recycle();
usingInputStream = false;
@@ -641,6 +648,13 @@
/**
+ * Alias for AsyncContext inner class.
+ */
+ public HttpServletRequest getRequestFacade() {
+ return getRequest();
+ }
+
+ /**
* The response with which this request is associated.
*/
protected org.apache.catalina.connector.Response response = null;
@@ -662,6 +676,13 @@
}
/**
+ * Alias for AsyncContext inner class.
+ */
+ public HttpServletResponse getResponseFacade() {
+ return getResponse().getResponse();
+ }
+
+ /**
* Return the input stream associated with this Request.
*/
public InputStream getStream() {
@@ -2739,32 +2760,26 @@
return true;
}
- @Override
public void addAsyncListener(AsyncListener listener,
ServletRequest servletRequest, ServletResponse servletResponse) {
- // TODO Auto-generated method stub
-
+ // FIXME: Maybe add to the asyncContext ?
}
- @Override
public void addAsyncListener(AsyncListener listener) {
- // TODO Auto-generated method stub
-
+ addAsyncListener(listener, getRequest(), response.getResponse());
}
- @Override
public AsyncContext getAsyncContext() {
- // TODO Auto-generated method stub
- return null;
+ return asyncContext;
}
public boolean isAsyncStarted() {
- return asyncMode;
+ return (asyncContext != null);
}
- @Override
public boolean isAsyncSupported() {
- // TODO Auto-generated method stub
+ // FIXME: Normally, this should be about checking that the Servlet has
+ // async supported, and that all filters in the chain do too ?
return false;
}
@@ -2778,10 +2793,9 @@
public AsyncContext startAsync(ServletRequest servletRequest,
ServletResponse servletResponse) throws IllegalStateException {
- // TODO Auto-generated method stub
- asyncMode = true;
+ asyncContext = new AsyncContextImpl(servletRequest, servletResponse);
eventMode = true;
- return null;
+ return asyncContext;
}
public DispatcherType getDispatcherType() {
@@ -2806,4 +2820,61 @@
return response;
}
+
+ // ------------------------------------------ AsyncContextImpl Inner Class
+
+
+ protected class AsyncContextImpl implements AsyncContext {
+
+ protected ServletRequest request = null;
+ protected ServletResponse response = null;
+
+ protected ServletContext servletContext = null;
+ protected String path = null;
+ protected Runnable runnable = null;
+
+ public AsyncContextImpl(ServletRequest request, ServletResponse response) {
+ this.request = request;
+ this.response = response;
+ }
+
+ public void complete() {
+ setEventMode(false);
+ // FIXME: Probably needs to set the context as the "current" one
+ resume();
+ }
+
+ public void dispatch() {
+ // FIXME: the SWrapperValve will invoke the current Servlet again if it supports async
+ resume();
+ }
+
+ public void dispatch(ServletContext servletContext, String path) {
+ this.servletContext = servletContext;
+ this.path = path;
+ // FIXME: No idea what the servletContext means right now ;)
+ // FIXME: the SWrapperValve will map the path and run the Servlet if it supports async
+ resume();
+ }
+
+ public ServletRequest getRequest() {
+ return request;
+ }
+
+ public ServletResponse getResponse() {
+ return response;
+ }
+
+ public boolean hasOriginalRequestAndResonse() {
+ return (request == getRequestFacade() && response == getResponseFacade());
+ }
+
+ public void start(Runnable runnable) {
+ this.runnable = runnable;
+ // FIXME: the SWrapperValve will run the runnable rather than a Servlet
+ resume();
+ }
+
+ }
+
}
16 years, 7 months