From ffb783ab9c5df0bc735d26a8e410da074a83da1d Mon Sep 17 00:00:00 2001 From: hunshcn Date: Sat, 18 May 2024 17:49:24 +0800 Subject: [PATCH] once do --- listener/http/proxy.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/listener/http/proxy.go b/listener/http/proxy.go index 4a11dba1..c77f9230 100644 --- a/listener/http/proxy.go +++ b/listener/http/proxy.go @@ -19,13 +19,14 @@ import ( type bodyWrapper struct { io.ReadCloser + once sync.Once onHitEOF func() } func (b *bodyWrapper) Read(p []byte) (n int, err error) { n, err = b.ReadCloser.Read(p) if err == io.EOF && b.onHitEOF != nil { - b.onHitEOF() + b.once.Do(b.onHitEOF) } return n, err }