1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

clear logic in v2io.Pipe

This commit is contained in:
v2ray 2016-05-11 11:54:29 -07:00
parent e9ae553f78
commit 7fd94e1116

View File

@ -3,12 +3,16 @@ package io
func Pipe(reader Reader, writer Writer) error {
for {
buffer, err := reader.Read()
if buffer.Len() > 0 {
err = writer.Write(buffer)
} else {
buffer.Release()
if err != nil {
return nil
}
if buffer.IsEmpty() {
buffer.Release()
continue
}
err = writer.Write(buffer)
if err != nil {
return nil
}