From ddb3854d00458022fd42a3ac3a5bc93241d7ae13 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Fri, 3 Nov 2023 22:54:28 -0600 Subject: [PATCH] Handle timeouts better in lockable --- lockable.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lockable.go b/lockable.go index aa4bafc..cefa010 100644 --- a/lockable.go +++ b/lockable.go @@ -298,12 +298,26 @@ func (ext *LockableExt) HandleTimeoutSignal(ctx *Context, node *Node, source Nod var messages Messages = nil var changes Changes = nil - //TODO: Handle timeout errors better wait_info, found := node.ProcessResponse(ext.WaitInfos, signal) if found == true { state, found := ext.Requirements[wait_info.NodeID] if found == true { ctx.Log.Logf("lockable", "%s timed out %s", wait_info.NodeID, ReqStateStrings[state]) + switch state { + case Locking: + ext.State = AbortingLock + ext.Requirements[wait_info.NodeID] = Unlocked + for id, state := range(ext.Requirements) { + if state == Locked { + ext.Requirements[id] = Unlocking + lock_signal := NewLockSignal("unlock") + ext.WaitInfos[lock_signal.Id] = node.QueueTimeout(id, lock_signal, 100*time.Millisecond) + messages = messages.Add(ctx, id, node, nil, lock_signal) + ctx.Log.Logf("lockable", "sent abort unlock to %s from %s", id, node.ID) + } + } + case Unlocking: + } } else { ctx.Log.Logf("lockable", "%s timed out", wait_info.NodeID) }