From 6ca9f93ddadd23dad9ac2bd7b94f067c7ad06efd Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Thu, 1 Aug 2013 12:36:31 +0200 Subject: [PATCH] restart if php-cgi process was terminated --- .../src/org/jetbrains/io/NettyUtil.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java index 6a522fa9c19d..2332b706eb7a 100644 --- a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java +++ b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java @@ -19,10 +19,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.ActionCallback; import com.intellij.util.Consumer; import org.jboss.netty.bootstrap.ClientBootstrap; -import org.jboss.netty.channel.Channel; -import org.jboss.netty.channel.ChannelException; -import org.jboss.netty.channel.ChannelFuture; -import org.jboss.netty.channel.ChannelFutureListener; +import org.jboss.netty.channel.*; import java.io.IOException; import java.net.SocketAddress; @@ -72,4 +69,16 @@ public final class NettyUtil { return (throwable instanceof IOException && message.equals("An existing connection was forcibly closed by the remote host")) || (throwable instanceof ChannelException && message.startsWith("Failed to bind to: ")); } + + // applicable only in case of ClientBootstrap&OioClientSocketChannelFactory + public static void closeAndReleaseFactory(Channel channel) { + ChannelFactory channelFactory = channel.getFactory(); + try { + channel.close().awaitUninterruptibly(); + } + finally { + // in our case it does nothing, we don't use ExecutorService, but we are aware of future changes + channelFactory.releaseExternalResources(); + } + } } \ No newline at end of file