From 5085b042bbf29057e517489f286dc25320b4de36 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Mon, 10 Apr 2017 13:46:48 -0500 Subject: [PATCH 1/2] fix: Closes the MultiplexingDatagramSocket held by a Component. --- src/main/java/org/ice4j/ice/Component.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/ice4j/ice/Component.java b/src/main/java/org/ice4j/ice/Component.java index fc96851..398fbfe 100644 --- a/src/main/java/org/ice4j/ice/Component.java +++ b/src/main/java/org/ice4j/ice/Component.java @@ -840,6 +840,7 @@ public class Component getParentStream().removePairStateChangeListener(this); keepAlivePairs.clear(); getComponentSocket().close(); + socket.close(); } /** From a524e1b2c009b5d35f807cf035e58cedde9ebfc8 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Mon, 10 Apr 2017 13:47:22 -0500 Subject: [PATCH 2/2] fix: Closes the MultiplexingDatagramSocket instances created by single-port UDP candidates. --- .../ice4j/ice/harvest/SinglePortUdpHarvester.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java b/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java index 87d2bbe..92d7cef 100644 --- a/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java @@ -307,6 +307,11 @@ public class SinglePortUdpHarvester synchronized (candidateSockets) { + for (IceSocketWrapper wrapper : candidateSockets.values()) + { + wrapper.close(); + } + candidateSockets.clear(); } @@ -372,7 +377,14 @@ public class SinglePortUdpHarvester // XXX is this necessary? synchronized (candidateSockets) { - candidateSockets.put(remoteAddress, candidateSocket); + IceSocketWrapper oldSocket + = candidateSockets.put(remoteAddress, candidateSocket); + if (oldSocket != null) + { + logger.warning("Replacing the socket for remote address " + + remoteAddress); + oldSocket.close(); + } } // XXX is this necessary?