357240 work in progress

This commit is contained in:
Greg Wilkins 2011-09-28 00:02:59 +10:00
commit 61dd1493b1

View File

@ -210,7 +210,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
private int process(ByteBuffer inBBuf, Buffer outBuf) throws IOException private int process(ByteBuffer inBBuf, Buffer outBuf) throws IOException
{ {
if (_debug) if (_debug)
LOG.debug("process {} {}",inBBuf!=null,outBuf!=null); LOG.debug("{} process closing={} in={} out={}",_session,_closing,inBBuf!=null,outBuf==null?null:outBuf.toDetailString());
// If there is no place to put incoming application data, // If there is no place to put incoming application data,
if (inBBuf==null) if (inBBuf==null)
@ -256,17 +256,17 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
// If closing, don't process application data // If closing, don't process application data
if (_closing) if (_closing)
{
if (outBuf!=null && outBuf.hasContent())
throw new IOException("Write while closing");
break; break;
}
// Try wrapping some application data // Try wrapping some application data
if (outBuf!=null)
{
int c=0;
if (outBuf!=null && outBuf.hasContent()) if (outBuf!=null && outBuf.hasContent())
{ {
c=wrap(outBuf); int c=wrap(outBuf);
progress=_result.bytesProduced()>0||_result.bytesConsumed()>0; progress=c>0||_result.bytesProduced()>0||_result.bytesConsumed()>0;
}
if (c>0) if (c>0)
sent+=c; sent+=c;
@ -324,7 +324,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
sent+=c; sent+=c;
else if (c<0 && sent==0) else if (c<0 && sent==0)
sent=-1; sent=-1;
break; break;
} }
@ -336,7 +335,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
progress|=unwrap(inBBuf); progress|=unwrap(inBBuf);
if (_closing) if (_closing)
inBBuf.clear(); inBBuf.clear();
break; break;
} }
} }
@ -358,8 +356,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
return; return;
LOG.debug("{} close",_session); LOG.debug("{} close",_session);
_closing=true; _closing=true;
_engine.closeOutbound();
// Processing will call flush(), which will handle the closing state with a closeOutbound then shutdownOutput
process(null,null); process(null,null);
} }
@ -448,27 +445,19 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
@Override @Override
public void flush() throws IOException public void flush() throws IOException
{ {
LOG.debug(_session+" flush");
if (isBufferingOutput()) if (isBufferingOutput())
{ {
int flushed=super.flush(_outNIOBuffer); int flushed=super.flush(_outNIOBuffer);
if (_debug) if (_debug)
LOG.debug(_session+" flushed "+flushed+" left="+_outNIOBuffer.length()); LOG.debug(_session+" flushed "+flushed+" left="+_outNIOBuffer.length());
} }
else if (_closing) else if (_engine.isOutboundDone() && !super.isOutputShutdown())
{
if (_engine.isOutboundDone() && !super.isOutputShutdown())
{ {
if (_debug) if (_debug)
LOG.debug(_session+" flush shutdownOutput"); LOG.debug(_session+" flush shutdownOutput");
super.shutdownOutput(); super.shutdownOutput();
} }
else
{
if (_debug)
LOG.debug(_session+" flush closeOutbound");
_engine.closeOutbound();
}
}
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */