mirror of https://github.com/v2ray/v2ray-core
clear logic in v2io.Pipe
parent
e9ae553f78
commit
7fd94e1116
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue