Rework Torrent pending requests assertions

Should provide more info, and sooner for #249.
This commit is contained in:
Matt Joiner 2018-06-16 17:00:50 +10:00
parent 0caafd8e87
commit 174120e1e8
2 changed files with 11 additions and 5 deletions

View File

@ -1369,7 +1369,15 @@ func (c *connection) deleteRequest(r request) bool {
return false return false
} }
delete(c.requests, r) delete(c.requests, r)
c.t.pendingRequests[r]-- pr := c.t.pendingRequests
pr[r]--
n := pr[r]
if n == 0 {
delete(pr, r)
}
if n < 0 {
panic(n)
}
c.updateRequests() c.updateRequests()
return true return true
} }

View File

@ -1231,10 +1231,8 @@ func (t *Torrent) deleteConnection(c *connection) (ret bool) {
} }
func (t *Torrent) assertNoPendingRequests() { func (t *Torrent) assertNoPendingRequests() {
for _, num := range t.pendingRequests { if len(t.pendingRequests) != 0 {
if num != 0 { panic(t.pendingRequests)
panic(num)
}
} }
} }