Skip to content

Commit

Permalink
peer lock fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mh0lt committed Jun 1, 2024
1 parent f4f5f02 commit 857e05d
Show file tree
Hide file tree
Showing 10 changed files with 305 additions and 272 deletions.
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1106,12 +1106,12 @@ func (p *Peer) initUpdateRequestsTimer() {
const peerUpdateRequestsTimerReason = "updateRequestsTimer"

func (c *Peer) updateRequestsTimerFunc() {
c.locker().Lock()
defer c.locker().Unlock()
c.mu.Lock()
defer c.mu.Unlock()
if c.closed.IsSet() {
return
}
if c.isLowOnRequests() {
if c.isLowOnRequests(false) {
// If there are no outstanding requests, then a request update should have already run.
return
}
Expand All @@ -1121,7 +1121,7 @@ func (c *Peer) updateRequestsTimerFunc() {
torrent.Add("spurious timer requests updates", 1)
return
}
c.updateRequests(peerUpdateRequestsTimerReason)
c.updateRequests(peerUpdateRequestsTimerReason, false)
}

// Maximum pending requests we allow peers to send us. If peer requests are buffered on read, this
Expand Down
2 changes: 1 addition & 1 deletion deferrwl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func stack(skip int) string {
func (me *lockWithDeferreds) Lock() {
me.internal.Lock()
me.lc.Add(1)
// me.locker = stack(2)
//me.locker = stack(2)
}

func (me *lockWithDeferreds) Unlock() {
Expand Down
2 changes: 1 addition & 1 deletion peer-impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ type peerImpl interface {
peerHasAllPieces() (all, known bool)
peerPieces() *roaring.Bitmap

nominalMaxRequests() maxRequests
nominalMaxRequests(lock bool) maxRequests
}
Loading

0 comments on commit 857e05d

Please sign in to comment.