JETTY-1467 close half closed when idle

This commit is contained in:
Greg Wilkins 2011-12-28 23:09:33 +11:00
parent 2b54d45280
commit 009f8176a1
3 changed files with 31 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.RequestLogHandler;
import org.eclipse.jetty.server.handler.StatisticsHandler;
import org.eclipse.jetty.server.nio.BlockingChannelConnector;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
import org.eclipse.jetty.server.ssl.SslSocketConnector;
@ -68,6 +69,13 @@ public class LikeJettyXml
server.setConnectors(new Connector[]
{ connector });
BlockingChannelConnector bConnector = new BlockingChannelConnector();
bConnector.setPort(8888);
bConnector.setMaxIdleTime(30000);
bConnector.setConfidentialPort(8443);
bConnector.setAcceptors(1);
server.addConnector(bConnector);
SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector();
ssl_connector.setPort(8443);

View File

@ -110,6 +110,13 @@ public class BlockingHttpConnection extends AbstractHttpConnection
_endp.shutdownOutput();
}
}
// If we don't have a committed response and we are not suspended
if (_endp.isInputShutdown() && _generator.isIdle() && !_request.getAsyncContinuation().isSuspended())
{
// then no more can happen, so close.
_endp.close();
}
}
}

View File

@ -17,6 +17,7 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.channels.ByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Set;
@ -341,5 +342,20 @@ public class BlockingChannelConnector extends AbstractNIOConnector
}
}
}
/* ------------------------------------------------------------ */
@Override
public String toString()
{
return String.format("BCEP@%x{l(%s)<->r(%s),open=%b,ishut=%b,oshut=%b}-{%s}",
hashCode(),
_socket.getRemoteSocketAddress(),
_socket.getLocalSocketAddress(),
isOpen(),
isInputShutdown(),
isOutputShutdown(),
_connection);
}
}
}