From: Jules G. <jul...@us...> - 2002-08-31 00:07:37
|
User: jules_gosnell Date: 02/08/30 17:07:35 Modified: jetty/src/main/org/mortbay/http HttpServer.java HttpContext.java HttpConnection.java Log: we are now up with : Jetty-4.1.0RC4 - 30 August 2002 + Included IbmJsseListener in the contrib directory. + Updated jasper2 to 4.1.10 tag. + Reverted to 302 for all redirections as all clients do not understand 303 + Created statsLock sync objects to avoid deadlock when stopping. Revision Changes Path 1.20 +56 -39 contrib/jetty/src/main/org/mortbay/http/HttpServer.java Index: HttpServer.java =================================================================== RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/mortbay/http/HttpServer.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- HttpServer.java 22 Aug 2002 01:13:39 -0000 1.19 +++ HttpServer.java 31 Aug 2002 00:07:35 -0000 1.20 @@ -1,6 +1,6 @@ // ======================================================================== // Copyright (c) 1999 Mort Bay Consulting (Australia) Pty. Ltd. -// $Id: HttpServer.java,v 1.19 2002/08/22 01:13:39 jules_gosnell Exp $ +// $Id: HttpServer.java,v 1.20 2002/08/31 00:07:35 jules_gosnell Exp $ // ======================================================================== package org.mortbay.http; @@ -62,7 +62,7 @@ * @see HttpConnection * @see HttpListener * @see org.mortbay.jetty.Server - * @version $Id: HttpServer.java,v 1.19 2002/08/22 01:13:39 jules_gosnell Exp $ + * @version $Id: HttpServer.java,v 1.20 2002/08/31 00:07:35 jules_gosnell Exp $ * @author Greg Wilkins (gregw) */ public class HttpServer implements LifeCycle, @@ -112,6 +112,7 @@ /* ------------------------------------------------------------ */ private boolean _statsOn=false; + private transient Object _statsLock=new Object[0]; private transient long _statsStartedAt=0; private transient int _connections; private transient int _connectionsOpen; @@ -159,6 +160,7 @@ _virtualHostMap.clear(); setContexts(contexts); setListeners(listeners); + _statsLock=new Object[0]; } @@ -682,7 +684,7 @@ if (!listener.isStarted()) try{listener.start();}catch(Exception e){mex.add(e);} } - + mex.ifExceptionThrowMulti(); Log.event("Started "+this); } @@ -701,7 +703,7 @@ } /* ------------------------------------------------------------ */ - /** Stop all listeners then handlers. + /** Stop all listeners then all contexts. * Equivalent to stop(false); * @exception InterruptedException If interrupted, stop may not have * been called on everything. @@ -713,9 +715,10 @@ } /* ------------------------------------------------------------ */ - /** Stop all listeners then handlers. - * @param graceful If true and statistics are on, then this method will wait - * for requestsActive to go to zero before calling stop() + /** Stop all listeners then all contexts. + * @param graceful If true and statistics are on for a context, + * then this method will wait for requestsActive to go to zero + * before stopping that context. */ public synchronized void stop(boolean graceful) throws InterruptedException @@ -1139,51 +1142,65 @@ public long getRequestsDurationMax() {return _requestsDurationMax;} /* ------------------------------------------------------------ */ - synchronized void statsOpenConnection() + void statsOpenConnection() { - if (++_connectionsOpen > _connectionsOpenMax) - _connectionsOpenMax=_connectionsOpen; + synchronized(_statsLock) + { + if (++_connectionsOpen > _connectionsOpenMax) + _connectionsOpenMax=_connectionsOpen; + } } /* ------------------------------------------------------------ */ - synchronized void statsGotRequest() + void statsGotRequest() { - if (++_requestsActive > _requestsActiveMax) - _requestsActiveMax=_requestsActive; + synchronized(_statsLock) + { + if (++_requestsActive > _requestsActiveMax) + _requestsActiveMax=_requestsActive; + } } + /* ------------------------------------------------------------ */ - synchronized void statsEndRequest(long duration,boolean ok) + void statsEndRequest(long duration,boolean ok) { - _requests++; - if (!ok) - _errors++; - if (--_requestsActive<0) - _requestsActive=0; - if (duration>_requestsDurationMax) - _requestsDurationMax=duration; - if (_requestsDurationAve==0) - _requestsDurationAve=duration*128; - _requestsDurationAve=_requestsDurationAve-_requestsDurationAve/128+duration; + synchronized(_statsLock) + { + _requests++; + if (!ok) + _errors++; + if (--_requestsActive<0) + _requestsActive=0; + if (duration>_requestsDurationMax) + _requestsDurationMax=duration; + if (_requestsDurationAve==0) + _requestsDurationAve=duration*128; + _requestsDurationAve=_requestsDurationAve-_requestsDurationAve/128+duration; + } } + /* ------------------------------------------------------------ */ - synchronized void statsCloseConnection(long duration,int requests) + void statsCloseConnection(long duration,int requests) { - _connections++; - _connectionsOpen--; - if (_connectionsOpen<0) - _connectionsOpen=0; - if (duration>_connectionsDurationMax) - _connectionsDurationMax=duration; - if (_connectionsDurationAve==0) - _connectionsDurationAve=128*duration; - _connectionsDurationAve=_connectionsDurationAve-_connectionsDurationAve/128+duration; - if (requests>_connectionsRequestsMax) - _connectionsRequestsMax=requests; - if (_connectionsRequestsAve==0) - _connectionsRequestsAve=16; - _connectionsRequestsAve=_connectionsRequestsAve-_connectionsRequestsAve/16+requests; + synchronized(_statsLock) + { + _connections++; + _connectionsOpen--; + if (_connectionsOpen<0) + _connectionsOpen=0; + if (duration>_connectionsDurationMax) + _connectionsDurationMax=duration; + if (_connectionsDurationAve==0) + _connectionsDurationAve=128*duration; + _connectionsDurationAve=_connectionsDurationAve-_connectionsDurationAve/128+duration; + if (requests>_connectionsRequestsMax) + _connectionsRequestsMax=requests; + if (_connectionsRequestsAve==0) + _connectionsRequestsAve=16; + _connectionsRequestsAve=_connectionsRequestsAve-_connectionsRequestsAve/16+requests; + } } 1.21 +21 -15 contrib/jetty/src/main/org/mortbay/http/HttpContext.java Index: HttpContext.java =================================================================== RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/mortbay/http/HttpContext.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- HttpContext.java 29 Aug 2002 20:14:23 -0000 1.20 +++ HttpContext.java 31 Aug 2002 00:07:35 -0000 1.21 @@ -1,6 +1,6 @@ // ======================================================================== // Copyright (c) 2000 Mort Bay Consulting (Australia) Pty. Ltd. -// $Id: HttpContext.java,v 1.20 2002/08/29 20:14:23 jules_gosnell Exp $ +// $Id: HttpContext.java,v 1.21 2002/08/31 00:07:35 jules_gosnell Exp $ // ======================================================================== package org.mortbay.http; @@ -64,7 +64,7 @@ * @see HttpServer * @see HttpHandler * @see org.mortbay.jetty.servlet.ServletHttpContext - * @version $Id: HttpContext.java,v 1.20 2002/08/29 20:14:23 jules_gosnell Exp $ + * @version $Id: HttpContext.java,v 1.21 2002/08/31 00:07:35 jules_gosnell Exp $ * @author Greg Wilkins (gregw) */ public class HttpContext implements LifeCycle, @@ -145,6 +145,7 @@ private transient String[] _hostsArray; /* ------------------------------------------------------------ */ + transient Object _statsLock=new Object[0]; transient long _statsStartedAt; transient int _requests; transient int _requestsActive; @@ -169,6 +170,7 @@ */ public HttpContext(HttpServer httpServer,String contextPathSpec) { + this(); setHttpServer(httpServer); setContextPath(contextPathSpec); } @@ -178,6 +180,7 @@ throws IOException, ClassNotFoundException { in.defaultReadObject(); + _statsLock=new Object[0]; _cache=new HashMap(); getHandlers(); for (int i=0;i<_handlersArray.length;i++) @@ -1557,7 +1560,7 @@ if (_statsOn) { - synchronized(this) + synchronized(_statsLock) { _requests++; _requestsActive++; @@ -1896,18 +1899,21 @@ {return _statsOn?(System.currentTimeMillis()-_statsStartedAt):0;} /* ------------------------------------------------------------ */ - public synchronized void statsReset() + public void statsReset() { - if (_statsOn) - _statsStartedAt=System.currentTimeMillis(); - _requests=0; - _requestsActive=0; - _requestsActiveMax=0; - _responses1xx=0; - _responses2xx=0; - _responses3xx=0; - _responses4xx=0; - _responses5xx=0; + synchronized(_statsLock) + { + if (_statsOn) + _statsStartedAt=System.currentTimeMillis(); + _requests=0; + _requestsActive=0; + _requestsActiveMax=0; + _responses1xx=0; + _responses2xx=0; + _responses3xx=0; + _responses4xx=0; + _responses5xx=0; + } } /* ------------------------------------------------------------ */ @@ -1985,7 +1991,7 @@ { if (_statsOn) { - synchronized(this) + synchronized(_statsLock) { if (--_requestsActive<0) _requestsActive=0; 1.20 +6 -5 contrib/jetty/src/main/org/mortbay/http/HttpConnection.java Index: HttpConnection.java =================================================================== RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/mortbay/http/HttpConnection.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- HttpConnection.java 22 Aug 2002 01:13:40 -0000 1.19 +++ HttpConnection.java 31 Aug 2002 00:07:35 -0000 1.20 @@ -1,6 +1,6 @@ // ======================================================================== // Copyright (c) 1999,2002 Mort Bay Consulting (Australia) Pty. Ltd. -// $Id: HttpConnection.java,v 1.19 2002/08/22 01:13:40 jules_gosnell Exp $ +// $Id: HttpConnection.java,v 1.20 2002/08/31 00:07:35 jules_gosnell Exp $ // ======================================================================== package org.mortbay.http; @@ -36,7 +36,7 @@ * * @see HttpListener * @see HttpServer - * @version $Id: HttpConnection.java,v 1.19 2002/08/22 01:13:40 jules_gosnell Exp $ + * @version $Id: HttpConnection.java,v 1.20 2002/08/31 00:07:35 jules_gosnell Exp $ * @author Greg Wilkins (gregw) */ public class HttpConnection @@ -964,7 +964,7 @@ // Complete the request if (_persistent) - { + { try{ // Read remaining input while(_inputStream.skip(4096)>0 || _inputStream.read()>=0); @@ -987,10 +987,11 @@ exception (new HttpException(_response.__400_Bad_Request, "Missing Content")); } - + // Commit the response try{ _outputStream.flush(true); + _response.commit(); bytes_written=_outputStream.getBytesWritten(); _outputStream.resetStream(); _outputStream.addObserver(this); @@ -1010,8 +1011,8 @@ // commit non persistent try{ - _response.commit(); _outputStream.flush(); + _response.commit(); bytes_written=_outputStream.getBytesWritten(); _outputStream.close(); _outputStream.resetStream(); |