From 158503477700d4c5fbe3f32acb3e43c11c03fba9 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sun, 2 Jul 2023 10:46:53 -0600 Subject: [PATCH] Fixed gql threadstate --- gql.go | 6 +++--- thread.go | 12 +----------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/gql.go b/gql.go index ccb1072..4d6a177 100644 --- a/gql.go +++ b/gql.go @@ -448,8 +448,8 @@ var gql_actions ThreadActions = ThreadActions{ var gql_handlers ThreadHandlers = ThreadHandlers{ "child_added": func(ctx * GraphContext, thread Thread, signal GraphSignal) (string, error) { ctx.Log.Logf("gql", "GQL_THREAD_CHILD_ADDED: %+v", signal) - UseStates(ctx, []GraphNode{thread}, func(states NodeStateMap)(error) { - server_state := states[thread.ID()].(*GQLThreadState) + UpdateStates(ctx, []GraphNode{thread}, func(nodes NodeMap)(error) { + server_state := thread.State().(*GQLThreadState) should_run, exists := server_state.child_info[signal.Source()].(*GQLThreadInfo) if exists == false { ctx.Log.Logf("gql", "GQL_THREAD_CHILD_ADDED: tried to start %s whis is not a child") @@ -457,7 +457,7 @@ var gql_handlers ThreadHandlers = ThreadHandlers{ } if should_run.Start == true && should_run.Started == false { ChildGo(ctx, server_state, thread, signal.Source()) - should_run.Started = false + should_run.Started = true } return nil }) diff --git a/thread.go b/thread.go index 0691b8e..5759f4b 100644 --- a/thread.go +++ b/thread.go @@ -367,17 +367,7 @@ func RunThread(ctx * GraphContext, thread Thread) error { ctx.Log.Logf("thread", "THREAD_RUN: %s", thread.ID()) err := UpdateStates(ctx, []GraphNode{thread}, func(nodes NodeMap) (error) { - thread_state := thread.State().(ThreadState) - owner_id := NodeID("") - if thread_state.Owner() != nil { - owner_id = thread_state.Owner().ID() - } - - if owner_id != thread.ID() { - return LockLockables(ctx, []Lockable{thread}, thread, nil, nodes) - } else { - return nil - } + return LockLockables(ctx, []Lockable{thread}, thread, nil, nodes) }) if err != nil { return err