Skip to content

Commit 36a8cd5

Browse files
committed
Fix for lua plugin coredump problem during reload
1 parent 7d37810 commit 36a8cd5

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

plugins/lua/ts_lua.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
131131
TSDebug(TS_LUA_DEBUG_TAG, "[%s] checking if script has been registered", __FUNCTION__);
132132

133133
// we only need to check the first lua VM for script registration
134+
TSMutexLock(ts_lua_main_ctx_array[0].mutexp);
134135
conf = ts_lua_script_registered(ts_lua_main_ctx_array[0].lua, script);
136+
TSMutexUnlock(ts_lua_main_ctx_array[0].mutexp);
135137
}
136138

137139
if (!conf) {
@@ -166,7 +168,9 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
166168
// register the script only if it is from a file and has no __init__ function
167169
if (fn && !conf->init_func) {
168170
// we only need to register the script for the first lua VM
171+
TSMutexLock(ts_lua_main_ctx_array[0].mutexp);
169172
ts_lua_script_register(ts_lua_main_ctx_array[0].lua, conf->script, conf);
173+
TSMutexUnlock(ts_lua_main_ctx_array[0].mutexp);
170174
}
171175
}
172176

plugins/lua/ts_lua_util.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,6 @@ ts_lua_add_module(ts_lua_instance_conf *conf, ts_lua_main_ctx *arr, int n, int a
264264
lua_newtable(L);
265265
lua_replace(L, LUA_GLOBALSINDEX); /* L[GLOBAL] = EMPTY */
266266

267-
lua_gc(L, LUA_GCCOLLECT, 0);
268-
269267
TSMutexUnlock(arr[i].mutexp);
270268
}
271269

@@ -306,8 +304,6 @@ ts_lua_del_module(ts_lua_instance_conf *conf, ts_lua_main_ctx *arr, int n)
306304
lua_newtable(L);
307305
lua_replace(L, LUA_GLOBALSINDEX); /* L[GLOBAL] = EMPTY */
308306

309-
lua_gc(L, LUA_GCCOLLECT, 0);
310-
311307
TSMutexUnlock(arr[i].mutexp);
312308
}
313309

@@ -369,8 +365,6 @@ ts_lua_reload_module(ts_lua_instance_conf *conf, ts_lua_main_ctx *arr, int n)
369365
lua_newtable(L);
370366
lua_replace(L, LUA_GLOBALSINDEX); /* L[GLOBAL] = EMPTY */
371367

372-
lua_gc(L, LUA_GCCOLLECT, 0);
373-
374368
TSMutexUnlock(arr[i].mutexp);
375369
}
376370

0 commit comments

Comments
 (0)