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

applying patch provided by Michael Berger for defect 142974

This commit is contained in:
David McKnight 2006-05-24 18:53:37 +00:00
parent f2f189dc51
commit 85532fc260
3 changed files with 34 additions and 5 deletions

View file

@ -39,7 +39,7 @@ public class ClientCommandHandler extends CommandHandler
protected DataElement _confirmKeepAliveDocumentElement; protected DataElement _confirmKeepAliveDocumentElement;
protected DataElement _pendingKeepAliveRequest; protected DataElement _pendingKeepAliveRequest;
protected DataElement _pendingKeepAliveConfirmation; protected DataElement _pendingKeepAliveConfirmation;
private static String[] _docAttributes = { private static String[] _docAttributes = {
DataStoreResources.DOCUMENT_TYPE, DataStoreResources.DOCUMENT_TYPE,
"client.doc.root.id", "client.doc.root.id",
@ -357,6 +357,7 @@ public class ClientCommandHandler extends CommandHandler
document.setAttribute(DE.A_VALUE, "confirm"); document.setAttribute(DE.A_VALUE, "confirm");
document.setParent(null); document.setParent(null);
_pendingKeepAliveConfirmation = document; _pendingKeepAliveConfirmation = document;
notifyInput();
} }
public void sendKeepAliveRequest() public void sendKeepAliveRequest()
@ -366,6 +367,15 @@ public class ClientCommandHandler extends CommandHandler
document.setAttribute(DE.A_NAME, "request"); document.setAttribute(DE.A_NAME, "request");
document.setAttribute(DE.A_VALUE, "request"); document.setAttribute(DE.A_VALUE, "request");
document.setParent(null); document.setParent(null);
_pendingKeepAliveRequest = document; _pendingKeepAliveRequest = document;
notifyInput();
}
public synchronized void waitForInput()
{
if (_commands.size() == 0 && _classesToSend.size() == 0 && _pendingKeepAliveConfirmation == null && _pendingKeepAliveRequest == null)
{
super.waitForInput();
}
} }
} }

View file

@ -437,7 +437,8 @@ public class ServerUpdateHandler extends UpdateHandler
document.setAttribute(DE.A_NAME, "request"); document.setAttribute(DE.A_NAME, "request");
document.setAttribute(DE.A_VALUE, "request"); document.setAttribute(DE.A_VALUE, "request");
document.setParent(null); document.setParent(null);
_pendingKeepAliveRequest = document; _pendingKeepAliveRequest = document;
notifyInput();
} }
public void sendKeepAliveConfirmation() public void sendKeepAliveConfirmation()
@ -448,6 +449,14 @@ public class ServerUpdateHandler extends UpdateHandler
document.setAttribute(DE.A_VALUE, "confirm"); document.setAttribute(DE.A_VALUE, "confirm");
document.setParent(null); document.setParent(null);
_pendingKeepAliveConfirmation = document; _pendingKeepAliveConfirmation = document;
notifyInput();
} }
public synchronized void waitForInput()
{
if (_dataObjects.size() == 0 && _classesToSend.size() == 0 && _pendingKeepAliveConfirmation == null && _pendingKeepAliveRequest == null)
{
super.waitForInput();
}
}
} }

View file

@ -50,7 +50,8 @@ public class XMLparser
public static final int IO_SOCKET_READ_TIMEOUT = 3600000; public static final int IO_SOCKET_READ_TIMEOUT = 3600000;
public static final long KEEPALIVE_RESPONSE_TIMEOUT = 60000; public static final long KEEPALIVE_RESPONSE_TIMEOUT = 60000;
public static final boolean VERBOSE_KEEPALIVE = false;
private DataStore _dataStore; private DataStore _dataStore;
private DataElement _rootDataElement; private DataElement _rootDataElement;
private Stack _tagStack; private Stack _tagStack;
@ -301,6 +302,7 @@ public class XMLparser
{ {
_initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, _dataStore); _initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, _dataStore);
_firstTime = false; _firstTime = false;
if (VERBOSE_KEEPALIVE) System.out.println("Starting initial KeepAlive thread.");
_initialKart.start(); _initialKart.start();
continue; continue;
} }
@ -309,11 +311,13 @@ public class XMLparser
if (!_initialKart.failed()) if (!_initialKart.failed())
{ {
_isKeepAliveCompatible = true; _isKeepAliveCompatible = true;
if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive compatible.");
_initialKart = null; _initialKart = null;
} }
else else
{ {
_isKeepAliveCompatible = false; _isKeepAliveCompatible = false;
if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive incompatible.");
_initialKart = null; _initialKart = null;
} }
} }
@ -332,12 +336,14 @@ public class XMLparser
if ((_kart != null) && _kart.failed()) if ((_kart != null) && _kart.failed())
{ {
done = true; done = true;
handlePanic(new Exception("KeepAlive request to client wasnt answered in time.")); if (_dataStore.isVirtual()) handlePanic(new Exception("KeepAlive request to server wasnt answered in time."));
else handlePanic(new Exception("KeepAlive request to client wasnt answered in time."));
continue; continue;
} }
else else
{ {
_kart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, _dataStore); _kart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, _dataStore);
if (VERBOSE_KEEPALIVE) System.out.println("No activity on socket. KeepAlive thread started.");
_kart.start(); _kart.start();
continue; continue;
} }
@ -610,11 +616,13 @@ public class XMLparser
} }
else if (_isKeepAlive && (result != null)) else if (_isKeepAlive && (result != null))
{ {
if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive request received, sending confirmation.");
result.getDataStore().sendKeepAliveConfirmation(); result.getDataStore().sendKeepAliveConfirmation();
_isKeepAlive = false; _isKeepAlive = false;
} }
else if (_isKeepAliveConfirm && (result != null)) else if (_isKeepAliveConfirm && (result != null))
{ {
if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive confirmation received.");
if (_initialKart != null) _initialKart.interrupt(); if (_initialKart != null) _initialKart.interrupt();
_isKeepAliveConfirm = false; _isKeepAliveConfirm = false;
} }
@ -1004,8 +1012,10 @@ public class XMLparser
} }
catch (InterruptedException e) catch (InterruptedException e)
{ {
if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive thread interrupted.");
return; return;
} }
if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive thread failed to be interrupted.");
_failed = true; _failed = true;
} }