diff --git a/pkg/util/sdnotify/clock.go b/pkg/util/sdnotify/clock.go deleted file mode 100644 index f5419d02..00000000 --- a/pkg/util/sdnotify/clock.go +++ /dev/null @@ -1,10 +0,0 @@ -package sdnotify - -import ( - // For go:linkname to work. - _ "unsafe" -) - -//go:noescape -//go:linkname nanotime runtime.nanotime -func nanotime() int64 diff --git a/pkg/util/sdnotify/clock.s b/pkg/util/sdnotify/clock.s deleted file mode 100644 index ad033ff4..00000000 --- a/pkg/util/sdnotify/clock.s +++ /dev/null @@ -1,2 +0,0 @@ -// The file is intentionally empty. -// It is a workaround for https://github.com/golang/go/issues/15006 diff --git a/pkg/util/sdnotify/sdnotify.go b/pkg/util/sdnotify/sdnotify.go index 16a3f11c..a3af50b2 100644 --- a/pkg/util/sdnotify/sdnotify.go +++ b/pkg/util/sdnotify/sdnotify.go @@ -6,6 +6,7 @@ import ( "net" "os" "strings" + "time" ) const ( @@ -16,6 +17,7 @@ const ( var ( socket *net.UnixAddr + start = time.Now() errSocketVariableIsNotPresent = errors.New("\"NOTIFY_SOCKET\" environment variable is not present") errSocketIsNotInitialized = errors.New("socket is not initialized") @@ -51,7 +53,7 @@ func FlagAndStatus(status string) error { // must be sent, containing "READY=1". // // For MONOTONIC_USEC format refer to https://www.man7.org/linux/man-pages/man3/sd_notify.3.html - status += fmt.Sprintf("\nMONOTONIC_USEC=%d", uint64(nanotime())/1e3 /* microseconds in nanoseconds */) + status += fmt.Sprintf("\nMONOTONIC_USEC=%d", uint64(time.Since(start))/1e3 /* microseconds in nanoseconds */) } status += "\nSTATUS=" + strings.TrimSuffix(status, "=1") return Send(status)