forked from I2P_Developers/i2p.i2p
- Fix deadlock when changing file priorities
This commit is contained in:
@@ -741,6 +741,7 @@ public class PeerCoordinator implements PeerListener
|
|||||||
_log.debug("Updated piece priorities called but no priorities to set?");
|
_log.debug("Updated piece priorities called but no priorities to set?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
List<Piece> toCancel = new ArrayList();
|
||||||
synchronized(wantedPieces) {
|
synchronized(wantedPieces) {
|
||||||
// Add incomplete and previously unwanted pieces to the list
|
// Add incomplete and previously unwanted pieces to the list
|
||||||
// Temp to avoid O(n**2)
|
// Temp to avoid O(n**2)
|
||||||
@@ -775,23 +776,31 @@ public class PeerCoordinator implements PeerListener
|
|||||||
p.setPriority(priority);
|
p.setPriority(priority);
|
||||||
} else {
|
} else {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
// cancel all peers
|
toCancel.add(p);
|
||||||
for (Peer peer : peers) {
|
|
||||||
peer.cancel(p.getId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Updated piece priorities, now wanted: " + wantedPieces);
|
_log.debug("Updated piece priorities, now wanted: " + wantedPieces);
|
||||||
// if we added pieces, they will be in-order unless we shuffle
|
// if we added pieces, they will be in-order unless we shuffle
|
||||||
Collections.shuffle(wantedPieces, _random);
|
Collections.shuffle(wantedPieces, _random);
|
||||||
|
}
|
||||||
|
|
||||||
// update request queues, in case we added wanted pieces
|
// cancel outside of wantedPieces lock to avoid deadlocks
|
||||||
// and we were previously uninterested
|
if (!toCancel.isEmpty()) {
|
||||||
for (Peer peer : peers) {
|
// cancel all peers
|
||||||
peer.request();
|
for (Peer peer : peers) {
|
||||||
|
for (Piece p : toCancel) {
|
||||||
|
peer.cancel(p.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ditto, avoid deadlocks
|
||||||
|
// update request queues, in case we added wanted pieces
|
||||||
|
// and we were previously uninterested
|
||||||
|
for (Peer peer : peers) {
|
||||||
|
peer.request();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
* i2psnark:
|
* i2psnark:
|
||||||
- Refactor tracker map
|
- Refactor tracker map
|
||||||
- Prevent torrent shutdown when changing file priority to skip
|
- Prevent torrent shutdown when changing file priority to skip
|
||||||
|
- Fix deadlock when changing file priorities
|
||||||
* RoutingKeyModifier: Update after large clock shift
|
* RoutingKeyModifier: Update after large clock shift
|
||||||
|
|
||||||
2012-05-20 zzz
|
2012-05-20 zzz
|
||||||
|
Reference in New Issue
Block a user