aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-02 11:47:51 +0900
committerOphestra <cat@gensokyo.uk>2025-11-02 11:47:51 +0900
commitf5274067f648a4fc40ba254b4ce546b1229d0bdf (patch)
tree5b4dbc2f7624e408ea18e5bb743a6c552cd952f2
parente7161f8e615dabdb14831fc0dd86cd2d33736a86 (diff)
internal/outcome/process: nil-safe unlock when failing to lock
This also prints a debug message which might be useful. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/outcome/process.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/outcome/process.go b/internal/outcome/process.go
index c27ec067..1baa588c 100644
--- a/internal/outcome/process.go
+++ b/internal/outcome/process.go
@@ -4,7 +4,6 @@ import (
"context"
"encoding/gob"
"errors"
- "iter"
"math"
"os"
"os/exec"
@@ -237,13 +236,15 @@ func (k *outcome) main(msg message.Msg) {
// this state transition to processFinal only
processState = processFinal
- unlock, err := handle.Lock()
- if err != nil {
+ unlock := func() { msg.Verbose("skipping unlock as lock was not successfully acquired") }
+ if f, err := handle.Lock(); err != nil {
perror(err, "acquire lock on store segment")
+ } else {
+ unlock = f
}
if entryHandle != nil {
- if err = entryHandle.Destroy(); err != nil {
+ if err := entryHandle.Destroy(); err != nil {
perror(err, "destroy state entry")
}
}
@@ -251,8 +252,7 @@ func (k *outcome) main(msg message.Msg) {
if isBeforeRevert {
ec := system.Process
- var entries iter.Seq[*store.EntryHandle]
- if entries, _, err = handle.Entries(); err != nil {
+ if entries, _, err := handle.Entries(); err != nil {
// it is impossible to continue from this point,
// per-process state will be reverted to limit damage
perror(err, "read store segment entries")
@@ -287,7 +287,7 @@ func (k *outcome) main(msg message.Msg) {
}
}
- if err = k.sys.Revert((*system.Criteria)(&ec)); err != nil {
+ if err := k.sys.Revert((*system.Criteria)(&ec)); err != nil {
var joinError interface {
Unwrap() []error
error