Skip to content

Commit 9973e05

Browse files
committed
add a mutex for the buffered reader to match the concurency behavior of net.Conn.
1 parent 995704a commit 9973e05

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/api/proxy.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ import (
1010
"net"
1111
"net/http"
1212
"net/url"
13+
"sync"
1314
)
1415

1516
type connWithBufferedReader struct {
1617
net.Conn
17-
r *bufio.Reader
18+
r *bufio.Reader
19+
mu sync.Mutex
1820
}
1921

2022
func (c *connWithBufferedReader) Read(p []byte) (int, error) {
23+
c.mu.Lock()
24+
defer c.mu.Unlock()
2125
return c.r.Read(p)
2226
}
2327

0 commit comments

Comments
 (0)