Skip to content

Commit b1995b4

Browse files
committed
TUN-6777: Fix race condition in TestFunnelIdleTimeout
1 parent b457cca commit b1995b4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ingress/origin_icmp_proxy_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,23 @@ func testICMPRouterRejectNotEcho(t *testing.T, srcDstIP netip.Addr, msgs []icmp.
264264
}
265265

266266
type echoFlowResponder struct {
267+
lock sync.Mutex
267268
decoder *packet.ICMPDecoder
268269
respChan chan []byte
269270
}
270271

271272
func (efr *echoFlowResponder) SendPacket(dst netip.Addr, pk packet.RawPacket) error {
273+
efr.lock.Lock()
274+
defer efr.lock.Unlock()
272275
copiedPacket := make([]byte, len(pk.Data))
273276
copy(copiedPacket, pk.Data)
274277
efr.respChan <- copiedPacket
275278
return nil
276279
}
277280

278281
func (efr *echoFlowResponder) Close() error {
282+
efr.lock.Lock()
283+
defer efr.lock.Unlock()
279284
close(efr.respChan)
280285
return nil
281286
}

0 commit comments

Comments
 (0)