From 950f684a0550ebb0f223d25b47005b8a5f000cba Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Thu, 5 Sep 2013 01:03:40 +0200 Subject: [PATCH] Try to disconnect unused tcp connections --- .../java/org/kde/connect/LinkProviders/LanLinkProvider.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/KdeConnect/src/main/java/org/kde/connect/LinkProviders/LanLinkProvider.java b/KdeConnect/src/main/java/org/kde/connect/LinkProviders/LanLinkProvider.java index 07e17aa9..dac87d78 100644 --- a/KdeConnect/src/main/java/org/kde/connect/LinkProviders/LanLinkProvider.java +++ b/KdeConnect/src/main/java/org/kde/connect/LinkProviders/LanLinkProvider.java @@ -16,7 +16,6 @@ import org.apache.mina.filter.codec.textline.TextLineCodecFactory; import org.apache.mina.transport.socket.nio.NioDatagramAcceptor; import org.apache.mina.transport.socket.nio.NioSocketAcceptor; import org.apache.mina.transport.socket.nio.NioSocketConnector; -import org.kde.connect.ComputerLinks.BaseComputerLink; import org.kde.connect.ComputerLinks.LanComputerLink; import org.kde.connect.NetworkPackage; @@ -45,10 +44,10 @@ public class LanLinkProvider extends BaseLinkProvider { LanComputerLink brokenLink = nioSessions.remove(session.getId()); if (brokenLink != null) { connectionLost(brokenLink); + brokenLink.disconnect(); String deviceId = brokenLink.getDeviceId(); if (visibleComputers.get(deviceId) == brokenLink) { visibleComputers.remove(deviceId); - connectionLost(brokenLink); } } @@ -161,11 +160,12 @@ public class LanLinkProvider extends BaseLinkProvider { private void addLink(NetworkPackage identityPackage, LanComputerLink link) { String deviceId = identityPackage.getString("deviceId"); Log.e("LanLinkProvider","addLink to "+deviceId); - BaseComputerLink oldLink = visibleComputers.get(deviceId); + LanComputerLink oldLink = visibleComputers.get(deviceId); visibleComputers.put(deviceId, link); connectionAccepted(identityPackage, link); if (oldLink != null) { Log.e("LanLinkProvider","Removing old connection to same device"); + oldLink.disconnect(); connectionLost(oldLink); } }