diff options
author | vrubezhny | 2014-01-15 18:50:21 +0000 |
---|---|---|
committer | vrubezhny | 2014-01-15 18:50:21 +0000 |
commit | 661e04b600b5a6ec86a63fb2f92f74433483d738 (patch) | |
tree | 8b78ca58b12306e93163ab685826453402dbaa0a | |
parent | 2eb0896efaba7090f49d572834b98b7d4f94fc73 (diff) | |
download | webtools.jsdt.debug-661e04b600b5a6ec86a63fb2f92f74433483d738.tar.gz webtools.jsdt.debug-661e04b600b5a6ec86a63fb2f92f74433483d738.tar.xz webtools.jsdt.debug-661e04b600b5a6ec86a63fb2f92f74433483d738.zip |
All the streams are closed in case of accept fails. Otherwise, in case of accept succeeded, a client and a server are responsible to close their connections accordingly.
Signed-off-by: vrubezhny <vrubezhny@exadel.com>
-rw-r--r-- | bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java b/bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java index 896ce82..d044991 100644 --- a/bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java +++ b/bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java @@ -108,36 +108,40 @@ public class PipedTransportService implements TransportService { PipedOutputStream clientos = new PipedOutputStream(); PipedOutputStream serveros = new PipedOutputStream(); PipedInputStream clientis = new PipedInputStream(); - - try { - serveris.connect(clientos); - serveros.connect(clientis); - - listeners.put(key, new PipedConnection(clientis, clientos)); - listeners.notifyAll(); - long startTime = System.currentTimeMillis(); - while (true) { - try { - listeners.wait(timeout); - } catch (InterruptedException e) { - throw new IOException("accept failed: interrupted"); //$NON-NLS-1$ - } - if (!listeners.containsKey(key)) - throw new IOException("accept failed: stopped listening"); //$NON-NLS-1$ + serveris.connect(clientos); + serveros.connect(clientis); - if (listeners.get(key) != null) { - if (System.currentTimeMillis() - startTime > timeout) { - listeners.put(key, null); - throw new IOException("accept failed: timed out"); //$NON-NLS-1$ - } - continue; + PipedConnection clientConnection = new PipedConnection(clientis, clientos); + PipedConnection serverConnection = new PipedConnection(serveris, serveros); + + listeners.put(key, clientConnection); + listeners.notifyAll(); + long startTime = System.currentTimeMillis(); + while (true) { + try { + listeners.wait(timeout); + } catch (InterruptedException e) { + clientConnection.close(); // Close unused client connection (and its streams); + serverConnection.close(); // Close unused server connection (and its streams); + throw new IOException("accept failed: interrupted"); //$NON-NLS-1$ + } + if (!listeners.containsKey(key)) { + clientConnection.close(); // Close unused client connection (and its streams); + serverConnection.close(); // Close unused server connection (and its streams); + throw new IOException("accept failed: stopped listening"); //$NON-NLS-1$ + } + + if (listeners.get(key) != null) { + if (System.currentTimeMillis() - startTime > timeout) { + listeners.put(key, null); + clientConnection.close(); // Close unused client connection (and its streams); + serverConnection.close(); // Close unused server connection (and its streams); + throw new IOException("accept failed: timed out"); //$NON-NLS-1$ } - return new PipedConnection(serveris, serveros); + continue; } - } - finally { - serveris.close(); - serveros.close(); + return serverConnection; // From this point both, the server and the client, + // are responsible to close their connections } } } |