fix: replace context by timeout-context from parent-context when selfSpeedTest (#17906)

This commit is contained in:
jiuker
2023-08-25 22:58:38 +08:00
committed by GitHub
parent 124e28578c
commit 6aeca54ece

View File

@@ -85,14 +85,9 @@ func selfSpeedTest(ctx context.Context, opts speedTestOpts) (SpeedTestResult, er
objCountPerThread := make([]uint64, opts.concurrency)
uploadsCtx, uploadsCancel := context.WithCancel(context.Background())
uploadsCtx, uploadsCancel := context.WithTimeout(ctx, opts.duration)
defer uploadsCancel()
go func() {
time.Sleep(opts.duration)
uploadsCancel()
}()
objNamePrefix := pathJoin(speedTest, mustGetUUID())
userMetadata := make(map[string]string)
@@ -144,12 +139,8 @@ func selfSpeedTest(ctx context.Context, opts speedTestOpts) (SpeedTestResult, er
}, nil
}
downloadsCtx, downloadsCancel := context.WithCancel(context.Background())
downloadsCtx, downloadsCancel := context.WithTimeout(ctx, opts.duration)
defer downloadsCancel()
go func() {
time.Sleep(opts.duration)
downloadsCancel()
}()
gopts := minio.GetObjectOptions{}
gopts.Set(globalObjectPerfUserMetadata, "true") // Bypass S3 API freeze