You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ki...@apache.org on 2020/02/08 12:53:45 UTC

[trafficserver] branch master updated: Fix for lua plugin coredump problem during reload

This is an automated email from the ASF dual-hosted git repository.

kichan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 36a8cd5  Fix for lua plugin coredump problem during reload
36a8cd5 is described below

commit 36a8cd5d24ec7fe9a4573d0aa6afaa1e052bb664
Author: Kit Chan <ki...@apache.org>
AuthorDate: Fri Feb 7 00:44:14 2020 -0800

    Fix for lua plugin coredump problem during reload
---
 plugins/lua/ts_lua.c      | 4 ++++
 plugins/lua/ts_lua_util.c | 6 ------
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/plugins/lua/ts_lua.c b/plugins/lua/ts_lua.c
index 6349462..c6529a1 100644
--- a/plugins/lua/ts_lua.c
+++ b/plugins/lua/ts_lua.c
@@ -131,7 +131,9 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
     TSDebug(TS_LUA_DEBUG_TAG, "[%s] checking if script has been registered", __FUNCTION__);
 
     // we only need to check the first lua VM for script registration
+    TSMutexLock(ts_lua_main_ctx_array[0].mutexp);
     conf = ts_lua_script_registered(ts_lua_main_ctx_array[0].lua, script);
+    TSMutexUnlock(ts_lua_main_ctx_array[0].mutexp);
   }
 
   if (!conf) {
@@ -166,7 +168,9 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
     // register the script only if it is from a file and has no __init__ function
     if (fn && !conf->init_func) {
       // we only need to register the script for the first lua VM
+      TSMutexLock(ts_lua_main_ctx_array[0].mutexp);
       ts_lua_script_register(ts_lua_main_ctx_array[0].lua, conf->script, conf);
+      TSMutexUnlock(ts_lua_main_ctx_array[0].mutexp);
     }
   }
 
diff --git a/plugins/lua/ts_lua_util.c b/plugins/lua/ts_lua_util.c
index 22b7575..c971b0a 100644
--- a/plugins/lua/ts_lua_util.c
+++ b/plugins/lua/ts_lua_util.c
@@ -264,8 +264,6 @@ ts_lua_add_module(ts_lua_instance_conf *conf, ts_lua_main_ctx *arr, int n, int a
     lua_newtable(L);
     lua_replace(L, LUA_GLOBALSINDEX); /* L[GLOBAL] = EMPTY */
 
-    lua_gc(L, LUA_GCCOLLECT, 0);
-
     TSMutexUnlock(arr[i].mutexp);
   }
 
@@ -306,8 +304,6 @@ ts_lua_del_module(ts_lua_instance_conf *conf, ts_lua_main_ctx *arr, int n)
     lua_newtable(L);
     lua_replace(L, LUA_GLOBALSINDEX); /* L[GLOBAL] = EMPTY  */
 
-    lua_gc(L, LUA_GCCOLLECT, 0);
-
     TSMutexUnlock(arr[i].mutexp);
   }
 
@@ -369,8 +365,6 @@ ts_lua_reload_module(ts_lua_instance_conf *conf, ts_lua_main_ctx *arr, int n)
     lua_newtable(L);
     lua_replace(L, LUA_GLOBALSINDEX); /* L[GLOBAL] = EMPTY */
 
-    lua_gc(L, LUA_GCCOLLECT, 0);
-
     TSMutexUnlock(arr[i].mutexp);
   }