Skip to content

Commit b65486d

Browse files
close the reqCh in Close() to avoid leaking goroutines (#1687)
fixes #1681
1 parent caf54c4 commit b65486d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

api-get-object.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func (c *Client) GetObject(ctx context.Context, bucketName, objectName string, o
6262

6363
// This routine feeds partial object data as and when the caller reads.
6464
go func() {
65-
defer close(reqCh)
6665
defer close(resCh)
6766
defer func() {
6867
// Close the http response body before returning.
@@ -616,6 +615,9 @@ func (o *Object) Close() (err error) {
616615
// Close successfully.
617616
o.cancel()
618617

618+
// Close the request channel to indicate the internal go-routine to exit.
619+
close(o.reqCh)
620+
619621
// Save for future operations.
620622
errMsg := "Object is already closed. Bad file descriptor."
621623
o.prevErr = errors.New(errMsg)

0 commit comments

Comments
 (0)