Skip to content

Commit

Permalink
change after_work_cb to run in protected mode
Browse files Browse the repository at this point in the history
  • Loading branch information
erw7 authored and zhaozg committed Sep 19, 2021
1 parent 8291e46 commit 0e9d8d8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/work.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,14 @@ static void luv_after_work_cb(uv_work_t* req, int status) {
luv_work_t* work = (luv_work_t*)req->data;
luv_work_ctx_t* ctx = work->ctx;
lua_State* L = ctx->L;
luv_ctx_t *lctx = luv_context(L);
int i;

(void)status;

lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->after_work_cb);
i = luv_thread_arg_push(L, &work->rets, LUVF_THREAD_SIDE_MAIN);
luv_cfpcall(L, i, 0, 0);
lctx->cb_pcall(L, i, 0, 0);

//cache lua_State to reuse
lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->pool_ref);
Expand Down

0 comments on commit 0e9d8d8

Please sign in to comment.