347898 Close channel on JVM exceptions

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3374 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-06-01 11:32:13 +00:00
parent 71ce6291d2
commit e55c21ca5c
3 changed files with 35 additions and 30 deletions

View File

@ -1,6 +1,7 @@
jetty-7.4.3-SNAPSHOT
+ 347617 Dynamically install/update/remove OSGi bundles discovered in the contexts folder
+ 347717 start.jar destroys dependent child of --exec
+ 347898 Close channel on JVM exceptions
+ JETTY-1342 Recreate selector in change task
+ 347889 OSGi should follow directive visibility:=reexport for META-INF/web-fragments and resources

View File

@ -445,6 +445,10 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
else
throw new IllegalArgumentException(change.toString());
}
catch (CancelledKeyException e)
{
Log.ignore(e);
}
catch (Throwable e)
{
if (e instanceof ThreadDeath)
@ -454,17 +458,14 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
Log.warn(e);
else
Log.debug(e);
if(ch!=null && key==null)
try
{
try
{
ch.close();
}
catch(IOException e2)
{
Log.debug(e2);
}
ch.close();
}
catch(IOException e2)
{
Log.debug(e2);
}
}
}
@ -522,6 +523,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
// Look for things to do
for (SelectionKey key: selector.selectedKeys())
{
SocketChannel channel=null;
try
{
if (!key.isValid())
@ -542,7 +545,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
else if (key.isConnectable())
{
// Complete a connection of a registered channel
SocketChannel channel = (SocketChannel)key.channel();
channel = (SocketChannel)key.channel();
boolean connected=false;
try
{
@ -570,7 +573,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
else
{
// Wrap readable registered channel in an endpoint
SocketChannel channel = (SocketChannel)key.channel();
channel = (SocketChannel)key.channel();
SelectChannelEndPoint endpoint = createEndPoint(channel,key);
key.attach(endpoint);
if (key.isReadable())
@ -589,6 +592,16 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
else
Log.ignore(e);
try
{
if (channel!=null)
channel.close();
}
catch(IOException e2)
{
Log.debug(e2);
}
if (key != null && !(key.channel() instanceof ServerSocketChannel) && key.isValid())
key.cancel();
}

View File

@ -564,28 +564,19 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
*/
protected SSLEngine createSSLEngine(SocketChannel channel) throws IOException
{
try
SSLEngine engine;
if (channel != null && _sslContextFactory.isSessionCachingEnabled())
{
SSLEngine engine;
if (channel != null && _sslContextFactory.isSessionCachingEnabled())
{
String peerHost = channel.socket().getInetAddress().getHostAddress();
int peerPort = channel.socket().getPort();
engine = _sslContextFactory.getSslContext().createSSLEngine(peerHost, peerPort);
}
else
{
engine = _sslContextFactory.getSslContext().createSSLEngine();
}
customizeEngine(engine);
return engine;
String peerHost = channel.socket().getInetAddress().getHostAddress();
int peerPort = channel.socket().getPort();
engine = _sslContextFactory.getSslContext().createSSLEngine(peerHost, peerPort);
}
catch (Exception x)
else
{
Log.warn("Error creating SSLEngine -- closing this connector", x);
close();
throw new IllegalStateException(x);
engine = _sslContextFactory.getSslContext().createSSLEngine();
}
customizeEngine(engine);
return engine;
}
/* ------------------------------------------------------------ */