mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-03-04 02:14:40 +01:00
Update clocksmith
This commit is contained in:
parent
817f2ff560
commit
ff81344aa8
2 changed files with 6 additions and 3 deletions
2
Gopkg.lock
generated
2
Gopkg.lock
generated
|
@ -98,7 +98,7 @@
|
|||
branch = "master"
|
||||
name = "github.com/jedisct1/go-clocksmith"
|
||||
packages = ["."]
|
||||
revision = "cd58e2ceb29bcb6568281e33a1166f55d2d80188"
|
||||
revision = "37ddc416ad55843f387500810537f09f0c8d2cf0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
|
7
vendor/github.com/jedisct1/go-clocksmith/clocksmith.go
generated
vendored
7
vendor/github.com/jedisct1/go-clocksmith/clocksmith.go
generated
vendored
|
@ -14,10 +14,13 @@ func SleepWithGranularity(duration time.Duration, granularity time.Duration) {
|
|||
time.Sleep(duration)
|
||||
return
|
||||
}
|
||||
now := time.Now()
|
||||
start := time.Now().Unix()
|
||||
for {
|
||||
time.Sleep(granularity)
|
||||
if elapsed := time.Since(now); elapsed > duration-granularity {
|
||||
elapsed := time.Duration(time.Now().Unix()-start) * time.Second
|
||||
if elapsed < 0 || elapsed > duration {
|
||||
break
|
||||
} else if elapsed > duration-granularity {
|
||||
time.Sleep(duration - elapsed)
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue