368821 SslConnection.handle always calls wrapped Connection.handle, so state can be processed

This commit is contained in:
Greg Wilkins 2012-01-18 13:39:24 +11:00
parent b57bf3b600
commit 9ff8633554
5 changed files with 71 additions and 66 deletions

View File

@ -619,10 +619,10 @@ public class SslBytesServerTest extends SslBytesTest
}
// Check that we did not spin
TimeUnit.MILLISECONDS.sleep(500);
TimeUnit.MILLISECONDS.sleep(1000);
Assert.assertThat(sslHandles.get(), lessThan(750));
Assert.assertThat(sslFlushes.get(), lessThan(750));
Assert.assertThat(httpParses.get(), lessThan(150));
Assert.assertThat(httpParses.get(), lessThan(1000));
client.close();
@ -1555,7 +1555,6 @@ public class SslBytesServerTest extends SslBytesTest
client.close();
}
@Ignore
@Test
public void testRequestConcurrentWithIdleExpiration() throws Exception
{
@ -1609,7 +1608,6 @@ public class SslBytesServerTest extends SslBytesTest
Assert.assertThat(sslFlushes.get(), lessThan(20));
Assert.assertThat(httpParses.get(), lessThan(50));
closeClient(client);
}
/*
@Test

View File

@ -194,7 +194,7 @@ public class HttpParser implements Parser
public void setPersistent(boolean persistent)
{
_persistent = persistent;
if (_state==STATE_END)
if (!_persistent &&(_state==STATE_END || _state==STATE_START))
_state=STATE_SEEKING_EOF;
}

View File

@ -185,11 +185,8 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
// If we are handshook let the delegate connection
if (_engine.getHandshakeStatus()!=HandshakeStatus.NOT_HANDSHAKING)
{
progress=process(null,null);
}
else
{
// handle the delegate connection
AsyncConnection next = (AsyncConnection)_connection.handle();
if (next!=_connection && next!=null)
@ -197,8 +194,6 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
_connection=next;
progress=true;
}
// TODO: consider moving here hasProgressed() - it's only used in SSL
}
LOG.debug("{} handle {} progress={}", _session, this, progress);
}
@ -389,6 +384,11 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
// The SSL needs to receive some handshake data from the other side
if (_handshook && !_allowRenegotiate)
_endp.close();
else if (!_inbound.hasContent()&&filled==-1)
{
// No more input coming
_endp.shutdownInput();
}
else if (unwrap(toFill))
progress=true;
}

View File

@ -177,6 +177,10 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async
// then no more can happen, so close.
_endp.close();
}
// Make idle parser seek EOF
if (_parser.isIdle())
_parser.setPersistent(false);
}
}

View File

@ -354,7 +354,7 @@ public class WebSocketClientFactory extends AggregateLifeCycle
private final HttpParser _parser;
private String _accept;
private String _error;
private boolean _handshaken;
private ByteArrayBuffer _handshake;
public HandshakeConnection(AsyncEndPoint endpoint, WebSocketClient.WebSocketFuture future)
{
@ -404,7 +404,9 @@ public class WebSocketClientFactory extends AggregateLifeCycle
});
}
private void handshake()
private boolean handshake()
{
if (_handshake==null)
{
String path = _future.getURI().getPath();
if (path == null || path.length() == 0)
@ -445,31 +447,32 @@ public class WebSocketClientFactory extends AggregateLifeCycle
request.append("\r\n");
_handshake=new ByteArrayBuffer(request.toString(), false);
}
// TODO extensions
try
{
Buffer handshake = new ByteArrayBuffer(request.toString(), false);
int len = handshake.length();
if (len != _endp.flush(handshake))
throw new IOException("incomplete");
int len = _handshake.length();
int flushed = _endp.flush(_handshake);
if (flushed<0)
throw new IOException("incomplete handshake");
}
catch (IOException e)
{
_future.handshakeFailed(e);
}
finally
{
_handshaken = true;
}
return _handshake.length()==0;
}
public Connection handle() throws IOException
{
while (_endp.isOpen() && !_parser.isComplete())
{
if (!_handshaken)
handshake();
if (_handshake==null || _handshake.length()>0)
if (!handshake())
return this;
if (!_parser.parseAvailable())
{