diff --git a/cmd/update.go b/cmd/update.go index 5239ee4d1..3b620ea83 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -33,6 +33,7 @@ import ( "path/filepath" "runtime" "strings" + "sync/atomic" "time" xhttp "github.com/minio/minio/internal/http" @@ -515,7 +516,14 @@ func getUpdateReaderFromURL(u *url.URL, transport http.RoundTripper, mode string return resp.Body, nil } +var updateInProgress uint32 + func doUpdate(u *url.URL, lrTime time.Time, sha256Sum []byte, releaseInfo string, mode string) (err error) { + if !atomic.CompareAndSwapUint32(&updateInProgress, 0, 1) { + return errors.New("update already in progress") + } + defer atomic.StoreUint32(&updateInProgress, 0) + transport := getUpdateTransport(30 * time.Second) var reader io.ReadCloser if u.Scheme == "https" || u.Scheme == "http" {