Split "if" statement in case of flushing while closing, so if the input is shutdown we do not call closeOutbound().
This commit is contained in:
parent
44923230e3
commit
ded5143700
|
@ -42,7 +42,7 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
||||
{
|
||||
public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio").getLogger("ssl");
|
||||
|
||||
|
||||
private static final Buffer __EMPTY_BUFFER=new DirectNIOBuffer(0);
|
||||
private static final ByteBuffer __ZERO_BUFFER=ByteBuffer.allocate(0);
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
SSLEngineResult result = _result;
|
||||
return result!=null && (result.bytesConsumed()>0 || result.bytesProduced()>0);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return True if SSL re-negotiation is allowed (default false)
|
||||
|
@ -213,29 +213,29 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
{
|
||||
if (_debug)
|
||||
LOG.debug("process {} {} {}",inbuf!=null,header!=null,buffer!=null);
|
||||
|
||||
// If there is no place to put incoming application data,
|
||||
|
||||
// If there is no place to put incoming application data,
|
||||
if (inbuf==null)
|
||||
{
|
||||
// use ZERO buffer
|
||||
inbuf=__ZERO_BUFFER;
|
||||
}
|
||||
|
||||
|
||||
int received=0;
|
||||
int sent=0;
|
||||
|
||||
|
||||
|
||||
|
||||
HandshakeStatus initialStatus = _engine.getHandshakeStatus();
|
||||
boolean progress=true;
|
||||
|
||||
|
||||
while (progress)
|
||||
{
|
||||
progress=false;
|
||||
|
||||
|
||||
// flush output data
|
||||
{
|
||||
int len=_outNIOBuffer==null?0:_outNIOBuffer.length();
|
||||
|
||||
|
||||
// we must flush it, as the other end might be
|
||||
// waiting for that outgoing data before sending
|
||||
// more incoming data
|
||||
|
@ -251,15 +251,15 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
{
|
||||
case FINISHED:
|
||||
throw new IllegalStateException();
|
||||
|
||||
|
||||
case NOT_HANDSHAKING:
|
||||
|
||||
|
||||
_handshook=true;
|
||||
|
||||
|
||||
// If closing, don't process application data
|
||||
if (_closing)
|
||||
break;
|
||||
|
||||
|
||||
// Try wrapping some application data
|
||||
if (header!=null||buffer!=null)
|
||||
{
|
||||
|
@ -277,7 +277,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
c=wrap(buffer);
|
||||
progress=_result.bytesProduced()>0||_result.bytesConsumed()>0;
|
||||
}
|
||||
|
||||
|
||||
if (c>0)
|
||||
sent+=c;
|
||||
else if (c<0 && sent==0)
|
||||
|
@ -293,7 +293,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case NEED_TASK:
|
||||
{
|
||||
// A task needs to be run, so run it!
|
||||
|
@ -342,31 +342,31 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
else if (c<0 && sent==0)
|
||||
sent=-1;
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case NEED_UNWRAP:
|
||||
{
|
||||
checkRenegotiate();
|
||||
|
||||
|
||||
// Need more data to be unwrapped so try another call to unwrap
|
||||
progress|=unwrap(inbuf);
|
||||
if (_closing)
|
||||
inbuf.clear();
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_debug) LOG.debug("{} progress {}",_session,progress);
|
||||
}
|
||||
|
||||
if (_debug) LOG.debug("{} received {} sent {}",_session,received,sent);
|
||||
return (received<0||sent<0)?-1:(received+sent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
|
@ -376,7 +376,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
return;
|
||||
LOG.debug("{} close",_session);
|
||||
_closing=true;
|
||||
|
||||
|
||||
// Processing will call flush(), which will handle the closing state with a closeOutbound then shutdownOutput
|
||||
process(null,null,null);
|
||||
}
|
||||
|
@ -388,18 +388,18 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
*/
|
||||
@Override
|
||||
public int fill(Buffer buffer) throws IOException
|
||||
{
|
||||
{
|
||||
LOG.debug("{} fill",_session);
|
||||
// This end point only works on NIO buffer type (director
|
||||
// or indirect), so extract the NIO buffer that is wrapped
|
||||
// by the passed jetty Buffer.
|
||||
ByteBuffer bbuf=((NIOBuffer)buffer).getByteBuffer();
|
||||
|
||||
|
||||
|
||||
// remember the original size of the unencrypted buffer
|
||||
int size=buffer.length();
|
||||
|
||||
|
||||
|
||||
synchronized (bbuf)
|
||||
{
|
||||
bbuf.position(buffer.putIndex());
|
||||
|
@ -411,7 +411,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
unwrap(bbuf);
|
||||
|
||||
int progress = process(bbuf,null,null);
|
||||
|
||||
|
||||
// TODO ???
|
||||
}
|
||||
finally
|
||||
|
@ -451,24 +451,27 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
|
|||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void flush() throws IOException
|
||||
{
|
||||
{
|
||||
if (isBufferingOutput())
|
||||
{
|
||||
int flushed=super.flush(_outNIOBuffer);
|
||||
if (_debug)
|
||||
if (_debug)
|
||||
LOG.debug(_session+" flushed "+flushed+" left="+_outNIOBuffer.length());
|
||||
}
|
||||
else if (_closing)
|
||||
{
|
||||
if (_engine.isOutboundDone() && !super.isOutputShutdown())
|
||||
if (_engine.isOutboundDone())
|
||||
{
|
||||
if (_debug)
|
||||
LOG.debug(_session+" flush shutdownOutput");
|
||||
super.shutdownOutput();
|
||||
if (!super.isOutputShutdown())
|
||||
{
|
||||
if (_debug)
|
||||
LOG.debug(_session+" flush shutdownOutput");
|
||||
super.shutdownOutput();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_debug)
|
||||
if (_debug)
|
||||
LOG.debug(_session+" flush closeOutbound");
|
||||
_engine.closeOutbound();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue