Skip to content

Commit

Permalink
Merge pull request #739 from truemedian/prevent-bad-uv-run
Browse files Browse the repository at this point in the history
fix: prevent calling uv.run while already running.
  • Loading branch information
zhaozg authored Nov 21, 2024
2 parents 117adf7 + 1ddd3fb commit 3ff02c8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ static const char *const luv_runmodes[] = {
static int luv_run(lua_State* L) {
int mode = luaL_checkoption(L, 1, "default", luv_runmodes);
luv_ctx_t* ctx = luv_context(L);
if (ctx->mode != -1) {
lua_pushnil(L);
lua_pushstring(L, "loop already running");
return 2;
}
ctx->mode = mode;
int ret = uv_run(ctx->loop, (uv_run_mode)mode);
ctx->mode = -1;
Expand Down

0 comments on commit 3ff02c8

Please sign in to comment.