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)
@ -455,8 +459,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
else
Log.debug(e);
if(ch!=null && key==null)
{
try
{
ch.close();
@ -467,7 +469,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
}
}
}
}
// Do and instant select to see if any connections can be handled.
@ -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

@ -563,8 +563,6 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
* @throws IOException if the SSLEngine cannot be created
*/
protected SSLEngine createSSLEngine(SocketChannel channel) throws IOException
{
try
{
SSLEngine engine;
if (channel != null && _sslContextFactory.isSessionCachingEnabled())
@ -580,13 +578,6 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
customizeEngine(engine);
return engine;
}
catch (Exception x)
{
Log.warn("Error creating SSLEngine -- closing this connector", x);
close();
throw new IllegalStateException(x);
}
}
/* ------------------------------------------------------------ */
private void customizeEngine(SSLEngine engine)