jetty-9 removed onInputShutdown
This commit is contained in:
parent
017d6e7c2a
commit
a1d8c640ce
|
@ -32,8 +32,8 @@ import java.util.NoSuchElementException;
|
|||
import java.util.StringTokenizer;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.eclipse.jetty.io.BufferDateCache;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.DateCache;
|
||||
import org.eclipse.jetty.util.LazyList;
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.StringMap;
|
||||
|
@ -57,7 +57,7 @@ public class HttpFields implements Iterable<HttpFields.Field>
|
|||
/* ------------------------------------------------------------ */
|
||||
public static final String __COOKIE_DELIM="\"\\\n\r\t\f\b%+ ;=";
|
||||
public static final TimeZone __GMT = TimeZone.getTimeZone("GMT");
|
||||
public static final BufferDateCache __dateCache = new BufferDateCache("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
|
||||
public static final DateCache __dateCache = new DateCache("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
static
|
||||
|
|
|
@ -10,7 +10,7 @@ public abstract class AbstractEndPoint implements EndPoint
|
|||
private final InetSocketAddress _local;
|
||||
private final InetSocketAddress _remote;
|
||||
private int _maxIdleTime;
|
||||
private volatile long _lastNotIdleTimestamp;
|
||||
private volatile long _idleTimestamp;
|
||||
|
||||
|
||||
protected AbstractEndPoint(InetSocketAddress local,InetSocketAddress remote)
|
||||
|
@ -53,15 +53,15 @@ public abstract class AbstractEndPoint implements EndPoint
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public long getNotIdleTimestamp()
|
||||
public long getIdleTimestamp()
|
||||
{
|
||||
return _lastNotIdleTimestamp;
|
||||
return _idleTimestamp;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void notIdle()
|
||||
{
|
||||
_lastNotIdleTimestamp=System.currentTimeMillis();
|
||||
_idleTimestamp=System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -193,7 +193,7 @@ public class AsyncByteArrayEndPoint extends ByteArrayEndPoint implements AsyncEn
|
|||
{
|
||||
if (_idlecheck || !_readFuture.isComplete() || !_writeFuture.isComplete())
|
||||
{
|
||||
long idleTimestamp=getNotIdleTimestamp();
|
||||
long idleTimestamp=getIdleTimestamp();
|
||||
long max_idle_time=getMaxIdleTime();
|
||||
|
||||
if (idleTimestamp!=0 && max_idle_time>0)
|
||||
|
|
|
@ -22,7 +22,6 @@ public interface AsyncConnection
|
|||
|
||||
void onReadable();
|
||||
void onReadFail(Throwable cause);
|
||||
void onInputShutdown();
|
||||
void onClose();
|
||||
void onIdleExpired(long idleForMs);
|
||||
|
||||
|
|
|
@ -122,6 +122,6 @@ public interface AsyncEndPoint extends EndPoint
|
|||
* @return Timestamp in ms since epoch of when the last data was
|
||||
* filled or flushed from this endpoint.
|
||||
*/
|
||||
long getNotIdleTimestamp();
|
||||
long getIdleTimestamp();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.io;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.DateCache;
|
||||
|
||||
public class BufferDateCache extends DateCache
|
||||
{
|
||||
ByteBuffer _buffer;
|
||||
String _last;
|
||||
|
||||
public BufferDateCache()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public BufferDateCache(String format, DateFormatSymbols s)
|
||||
{
|
||||
super(format,s);
|
||||
}
|
||||
|
||||
public BufferDateCache(String format, Locale l)
|
||||
{
|
||||
super(format,l);
|
||||
}
|
||||
|
||||
public BufferDateCache(String format)
|
||||
{
|
||||
super(format);
|
||||
}
|
||||
|
||||
public synchronized ByteBuffer formatBuffer(long date)
|
||||
{
|
||||
String d = super.format(date);
|
||||
if (d==_last)
|
||||
return _buffer;
|
||||
_last=d;
|
||||
_buffer=BufferUtil.toBuffer(d);
|
||||
|
||||
return _buffer;
|
||||
}
|
||||
}
|
|
@ -48,8 +48,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
/** The desired value for {@link SelectionKey#interestOps()} */
|
||||
private int _interestOps;
|
||||
|
||||
private boolean _ishutCalled;
|
||||
|
||||
/** true if {@link SelectSet#destroyEndPoint(SelectChannelEndPoint)} has not been called */
|
||||
private boolean _open;
|
||||
|
||||
|
@ -181,11 +179,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
if (can_write && _writeBuffers!=null)
|
||||
completeWrite();
|
||||
|
||||
if (isInputShutdown() && !_ishutCalled)
|
||||
{
|
||||
_ishutCalled=true;
|
||||
getAsyncConnection().onInputShutdown();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -228,7 +221,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
{
|
||||
if (_idlecheck || !_readFuture.isComplete() || !_writeFuture.isComplete())
|
||||
{
|
||||
long idleTimestamp=getNotIdleTimestamp();
|
||||
long idleTimestamp=getIdleTimestamp();
|
||||
long max_idle_time=getMaxIdleTime();
|
||||
|
||||
if (idleTimestamp!=0 && max_idle_time>0)
|
||||
|
|
|
@ -97,7 +97,6 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
private AsyncEndPoint _endp;
|
||||
private boolean _allowRenegotiate=true;
|
||||
private boolean _handshook;
|
||||
private boolean _eofIn;
|
||||
private boolean _oshut;
|
||||
private IOFuture _netReadFuture;
|
||||
private IOFuture _netWriteFuture;
|
||||
|
@ -177,8 +176,8 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
/* ------------------------------------------------------------ */
|
||||
private void allocateBuffers()
|
||||
{
|
||||
// TODO remove this lock if always called with lock held?
|
||||
_lock.lock();
|
||||
if (!_lock.tryLock())
|
||||
throw new IllegalStateException();
|
||||
try
|
||||
{
|
||||
if (_allocations++==0)
|
||||
|
@ -204,8 +203,8 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
/* ------------------------------------------------------------ */
|
||||
private void releaseBuffers()
|
||||
{
|
||||
// TODO remove this lock if always called with lock held?
|
||||
_lock.lock();
|
||||
if (!_lock.tryLock())
|
||||
throw new IllegalStateException();
|
||||
try
|
||||
{
|
||||
if (--_allocations==0)
|
||||
|
@ -233,11 +232,11 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
// TODO is this right?
|
||||
_appConnection.onClose();
|
||||
}
|
||||
|
||||
|
@ -283,9 +282,7 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
{
|
||||
int filled = _endp.fill(_inNet);
|
||||
LOG.debug("filled {}",filled);
|
||||
if (filled<0)
|
||||
_eofIn=true;
|
||||
else if (filled>0)
|
||||
if (filled>0)
|
||||
progress=true;
|
||||
}
|
||||
|
||||
|
@ -401,7 +398,7 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
// The SSL needs to receive some handshake data from the other side
|
||||
if (_handshook && !_allowRenegotiate)
|
||||
_endp.close();
|
||||
else if (BufferUtil.isEmpty(_inNet) && _eofIn)
|
||||
else if (BufferUtil.isEmpty(_inNet) && _endp.isInputShutdown())
|
||||
_endp.close();
|
||||
else
|
||||
progress|=unwrap();
|
||||
|
@ -410,7 +407,7 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
}
|
||||
|
||||
// pass on ishut/oshut state
|
||||
if (_endp.isOpen() && _eofIn && BufferUtil.isEmpty(_inNet))
|
||||
if (_endp.isOpen() && _endp.isInputShutdown() && BufferUtil.isEmpty(_inNet))
|
||||
_engine.closeInbound();
|
||||
if (_endp.isOpen() && _engine.isOutboundDone() && BufferUtil.isEmpty(_outNet))
|
||||
_endp.shutdownOutput();
|
||||
|
@ -535,7 +532,7 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
{
|
||||
case BUFFER_UNDERFLOW:
|
||||
// need to wait for more net data
|
||||
if (_eofIn)
|
||||
if (_endp.isInputShutdown())
|
||||
_inNet.clear().limit(0);
|
||||
else if (_netReadFuture==null)
|
||||
_netReadFuture=scheduleOnReadable();
|
||||
|
@ -570,12 +567,6 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
return result.bytesConsumed()>0 || result.bytesProduced()>0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void onInputShutdown()
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public AsyncEndPoint getAppEndPoint()
|
||||
{
|
||||
|
@ -681,7 +672,7 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
}
|
||||
int filled=buffer.remaining()-size;
|
||||
|
||||
if (filled==0 && _eofIn)
|
||||
if (filled==0 && _endp.isInputShutdown())
|
||||
return -1;
|
||||
return filled;
|
||||
}
|
||||
|
@ -745,19 +736,19 @@ public class SslConnection extends AbstractAsyncConnection
|
|||
int i = inbound == null? -1 : inbound.remaining();
|
||||
int o = outbound == null ? -1 : outbound.remaining();
|
||||
int u = unwrap == null ? -1 : unwrap.remaining();
|
||||
return String.format("SSL %s %s i/o/u=%d/%d/%d eof=%b oshut=%b {%s}",
|
||||
return String.format("SSL %s %s i/o/u=%d/%d/%d ep.ishut=%b oshut=%b {%s}",
|
||||
super.toString(),
|
||||
_engine.getHandshakeStatus(),
|
||||
i, o, u,
|
||||
_eofIn, _oshut,
|
||||
_endp.isInputShutdown(), _oshut,
|
||||
_appConnection);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getNotIdleTimestamp()
|
||||
public long getIdleTimestamp()
|
||||
{
|
||||
return _endp.getNotIdleTimestamp();
|
||||
return _endp.getIdleTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -138,7 +138,11 @@ public class SelectChannelEndPointTest
|
|||
|
||||
// Fill the input buffer with everything available
|
||||
if (!BufferUtil.isFull(_in))
|
||||
progress|=_endp.fill(_in)>0;
|
||||
{
|
||||
int filled=_endp.fill(_in);
|
||||
if (filled>0)
|
||||
progress=true;
|
||||
}
|
||||
|
||||
// If the tests wants to block, then block
|
||||
while (_blockAt>0 && _endp.isOpen() && _in.remaining()<_blockAt)
|
||||
|
@ -163,6 +167,10 @@ public class SelectChannelEndPointTest
|
|||
}
|
||||
progress=true;
|
||||
}
|
||||
|
||||
// are we done?
|
||||
if (BufferUtil.isEmpty(_out) && _endp.isInputShutdown())
|
||||
_endp.shutdownOutput();
|
||||
}
|
||||
}
|
||||
catch(ClosedChannelException e)
|
||||
|
@ -200,27 +208,10 @@ public class SelectChannelEndPointTest
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInputShutdown()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (BufferUtil.isEmpty(_out))
|
||||
_endp.shutdownOutput();
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
@ -281,4 +282,17 @@ public class DateCache
|
|||
return _formatString;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private volatile ByteBuffer _buffer;
|
||||
private volatile String _last;
|
||||
public synchronized ByteBuffer formatBuffer(long date)
|
||||
{
|
||||
String d = format(date);
|
||||
if (d==_last)
|
||||
return _buffer;
|
||||
_last=d;
|
||||
_buffer=BufferUtil.toBuffer(d);
|
||||
|
||||
return _buffer;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue