|  | @@ -1,7 +1,6 @@
 | 
											
												
													
														|  |  package ray
 |  |  package ray
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import (
 |  |  import (
 | 
											
												
													
														|  | -	"errors"
 |  | 
 | 
											
												
													
														|  |  	"io"
 |  |  	"io"
 | 
											
												
													
														|  |  	"sync"
 |  |  	"sync"
 | 
											
												
													
														|  |  	"time"
 |  |  	"time"
 | 
											
										
											
												
													
														|  | @@ -13,10 +12,6 @@ const (
 | 
											
												
													
														|  |  	bufferSize = 128
 |  |  	bufferSize = 128
 | 
											
												
													
														|  |  )
 |  |  )
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -var (
 |  | 
 | 
											
												
													
														|  | -	ErrIOTimeout = errors.New("IO Timeout")
 |  | 
 | 
											
												
													
														|  | -)
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  // NewRay creates a new Ray for direct traffic transport.
 |  |  // NewRay creates a new Ray for direct traffic transport.
 | 
											
												
													
														|  |  func NewRay() Ray {
 |  |  func NewRay() Ray {
 | 
											
												
													
														|  |  	return &directRay{
 |  |  	return &directRay{
 | 
											
										
											
												
													
														|  | @@ -79,24 +74,24 @@ func (this *Stream) Read() (*alloc.Buffer, error) {
 | 
											
												
													
														|  |  func (this *Stream) Write(data *alloc.Buffer) error {
 |  |  func (this *Stream) Write(data *alloc.Buffer) error {
 | 
											
												
													
														|  |  	for !this.closed {
 |  |  	for !this.closed {
 | 
											
												
													
														|  |  		err := this.TryWriteOnce(data)
 |  |  		err := this.TryWriteOnce(data)
 | 
											
												
													
														|  | -		if err != ErrIOTimeout {
 |  | 
 | 
											
												
													
														|  | 
 |  | +		if err != io.ErrNoProgress {
 | 
											
												
													
														|  |  			return err
 |  |  			return err
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  | -	return io.EOF
 |  | 
 | 
											
												
													
														|  | 
 |  | +	return io.ErrClosedPipe
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  func (this *Stream) TryWriteOnce(data *alloc.Buffer) error {
 |  |  func (this *Stream) TryWriteOnce(data *alloc.Buffer) error {
 | 
											
												
													
														|  |  	this.access.RLock()
 |  |  	this.access.RLock()
 | 
											
												
													
														|  |  	defer this.access.RUnlock()
 |  |  	defer this.access.RUnlock()
 | 
											
												
													
														|  |  	if this.closed {
 |  |  	if this.closed {
 | 
											
												
													
														|  | -		return io.EOF
 |  | 
 | 
											
												
													
														|  | 
 |  | +		return io.ErrClosedPipe
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  	select {
 |  |  	select {
 | 
											
												
													
														|  |  	case this.buffer <- data:
 |  |  	case this.buffer <- data:
 | 
											
												
													
														|  |  		return nil
 |  |  		return nil
 | 
											
												
													
														|  |  	case <-time.After(2 * time.Second):
 |  |  	case <-time.After(2 * time.Second):
 | 
											
												
													
														|  | -		return ErrIOTimeout
 |  | 
 | 
											
												
													
														|  | 
 |  | +		return io.ErrNoProgress
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 |