jetty-9 improved handling of half close

This commit is contained in:
Greg Wilkins 2012-08-17 15:34:53 +10:00
parent 6d2da78aac
commit 2a66567a5b
4 changed files with 36 additions and 3 deletions

View File

@ -277,6 +277,11 @@ public class SslConnection extends AbstractConnection
super(null,getEndPoint().getLocalAddress(), getEndPoint().getRemoteAddress());
}
public EndPoint getEncryptedEndPoint()
{
return getEndPoint();
}
@Override
protected FillInterest getFillInterest()
{
@ -761,5 +766,11 @@ public class SslConnection extends AbstractConnection
{
return _ishut;
}
@Override
public String toString()
{
return super.toString()+"->"+getEndPoint().toString();
}
}
}

View File

@ -201,6 +201,8 @@ public class HttpConnection extends AbstractConnection
{
LOG.debug("{} onReadable {}",this,_channel.isIdle());
int filled=-2;
try
{
setCurrentConnection(this);
@ -214,7 +216,7 @@ public class HttpConnection extends AbstractConnection
if (_requestBuffer==null)
_requestBuffer=_bufferPool.acquire(_httpConfig.getRequestHeaderSize(),false); // TODO may acquire on speculative read. probably released to early
int filled=getEndPoint().fill(_requestBuffer);
filled=getEndPoint().fill(_requestBuffer);
LOG.debug("{} filled {}",this,filled);
@ -233,7 +235,10 @@ public class HttpConnection extends AbstractConnection
// read -1 then we have nothing to parse and thus nothing that
// will generate a response. If we had a suspended request pending
// a response or a request waiting in the buffer, we would not be here.
getEndPoint().shutdownOutput();
if (getEndPoint().isOutputShutdown())
getEndPoint().close();
else
getEndPoint().shutdownOutput();
// buffer must be empty and the channel must be idle, so we can release.
releaseRequestBuffer();
return;
@ -480,7 +485,9 @@ public class HttpConnection extends AbstractConnection
// make sure that an oshut connection is driven towards close
// TODO this is a little ugly
if (getEndPoint().isOpen() && getEndPoint().isOutputShutdown())
{
fillInterested();
}
}
/* ------------------------------------------------------------ */

View File

@ -1040,6 +1040,12 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
Thread.sleep(200);
// TODO this sometimes fails for SSL ???
if (handler._endp.isOpen())
{
System.err.println(handler._endp);
System.err.println(((SslConnection.DecryptedEndPoint)handler._endp).getEncryptedEndPoint());
System.err.println(handler._endp.getConnection());
}
assertTrue(!handler._endp.isOpen());
}
finally
@ -1051,7 +1057,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
}
}
protected static class CommittedErrorHandler extends AbstractHandler
public static class CommittedErrorHandler extends AbstractHandler
{
public EndPoint _endp;

View File

@ -13,8 +13,10 @@
package org.eclipse.jetty.server.ssl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.security.KeyStore;
@ -24,8 +26,14 @@ import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.HttpServerTestBase;
import org.eclipse.jetty.server.SelectChannelConnector;
import org.eclipse.jetty.server.HttpServerTestBase.CommittedErrorHandler;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.StdErrLog;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.Before;
import org.junit.BeforeClass;
@ -135,5 +143,6 @@ public class SelectChannelServerSslTest extends HttpServerTestBase
public void testAvailable() throws Exception
{
}
}