fix race condition

This commit is contained in:
ginuerzh
2023-10-19 23:47:47 +08:00
parent f2fd6554ad
commit cc4310106b
29 changed files with 157 additions and 156 deletions

View File

@ -39,13 +39,13 @@ func (c *dtlsConn) Read(p []byte) (n int, err error) {
buf := bufpool.Get(bufferSize)
defer bufpool.Put(buf)
nn, err := c.Conn.Read(*buf)
nn, err := c.Conn.Read(buf)
if err != nil {
return 0, err
}
n = copy(p, (*buf)[:nn])
c.rbuf.Write((*buf)[n:nn])
n = copy(p, buf[:nn])
c.rbuf.Write(buf[n:nn])
return
}