mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix a lock problem in pkg/tcpip/sample/tun_tcp_echo
This commit is contained in:
@@ -87,8 +87,8 @@ func echo(wq *waiter.Queue, ep tcpip.Endpoint) {
|
||||
}
|
||||
|
||||
for {
|
||||
_, err := ep.Read(&w, tcpip.ReadOptions{})
|
||||
if err != nil {
|
||||
var buf bytes.Buffer
|
||||
if _, err := ep.Read(&buf, tcpip.ReadOptions{}); err != nil {
|
||||
if _, ok := err.(*tcpip.ErrWouldBlock); ok {
|
||||
<-notifyCh
|
||||
continue
|
||||
@@ -96,6 +96,10 @@ func echo(wq *waiter.Queue, ep tcpip.Endpoint) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := w.Write(buf.Bytes()); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user