aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-02-17 22:14:12 +0800
committerFelix Lange <fjl@twurst.com>2015-02-17 22:21:39 +0800
commit7ea131d4ffddaae15c697fe0d025ff431bacc01a (patch)
tree840057da55b3ab0bbfb7646bb2a2a4372fc98256 /p2p
parent643eda5c2d3190147bc55ef27c4ce241c7c59da2 (diff)
downloadgo-tangerine-7ea131d4ffddaae15c697fe0d025ff431bacc01a.tar
go-tangerine-7ea131d4ffddaae15c697fe0d025ff431bacc01a.tar.gz
go-tangerine-7ea131d4ffddaae15c697fe0d025ff431bacc01a.tar.bz2
go-tangerine-7ea131d4ffddaae15c697fe0d025ff431bacc01a.tar.lz
go-tangerine-7ea131d4ffddaae15c697fe0d025ff431bacc01a.tar.xz
go-tangerine-7ea131d4ffddaae15c697fe0d025ff431bacc01a.tar.zst
go-tangerine-7ea131d4ffddaae15c697fe0d025ff431bacc01a.zip
p2p/discover: fix pending replies iteration
Range expressions capture the length of the slice once before the first iteration. A range expression cannot be used here since the loop modifies the slice variable (including length changes).
Diffstat (limited to 'p2p')
-rw-r--r--p2p/discover/udp.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go
index b2a895442..69e9f3c2e 100644
--- a/p2p/discover/udp.go
+++ b/p2p/discover/udp.go
@@ -253,7 +253,8 @@ func (t *udp) loop() {
case reply := <-t.replies:
// run matching callbacks, remove if they return false.
- for i, p := range pending {
+ for i := 0; i < len(pending); i++ {
+ p := pending[i]
if reply.from == p.from && reply.ptype == p.ptype && p.callback(reply.data) {
p.errc <- nil
copy(pending[i:], pending[i+1:])