mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix "too many nio worker threads" problem
This commit is contained in:
@@ -128,7 +128,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
|
||||
private final ChannelGroup myAllOpenChannels = new DefaultChannelGroup("build-manager");
|
||||
private final BuildMessageDispatcher myMessageDispatcher = new BuildMessageDispatcher();
|
||||
private int myListenPort = -1;
|
||||
private volatile int myListenPort = -1;
|
||||
private volatile CmdlineRemoteProto.Message.ControllerMessage.GlobalSettings myGlobals;
|
||||
|
||||
public BuildManager(final ProjectManager projectManager) {
|
||||
@@ -380,7 +380,11 @@ public class BuildManager implements ApplicationComponent{
|
||||
// ensure server is listening
|
||||
if (myListenPort < 0) {
|
||||
try {
|
||||
myListenPort = startListening();
|
||||
synchronized (this) {
|
||||
if (myListenPort < 0) {
|
||||
myListenPort = startListening();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
handler.handleFailure(sessionId, CmdlineProtoUtil.createFailure(e.getMessage(), null));
|
||||
@@ -795,7 +799,7 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
|
||||
private int startListening() throws Exception {
|
||||
final ChannelFactory channelFactory = new NioServerSocketChannelFactory(myPooledThreadExecutor, myPooledThreadExecutor);
|
||||
final ChannelFactory channelFactory = new NioServerSocketChannelFactory(myPooledThreadExecutor, myPooledThreadExecutor, Math.min(4, Math.max(2, Runtime.getRuntime().availableProcessors())));
|
||||
final SimpleChannelUpstreamHandler channelRegistrar = new SimpleChannelUpstreamHandler() {
|
||||
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
|
||||
myAllOpenChannels.add(e.getChannel());
|
||||
|
||||
Reference in New Issue
Block a user