jetty-9 new simple SslConnection (comments)

This commit is contained in:
Greg Wilkins 2012-05-31 01:07:29 +02:00
parent 80ff0586a8
commit 117d7e5ad8
1 changed files with 13 additions and 7 deletions

View File

@ -122,12 +122,11 @@ public class SslConnection extends AbstractAsyncConnection
public void onReadable() public void onReadable()
{ {
LOG.debug("{} onReadable",this); LOG.debug("{} onReadable",this);
// We are hand shaking so could be either a reader or a writer // wake up whoever is doing the fill or the flush so they can
// that is interested. So tell both either if they care // do all the filling, unwrapping ,wrapping and flushing
if (_appEndPoint._readInterest.isInterested()) if (_appEndPoint._readInterest.isInterested())
_appEndPoint._readInterest.readable(); _appEndPoint._readInterest.readable();
else if (_appEndPoint._writeFlusher.isWriting()) else if (_appEndPoint._writeFlusher.isWriting())
_appEndPoint._writeFlusher.completeWrite(); _appEndPoint._writeFlusher.completeWrite();
} }
@ -205,6 +204,9 @@ public class SslConnection extends AbstractAsyncConnection
{ {
if (BufferUtil.hasContent(_appIn)||BufferUtil.hasContent(_netIn)) if (BufferUtil.hasContent(_appIn)||BufferUtil.hasContent(_netIn))
return true; return true;
// TODO handle the case where we need to wrap some more.
scheduleOnReadable(); scheduleOnReadable();
return false; return false;
} }
@ -215,9 +217,11 @@ public class SslConnection extends AbstractAsyncConnection
@Override @Override
protected void scheduleCompleteWrite() protected void scheduleCompleteWrite()
{ {
if (BufferUtil.isEmpty(_netOut)) if (BufferUtil.hasContent(_netOut))
getEndPoint().write(null,_writeCallback,_netOut);
else
// TODO handle the case where we need to unwrap some more.
throw new IllegalStateException(); throw new IllegalStateException();
getEndPoint().write(null,_writeCallback,_netOut);
} }
}; };
@ -330,6 +334,7 @@ public class SslConnection extends AbstractAsyncConnection
continue; continue;
case NEED_WRAP: case NEED_WRAP:
// TODO maybe just do the wrap here ourselves?
// we need to send some handshake data // we need to send some handshake data
_fillWrap=true; _fillWrap=true;
flush(BufferUtil.EMPTY_BUFFER); flush(BufferUtil.EMPTY_BUFFER);
@ -431,10 +436,11 @@ public class SslConnection extends AbstractAsyncConnection
continue; continue;
case NEED_WRAP: case NEED_WRAP:
// Hey we just wrapped! Oh well we will wrap again when flush is called again // Hey we just wrapped!
continue; continue;
case NEED_UNWRAP: case NEED_UNWRAP:
// TODO maybe just do the unwrap here ourselves?
// Were we were not called from fill and not reading anyway // Were we were not called from fill and not reading anyway
if ((appOuts.length!=1 || appOuts[0]!=BufferUtil.EMPTY_BUFFER) && !_readInterest.isInterested()) if ((appOuts.length!=1 || appOuts[0]!=BufferUtil.EMPTY_BUFFER) && !_readInterest.isInterested())
fill(BufferUtil.EMPTY_BUFFER); fill(BufferUtil.EMPTY_BUFFER);