Changeset e27df77


Ignore:
Timestamp:
May 22, 2012 7:26:37 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
580bb5a6
Parents:
0f321f1
Message:
  • Fix deadlock when changing file priorities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/PeerCoordinator.java

    r0f321f1 re27df77  
    742742          return;
    743743      }
     744      List<Piece> toCancel = new ArrayList();
    744745      synchronized(wantedPieces) {
    745746          // Add incomplete and previously unwanted pieces to the list
     
    776777               } else {
    777778                   iter.remove();
    778                    // cancel all peers
    779                        for (Peer peer : peers) {
    780                            peer.cancel(p.getId());
    781                        }
     779                   toCancel.add(p);
    782780               }
    783781          }
     
    786784          // if we added pieces, they will be in-order unless we shuffle
    787785          Collections.shuffle(wantedPieces, _random);
    788 
    789           // update request queues, in case we added wanted pieces
    790           // and we were previously uninterested
    791               for (Peer peer : peers) {
    792                   peer.request();
    793           }
     786      }
     787
     788      // cancel outside of wantedPieces lock to avoid deadlocks
     789      if (!toCancel.isEmpty()) {
     790          // cancel all peers
     791          for (Peer peer : peers) {
     792              for (Piece p : toCancel) {
     793                  peer.cancel(p.getId());
     794              }
     795          }
     796      }
     797
     798      // ditto, avoid deadlocks
     799      // update request queues, in case we added wanted pieces
     800      // and we were previously uninterested
     801      for (Peer peer : peers) {
     802          peer.request();
    794803      }
    795804  }
  • history.txt

    r0f321f1 re27df77  
    33   - Refactor tracker map
    44   - Prevent torrent shutdown when changing file priority to skip
     5   - Fix deadlock when changing file priorities
    56 * RoutingKeyModifier: Update after large clock shift
    67
Note: See TracChangeset for help on using the changeset viewer.