From 6fa84624cb81ffa1d90bda1d8b5fbad0d9ef7707 Mon Sep 17 00:00:00 2001 From: v2ray Date: Fri, 29 Jul 2016 12:13:09 +0200 Subject: [PATCH] simplify logic --- transport/ray/direct.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/transport/ray/direct.go b/transport/ray/direct.go index 93f8271b2..550aa28fd 100644 --- a/transport/ray/direct.go +++ b/transport/ray/direct.go @@ -77,15 +77,13 @@ func (this *Stream) Read() (*alloc.Buffer, error) { } func (this *Stream) Write(data *alloc.Buffer) error { - if this.closed { - return io.EOF - } - for { + for !this.closed { err := this.TryWriteOnce(data) if err != ErrIOTimeout { return err } } + return io.EOF } func (this *Stream) TryWriteOnce(data *alloc.Buffer) error {