From eae3034260b3abbb8da1deeddfef135b36eeb390 Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Thu, 19 Dec 2024 21:36:17 +0900 Subject: state: expose aids and use instance id as key Fortify state store instances was specific to aids due to outdated design decisions carried over from the ego rewrite. That no longer makes sense in the current application, so the interface now enables a single store object to manage all transient state. Signed-off-by: Ophestra Umiker --- internal/app/seal.go | 2 +- internal/app/start.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'internal/app') diff --git a/internal/app/seal.go b/internal/app/seal.go index d71553a2..3c49584a 100644 --- a/internal/app/seal.go +++ b/internal/app/seal.go @@ -218,7 +218,7 @@ func (a *app) Seal(config *fst.Config) error { // open process state store // the simple store only starts holding an open file after first action // store activity begins after Start is called and must end before Wait - seal.store = state.NewSimple(seal.RunDirPath, seal.sys.user.as) + seal.store = state.NewMulti(seal.RunDirPath) // initialise system interface with full uid seal.sys.I = system.New(seal.sys.user.uid) diff --git a/internal/app/start.go b/internal/app/start.go index 1ebc94f8..8de7821b 100644 --- a/internal/app/start.go +++ b/internal/app/start.go @@ -76,8 +76,8 @@ func (a *app) Start() error { // register process state var err0 = new(StateStoreError) - err0.Inner, err0.DoErr = a.seal.store.Do(func(b state.Backend) { - err0.InnerErr = b.Save(&sd) + err0.Inner, err0.DoErr = a.seal.store.Do(a.seal.sys.user.aid, func(c state.Cursor) { + err0.InnerErr = c.Save(&sd) }) a.seal.sys.saveState = true return err0.equiv("cannot save process state:") @@ -199,11 +199,11 @@ func (a *app) Wait() (int, error) { // update store and revert app setup transaction e := new(StateStoreError) - e.Inner, e.DoErr = a.seal.store.Do(func(b state.Backend) { + e.Inner, e.DoErr = a.seal.store.Do(a.seal.sys.user.aid, func(b state.Cursor) { e.InnerErr = func() error { // destroy defunct state entry if cmd := a.shim.Unwrap(); cmd != nil && a.seal.sys.saveState { - if err := b.Destroy(cmd.Process.Pid); err != nil { + if err := b.Destroy(*a.id); err != nil { return err } } -- cgit v1.3.1