good morning!!!!

Skip to content
Snippets Groups Projects
Commit 7ea131d4 authored by Felix Lange's avatar Felix Lange
Browse files

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).
parent 643eda5c
No related branches found
No related tags found
No related merge requests found
......@@ -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:])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment