aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-05 03:58:52 +0900
committerOphestra <cat@gensokyo.uk>2025-10-05 03:59:52 +0900
commit80ad2e4e2384adc84dc70ee15138c0ea4f9b6784 (patch)
treedd8096a8de40bc24816e6518c8100d7d8775044f
parent92b83bd599adf085c1a2a9c73eeb6b6dc1eee6e4 (diff)
internal/app: do not offset base value
This value is applied to the shim, it is incorrect to offset the base value as well. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--hst/config.go7
-rw-r--r--internal/app/finalise.go9
-rw-r--r--internal/app/process.go4
-rw-r--r--internal/app/shim.go5
4 files changed, 13 insertions, 12 deletions
diff --git a/hst/config.go b/hst/config.go
index 3aa71aa4..f5689a4c 100644
--- a/hst/config.go
+++ b/hst/config.go
@@ -11,6 +11,13 @@ const Tmp = "/.hakurei"
var AbsTmp = container.MustAbs(Tmp)
+const (
+ // DefaultWaitDelay is used when WaitDelay has its zero value.
+ DefaultWaitDelay = 5 * time.Second
+ // MaxWaitDelay is used if WaitDelay exceeds its value.
+ MaxWaitDelay = 30 * time.Second
+)
+
// Config is used to seal an app implementation.
type (
Config struct {
diff --git a/internal/app/finalise.go b/internal/app/finalise.go
index f5ae398c..ec2d0a9a 100644
--- a/internal/app/finalise.go
+++ b/internal/app/finalise.go
@@ -186,13 +186,12 @@ func (k *outcome) finalise(ctx context.Context, msg container.Msg, id *state.ID,
}
// enforce bounds and default early
- kp.waitDelay = shimWaitTimeout
if s.Container.WaitDelay <= 0 {
- kp.waitDelay += DefaultShimWaitDelay
- } else if s.Container.WaitDelay > MaxShimWaitDelay {
- kp.waitDelay += MaxShimWaitDelay
+ kp.waitDelay = hst.DefaultWaitDelay
+ } else if s.Container.WaitDelay > hst.MaxWaitDelay {
+ kp.waitDelay = hst.MaxWaitDelay
} else {
- kp.waitDelay += s.Container.WaitDelay
+ kp.waitDelay = s.Container.WaitDelay
}
if s.Container.MapRealUID {
diff --git a/internal/app/process.go b/internal/app/process.go
index 41fe4bd8..63f424f6 100644
--- a/internal/app/process.go
+++ b/internal/app/process.go
@@ -19,7 +19,7 @@ import (
"hakurei.app/system"
)
-// duration to wait for shim to exit, after container WaitDelay has elapsed.
+// Duration to wait for shim to exit on top of container WaitDelay.
const shimWaitTimeout = 5 * time.Second
// mainState holds persistent state bound to outcome.main.
@@ -81,7 +81,7 @@ func (ms mainState) beforeExit(isFault bool) {
waitDone := make(chan struct{})
// this ties waitDone to ctx with the additional compensated timeout duration
- go func() { <-ms.k.ctx.Done(); time.Sleep(ms.waitDelay); close(waitDone) }()
+ go func() { <-ms.k.ctx.Done(); time.Sleep(ms.waitDelay + shimWaitTimeout); close(waitDone) }()
select {
case err := <-ms.cmdWait:
diff --git a/internal/app/shim.go b/internal/app/shim.go
index 417f793c..de53b975 100644
--- a/internal/app/shim.go
+++ b/internal/app/shim.go
@@ -42,11 +42,6 @@ const (
ShimExitRequest = 254
// ShimExitOrphan is returned when the shim is orphaned before monitor delivers a signal.
ShimExitOrphan = 3
-
- // DefaultShimWaitDelay is used when WaitDelay has its zero value.
- DefaultShimWaitDelay = 5 * time.Second
- // MaxShimWaitDelay is used instead if WaitDelay exceeds its value.
- MaxShimWaitDelay = 30 * time.Second
)
// ShimMain is the main function of the shim process and runs as the unconstrained target user.