diff --git a/ws2012/P2P/uebungen/4/src/node/Node.java b/ws2012/P2P/uebungen/4/src/node/Node.java index 6cba241e..8f2ea031 100644 --- a/ws2012/P2P/uebungen/4/src/node/Node.java +++ b/ws2012/P2P/uebungen/4/src/node/Node.java @@ -196,7 +196,12 @@ public class Node { sendLeave(neighbors.get(i)); } - try { + try { + // Wait until all we received all acks + while (!acks.isEmpty()) { + Thread.sleep(10); + } + if (thread != null) { udpListen.terminate(); thread.join(); @@ -257,7 +262,7 @@ public class Node { Ack theAck = acks.get(ack_id); if (theAck.check(from)) { theAck.setReceived(); - acks.remove(theAck); + acks.remove(theAck.getId()); } } } @@ -270,7 +275,7 @@ public class Node { if (idToRemove != -1) { neighbors.remove(idToRemove); int ack_id = buf.getInt(); - sendAck(from, ack_id); + sendAck(from, ack_id); } // If we don't know that neighbor, we don't have to // ack