Updated Branches:
  refs/heads/master 16099e854 -> 114f1719a

TS-1877: fix multiple Lua remap instance loading

Fix loading multiple remap instances using the Lua plugin. Previously
we always just clobbered the first remap instance.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/114f1719
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/114f1719
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/114f1719

Branch: refs/heads/master
Commit: 114f1719ad44c84b603ee8afac2293874f719857
Parents: 16099e8
Author: James Peach <[email protected]>
Authored: Sat May 4 21:40:40 2013 -0700
Committer: James Peach <[email protected]>
Committed: Sat May 4 21:52:09 2013 -0700

----------------------------------------------------------------------
 CHANGES                           |    4 +++-
 plugins/experimental/lua/remap.cc |    2 ++
 plugins/experimental/lua/state.cc |    4 +++-
 3 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/114f1719/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 7fb4676..dad74a7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,7 +2,9 @@
   Changes with Apache Traffic Server 3.3.3
 
 
-  *) [TS-1770]  Unable to create remap rule for SSL sites when accessed as a
+  *) [TS-1877] Fix multiple Lua remap plugin instance creation.
+
+  *) [TS-1770] Unable to create remap rule for SSL sites when accessed as a
    forward proxy. Author: Mark Harrison.
 
   *) [TS-1867] The combo_handler plugin crashes when receiving non-200 
responses.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/114f1719/plugins/experimental/lua/remap.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/remap.cc 
b/plugins/experimental/lua/remap.cc
index 76590d8..ac42075 100644
--- a/plugins/experimental/lua/remap.cc
+++ b/plugins/experimental/lua/remap.cc
@@ -79,6 +79,8 @@ TSRemapNewInstance(int argc, char * argv[], void ** ih, char 
* /* errbuf ATS_UNU
   *ih = (void *)(intptr_t)instanceid;
 
   pthread_mutex_unlock(&PluginInstanceLock);
+
+  LuaLogDebug("created Lua remap instance %u", instanceid);
   return TS_SUCCESS;
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/114f1719/plugins/experimental/lua/state.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/state.cc 
b/plugins/experimental/lua/state.cc
index 596322d..01d357e 100644
--- a/plugins/experimental/lua/state.cc
+++ b/plugins/experimental/lua/state.cc
@@ -164,9 +164,10 @@ LuaPluginRegister(unsigned argc, const char ** argv)
   LuaPluginInstance * plugin;
 
   LuaLogDebug("registering plugin");
+
   // OK, first we try to find an unused instance slot.
   for (unsigned i = 0; i < LuaPluginStorage.size(); ++i) {
-    if (LuaPluginStorage[i]) {
+    if (LuaPluginStorage[i] == NULL) {
       // This slot looks ok, let's try to claim it.
       instanceid = i;
       break;
@@ -255,6 +256,7 @@ bool
 LuaThreadState::init(LuaPluginInstance * plugin)
 {
   for (LuaPluginInstance::pathlist_t::const_iterator p = 
plugin->paths.begin(); p < plugin->paths.end(); ++p) {
+    LuaLogDebug("loading Lua program from %s", p->c_str());
     if (access(p->c_str(), F_OK) != 0) {
       LuaLogError("%s: %s", p->c_str(), strerror(errno));
       continue;

Reply via email to