Skip to content

Commit f14663f

Browse files
authored
fix: putObjectMultipartStreamFromReadAt goroutine leak (#2170)
1 parent 6217ce2 commit f14663f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

api-put-object-streaming.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,13 @@ func (c *Client) putObjectMultipartStreamFromReadAt(ctx context.Context, bucketN
210210
}
211211
objPart, err := c.uploadPart(ctx, p)
212212
if err != nil {
213-
uploadedPartsCh <- uploadedPartRes{
213+
select {
214+
case <-ctx.Done():
215+
case uploadedPartsCh <- uploadedPartRes{
214216
Error: err,
217+
}:
215218
}
219+
216220
// Exit the goroutine.
217221
return
218222
}
@@ -221,10 +225,13 @@ func (c *Client) putObjectMultipartStreamFromReadAt(ctx context.Context, bucketN
221225
uploadReq.Part = objPart
222226

223227
// Send successful part info through the channel.
224-
uploadedPartsCh <- uploadedPartRes{
228+
select {
229+
case <-ctx.Done():
230+
case uploadedPartsCh <- uploadedPartRes{
225231
Size: objPart.Size,
226232
PartNum: uploadReq.PartNum,
227233
Part: uploadReq.Part,
234+
}:
228235
}
229236
}
230237
}(partSize)

0 commit comments

Comments
 (0)