Skip to content

Commit 51bc674

Browse files
author
Roman Proskuryakov
committed
Fix data race in params.Entries chan
1 parent 06dd1a3 commit 51bc674

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

client.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type ServiceEntry struct {
2626
Addr net.IP // @Deprecated
2727

2828
hasTXT bool
29-
sent bool
3029
}
3130

3231
// complete is used to check if we have all the info we need
@@ -278,12 +277,10 @@ func (c *client) query(params *QueryParam) error {
278277

279278
// Check if this entry is complete
280279
if inp.complete() {
281-
if inp.sent {
282-
continue
283-
}
284-
inp.sent = true
280+
copyInp := *inp // copy inp because we send it into another thread
281+
// which can cause data race
285282
select {
286-
case params.Entries <- inp:
283+
case params.Entries <- &copyInp:
287284
default:
288285
}
289286
} else {

0 commit comments

Comments
 (0)