1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 07:15:39 +02:00

[246826][dstore] KeepAlive does not work correctly

This commit is contained in:
David McKnight 2009-04-20 18:37:32 +00:00
parent a4c83b7f30
commit 373680288a
3 changed files with 25 additions and 11 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation and others. * Copyright (c) 2002, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -14,6 +14,7 @@
* Contributors: * Contributors:
* David McKnight (IBM) [220123][dstore] Configurable timeout on irresponsiveness * David McKnight (IBM) [220123][dstore] Configurable timeout on irresponsiveness
* David McKnight (IBM) [222168][dstore] Buffer in DataElement is not sent * David McKnight (IBM) [222168][dstore] Buffer in DataElement is not sent
* David McKnight (IBM) [246826][dstore] KeepAlive does not work correctly
*******************************************************************************/ *******************************************************************************/
package org.eclipse.dstore.internal.core.client; package org.eclipse.dstore.internal.core.client;
@ -359,7 +360,8 @@ public class ClientCommandHandler extends CommandHandler
document.setAttribute(DE.A_VALUE, "confirm"); //$NON-NLS-1$ document.setAttribute(DE.A_VALUE, "confirm"); //$NON-NLS-1$
document.setParent(null); document.setParent(null);
_pendingKeepAliveConfirmation = document; _pendingKeepAliveConfirmation = document;
notifyInput();
handle(); // bypassing threading
} }
public void sendKeepAliveRequest() public void sendKeepAliveRequest()
@ -370,7 +372,8 @@ public class ClientCommandHandler extends CommandHandler
document.setAttribute(DE.A_VALUE, "request"); //$NON-NLS-1$ document.setAttribute(DE.A_VALUE, "request"); //$NON-NLS-1$
document.setParent(null); document.setParent(null);
_pendingKeepAliveRequest = document; _pendingKeepAliveRequest = document;
notifyInput();
handle(); // bypassing threading
} }
public synchronized void waitForInput() public synchronized void waitForInput()

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation and others. * Copyright (c) 2002, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -14,6 +14,7 @@
* Contributors: * Contributors:
* David McKnight (IBM) [222168][dstore] Buffer in DataElement is not sent * David McKnight (IBM) [222168][dstore] Buffer in DataElement is not sent
* David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types * David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types
* David McKnight (IBM) [246826][dstore] KeepAlive does not work correctly
*******************************************************************************/ *******************************************************************************/
package org.eclipse.dstore.internal.core.server; package org.eclipse.dstore.internal.core.server;
@ -440,7 +441,8 @@ public class ServerUpdateHandler extends UpdateHandler
document.setAttribute(DE.A_VALUE, "request"); //$NON-NLS-1$ document.setAttribute(DE.A_VALUE, "request"); //$NON-NLS-1$
document.setParent(null); document.setParent(null);
_pendingKeepAliveRequest = document; _pendingKeepAliveRequest = document;
notifyInput();
handle(); // bypassing threading
} }
public void sendKeepAliveConfirmation() public void sendKeepAliveConfirmation()
@ -451,7 +453,8 @@ public class ServerUpdateHandler extends UpdateHandler
document.setAttribute(DE.A_VALUE, "confirm"); //$NON-NLS-1$ document.setAttribute(DE.A_VALUE, "confirm"); //$NON-NLS-1$
document.setParent(null); document.setParent(null);
_pendingKeepAliveConfirmation = document; _pendingKeepAliveConfirmation = document;
notifyInput();
handle(); // bypassing threading
} }
public synchronized void waitForInput() public synchronized void waitForInput()

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation and others. * Copyright (c) 2002, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -16,6 +16,7 @@
* David McKnight (IBM) [221601][dstore] xmlparser needs to be able to handle very large attributes * David McKnight (IBM) [221601][dstore] xmlparser needs to be able to handle very large attributes
* David McKnight (IBM) [222163][dstore] Special characters from old server are not restored * David McKnight (IBM) [222163][dstore] Special characters from old server are not restored
* David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability * David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability
* David McKnight (IBM) [246826][dstore] KeepAlive does not work correctly
*******************************************************************************/ *******************************************************************************/
package org.eclipse.dstore.internal.core.util; package org.eclipse.dstore.internal.core.util;
@ -319,7 +320,7 @@ public class XMLparser
{ {
if (_firstTime) if (_firstTime)
{ {
_initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT); _initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, socket);
_firstTime = false; _firstTime = false;
if (VERBOSE_KEEPALIVE) System.out.println("Starting initial KeepAlive thread."); //$NON-NLS-1$ if (VERBOSE_KEEPALIVE) System.out.println("Starting initial KeepAlive thread."); //$NON-NLS-1$
_initialKart.start(); _initialKart.start();
@ -349,10 +350,12 @@ public class XMLparser
if (_kart == null || !_kart.isAlive()){ // normal read wait if (_kart == null || !_kart.isAlive()){ // normal read wait
socket.setSoTimeout(IO_SOCKET_READ_TIMEOUT); socket.setSoTimeout(IO_SOCKET_READ_TIMEOUT);
} }
/* the SoTimeout is set in the kart before sleeping
else { // read wait time when awaking a keepalive response else { // read wait time when awaking a keepalive response
// otherwise, if IO_SOCKET_READ_TIMEOUT is bigger we don't get out of here until IO_SOCKET_READ_TIMEOUT is complete // otherwise, if IO_SOCKET_READ_TIMEOUT is bigger we don't get out of here until IO_SOCKET_READ_TIMEOUT is complete
socket.setSoTimeout((int)KEEPALIVE_RESPONSE_TIMEOUT); socket.setSoTimeout((int)KEEPALIVE_RESPONSE_TIMEOUT);
} }
*/
try try
{ {
@ -370,7 +373,7 @@ public class XMLparser
else else
{ {
if (_kart == null || !_kart.isAlive()){ if (_kart == null || !_kart.isAlive()){
_kart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT); _kart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, socket);
if (VERBOSE_KEEPALIVE) System.out.println("No activity on socket. KeepAlive thread started."); //$NON-NLS-1$ if (VERBOSE_KEEPALIVE) System.out.println("No activity on socket. KeepAlive thread started."); //$NON-NLS-1$
_kart.start(); _kart.start();
continue; continue;
@ -1056,20 +1059,25 @@ public class XMLparser
{ {
private long _timeout; private long _timeout;
private boolean _failed; private boolean _failed;
private Socket _socket;
public KeepAliveRequestThread(long timeout) public KeepAliveRequestThread(long timeout, Socket socket)
{ {
_timeout = timeout; _timeout = timeout;
_failed = false; _failed = false;
_socket = socket;
} }
public void run() public void run()
{ {
_dataStore.sendKeepAliveRequest(); _dataStore.sendKeepAliveRequest();
try try
{ {
_socket.setSoTimeout((int)_timeout);
sleep(_timeout); sleep(_timeout);
} }
catch (SocketException e){
}
catch (InterruptedException e) catch (InterruptedException e)
{ {
if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive thread interrupted."); //$NON-NLS-1$ if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive thread interrupted."); //$NON-NLS-1$