From: Sergey Matveev Date: Tue, 7 Jan 2025 10:59:37 +0000 (+0300) Subject: Randomise sleep time while waiting for the lock X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d0d5eb2605461569e985f9d502162b0f54392873;p=goredo.git Randomise sleep time while waiting for the lock --- diff --git a/run.go b/run.go index 5423b49..1b00bf0 100644 --- a/run.go +++ b/run.go @@ -27,6 +27,7 @@ import ( "io" "io/fs" "log" + mrand "math/rand" "os" "os/exec" "path" @@ -228,7 +229,7 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error { LockAgain: if err = unix.FcntlFlock(fdLock.Fd(), unix.F_SETLKW, &flock); err != nil { if errors.Is(err, unix.EDEADLK) || errors.Is(err, unix.EINTR) { - time.Sleep(10 * time.Millisecond) + time.Sleep(time.Duration(1+mrand.Intn(20)) * time.Millisecond) goto LockAgain } log.Fatalln(err, fdLock.Name())