Wait for all acks before leaving
This commit is contained in:
parent
eea5415f2f
commit
52aa64b200
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user