From 5da41f1fe55f6bb906f0e05d2539ccf9a21cdfa6 Mon Sep 17 00:00:00 2001 From: Ekaterina Lebedeva Date: Wed, 14 Aug 2024 13:55:34 +0300 Subject: [PATCH] Revert "[#1262] sdnotify: Get rid of go:linkname for nanotime" This reverts commit 327d364f34de730879f330ea51d8801f5c6bddc9. Reverted due to the problem with reload signal sent by systemd. `frostfs-ir` service reconfigures correctly and service's statuses are being reported to systemd. However, since we replaced `go:linkname` & `nanotime()` with `time.Since()`, systemd refuses to accept reload signal response from `frostfs-ir`. To maintain correct behaviour it was decided to revevrt systemd-related changes until a better solution is found. Signed-off-by: Ekaterina Lebedeva --- pkg/util/sdnotify/clock.go | 10 ++++++++++ pkg/util/sdnotify/clock.s | 2 ++ pkg/util/sdnotify/sdnotify.go | 4 +--- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 pkg/util/sdnotify/clock.go create mode 100644 pkg/util/sdnotify/clock.s diff --git a/pkg/util/sdnotify/clock.go b/pkg/util/sdnotify/clock.go new file mode 100644 index 000000000..f5419d027 --- /dev/null +++ b/pkg/util/sdnotify/clock.go @@ -0,0 +1,10 @@ +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 new file mode 100644 index 000000000..ad033ff4f --- /dev/null +++ b/pkg/util/sdnotify/clock.s @@ -0,0 +1,2 @@ +// 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 a3af50b22..16a3f11c1 100644 --- a/pkg/util/sdnotify/sdnotify.go +++ b/pkg/util/sdnotify/sdnotify.go @@ -6,7 +6,6 @@ import ( "net" "os" "strings" - "time" ) const ( @@ -17,7 +16,6 @@ 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") @@ -53,7 +51,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(time.Since(start))/1e3 /* microseconds in nanoseconds */) + status += fmt.Sprintf("\nMONOTONIC_USEC=%d", uint64(nanotime())/1e3 /* microseconds in nanoseconds */) } status += "\nSTATUS=" + strings.TrimSuffix(status, "=1") return Send(status) -- 2.45.2