mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 20:16:52 +00:00
fix buffer size bug
This commit is contained in:
@@ -264,13 +264,19 @@ func GetPortByAddr(addr string) int {
|
||||
return p
|
||||
}
|
||||
|
||||
func CopyBuffer(dst io.Writer, src io.Reader,connId int32) (written int64, err error) {
|
||||
buf := pool.GetBufPoolCopy()
|
||||
defer pool.PutBufPoolCopy(buf)
|
||||
func CopyBuffer(dst io.Writer, src io.Reader, connId int32) (written int64, err error) {
|
||||
buf := pool.CopyBuff.Get()
|
||||
defer pool.CopyBuff.Put(buf)
|
||||
for {
|
||||
nr, er := src.Read(buf)
|
||||
if er != nil {
|
||||
if er != io.EOF {
|
||||
err = er
|
||||
}
|
||||
break
|
||||
}
|
||||
if nr > 0 {
|
||||
logs.Warn("write",connId, nr, string(buf[0:10]))
|
||||
logs.Warn("write", connId, nr, string(buf[0:10]))
|
||||
nw, ew := dst.Write(buf[0:nr])
|
||||
if nw > 0 {
|
||||
written += int64(nw)
|
||||
@@ -284,12 +290,6 @@ func CopyBuffer(dst io.Writer, src io.Reader,connId int32) (written int64, err e
|
||||
break
|
||||
}
|
||||
}
|
||||
if er != nil {
|
||||
if er != io.EOF {
|
||||
err = er
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return written, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user