fix(lua): 修复协程上下文设置问题
使用执行上下文(ExecutionContext)替代 RequestCtx 作为 LState 上下文, 因为 RequestCtx.Done() 依赖服务器连接状态,不适合用于超时控制。 RequestCtx 通过 coro.RequestCtx 字段访问。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
26ffc6b60d
commit
b18476b443
@ -141,8 +141,10 @@ func (e *LuaEngine) NewCoroutine(req *fasthttp.RequestCtx) (*LuaCoroutine, error
|
||||
coro.CreatedAt = time.Now()
|
||||
coro.ExecutionContext, coro.executionCancel = context.WithTimeout(e.ctx, e.config.MaxExecutionTime)
|
||||
|
||||
// 设置 LState 的上下文,使 getRequestCtx 能够获取到 RequestCtx
|
||||
co.SetContext(req)
|
||||
// 设置 LState 的上下文为执行上下文(用于超时控制)
|
||||
// 注意:不直接使用 RequestCtx,因为 RequestCtx.Done() 依赖服务器连接
|
||||
// RequestCtx 通过 coro.RequestCtx 字段访问,而不是 L.Context()
|
||||
co.SetContext(coro.ExecutionContext)
|
||||
|
||||
atomic.AddUint64(&e.stats.CoroutinesCreated, 1)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user