9956: Load volume config from YAML file
[arvados.git] / sdk / go / streamer / streamer.go
index 2217dd3352eae69255b74b4faa5a74425efca0ee..0c4d20834852ab9c6b8fe7170c6a39a18f71158d 100644 (file)
@@ -37,8 +37,11 @@ package streamer
 
 import (
        "io"
+       "errors"
 )
 
+var ErrAlreadyClosed = errors.New("cannot close a stream twice")
+
 type AsyncStream struct {
        buffer            []byte
        requests          chan sliceRequest
@@ -115,6 +118,9 @@ func (this *StreamReader) WriteTo(dest io.Writer) (written int64, err error) {
 
 // Close the responses channel
 func (this *StreamReader) Close() error {
+       if this.stream == nil {
+               return ErrAlreadyClosed
+       }
        this.stream.subtract_reader <- true
        close(this.responses)
        this.stream = nil