2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 11:28:54 +00:00

Reduce lock timeout to zero

This commit is contained in:
Alexander Neumann 2016-09-01 21:13:06 +02:00
parent eb6e3ba8b3
commit 88d0f24ce7
2 changed files with 9 additions and 1 deletions

View File

@ -43,6 +43,7 @@ func parseIDsFromReader(t testing.TB, rd io.Reader) restic.IDs {
func cmdInit(t testing.TB, global GlobalOptions) {
repository.TestUseLowSecurityKDFParameters(t)
restic.TestSetLockTimeout(t, 0)
cmd := &CmdInit{global: &global}
OK(t, cmd.Execute(nil))

View File

@ -7,6 +7,7 @@ import (
"os/user"
"sync"
"syscall"
"testing"
"time"
"github.com/pkg/errors"
@ -68,7 +69,13 @@ func NewExclusiveLock(repo Repository) (*Lock, error) {
return newLock(repo, true)
}
const waitBeforeLockCheck = 200 * time.Millisecond
var waitBeforeLockCheck = 200 * time.Millisecond
// TestSetLockTimeout can be used to reduce the lock wait timeout for tests.
func TestSetLockTimeout(t testing.TB, d time.Duration) {
t.Logf("setting lock timeout to %v", d)
waitBeforeLockCheck = d
}
func newLock(repo Repository, excl bool) (*Lock, error) {
lock := &Lock{