From a524e1b2c009b5d35f807cf035e58cedde9ebfc8 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Mon, 10 Apr 2017 13:47:22 -0500 Subject: [PATCH] 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?