diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 60293720..9815847c 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -3426,7 +3426,7 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_ //- rjf: loop: try to grab cached call stack; request; wait // B32 can_request = !ins_atomic_u64_eval(&ctrl_state->ctrl_thread_run_state); - for(;;) + for(U64 retry_idx = 0;; retry_idx += 1) { //- rjf: [read-only] try to look for current call stack; wait if working B32 node_exists = 0; @@ -3462,6 +3462,12 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_ } } + //- rjf: out of time => exit + if(retry_idx > 0 && os_now_microseconds() >= endt_us) + { + break; + } + //- rjf: [write] node does not exist => create; request if new or stale B32 need_request = (!node_exists || node_stale); CTRL_CallStackCacheNode *node_to_request = 0; @@ -3501,12 +3507,6 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_ node_to_request->working_count -= 1; } } - - //- rjf: out of time => exit - if(os_now_microseconds() >= endt_us) - { - break; - } } return call_stack;