1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-16 04:35:45 +02:00

[373459] [dstore][multithread] duplicate finish() calls during idle timeout

This commit is contained in:
David McKnight 2012-03-07 14:14:38 +00:00
parent 7e326c2026
commit 1768999c02
2 changed files with 46 additions and 15 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 IBM Corporation and others.
* Copyright (c) 2008, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,6 +13,7 @@
* Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
* Noriaki Takatsu (IBM) - [228335] [dstore][multithread] start() in SecuredThread class
* David McKnight (IBM) - [358301] [DSTORE] Hang during debug source look up
* David McKnight (IBM) - [373459] [dstore][multithread] duplicate finish() calls during idle timeout
*******************************************************************************/
package org.eclipse.dstore.core.server;
@ -123,6 +124,9 @@ public class SecuredThread extends Thread
*/
public void run()
{
if (_dataStore != null && _dataStore.getClient() != null) {
_dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "SecuredThread.run()..."); //$NON-NLS-1$
}
try
{
ISystemService systemService = SystemServiceManager.getInstance().getSystemService();
@ -139,6 +143,9 @@ public class SecuredThread extends Thread
}
super.run();
if (_dataStore != null && _dataStore.getClient() != null) {
_dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "... end of SecuredThread.run()"); //$NON-NLS-1$
}
}
/**

View file

@ -19,6 +19,7 @@
* David McKnight (IBM) - [294933] [dstore] RSE goes into loop
* David McKnight (IBM) - [282364] [dstore][multithread] timer-threads stay active after disconnect
* David McKnight (IBM) - [371401] [dstore][multithread] avoid use of static variables - causes memory leak after disconnect
* David McKnight (IBM) - [373459] [dstore][multithread] duplicate finish() calls during idle timeout
*******************************************************************************/
package org.eclipse.dstore.internal.core.server;
@ -41,7 +42,7 @@ import org.eclipse.dstore.core.model.IDataStoreConstants;
import org.eclipse.dstore.core.server.SystemServiceManager;
/**
* The ServerCommandHandler is reponsible for maintaining
* The ServerCommandHandler is responsible for maintaining
* a queue of commands and periodically routing commands
* from the queue to the appropriate miners.
*/
@ -61,24 +62,28 @@ public class ServerCommandHandler extends CommandHandler
{
while (!_serverTimedOut)
{
if (_dataStore.getClient() != null) {
_dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "ServerIdleThread.waitForTimeout()..."); //$NON-NLS-1$
}
waitForTimeout();
}
if (_serverTimedOut)
{
_dataStore.getCommandHandler().finish();
_dataStore.getUpdateHandler().finish();
_dataStore.finish();
System.out.println(ServerReturnCodes.RC_FINISHED);
if (_dataStore.getClient() != null) {
_dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "Server timeout");
_dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "Server timeout"); //$NON-NLS-1$
}
System.out.println(ServerReturnCodes.RC_FINISHED);
// only exit if there's no service manager
if (SystemServiceManager.getInstance().getSystemService() == null){
if (SystemServiceManager.getInstance().getSystemService() == null){
_dataStore.getCommandHandler().finish();
_dataStore.getUpdateHandler().finish();
_dataStore.finish();
System.exit(0);
}
else {
_dataStore.getClient().disconnectServerReceiver();
_dataStore.getClient().disconnectServerReceiver();
}
}
}
@ -202,13 +207,32 @@ public class ServerCommandHandler extends CommandHandler
*/
public void finish()
{
if (_serverIdleThread != null && _serverIdleThread.isAlive()){
_serverIdleThread._serverTimedOut=true; // ensures that the wait loop won't continue after the interrupt
_serverIdleThread.interrupt();
if (_dataStore.getClient() != null) {
_dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "ServerCommandHandler.finish()"); //$NON-NLS-1$
}
_serverIdleThread = null;
if (_minerLoader != null)
if (_serverIdleThread != null){
if (_dataStore.getClient() != null) {
_dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "ServerCommandHandler clearing server idle thread"); //$NON-NLS-1$
}
if (_serverIdleThread.isAlive()){
_serverIdleThread._serverTimedOut = true;
_serverIdleThread.interrupt();
}
_serverIdleThread = null;
}
if (_minerLoader != null){
if (_dataStore.getClient() != null) {
_dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "ServerCommandHandler.finish() - calling finishMiners..."); //$NON-NLS-1$
}
_minerLoader.finishMiners();
if (_dataStore.getClient() != null) {
_dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "ServerCommandHandler.finish() - ...completed calling finishMiners"); //$NON-NLS-1$
}
}
super.finish();
}