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

commit 3192bce394b95de37f231a8c472c78cf8313e57a
Author: Kit Chan <kic...@apache.org>
AuthorDate: Wed Jul 11 00:07:20 2018 -0700

    Add flag to enable the reload feature. Disable by default
---
 plugins/lua/ts_lua.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/plugins/lua/ts_lua.c b/plugins/lua/ts_lua.c
index ea73143..0d8af2c 100644
--- a/plugins/lua/ts_lua.c
+++ b/plugins/lua/ts_lua.c
@@ -457,8 +457,10 @@ TSPluginInit(int argc, const char *argv[])
   }
 
   int states                           = TS_LUA_MAX_STATE_COUNT;
+  int reload                           = 0;
   static const struct option longopt[] = {
     {"states", required_argument, 0, 's'},
+    {"enable-reload", no_argument, 0, 'r'},
     {0, 0, 0, 0},
   };
 
@@ -471,6 +473,10 @@ TSPluginInit(int argc, const char *argv[])
       states = atoi(optarg);
       // set state
       break;
+    case 'r':
+      reload = 1;
+      TSDebug(TS_LUA_DEBUG_TAG, "[%s] enable global plugin reload [%d]", 
__FUNCTION__, reload);
+      break;
     }
 
     if (opt == -1) {
@@ -607,12 +613,15 @@ TSPluginInit(int argc, const char *argv[])
 
   ts_lua_destroy_http_ctx(http_ctx);
 
-  TSCont config_contp = TSContCreate(configHandler, NULL);
-  if (!config_contp) {
-    TSError("[ts_lua][%s] could not create configuration continuation", 
__FUNCTION__);
-    return;
-  }
-  TSContDataSet(config_contp, conf);
+  // support for reload as global plugin
+  if (reload) {
+    TSCont config_contp = TSContCreate(configHandler, NULL);
+    if (!config_contp) {
+      TSError("[ts_lua][%s] could not create configuration continuation", 
__FUNCTION__);
+      return;
+    }
+    TSContDataSet(config_contp, conf);
 
-  TSMgmtUpdateRegister(config_contp, "ts_lua");
+    TSMgmtUpdateRegister(config_contp, "ts_lua");
+  }
 }

Reply via email to