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(); } /** 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?