From 373680288a1a414cae0d0b4883bf7dd1f0388dc8 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Mon, 20 Apr 2009 18:37:32 +0000 Subject: [PATCH] [246826][dstore] KeepAlive does not work correctly --- .../core/client/ClientCommandHandler.java | 9 ++++++--- .../core/server/ServerUpdateHandler.java | 9 ++++++--- .../dstore/internal/core/util/XMLparser.java | 18 +++++++++++++----- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientCommandHandler.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientCommandHandler.java index 434b2cf3415..00d8481bb66 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientCommandHandler.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientCommandHandler.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * David McKnight (IBM) [220123][dstore] Configurable timeout on irresponsiveness * 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; @@ -359,7 +360,8 @@ public class ClientCommandHandler extends CommandHandler document.setAttribute(DE.A_VALUE, "confirm"); //$NON-NLS-1$ document.setParent(null); _pendingKeepAliveConfirmation = document; - notifyInput(); + + handle(); // bypassing threading } public void sendKeepAliveRequest() @@ -370,7 +372,8 @@ public class ClientCommandHandler extends CommandHandler document.setAttribute(DE.A_VALUE, "request"); //$NON-NLS-1$ document.setParent(null); _pendingKeepAliveRequest = document; - notifyInput(); + + handle(); // bypassing threading } public synchronized void waitForInput() diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerUpdateHandler.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerUpdateHandler.java index 84a721f615d..326da2c6659 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerUpdateHandler.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerUpdateHandler.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * 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) [246826][dstore] KeepAlive does not work correctly *******************************************************************************/ 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.setParent(null); _pendingKeepAliveRequest = document; - notifyInput(); + + handle(); // bypassing threading } public void sendKeepAliveConfirmation() @@ -451,7 +453,8 @@ public class ServerUpdateHandler extends UpdateHandler document.setAttribute(DE.A_VALUE, "confirm"); //$NON-NLS-1$ document.setParent(null); _pendingKeepAliveConfirmation = document; - notifyInput(); + + handle(); // bypassing threading } public synchronized void waitForInput() diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java index 0f1b8bf9c84..e20bc4dff8f 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java @@ -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 * are made available under the terms of the Eclipse Public License v1.0 * 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) [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) [246826][dstore] KeepAlive does not work correctly *******************************************************************************/ package org.eclipse.dstore.internal.core.util; @@ -319,7 +320,7 @@ public class XMLparser { if (_firstTime) { - _initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT); + _initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, socket); _firstTime = false; if (VERBOSE_KEEPALIVE) System.out.println("Starting initial KeepAlive thread."); //$NON-NLS-1$ _initialKart.start(); @@ -349,10 +350,12 @@ public class XMLparser if (_kart == null || !_kart.isAlive()){ // normal read wait socket.setSoTimeout(IO_SOCKET_READ_TIMEOUT); } + /* the SoTimeout is set in the kart before sleeping 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 socket.setSoTimeout((int)KEEPALIVE_RESPONSE_TIMEOUT); } + */ try { @@ -370,7 +373,7 @@ public class XMLparser else { 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$ _kart.start(); continue; @@ -1056,20 +1059,25 @@ public class XMLparser { private long _timeout; private boolean _failed; + private Socket _socket; - public KeepAliveRequestThread(long timeout) + public KeepAliveRequestThread(long timeout, Socket socket) { _timeout = timeout; _failed = false; + _socket = socket; } public void run() { - _dataStore.sendKeepAliveRequest(); + _dataStore.sendKeepAliveRequest(); try { + _socket.setSoTimeout((int)_timeout); sleep(_timeout); } + catch (SocketException e){ + } catch (InterruptedException e) { if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive thread interrupted."); //$NON-NLS-1$