Merge pull request #1655 from govrin/patch-1

Fix boot time not returning stat file value
pull/1667/head
shirou 11 months ago committed by GitHub
commit bf0a7e9838
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -90,6 +90,8 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
if enableCache {
atomic.StoreUint64(&cachedBootTime, t)
}
return t, nil
}
filename := HostProcWithContext(ctx, "uptime")
@ -97,6 +99,8 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
if err != nil {
return handleBootTimeFileReadErr(err)
}
currentTime := float64(time.Now().UnixNano()) / float64(time.Second)
if len(lines) != 1 {
return 0, fmt.Errorf("wrong uptime format")
}
@ -105,7 +109,6 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
if err != nil {
return 0, err
}
currentTime := float64(time.Now().UnixNano()) / float64(time.Second)
t := currentTime - b
if enableCache {

Loading…
Cancel
Save