mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
Try writing again when there are some bytes left
This commit is contained in:
parent
936fd03c30
commit
cdea39ff95
@ -33,7 +33,10 @@ func ReaderToChan(stream chan<- *alloc.Buffer, reader io.Reader) error {
|
||||
// ChanToWriter dumps all content from a given chan to a writer until the chan is closed.
|
||||
func ChanToWriter(writer io.Writer, stream <-chan *alloc.Buffer) error {
|
||||
for buffer := range stream {
|
||||
_, err := writer.Write(buffer.Value)
|
||||
nBytes, err := writer.Write(buffer.Value)
|
||||
if nBytes < buffer.Len() {
|
||||
_, err = writer.Write(buffer.Value[nBytes:])
|
||||
}
|
||||
buffer.Release()
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user