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
{
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 (inBBuf==null)
@ -256,17 +256,17 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
// If closing, don't process application data
if (_closing)
{
if (outBuf!=null && outBuf.hasContent())
throw new IOException("Write while closing");
break;
}
// Try wrapping some application data
if (outBuf!=null)
if (outBuf!=null && outBuf.hasContent())
{
int c=0;
if (outBuf!=null && outBuf.hasContent())
{
c=wrap(outBuf);
progress=_result.bytesProduced()>0||_result.bytesConsumed()>0;
}
int c=wrap(outBuf);
progress=c>0||_result.bytesProduced()>0||_result.bytesConsumed()>0;
if (c>0)
sent+=c;
@ -324,7 +324,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
sent+=c;
else if (c<0 && sent==0)
sent=-1;
break;
}
@ -336,7 +335,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
progress|=unwrap(inBBuf);
if (_closing)
inBBuf.clear();
break;
}
}
@ -358,8 +356,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
_engine.closeOutbound();
process(null,null);
}
@ -448,26 +445,18 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
@Override
public void flush() throws IOException
{
LOG.debug(_session+" flush");
if (isBufferingOutput())
{
int flushed=super.flush(_outNIOBuffer);
if (_debug)
LOG.debug(_session+" flushed "+flushed+" left="+_outNIOBuffer.length());
}
else if (_closing)
else if (_engine.isOutboundDone() && !super.isOutputShutdown())
{
if (_engine.isOutboundDone() && !super.isOutputShutdown())
{
if (_debug)
LOG.debug(_session+" flush shutdownOutput");
super.shutdownOutput();
}
else
{
if (_debug)
LOG.debug(_session+" flush closeOutbound");
_engine.closeOutbound();
}
if (_debug)
LOG.debug(_session+" flush shutdownOutput");
super.shutdownOutput();
}
}