|  | @@ -57,11 +57,13 @@ func (this *Stream) Read() (*alloc.Buffer, error) {
 | 
											
												
													
														|  |  		return nil, io.EOF
 |  |  		return nil, io.EOF
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  	this.access.RLock()
 |  |  	this.access.RLock()
 | 
											
												
													
														|  | -	defer this.access.RUnlock()
 |  | 
 | 
											
												
													
														|  |  	if this.buffer == nil {
 |  |  	if this.buffer == nil {
 | 
											
												
													
														|  | 
 |  | +		this.access.RUnlock()
 | 
											
												
													
														|  |  		return nil, io.EOF
 |  |  		return nil, io.EOF
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  | -	result, open := <-this.buffer
 |  | 
 | 
											
												
													
														|  | 
 |  | +	channel := this.buffer
 | 
											
												
													
														|  | 
 |  | +	this.access.RUnlock()
 | 
											
												
													
														|  | 
 |  | +	result, open := <-channel
 | 
											
												
													
														|  |  	if !open {
 |  |  	if !open {
 | 
											
												
													
														|  |  		return nil, io.EOF
 |  |  		return nil, io.EOF
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
										
											
												
													
														|  | @@ -72,17 +74,11 @@ func (this *Stream) Write(data *alloc.Buffer) error {
 | 
											
												
													
														|  |  	if this.closed {
 |  |  	if this.closed {
 | 
											
												
													
														|  |  		return io.EOF
 |  |  		return io.EOF
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  | -	if this.buffer == nil {
 |  | 
 | 
											
												
													
														|  | -		return io.EOF
 |  | 
 | 
											
												
													
														|  | -	}
 |  | 
 | 
											
												
													
														|  |  	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.EOF
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  | -	if this.buffer == nil {
 |  | 
 | 
											
												
													
														|  | -		return io.EOF
 |  | 
 | 
											
												
													
														|  | -	}
 |  | 
 | 
											
												
													
														|  |  	this.buffer <- data
 |  |  	this.buffer <- data
 | 
											
												
													
														|  |  	return nil
 |  |  	return nil
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
										
											
												
													
														|  | @@ -91,8 +87,8 @@ func (this *Stream) Close() {
 | 
											
												
													
														|  |  	if this.closed {
 |  |  	if this.closed {
 | 
											
												
													
														|  |  		return
 |  |  		return
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  | -	this.access.RLock()
 |  | 
 | 
											
												
													
														|  | -	defer this.access.RUnlock()
 |  | 
 | 
											
												
													
														|  | 
 |  | +	this.access.Lock()
 | 
											
												
													
														|  | 
 |  | +	defer this.access.Unlock()
 | 
											
												
													
														|  |  	if this.closed {
 |  |  	if this.closed {
 | 
											
												
													
														|  |  		return
 |  |  		return
 | 
											
												
													
														|  |  	}
 |  |  	}
 |