You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2014/05/30 23:04:33 UTC

[01/50] [abbrv] git commit: Change the docs links to HTTPS (for SPDY :).

Repository: trafficserver
Updated Branches:
  refs/heads/5.0.x 721d5cf50 -> 59aca28fe


Change the docs links to HTTPS (for SPDY :).


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

Branch: refs/heads/5.0.x
Commit: ca09fb247288f6cb31191502b021e5fad5a78e74
Parents: 7144c2f
Author: Leif Hedstrom <zw...@apache.org>
Authored: Sat May 24 08:28:04 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Sat May 24 08:28:04 2014 -0600

----------------------------------------------------------------------
 proxy/config/records.config.default.in | 66 ++++++++++++++---------------
 1 file changed, 33 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ca09fb24/proxy/config/records.config.default.in
----------------------------------------------------------------------
diff --git a/proxy/config/records.config.default.in b/proxy/config/records.config.default.in
index c474110..9120089 100644
--- a/proxy/config/records.config.default.in
+++ b/proxy/config/records.config.default.in
@@ -1,12 +1,12 @@
 ##############################################################################
 # *NOTE*: All options covered in this file should be documented in the docs:
 #
-#    http://docs.trafficserver.apache.org/en/latest/reference/configuration/records.config.en.html
+#    https://docs.trafficserver.apache.org/en/latest/reference/configuration/records.config.en.html
 ##############################################################################
 
 ##############################################################################
 # Thread configurations. Docs:
-#    http://docs.trafficserver.apache.org/records.config#proxy-config-exec-thread-autoconfig
+#    https://docs.trafficserver.apache.org/records.config#proxy-config-exec-thread-autoconfig
 ##############################################################################
 CONFIG proxy.config.exec_thread.autoconfig INT 1
 CONFIG proxy.config.exec_thread.autoconfig.scale FLOAT 1.5
@@ -15,26 +15,26 @@ CONFIG proxy.config.ssl.number.threads INT 0
 CONFIG proxy.config.accept_threads INT 1
 CONFIG proxy.config.task_threads INT 2
 CONFIG proxy.config.cache.threads_per_disk INT 8
-    # http://docs.trafficserver.apache.org/records.config#proxy-config-exec-thread-affinity
+    # https://docs.trafficserver.apache.org/records.config#proxy-config-exec-thread-affinity
 CONFIG proxy.config.exec_thread.affinity INT 0
 
 ##############################################################################
 # Specify server addresses and ports to bind for HTTP and HTTPS. Docs:
-#    http://docs.trafficserver.apache.org/records.config#proxy-config-http-server-ports
+#    https://docs.trafficserver.apache.org/records.config#proxy-config-http-server-ports
 ##############################################################################
 CONFIG proxy.config.http.server_ports STRING 8080
 
 ##############################################################################
 # Via: headers. Docs:
-#     http://docs.trafficserver.apache.org/records.config#proxy-config-http-insert-response-via-str
+#     https://docs.trafficserver.apache.org/records.config#proxy-config-http-insert-response-via-str
 ##############################################################################
 CONFIG proxy.config.http.insert_request_via_str INT 1
 CONFIG proxy.config.http.insert_response_via_str INT 0
 
 ##############################################################################
 # Parent proxy configuration, in addition to these settings also see parent.config. Docs:
-#    http://docs.trafficserver.apache.org/records.config#parent-proxy-configuration
-#    http://docs.trafficserver.apache.org/en/latest/reference/configuration/parent.config.en.html
+#    https://docs.trafficserver.apache.org/records.config#parent-proxy-configuration
+#    https://docs.trafficserver.apache.org/en/latest/reference/configuration/parent.config.en.html
 ##############################################################################
 CONFIG proxy.config.http.parent_proxy_routing_enable INT 0
 CONFIG proxy.config.http.parent_proxy.retry_time INT 300
@@ -43,7 +43,7 @@ CONFIG proxy.config.http.forward.proxy_auth_to_parent INT 0
 
 ##############################################################################
 # HTTP connection timeouts (secs). Docs:
-#    http://docs.trafficserver.apache.org/records.config#http-connection-timeouts
+#    https://docs.trafficserver.apache.org/records.config#http-connection-timeouts
 ##############################################################################
 CONFIG proxy.config.http.keep_alive_no_activity_timeout_in INT 115
 CONFIG proxy.config.http.keep_alive_no_activity_timeout_out INT 120
@@ -56,7 +56,7 @@ CONFIG proxy.config.net.default_inactivity_timeout INT 86400
 
 ##############################################################################
 # Origin server connect attempts. Docs:
-#    http://docs.trafficserver.apache.org/records.config#origin-server-connect-attempts
+#    https://docs.trafficserver.apache.org/records.config#origin-server-connect-attempts
 ##############################################################################
 CONFIG proxy.config.http.connect_attempts_max_retries INT 6
 CONFIG proxy.config.http.connect_attempts_max_retries_dead_server INT 3
@@ -68,41 +68,41 @@ CONFIG proxy.config.http.down_server.abort_threshold INT 10
 
 ##############################################################################
 # Negative response caching, for redirects and errors. Docs:
-#    http://docs.trafficserver.apache.org/records.config#negative-response-caching
+#    https://docs.trafficserver.apache.org/records.config#negative-response-caching
 ##############################################################################
 CONFIG proxy.config.http.negative_caching_enabled INT 0
 CONFIG proxy.config.http.negative_caching_lifetime INT 1800
 
 ##############################################################################
 # Proxy users variables. Docs:
-#    http://docs.trafficserver.apache.org/records.config#proxy-user-variables
+#    https://docs.trafficserver.apache.org/records.config#proxy-user-variables
 ##############################################################################
 CONFIG proxy.config.http.anonymize_insert_client_ip INT 1
 CONFIG proxy.config.http.insert_squid_x_forwarded_for INT 1
 
 ##############################################################################
 # Security. Docs:
-#    http://docs.trafficserver.apache.org/records.config#security
+#    https://docs.trafficserver.apache.org/records.config#security
 ##############################################################################
 CONFIG proxy.config.http.push_method_enabled INT 0
 
 ##############################################################################
 # Cache control. Docs:
-#    http://docs.trafficserver.apache.org/records.config#cache-control
-#    http://docs.trafficserver.apache.org/en/latest/reference/configuration/cache.config.en.html
+#    https://docs.trafficserver.apache.org/records.config#cache-control
+#    https://docs.trafficserver.apache.org/en/latest/reference/configuration/cache.config.en.html
 ##############################################################################
 CONFIG proxy.config.http.cache.ignore_client_cc_max_age INT 1
 CONFIG proxy.config.http.normalize_ae_gzip INT 1
 CONFIG proxy.config.http.cache.cache_responses_to_cookies INT 1
 CONFIG proxy.config.http.cache.cache_urls_that_look_dynamic INT 1
-    # http://docs.trafficserver.apache.org/records.config#proxy-config-http-cache-when-to-revalidate
+    # https://docs.trafficserver.apache.org/records.config#proxy-config-http-cache-when-to-revalidate
 CONFIG proxy.config.http.cache.when_to_revalidate INT 0
-    # http://docs.trafficserver.apache.org/records.config#proxy-config-http-cache-required-headers
+    # https://docs.trafficserver.apache.org/records.config#proxy-config-http-cache-required-headers
 CONFIG proxy.config.http.cache.required_headers INT 2
 
 ##############################################################################
 # Heuristic cache expiration. Docs:
-#    http://docs.trafficserver.apache.org/records.config#heuristic-expiration
+#    https://docs.trafficserver.apache.org/records.config#heuristic-expiration
 ##############################################################################
 CONFIG proxy.config.http.cache.heuristic_min_lifetime INT 3600
 CONFIG proxy.config.http.cache.heuristic_max_lifetime INT 86400
@@ -110,27 +110,27 @@ CONFIG proxy.config.http.cache.heuristic_lm_factor FLOAT 0.10
 
 ##############################################################################
 # Network. Docs:
-#    http://docs.trafficserver.apache.org/records.config#network
+#    https://docs.trafficserver.apache.org/records.config#network
 ##############################################################################
 CONFIG proxy.config.net.connections_throttle INT 30000
 
 ##############################################################################
 # RAM and disk cache configurations. Docs:
-#    http://docs.trafficserver.apache.org/records.config#ram-cache
-#    http://docs.trafficserver.apache.org/en/latest/reference/configuration/storage.config.en.html
+#    https://docs.trafficserver.apache.org/records.config#ram-cache
+#    https://docs.trafficserver.apache.org/en/latest/reference/configuration/storage.config.en.html
 ##############################################################################
 CONFIG proxy.config.cache.ram_cache.size INT -1
 CONFIG proxy.config.cache.ram_cache_cutoff INT 4194304
-    # http://docs.trafficserver.apache.org/records.config#proxy-config-cache-limits-http-max-alts
+    # https://docs.trafficserver.apache.org/records.config#proxy-config-cache-limits-http-max-alts
 CONFIG proxy.config.cache.limits.http.max_alts INT 5
-    # http://docs.trafficserver.apache.org/records.config#proxy-config-cache-max-doc-size
+    # https://docs.trafficserver.apache.org/records.config#proxy-config-cache-max-doc-size
 CONFIG proxy.config.cache.max_doc_size INT 0
 CONFIG proxy.config.cache.min_average_object_size INT 8000
 
 ##############################################################################
 # Logging Config. Docs:
-#    http://docs.trafficserver.apache.org/records.config#logging-configuration
-#    http://docs.trafficserver.apache.org/en/latest/reference/configuration/logs_xml.config.en.html
+#    https://docs.trafficserver.apache.org/records.config#logging-configuration
+#    https://docs.trafficserver.apache.org/en/latest/reference/configuration/logs_xml.config.en.html
 ##############################################################################
 CONFIG proxy.config.log.logging_enabled INT 3
 CONFIG proxy.config.log.max_space_mb_for_logs INT 25000
@@ -144,31 +144,31 @@ CONFIG proxy.config.log.auto_delete_rolled_files INT 1
 
 ##############################################################################
 # These settings control remapping, and if the proxy allows (open) forward proxy or not. Docs:
-#    http://docs.trafficserver.apache.org/records.config#url-remap-rules
-#    http://docs.trafficserver.apache.org/en/latest/reference/configuration/remap.config.en.html
+#    https://docs.trafficserver.apache.org/records.config#url-remap-rules
+#    https://docs.trafficserver.apache.org/en/latest/reference/configuration/remap.config.en.html
 ##############################################################################
 CONFIG proxy.config.url_remap.remap_required INT 1
-    # http://docs.trafficserver.apache.org/records.config#proxy-config-url-remap-pristine-host-hdr
+    # https://docs.trafficserver.apache.org/records.config#proxy-config-url-remap-pristine-host-hdr
 CONFIG proxy.config.url_remap.pristine_host_hdr INT 0
 
 ##############################################################################
 # SSL Termination. Docs:
-#    http://docs.trafficserver.apache.org/records.config#client-related-configuration
-#    http://docs.trafficserver.apache.org/en/latest/reference/configuration/ssl_multicert.config.en.html
+#    https://docs.trafficserver.apache.org/records.config#client-related-configuration
+#    https://docs.trafficserver.apache.org/en/latest/reference/configuration/ssl_multicert.config.en.html
 ##############################################################################
 CONFIG proxy.config.ssl.client.verify.server INT 0
 CONFIG proxy.config.ssl.client.CA.cert.filename STRING NULL
 
 ##############################################################################
 # ICP Configuration. Docs:
-#    http://docs.trafficserver.apache.org/records.config#icp-configuration
-#    http://docs.trafficserver.apache.org/en/latest/reference/configuration/icp.config.en.html
+#    https://docs.trafficserver.apache.org/records.config#icp-configuration
+#    https://docs.trafficserver.apache.org/en/latest/reference/configuration/icp.config.en.html
 ##############################################################################
 CONFIG proxy.config.icp.enabled INT 0
 
 ##############################################################################
 # Debugging. Docs:
-#    http://docs.trafficserver.apache.org/records.config#diagnostic-logging-configuration
+#    https://docs.trafficserver.apache.org/records.config#diagnostic-logging-configuration
 ##############################################################################
 CONFIG proxy.config.diags.debug.enabled INT 0
 CONFIG proxy.config.diags.debug.tags STRING http.*|dns.*
@@ -186,7 +186,7 @@ CONFIG proxy.config.output.logfile STRING traffic.out
 
 ##############################################################################
 # Cluster Subsystem. Docs:
-#    http://docs.trafficserver.apache.org/records.config#cluster
+#    https://docs.trafficserver.apache.org/records.config#cluster
 ##############################################################################
 LOCAL proxy.local.cluster.type INT 3
 CONFIG proxy.config.cluster.ethernet_interface STRING @default_loopback_iface@


[48/50] [abbrv] git commit: TS-2580: SSL Connection reset by peer errors in 4.2.0-rc0

Posted by bc...@apache.org.
TS-2580: SSL Connection reset by peer errors in 4.2.0-rc0


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

Branch: refs/heads/5.0.x
Commit: 9297edbbd947e75c05ee563db81e5711db738769
Parents: 879bedc
Author: Bryan Call <bc...@apache.org>
Authored: Fri May 30 12:45:23 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Fri May 30 12:45:23 2014 -0700

----------------------------------------------------------------------
 CHANGES                         | 2 ++
 iocore/net/SSLNetVConnection.cc | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9297edbb/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3b25d18..948df744c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2580] SSL Connection reset by peer errors in 4.2.0-rc0
+
   *) [TS-2783] Update documentation defaults, and fix RecordsConfig.cc.
 
   *) [TS-1981] Url remap method filtering is broken with invalid method.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9297edbb/iocore/net/SSLNetVConnection.cc
----------------------------------------------------------------------
diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index bef9c4b..61aaa3e 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -155,7 +155,7 @@ ssl_read_from_net(SSLNetVConnection * sslvc, EThread * lthread, int64_t &ret)
           // not EOF
           event = SSL_READ_ERROR;
           ret = errno;
-          SSLErrorVC(sslvc, "[SSL_NetVConnection::ssl_read_from_net] SSL_ERROR_SYSCALL, underlying IO error: %s", strerror(errno));
+          Debug(ssl, "[SSL_NetVConnection::ssl_read_from_net] SSL_ERROR_SYSCALL, underlying IO error: %s", strerror(errno));
         } else {
           // then EOF observed, treat it as EOS
           event = SSL_READ_EOS;


[05/50] [abbrv] git commit: TS-2555: update README.md and remove old lua plugin

Posted by bc...@apache.org.
TS-2555: update README.md and remove old lua plugin


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

Branch: refs/heads/5.0.x
Commit: 9a3e5de5f2009921436069b3393a133e0c23d5d1
Parents: 14c484b
Author: Kit Chan <ki...@apache.org>
Authored: Sun May 25 00:54:40 2014 -0700
Committer: Kit Chan <ki...@apache.org>
Committed: Sun May 25 00:54:40 2014 -0700

----------------------------------------------------------------------
 plugins/experimental/lua/Makefile.am            |  35 -
 plugins/experimental/lua/TODO                   |  51 --
 .../experimental/lua/examples/cachestatus.lua   |  48 --
 plugins/experimental/lua/examples/hooks.lua     |  90 ---
 plugins/experimental/lua/examples/remap.lua     |  73 ---
 plugins/experimental/lua/examples/test.lua      |  30 -
 plugins/experimental/lua/hook.cc                | 503 --------------
 plugins/experimental/lua/hook.h                 |  39 --
 plugins/experimental/lua/lapi.cc                | 651 -------------------
 plugins/experimental/lua/lapi.h                 |  63 --
 plugins/experimental/lua/lconfig.cc             | 151 -----
 plugins/experimental/lua/lutil.cc               | 139 ----
 plugins/experimental/lua/lutil.h                |  85 ---
 plugins/experimental/lua/plugin.cc              |  45 --
 plugins/experimental/lua/remap.cc               | 104 ---
 plugins/experimental/lua/state.cc               | 348 ----------
 plugins/experimental/lua/state.h                | 157 -----
 plugins/experimental/ts_lua/README.md           | 541 +--------------
 18 files changed, 2 insertions(+), 3151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/Makefile.am b/plugins/experimental/lua/Makefile.am
deleted file mode 100644
index 0a41390..0000000
--- a/plugins/experimental/lua/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-#  Licensed to the Apache Software Foundation (ASF) under one
-#  or more contributor license agreements.  See the NOTICE file
-#  distributed with this work for additional information
-#  regarding copyright ownership.  The ASF licenses this file
-#  to you under the Apache License, Version 2.0 (the
-#  "License"); you may not use this file except in compliance
-#  with the License.  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
-
-include $(top_srcdir)/build/plugins.mk
-
-if BUILD_LUA_SUPPORT
-
-# We have to use the per-target CPPFLAGS here to make sure that the Lua include
-# path comes first. If we have LuaJIT (/opt/local/include/luajit-2.0) and Lua
-# (/opt/local/include) headers, then we need to make sure that we don't end up
-# building with the Lua headers but linking LuaJIT.
-lua_la_CPPFLAGS = \
-  $(LUA_CFLAGS) \
-  $(AM_CPPFLAGS)
-
-pkglib_LTLIBRARIES = lua.la
-
-lua_la_LIBADD = $(LUA_LIBS)
-lua_la_SOURCES = remap.cc plugin.cc lapi.cc lutil.cc lconfig.cc hook.cc state.cc
-lua_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)
-
-endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/TODO
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/TODO b/plugins/experimental/lua/TODO
deleted file mode 100644
index e926771..0000000
--- a/plugins/experimental/lua/TODO
+++ /dev/null
@@ -1,51 +0,0 @@
-- Hook registration consistency
-
-  Per-object hooks register a hook table, but global hooks register
-  an individual function. We should make the register function
-  accept both calling conventions.
-
-- Transaction object parity
-
-  The transaction object that remap callbacks get is richer than
-  the one that hook callbacks get. They should both use the same
-  object and get the same API.
-
-- Richer TS API support
-
-  Flesh out API mappings. Humbedooh has a script that can generate
-  a lot of Lua binding. We should use that to make as much API as
-  we reasonably can.
-
-- HTTP client support
-
-  Wrap TSFetchURL (or its successor), such that Lua can fetch single
-  resources or multiple resources in parallel. For single resources,
-  use yield to make the call look synchronous; for multiple resources
-  consider a callback table.
-
-- HTTP server support
-
-  Reference stats_over_http to enabLe us server responses directly
-  from a Lua plugin. This would be useful for serving status, log
-  builder pages, admin tools, etc.
-
-- HTTP Alternate selection support
-
-  Enable support for HTTP_SELECT_ALT_HOOK. This probably just
-  requires plumbing an object for the TSHttpAltInfo edata argument.
-
-- Documentation
-
-  Document the Lua API in LuaDoc.
-
-- More examples
-
-  Add more Lua plugin examples. Take some of the header manipulation
-  C plugins and rewrite them in Lua. More examples will help us
-  figure out which Lua API is missing.
-
-- Transformation plugins
-
-  We don't support transforms yet. This probably warrants some
-  special purpose API rather than just using the existing hook
-  registration API.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/examples/cachestatus.lua
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/examples/cachestatus.lua b/plugins/experimental/lua/examples/cachestatus.lua
deleted file mode 100644
index 36d60df..0000000
--- a/plugins/experimental/lua/examples/cachestatus.lua
+++ /dev/null
@@ -1,48 +0,0 @@
---  Licensed to the Apache Software Foundation (ASF) under one
---  or more contributor license agreements.  See the NOTICE file
---  distributed with this work for additional information
---  regarding copyright ownership.  The ASF licenses this file
---  to you under the Apache License, Version 2.0 (the
---  "License"); you may not use this file except in compliance
---  with the License.  You may obtain a copy of the License at
---
---  http://www.apache.org/licenses/LICENSE-2.0
---
---  Unless required by applicable law or agreed to in writing, software
---  distributed under the License is distributed on an "AS IS" BASIS,
---  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
---  See the License for the specific language governing permissions and
---  limitations under the License.
-
--- Lua example to log the HTTP transaction cache lookup status.
-
-require 'string'
-require 'debug'
-
-ts = require 'ts'
-ts.hook = require 'ts.hook'
-
-ts.debug('cachestatus', string.format('loaded %s', debug.getinfo(1).source))
-
-do
-
-local strings = { }
-strings[ts.CACHE_LOOKUP_MISS]       = "TS_CACHE_LOOKUP_MISS"
-strings[ts.CACHE_LOOKUP_HIT_STALE]  = "TS_CACHE_LOOKUP_HIT_STALE"
-strings[ts.CACHE_LOOKUP_HIT_FRESH]  = "TS_CACHE_LOOKUP_HIT_FRESH"
-strings[ts.CACHE_LOOKUP_SKIPPED]    = "TS_CACHE_LOOKUP_SKIPPED"
-
-function cachestatus(status)
-    return strings[status]
-end
-end
-
-ts.hook.register(ts.hook.HTTP_CACHE_LOOKUP_COMPLETE_HOOK,
-    function(event, txn)
-        ts.debug('cachestatus',
-            string.format('cache lookup status is %s', cachestatus(txn:cachestatus())))
-        txn:continue()
-    end
-)
-
--- vim: set sw=4 ts=4 et :

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/examples/hooks.lua
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/examples/hooks.lua b/plugins/experimental/lua/examples/hooks.lua
deleted file mode 100644
index 931cd22..0000000
--- a/plugins/experimental/lua/examples/hooks.lua
+++ /dev/null
@@ -1,90 +0,0 @@
---  Licensed to the Apache Software Foundation (ASF) under one
---  or more contributor license agreements.  See the NOTICE file
---  distributed with this work for additional information
---  regarding copyright ownership.  The ASF licenses this file
---  to you under the Apache License, Version 2.0 (the
---  "License"); you may not use this file except in compliance
---  with the License.  You may obtain a copy of the License at
---
---  http://www.apache.org/licenses/LICENSE-2.0
---
---  Unless required by applicable law or agreed to in writing, software
---  distributed under the License is distributed on an "AS IS" BASIS,
---  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
---  See the License for the specific language governing permissions and
---  limitations under the License.
-
--- Example Lua hooks plugin to demonstrate the use of global, per-session and per-transaction hooks.
-
-require 'string'
-require 'debug'
-
-ts = require 'ts'
-ts.hook = require 'ts.hook'
-
-function OnSession(event, ssn)
-    -- NOTE: the 'ssn' argument is either a session or a transaction object, depending on the event.
-    ts.debug('hooks', string.format('handling session event %d', event))
-    ssn:continue()
-end
-
--- Callback function for per-transaction hooks.
-function OnTransaction(event, txn)
-    ts.debug('hooks', string.format('handling transaction event %d', event))
-   txn:continue()
-end
-
-events = {
-    ssn = {},
-    txn = {}
-}
-
-events.txn[ts.hook.HTTP_OS_DNS_HOOK]                = OnTransaction
-events.txn[ts.hook.HTTP_READ_CACHE_HDR_HOOK]        = OnTransaction
-events.txn[ts.hook.HTTP_READ_REQUEST_HDR_HOOK]      = OnTransaction
-events.txn[ts.hook.HTTP_SEND_REQUEST_HDR_HOOK]      = OnTransaction
-events.txn[ts.hook.HTTP_READ_RESPONSE_HDR_HOOK]     = OnTransaction
-events.txn[ts.hook.HTTP_SEND_RESPONSE_HDR_HOOK]     = OnTransaction
-events.txn[ts.hook.HTTP_TXN_START_HOOK]             = OnTransaction
-events.txn[ts.hook.HTTP_TXN_CLOSE_HOOK]             = OnTransaction
-events.txn[ts.hook.HTTP_SSN_START_HOOK]             = OnTransaction
-events.txn[ts.hook.HTTP_SSN_CLOSE_HOOK]             = OnTransaction
-events.txn[ts.hook.HTTP_CACHE_LOOKUP_COMPLETE_HOOK] = OnTransaction
-events.txn[ts.hook.HTTP_PRE_REMAP_HOOK]             = OnTransaction
-events.txn[ts.hook.HTTP_POST_REMAP_HOOK]            = OnTransaction
-
-events.ssn[ts.hook.HTTP_READ_REQUEST_HDR_HOOK]      = OnSession
-events.ssn[ts.hook.HTTP_OS_DNS_HOOK]                = OnSession
-events.ssn[ts.hook.HTTP_SEND_REQUEST_HDR_HOOK]      = OnSession
-events.ssn[ts.hook.HTTP_READ_CACHE_HDR_HOOK]        = OnSession
-events.ssn[ts.hook.HTTP_READ_RESPONSE_HDR_HOOK]     = OnSession
-events.ssn[ts.hook.HTTP_SEND_RESPONSE_HDR_HOOK]     = OnSession
-events.ssn[ts.hook.HTTP_TXN_START_HOOK]             = OnSession
-events.ssn[ts.hook.HTTP_TXN_CLOSE_HOOK]             = OnSession
-events.ssn[ts.hook.HTTP_SSN_START_HOOK]             = OnSession
-events.ssn[ts.hook.HTTP_SSN_CLOSE_HOOK]             = OnSession
-events.ssn[ts.hook.HTTP_CACHE_LOOKUP_COMPLETE_HOOK] = OnSession
-events.ssn[ts.hook.HTTP_PRE_REMAP_HOOK]             = OnSession
-events.ssn[ts.hook.HTTP_POST_REMAP_HOOK]            = OnSession
-
-ts.debug('hooks', string.format('loaded %s', debug.getinfo(1).source))
-
--- Hook the global session start so we can register the per-session events.
-ts.hook.register(ts.hook.HTTP_SSN_START_HOOK,
-    function(event, ssn)
-        ts.debug('hooks', string.format('callback for HTTP_SSN_START event=%d', event))
-        ssn:register(events.ssn)
-        ssn:continue()
-    end
-)
-
--- Hook the global transaction start so we can register the per-transaction events.
-ts.hook.register(ts.hook.HTTP_TXN_START_HOOK,
-    function(event, txn)
-        ts.debug('hooks', string.format('callback for HTTP_TXN_START event=%d', event))
-        txn:register(events.txn)
-        txn:continue()
-    end
-)
-
--- vim: set sw=4 ts=4 et :

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/examples/remap.lua
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/examples/remap.lua b/plugins/experimental/lua/examples/remap.lua
deleted file mode 100644
index e360c76..0000000
--- a/plugins/experimental/lua/examples/remap.lua
+++ /dev/null
@@ -1,73 +0,0 @@
---  Licensed to the Apache Software Foundation (ASF) under one
---  or more contributor license agreements.  See the NOTICE file
---  distributed with this work for additional information
---  regarding copyright ownership.  The ASF licenses this file
---  to you under the Apache License, Version 2.0 (the
---  "License"); you may not use this file except in compliance
---  with the License.  You may obtain a copy of the License at
---
---  http://www.apache.org/licenses/LICENSE-2.0
---
---  Unless required by applicable law or agreed to in writing, software
---  distributed under the License is distributed on an "AS IS" BASIS,
---  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
---  See the License for the specific language governing permissions and
---  limitations under the License.
-
--- Example Lua remap plugin. Load this with the following remap.comfig line:
---
--- map http://test.foo.com http://foo.foo.com @plugin=lua.so @pparam=/path/to/example.lua
-
--- Pull in the Traffic Server API.
-local TS = require 'ts'
-
-require 'string'
-require 'math'
-
--- Compulsory remap hook. We are given a request object that we can modify if necessary.
-function remap(request)
-  -- Get a copy of the current URL.
-  url = request:url()
-
-  TS.debug('example', string.format('remapping %s://%s', url.scheme, url.host))
-
-  -- Do some header manipulation, just to mess with the origin.
-  request.headers['added-bool'] = true
-  request.headers['added-int'] = 1
-  request.headers['added-string'] = 'ttt'
-  request.headers['added-table'] = {}
-  request.headers['deleted'] = nil
-
-  -- We can also print to stdout using Lua standard library.
-  print(string.format('request URL is %s://%s:%d/%s',
-        url.scheme, url.host, url.port, url.path and url.path or ''))
-
-  -- Modify components of the URL ... everybody loves slashdot.
-  url.host = 'www.slashdot.org'
-  url.port = 80
-  url.method = 'POST'
-
-  -- Plugin chain evaluation rules:
-  --    redirect: plugin chain terminates
-  --    reject: plugin chain terminates
-  --    rewrite: plugin chain continues
-
-  chance = math.random(4)
-  if chance == 1 then
-    -- Send a 301 redirect to the new URL.
-    request:redirect(url)
-  elseif chance == 2 then
-    -- Reject the request with an optional message.
-    request:reject(400, "Denied")
-  elseif chance == 3 then
-    -- Reject the request with a response body. We sniff the body to set the content type.
-    request:reject(500, [[
-      <HEAD></TITLE></HEAD>
-      <BODY>Internal error, sorry</BODY>
-      ]])
-  else
-    -- Rewrite the request URL. The remap plugin chain continues and other plugins
-    request:rewrite(url)
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/examples/test.lua
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/examples/test.lua b/plugins/experimental/lua/examples/test.lua
deleted file mode 100644
index 3f9f450..0000000
--- a/plugins/experimental/lua/examples/test.lua
+++ /dev/null
@@ -1,30 +0,0 @@
---  Licensed to the Apache Software Foundation (ASF) under one
---  or more contributor license agreements.  See the NOTICE file
---  distributed with this work for additional information
---  regarding copyright ownership.  The ASF licenses this file
---  to you under the Apache License, Version 2.0 (the
---  "License"); you may not use this file except in compliance
---  with the License.  You may obtain a copy of the License at
---
---  http://www.apache.org/licenses/LICENSE-2.0
---
---  Unless required by applicable law or agreed to in writing, software
---  distributed under the License is distributed on an "AS IS" BASIS,
---  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
---  See the License for the specific language governing permissions and
---  limitations under the License.
-
-require 'string'
-require 'debug'
-ts = require 'ts'
-ts.hook = require 'ts.hook'
-
-ts.debug('lua', string.format('loaded %s', debug.getinfo(1).source))
-
-ts.hook.register(ts.hook.OS_DNS_HOOK,
-    function(event, txn)
-        ts.debug('lua', string.format('callback for event=%d', event))
-        txn:continue()
-    end
-)
--- vim: set sw=4 ts=4 et :

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/hook.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/hook.cc b/plugins/experimental/lua/hook.cc
deleted file mode 100644
index 3f3f7cb..0000000
--- a/plugins/experimental/lua/hook.cc
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#include <ts/ts.h>
-#include <ts/remap.h>
-#include <string.h>
-#include "lapi.h"
-#include "lutil.h"
-#include "hook.h"
-#include "state.h"
-
-#include <memory> // placement new
-
-#include "ink_config.h"
-#include "ink_defs.h"
-
-const char *
-HttpHookName(TSHttpHookID hookid)
-{
-  static const char * names[TS_HTTP_LAST_HOOK] = {
-    "HTTP_READ_REQUEST_HDR_HOOK",
-    "HTTP_OS_DNS_HOOK",
-    "HTTP_SEND_REQUEST_HDR_HOOK",
-    "HTTP_READ_CACHE_HDR_HOOK",
-    "HTTP_READ_RESPONSE_HDR_HOOK",
-    "HTTP_SEND_RESPONSE_HDR_HOOK",
-    NULL, // XXX TS_HTTP_REQUEST_TRANSFORM_HOOK
-    NULL, // XXX TS_HTTP_RESPONSE_TRANSFORM_HOOK
-    NULL, // XXX HTTP_SELECT_ALT_HOOK
-    "HTTP_TXN_START_HOOK",
-    "HTTP_TXN_CLOSE_HOOK",
-    "HTTP_SSN_START_HOOK",
-    "HTTP_SSN_CLOSE_HOOK",
-    "HTTP_CACHE_LOOKUP_COMPLETE_HOOK",
-    "HTTP_PRE_REMAP_HOOK",
-    "HTTP_POST_REMAP_HOOK",
-  };
-
-  if (hookid >= 0 && hookid < static_cast<TSHttpHookID>(countof(names))) {
-    return names[hookid];
-  }
-
-  return NULL;
-}
-
-static bool
-HookIsValid(int hookid)
-{
-  if (hookid == TS_HTTP_REQUEST_TRANSFORM_HOOK || hookid == TS_HTTP_RESPONSE_TRANSFORM_HOOK) {
-    return false;
-  }
-
-  return hookid >= 0 && hookid < TS_HTTP_LAST_HOOK;
-}
-
-static void
-LuaPushEventData(lua_State * lua, TSEvent event, void * edata)
-{
-  switch (event) {
-  case TS_EVENT_HTTP_READ_REQUEST_HDR:
-  case TS_EVENT_HTTP_OS_DNS:
-  case TS_EVENT_HTTP_SEND_REQUEST_HDR:
-  case TS_EVENT_HTTP_READ_CACHE_HDR:
-  case TS_EVENT_HTTP_READ_RESPONSE_HDR:
-  case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
-  case TS_EVENT_HTTP_SELECT_ALT:
-  case TS_EVENT_HTTP_TXN_START:
-  case TS_EVENT_HTTP_TXN_CLOSE:
-  case TS_EVENT_CACHE_LOOKUP_COMPLETE:
-  case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
-  case TS_EVENT_HTTP_PRE_REMAP:
-  case TS_EVENT_HTTP_POST_REMAP:
-    LuaPushHttpTransaction(lua, (TSHttpTxn)edata);
-    break;
-  case TS_EVENT_HTTP_SSN_START:
-  case TS_EVENT_HTTP_SSN_CLOSE:
-    LuaPushHttpSession(lua, (TSHttpSsn)edata);
-    break;
-  default:
-    lua_pushnil(lua);
-  }
-}
-
-
-#if defined(INLINE_LUA_HOOK_REFERENCE)
-typedef char __size_check[sizeof(this_type) == sizeof(void *) ? 0 : -1];
-#endif
-
-// For 64-bit pointers, we can inline the LuaHookReference, otherwise we need an extra malloc.
-//
-#if SIZEOF_VOID_POINTER >= 8
-#define INLINE_LUA_HOOK_REFERENCE 1
-#else
-#undef INLINE_LUA_HOOK_REFERENCE
-#endif
-
-template <typename t1, typename t2>
-struct inline_tuple
-{
-  typedef t1 first_type;
-  typedef t2 second_type;
-  typedef inline_tuple<first_type, second_type> this_type;
-
-  union {
-    struct {
-      first_type first;
-      second_type second;
-    } s;
-    void * ptr;
-  } storage;
-
-  first_type& first() { return storage.s.first; }
-  second_type& second() { return storage.s.second; }
-
-  static void * allocate(const first_type first, const second_type second) {
-#if defined(INLINE_LUA_HOOK_REFERENCE)
-    this_type obj;
-    obj.first() = first;
-    obj.second() = second;
-    return obj.storage.ptr;
-#else
-    this_type * ptr = (this_type *)TSmalloc(sizeof(this_type));
-    ptr->first() = first;
-    ptr->second() = second;
-    return ptr;
-#endif
-  }
-
-  static void free(void *ptr ATS_UNUSED) {
-#if defined(INLINE_LUA_HOOK_REFERENCE)
-    // Nothing to do, because we never allocated.
-#else
-    TSfree(ptr);
-#endif
-  }
-
-  static this_type get(void * ptr) {
-#if defined(INLINE_LUA_HOOK_REFERENCE)
-    this_type obj;
-    obj.storage.ptr = ptr;
-    return obj;
-#else
-    return ptr ? *(this_type *)ptr : this_type();
-#endif
-  }
-
-};
-
-// The per-ssn and per-txn argument mechanism stores a pointer, so it's NULL when not set. Unfortunately, 0 is a
-// legitimate Lua reference value (all values except LUA_NOREF are legitimate), so we can't distinguish NULL from a 0
-// reference. In 64-bit mode we have some extra bits and we can maintain the state, but in 32-bit mode, we need to
-// allocate the LuaHookReference to have enough space to store the state.
-typedef inline_tuple<int, bool> LuaHookReference;
-
-static void *
-LuaHttpObjectArgGet(TSHttpSsn ssn)
-{
-  return TSHttpSsnArgGet(ssn, LuaHttpArgIndex);
-}
-
-static void *
-LuaHttpObjectArgGet(TSHttpTxn txn)
-{
-  return TSHttpTxnArgGet(txn, LuaHttpArgIndex);
-}
-
-static void
-LuaHttpObjectArgSet(TSHttpSsn ssn, void * ptr)
-{
-  return TSHttpSsnArgSet(ssn, LuaHttpArgIndex, ptr);
-}
-
-static void
-LuaHttpObjectArgSet(TSHttpTxn txn, void * ptr)
-{
-  return TSHttpTxnArgSet(txn, LuaHttpArgIndex, ptr);
-}
-
-template<typename T> static int
-LuaGetArgReference(T ptr)
-{
-  LuaHookReference href(LuaHookReference::get(LuaHttpObjectArgGet(ptr)));
-  // Only return the Lua ref if it was previously set.
-  return href.second() ? href.first() : LUA_NOREF;
-}
-
-template <typename T> void
-LuaSetArgReference(T ptr, int ref)
-{
-  LuaHookReference::free(LuaHttpObjectArgGet(ptr));
-  LuaHttpObjectArgSet(ptr, LuaHookReference::allocate(ref, true));
-}
-
-template <typename T> static void
-LuaClearArgReference(T ptr)
-{
-  LuaHookReference::free(LuaHttpObjectArgGet(ptr));
-  LuaHttpObjectArgSet(ptr, NULL);
-}
-
-// Force template instantiation of LuaSetArgReference().
-template void LuaSetArgReference<TSHttpSsn>(TSHttpSsn ssn, int ref);
-template void LuaSetArgReference<TSHttpTxn>(TSHttpTxn txn, int ref);
-
-static void
-LuaDemuxInvokeCallback(lua_State * lua, TSHttpHookID hookid, TSEvent event, void * edata, int ref)
-{
-  int nitems = lua_gettop(lua);
-
-  // Push the callback table onto the top of the stack.
-  lua_rawgeti(lua, LUA_REGISTRYINDEX, ref);
-
-  // XXX If this is a global hook, we have a function reference. If it's a ssn or txn hook then we
-  // have a callback table reference. We need to make these the same, but not rught now ...
-
-  switch (lua_type(lua, -1)) {
-    case LUA_TFUNCTION:
-      // Nothing to do, the function we want to invoke is already on top of the stack.
-      break;
-    case LUA_TTABLE:
-      // Push the hookid onto the stack so we can use it to index the table (that is now at -2).
-      lua_pushinteger(lua, hookid);
-
-      TSAssert(lua_isnumber(lua, -1));
-      TSAssert(lua_istable(lua, -2));
-
-      // Index the callback table with the hookid to get the callback function for this hook.
-      lua_gettable(lua, -2);
-
-      break;
-    default:
-      LuaLogError("invalid callback reference type %s", ltypeof(lua, -1));
-      TSReleaseAssert(0);
-  }
-
-  // The item on the top of the stack *ought* to be the callback function. However when we register a
-  // cleanup function to release the callback reference (because the ssn or txn closes), then we won't
-  // have a function because there's nothing to do here.
-  if (!lua_isnil(lua, -1)) {
-
-    TSAssert(lua_isfunction(lua, -1));
-
-    lua_pushinteger(lua, event);
-    LuaPushEventData(lua, event, edata);
-
-    if (lua_pcall(lua, 2 /* nargs */, 0, 0) != 0) {
-      LuaLogDebug("hook callback failed: %s", lua_tostring(lua, -1));
-      lua_pop(lua, 1); // pop the error message
-    }
-  }
-
-  // If we left anything on the stack, pop it.
-  lua_pop(lua, lua_gettop(lua) - nitems);
-}
-
-int
-LuaDemuxGlobalHook(TSHttpHookID hookid, TSCont cont, TSEvent event, void * edata)
-{
-  instanceid_t        instanceid = (uintptr_t)TSContDataGet(cont);
-  ScopedLuaState      lstate(instanceid);
-  int                 ref = lstate->hookrefs[hookid];
-
-  LuaLogDebug("%u/%p %s event=%d edata=%p, ref=%d",
-      instanceid, lstate->lua,
-      HttpHookName(hookid), event, edata, ref);
-
-  if (ref == LUA_NOREF) {
-    LuaLogError("no Lua callback for hook %s", HttpHookName(hookid));
-    return TS_EVENT_ERROR;
-  }
-
-  LuaDemuxInvokeCallback(lstate->lua, hookid, event, edata, ref);
-  return TS_EVENT_NONE;
-}
-
-int
-LuaDemuxTxnHook(TSHttpHookID hookid, TSCont cont, TSEvent event, void * edata)
-{
-  int                 ref = LuaGetArgReference((TSHttpTxn)edata);
-  instanceid_t        instanceid = (uintptr_t)TSContDataGet(cont);
-  ScopedLuaState      lstate(instanceid);
-
-  LuaLogDebug("%s(%s) instanceid=%u event=%d edata=%p",
-      __func__, HttpHookName(hookid), instanceid, event, edata);
-
-  if (ref == LUA_NOREF) {
-    LuaLogError("no Lua callback for hook %s", HttpHookName(hookid));
-    return TS_EVENT_ERROR;
-  }
-
-  LuaDemuxInvokeCallback(lstate->lua, hookid, event, edata, ref);
-
-  if (event == TS_EVENT_HTTP_TXN_CLOSE) {
-    LuaLogDebug("unref event handler %d", ref);
-    luaL_unref(lstate->lua, LUA_REGISTRYINDEX, ref);
-    LuaClearArgReference((TSHttpTxn)edata);
-  }
-
-  return TS_EVENT_NONE;
-}
-
-int
-LuaDemuxSsnHook(TSHttpHookID hookid, TSCont cont, TSEvent event, void * edata)
-{
-  instanceid_t        instanceid = (uintptr_t)TSContDataGet(cont);
-  ScopedLuaState      lstate(instanceid);
-  TSHttpSsn           ssn;
-  int                 ref;
-
-  // The edata might be a Txn or a Ssn, depending on the event type. If we get here, it's because we
-  // registered a callback on the Ssn, so we need to get back to the Ssn object in order to the the
-  // callback table reference ...
-  switch (event) {
-    case TS_EVENT_HTTP_SSN_START:
-    case TS_EVENT_HTTP_SSN_CLOSE:
-      ssn = (TSHttpSsn)edata;
-      break;
-    default:
-      ssn = TSHttpTxnSsnGet((TSHttpTxn)edata);
-  }
-
-  LuaLogDebug("%s(%s) instanceid=%u event=%d edata=%p",
-      __func__, HttpHookName(hookid), instanceid, event, edata);
-
-  ref = LuaGetArgReference(ssn);
-  if (ref == LUA_NOREF) {
-    LuaLogError("no Lua callback for hook %s", HttpHookName(hookid));
-    return TS_EVENT_ERROR;
-  }
-
-  LuaDemuxInvokeCallback(lstate->lua, hookid, event, edata, ref);
-
-  if (event == TS_EVENT_HTTP_SSN_CLOSE) {
-    LuaLogDebug("unref event handler %d", ref);
-    luaL_unref(lstate->lua, LUA_REGISTRYINDEX, ref);
-    LuaClearArgReference((TSHttpSsn)edata);
-  }
-
-  return TS_EVENT_NONE;
-}
-
-bool
-LuaRegisterHttpHooks(lua_State * lua, void * obj, LuaHookAddFunction add, int hooks)
-{
-  bool                hooked_close = false;
-  const TSHttpHookID  closehook = (add == LuaHttpSsnHookAdd ? TS_HTTP_SSN_CLOSE_HOOK : TS_HTTP_TXN_CLOSE_HOOK);
-
-  TSAssert(add == LuaHttpSsnHookAdd || add == LuaHttpTxnHookAdd);
-
-  // Push the hooks reference back onto the stack.
-  lua_rawgeti(lua, LUA_REGISTRYINDEX, hooks);
-
-  // The value on the top of the stack (index -1) MUST be the callback table.
-  TSAssert(lua_istable(lua, lua_gettop(lua)));
-
-  // Now we need our LuaThreadState to access the hook tables.
-  ScopedLuaState lstate(lua);
-
-  // Walk the table and register the hook for each entry.
-  lua_pushnil(lua);  // Push the first key, makes the callback table index -2.
-  while (lua_next(lua, -2) != 0) {
-    TSHttpHookID hookid;
-
-    // uses 'key' (at index -2) and 'value' (at index -1).
-    // LuaLogDebug("key=%s value=%s\n", ltypeof(lua, -2), ltypeof(lua, -1));
-
-    // Now the key (index -2) and value (index -1) got pushed onto the stack. The key must be a hook ID and
-    // the value must be a callback function.
-    luaL_checktype(lua, -1, LUA_TFUNCTION);
-    hookid = (TSHttpHookID)luaL_checkint(lua, -2);
-
-    if (!HookIsValid(hookid)) {
-      LuaLogError("invalid Hook ID %d", hookid);
-      goto next;
-    }
-
-    if (hookid == closehook) {
-      hooked_close = true;
-    }
-
-    // At demux time, we need the hook ID and the table (or function) ref.
-    add(obj, lstate.instance(), hookid);
-    LuaLogDebug("registered callback table %d for event %s on object %p",
-        hooks, HttpHookName(hookid), obj);
-
-next:
-    // Pop the value (index -1), leaving key as the new top (index -1).
-    lua_pop(lua, 1);
-  }
-
-  // we always need to hook the close because we keep a reference to the callback table and we need to
-  // release that reference when the object's lifetime ends.
-  if (!hooked_close) {
-    add(obj, lstate.instance(), closehook);
-  }
-
-  return true;
-}
-
-void
-LuaHttpSsnHookAdd(void * ssn, const LuaPluginInstance * instance, TSHttpHookID hookid)
-{
-  TSHttpSsnHookAdd((TSHttpSsn)ssn, hookid, instance->demux.ssn[hookid]);
-}
-
-void
-LuaHttpTxnHookAdd(void * txn, const LuaPluginInstance * instance, TSHttpHookID hookid)
-{
-  TSHttpTxnHookAdd((TSHttpTxn)txn, hookid, instance->demux.txn[hookid]);
-}
-
-static int
-TSLuaHttpHookRegister(lua_State * lua)
-{
-  TSHttpHookID      hookid;
-
-  hookid = (TSHttpHookID)luaL_checkint(lua, 1);
-  luaL_checktype(lua, 2, LUA_TFUNCTION);
-
-  LuaLogDebug("registering hook %s (%d)", HttpHookName(hookid), (int)hookid);
-  if (hookid < 0 || hookid >= TS_HTTP_LAST_HOOK) {
-    LuaLogDebug("hook ID %d out of range", hookid);
-    return -1;
-  }
-
-  ScopedLuaState lstate(lua);
-  TSReleaseAssert(lstate);
-
-  // The lstate must match the current Lua state or something is seriously wrong.
-  TSReleaseAssert(lstate->lua == lua);
-
-  // Global hooks can only be registered once, but we load the Lua scripts in every thread. Check whether
-  // the hook has already been registered and ignore any double-registrations.
-  if (lstate->hookrefs[hookid] != LUA_NOREF) {
-    LuaLogDebug("ignoring double registration for %s hook", HttpHookName(hookid));
-    return 0;
-  }
-
-  // The callback function for the hook should be on the top of the stack now. Keep a reference
-  // to the callback function in the registry so we can pop it out later.
-  TSAssert(lua_type(lua, lua_gettop(lua)) == LUA_TFUNCTION);
-  lstate->hookrefs[hookid] = luaL_ref(lua, LUA_REGISTRYINDEX);
-
-  LuaLogDebug("%u/%p added hook ref %d for %s",
-      lstate->instance->instanceid, lua, lstate->hookrefs[hookid], HttpHookName(hookid));
-
-  // We need to atomically install this global hook. We snaffle the high bit to mark whether or
-  // not it has been installed.
-  if (((uintptr_t)lstate->instance->demux.global[hookid] & 0x01u) == 0) {
-    TSCont cont = (TSCont)((uintptr_t)lstate->instance->demux.global[hookid] | 0x01u);
-
-    if (__sync_bool_compare_and_swap(&lstate->instance->demux.global[hookid],
-          lstate->instance->demux.global[hookid], cont)) {
-      LuaLogDebug("installed continuation for %s", HttpHookName(hookid));
-      TSHttpHookAdd(hookid, (TSCont)((uintptr_t)cont & ~0x01u));
-    } else {
-      LuaLogDebug("lost hook creation race for %s", HttpHookName(hookid));
-    }
-  }
-
-  return 0;
-}
-
-static const luaL_Reg LUAEXPORTS[] =
-{
-  { "register", TSLuaHttpHookRegister },
-  { NULL, NULL}
-};
-
-int
-LuaHookApiInit(lua_State * lua)
-{
-  LuaLogDebug("initializing TS Hook API");
-
-  lua_newtable(lua);
-
-  // Register functions in the "ts.hook" module.
-  luaL_register(lua, NULL, LUAEXPORTS);
-
-  for (unsigned i = 0; i < TS_HTTP_LAST_HOOK; ++i) {
-    if (HttpHookName((TSHttpHookID)i) != NULL) {
-      // Register named constants for each hook ID.
-      LuaSetConstantField(lua, HttpHookName((TSHttpHookID)i), i);
-    }
-  }
-
-  return 1;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/hook.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/hook.h b/plugins/experimental/lua/hook.h
deleted file mode 100644
index 8c3f642..0000000
--- a/plugins/experimental/lua/hook.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#ifndef LUA_HOOK_H_
-#define LUA_HOOK_H_
-
-struct LuaPluginInstance;
-
-// Pointer to LuaHttpSsnHookAdd() or LuaHttpTxnsnHookAdd().
-typedef void (*LuaHookAddFunction)(void *, const LuaPluginInstance *, TSHttpHookID);
-
-void LuaHttpSsnHookAdd(void *, const LuaPluginInstance *, TSHttpHookID);
-void LuaHttpTxnHookAdd(void *, const LuaPluginInstance *, TSHttpHookID);
-
-// Set a LuaHookReference as the argument on the corresponding object. T can be either TSHttpSsn or TSHttpTxn.
-template <typename T> void LuaSetArgReference(T ptr, int ref);
-
-bool LuaRegisterHttpHooks(lua_State *, void *, LuaHookAddFunction, int);
-
-int LuaDemuxSsnHook(TSHttpHookID hookid, TSCont cont, TSEvent event, void * edata);
-int LuaDemuxTxnHook(TSHttpHookID hookid, TSCont cont, TSEvent event, void * edata);
-int LuaDemuxGlobalHook(TSHttpHookID hookid, TSCont cont, TSEvent event, void * edata);
-
-#endif // LUA_HOOK_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/lapi.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/lapi.cc b/plugins/experimental/lua/lapi.cc
deleted file mode 100644
index 6121113..0000000
--- a/plugins/experimental/lua/lapi.cc
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#include "ts/ts.h"
-#include "ts/remap.h"
-#include "ink_defs.h"
-
-#include <string.h>
-#include "lapi.h"
-#include "lutil.h"
-#include "hook.h"
-
-template <typename LuaType, typename Param1> LuaType *
-push_userdata_object(lua_State * lua, Param1 p1)
-{
-  LuaType * ltype;
-  ltype = LuaType::alloc(lua, p1);
-  TSReleaseAssert(lua_isuserdata(lua, -1) == 1);
-  return ltype;
-}
-
-template <typename LuaType, typename Param1, typename Param2> LuaType *
-push_userdata_object(lua_State * lua, Param1 p1, Param2 p2)
-{
-  LuaType * ltype;
-  ltype = LuaType::alloc(lua, p1, p2);
-  TSReleaseAssert(lua_isuserdata(lua, -1) == 1);
-  return ltype;
-}
-
-struct LuaRemapHeaders
-{
-  TSMBuffer buffer;
-  TSMLoc    headers;
-
-  static LuaRemapHeaders * get(lua_State * lua, int index) {
-    return (LuaRemapHeaders *)luaL_checkudata(lua, index, "ts.meta.rri.headers");
-  }
-
-  static LuaRemapHeaders * alloc(lua_State * lua) {
-    LuaRemapHeaders * hdrs;
-
-    hdrs = LuaNewUserData<LuaRemapHeaders>(lua);
-    luaL_getmetatable(lua, "ts.meta.rri.headers");
-    lua_setmetatable(lua, -2);
-
-    return hdrs;
-  }
-};
-
-struct LuaHttpTransaction
-{
-  TSHttpTxn txn;
-
-  LuaHttpTransaction() : txn(NULL) {}
-
-  static LuaHttpTransaction * get(lua_State * lua, int index) {
-    return (LuaHttpTransaction *)luaL_checkudata(lua, index, "ts.meta.http.txn");
-  }
-
-  static LuaHttpTransaction * alloc(lua_State * lua, TSHttpTxn ptr) {
-    LuaHttpTransaction * txn;
-
-    txn = LuaNewUserData<LuaHttpTransaction>(lua);
-    txn->txn = ptr;
-    luaL_getmetatable(lua, "ts.meta.http.txn");
-    lua_setmetatable(lua, -2);
-
-    return txn;
-  }
-};
-
-struct LuaHttpSession
-{
-  TSHttpSsn ssn;      // session pointer
-
-  LuaHttpSession() : ssn(NULL) {}
-
-  static LuaHttpSession * get(lua_State * lua, int index) {
-    return (LuaHttpSession *)luaL_checkudata(lua, index, "ts.meta.http.ssn");
-  }
-
-  static LuaHttpSession * alloc(lua_State * lua, TSHttpSsn ptr) {
-    LuaHttpSession * ssn;
-
-    ssn = LuaNewUserData<LuaHttpSession>(lua);
-    ssn->ssn = ptr;
-    luaL_getmetatable(lua, "ts.meta.http.ssn");
-    lua_setmetatable(lua, -2);
-
-    return ssn;
-  }
-};
-
-LuaRemapRequest *
-LuaRemapRequest::get(lua_State * lua, int index)
-{
-  return (LuaRemapRequest *)luaL_checkudata(lua, index, "ts.meta.rri");
-}
-
-LuaRemapRequest *
-LuaRemapRequest::alloc(lua_State * lua, TSRemapRequestInfo * rri, TSHttpTxn txn)
-{
-  LuaRemapRequest * rq;
-
-  rq = new(lua_newuserdata(lua, sizeof(LuaRemapRequest))) LuaRemapRequest(rri, txn);
-  luaL_getmetatable(lua, "ts.meta.rri");
-  lua_setmetatable(lua, -2);
-
-  // Stash a new table as the environment for this object. We will use it later for __index.
-  lua_newtable(lua);
-  TSReleaseAssert(lua_setfenv(lua, -2));
-
-  return rq;
-}
-
-// Given a URL table on the top of the stack, pop it's values into the URL buffer.
-bool
-LuaPopUrl(lua_State * lua, TSMBuffer buffer, TSMLoc url)
-{
-  const char *  strval;
-  size_t        len;
-
-#define SET_URL_COMPONENT(name, setter) do { \
-  lua_getfield(lua, -1, name); \
-  if (!lua_isnil(lua, -1)) { \
-    strval = luaL_checklstring(lua, -1, &len); \
-    if (strval) { \
-      setter(buffer, url, strval, len); \
-    } \
-  } \
-  lua_pop(lua, 1); \
-} while (0)
-
-  // We ignore the 'href' field. When constructing URL tables, it's convenient, but it doesn't seem
-  // necessary here. Callers can easily construct the URL table.
-  SET_URL_COMPONENT("scheme", TSUrlSchemeSet);
-  SET_URL_COMPONENT("user", TSUrlUserSet);
-  SET_URL_COMPONENT("password", TSUrlPasswordSet);
-  SET_URL_COMPONENT("host", TSUrlHostSet);
-  SET_URL_COMPONENT("path", TSUrlPathSet);
-  SET_URL_COMPONENT("query", TSUrlHttpQuerySet);
-  SET_URL_COMPONENT("fragment", TSUrlHttpFragmentSet);
-
-  lua_getfield(lua, -1, "port");
-  if (!lua_isnil(lua, -1)) {
-    TSUrlPortSet(buffer, url, luaL_checkint(lua, -1));
-  }
-  lua_pop(lua, 1);
-
-#undef SET_URL_COMPONENT
-  return true;
-}
-
-bool
-LuaPushUrl(lua_State * lua, TSMBuffer buffer, TSMLoc url)
-{
-  int len;
-  const char * str;
-
-#define PUSH_URL_COMPONENT(accessor, name) do { \
-  str = accessor(buffer, url, &len); \
-  if (str) { \
-    lua_pushlstring(lua, str, len); \
-  }  else { \
-    lua_pushnil(lua); \
-  } \
-  lua_setfield(lua, -2, name); \
-} while (0)
-
-  lua_newtable(lua);
-
-  // Set fundamental URL fields.
-  // XXX should we be luvit-compatible with these names?
-  PUSH_URL_COMPONENT(TSUrlSchemeGet, "scheme");       // luvit: protocol
-  PUSH_URL_COMPONENT(TSUrlUserGet, "user");
-  PUSH_URL_COMPONENT(TSUrlPasswordGet, "password");
-  PUSH_URL_COMPONENT(TSUrlHostGet, "host");
-  lua_pushinteger(lua, TSUrlPortGet(buffer, url));
-  lua_setfield(lua, -2, "port");
-  PUSH_URL_COMPONENT(TSUrlPathGet, "path");           // luvit: pathname
-  PUSH_URL_COMPONENT(TSUrlHttpQueryGet, "query");     // luvit: search
-  PUSH_URL_COMPONENT(TSUrlHttpFragmentGet, "fragment");
-
-  // It would be cleaner to add a __tostring metamethod, but to do that we would have to keep the
-  // buffer and url around indefinitely. Better to make a straight copy now; use the 'href' key
-  // just like luvit does.
-  str = TSUrlStringGet(buffer, url, &len);
-  if (str) {
-    lua_pushlstring(lua, str, len);
-    lua_setfield(lua, -2, "href");
-    TSfree((void *)str);
-  }
-
-  TSReleaseAssert(lua_istable(lua, -1) == 1);
-  return true;
-
-#undef PUSH_URL_COMPONENT
-}
-
-static int
-LuaRemapRedirect(lua_State * lua)
-{
-  LuaRemapRequest * rq;
-
-  rq = LuaRemapRequest::get(lua, 1);
-  luaL_checktype(lua, 2, LUA_TTABLE);
-
-  LuaLogDebug("redirecting request %p", rq->rri);
-
-  lua_pushvalue(lua, 2);
-  LuaPopUrl(lua, rq->rri->requestBufp, rq->rri->requestUrl);
-  lua_pop(lua, 1);
-
-  // A redirect always terminates plugin chain evaluation.
-  rq->rri->redirect = 1;
-  rq->status = TSREMAP_DID_REMAP_STOP;
-
-  // Return true back to Lua-space.
-  lua_pushboolean(lua, 1);
-  return 1;
-}
-
-static int
-LuaRemapRewrite(lua_State * lua)
-{
-  LuaRemapRequest * rq;
-
-  rq = LuaRemapRequest::get(lua, 1);
-  luaL_checktype(lua, 2, LUA_TTABLE);
-
-  LuaLogDebug("rewriting request %p", rq->rri);
-
-  lua_pushvalue(lua, 2);
-  LuaPopUrl(lua, rq->rri->requestBufp, rq->rri->requestUrl);
-  lua_pop(lua, 1);
-
-  // A rewrite updates the request URL but never terminates plugin chain evaluation.
-  rq->status = TSREMAP_DID_REMAP;
-
-  // Return true back to Lua-space.
-  lua_pushboolean(lua, 1);
-  return 1;
-}
-
-static int
-LuaRemapReject(lua_State * lua)
-{
-  LuaRemapRequest * rq;
-  int status;
-  size_t body_len;
-  const char * body = NULL;
-
-  rq = LuaRemapRequest::get(lua, 1);
-  status = luaL_checkint(lua, 2);
-  if (!lua_isnoneornil(lua, 3)) {
-    body = luaL_checklstring(lua, 3, &body_len);
-    // body = luaL_checkstring(lua, 3);
-  }
-
-  LuaLogDebug("rejecting request %p with status %d", rq->rri, status);
-
-  TSHttpTxnSetHttpRetStatus(rq->txn, (TSHttpStatus)status);
-  if (body && *body) {
-    TSHttpTxnErrorBodySet(rq->txn, TSstrdup(body), body_len, NULL); // Defaults to text/html
-  }
-
-  // A reject terminates plugin chain evaluation but does not update the request URL.
-  rq->status = TSREMAP_NO_REMAP_STOP;
-
-  return 1;
-}
-
-static int
-LuaRemapUrl(lua_State * lua)
-{
-  LuaRemapRequest * rq;
-
-  rq = LuaRemapRequest::get(lua, 1);
-  LuaPushUrl(lua, rq->rri->requestBufp, rq->rri->requestUrl);
-  return 1;
-}
-
-// Since we cannot add fields to userdata objects, we use the environment to store the fields. If the requested
-// field isn't in our metatable, try to find it in the environment. Populate keys in the environment on demand if
-// the request is for a key that we know about.
-//
-// XXX When we set __index in the metatable, Lua routes all method calls through here rather than checking for the
-// existing key first. That's a bit surprising and I wonder whether there's a better way to handle this.
-static int
-LuaRemapIndex(lua_State * lua)
-{
-  LuaRemapRequest * rq;
-  const char * index;
-
-  rq = LuaRemapRequest::get(lua, 1);
-  index = luaL_checkstring(lua, 2);
-
-  LuaLogDebug("%s[%s]", __func__, index);
-
-  // Get the userdata's metatable and look up the index in it.
-  lua_getmetatable(lua, 1);
-  lua_getfield(lua, -1, index);
-  if (!lua_isnoneornil(lua, -1)) {
-    // Pop the metatable, leaving the field value on top.
-    lua_remove(lua, -2);
-    return 1;
-  }
-
-  // Pop the field value and the metatable.
-  lua_pop(lua, 2);
-
-  lua_getfenv(lua, 1);
-
-  // Get the requested field from the environment table.
-  lua_getfield(lua, -1, index);
-
-  // If we have a value for that field, pop the environment table, leaving the value on top.
-  if (!lua_isnoneornil(lua, -1)) {
-    lua_remove(lua, -2);
-    return 1;
-  }
-
-  // Pop the nil field value.
-  lua_pop(lua, 1);
-
-  if (strcmp(index, "headers") == 0) {
-    LuaRemapHeaders * hdrs;
-
-    hdrs = LuaRemapHeaders::alloc(lua);
-    hdrs->buffer = rq->rri->requestBufp;
-    hdrs->headers = rq->rri->requestHdrp;
-
-    // Set it for the 'headers' index and then push it on the stack.
-    lua_setfield(lua, -2, index);
-    lua_getfield(lua, -1, index);
-
-    // Pop the environment table, leaving the field value on top.
-    lua_remove(lua, -2);
-    return 1;
-  }
-
-  return 0;
-}
-
-static const luaL_Reg RRI[] =
-{
-  { "redirect", LuaRemapRedirect },
-  { "rewrite", LuaRemapRewrite },
-  { "reject", LuaRemapReject },
-  { "url", LuaRemapUrl },
-  { "__index", LuaRemapIndex },
-  { NULL, NULL}
-};
-
-static int
-LuaRemapHeaderIndex(lua_State * lua)
-{
-  LuaRemapHeaders * hdrs;
-  const char *      index;
-  const char *      value;
-  int               vlen;
-  TSMLoc            field;
-
-  hdrs = LuaRemapHeaders::get(lua, 1);;
-  index = luaL_checkstring(lua, 2);
-
-  LuaLogDebug("%s[%s]", __func__, index);
-
-  field = TSMimeHdrFieldFind(hdrs->buffer, hdrs->headers, index, -1);
-  if (field == TS_NULL_MLOC) {
-    lua_pushnil(lua);
-    return 1;
-  }
-
-  value = TSMimeHdrFieldValueStringGet(hdrs->buffer, hdrs->headers, field, -1, &vlen);
-  lua_pushlstring(lua, value, vlen);
-  return 1;
-}
-
-static int
-LuaRemapHeaderNewIndex(lua_State * lua)
-{
-  LuaRemapHeaders * hdrs;
-  const char *      index;
-  const char *      value;
-  size_t            vlen;
-  TSMLoc            field;
-
-  hdrs = LuaRemapHeaders::get(lua, 1);
-  index = luaL_checkstring(lua, 2);
-
-  LuaLogDebug("%s[%s] = (%s)", __func__, index, ltypeof(lua, 3));
-  field = TSMimeHdrFieldFind(hdrs->buffer, hdrs->headers, index, -1);
-
-  // Setting a key to nil means to delete it.
-  if (lua_isnoneornil(lua, 3)) {
-    if (field != TS_NULL_MLOC) {
-      TSMimeHdrFieldDestroy(hdrs->buffer, hdrs->headers, field);
-      TSHandleMLocRelease(hdrs->buffer, hdrs->headers, field);
-    }
-
-    return 1;
-  }
-
-  // If the MIME field doesn't exist yet, we'd better make it.
-  if (field == TS_NULL_MLOC) {
-    TSMimeHdrFieldCreateNamed(hdrs->buffer, hdrs->headers, index, -1, &field);
-    TSMimeHdrFieldAppend(hdrs->buffer, hdrs->headers, field);
-  }
-
-  TSMimeHdrFieldValuesClear(hdrs->buffer, hdrs->headers, field);
-
-  // Finally, we can set it's value.
-  switch(lua_type(lua, 3)) {
-    case LUA_TBOOLEAN:
-      value = lua_toboolean(lua, 3) ? "1" : "0";
-      vlen = 1;
-      break;
-    default:
-      value = lua_tolstring(lua, 3, &vlen);
-      break;
-  }
-
-  if (value) {
-    TSMimeHdrFieldValueStringInsert(hdrs->buffer, hdrs->headers, field, -1, value, vlen);
-  }
-
-  TSHandleMLocRelease(hdrs->buffer, hdrs->headers, field);
-  return 1;
-}
-
-static const luaL_Reg HEADERS[] =
-{
-  { "__index", LuaRemapHeaderIndex },
-  { "__newindex", LuaRemapHeaderNewIndex },
-  { NULL, NULL }
-};
-
-static int
-LuaHttpTxnAbort(lua_State * lua)
-{
-  LuaHttpTransaction * txn;
-
-  txn = LuaHttpTransaction::get(lua, 1);
-  TSHttpTxnReenable(txn->txn, TS_EVENT_HTTP_ERROR);
-
-  return 1;
-}
-
-static int
-LuaHttpTxnContinue(lua_State * lua)
-{
-  LuaHttpTransaction * txn;
-
-  txn = LuaHttpTransaction::get(lua, 1);
-  TSHttpTxnReenable(txn->txn, TS_EVENT_HTTP_CONTINUE);
-
-  return 1;
-}
-
-static int
-LuaHttpTxnRegister(lua_State * lua)
-{
-  LuaHttpTransaction * txn;
-  int tableref;
-
-  txn = LuaHttpTransaction::get(lua, 1);
-  luaL_checktype(lua, 2, LUA_TTABLE);
-
-  // Keep a reference to the hooks table in ssn->hooks.
-  tableref = luaL_ref(lua, LUA_REGISTRYINDEX);
-
-  // On the other side of the denux, we need the hook, and the table.
-  if (LuaRegisterHttpHooks(lua, txn->txn, LuaHttpTxnHookAdd, tableref)) {
-    LuaSetArgReference(txn->txn, tableref);
-    return 1;
-  }
-
-  return 0;
-}
-
-static int
-LuaHttpTxnCacheLookupStatus(lua_State * lua)
-{
-  LuaHttpTransaction * txn;
-  int status;
-
-  txn = LuaHttpTransaction::get(lua, 1);
-  if (TSHttpTxnCacheLookupStatusGet(txn->txn, &status) == TS_SUCCESS) {
-    lua_pushinteger(lua, status);
-  } else {
-    lua_pushinteger(lua, -1);
-  }
-
-  return 1;
-}
-
-static const luaL_Reg HTTPTXN[] =
-{
-  { "abort", LuaHttpTxnAbort },
-  { "continue", LuaHttpTxnContinue },
-  { "register", LuaHttpTxnRegister },
-  { "cachestatus", LuaHttpTxnCacheLookupStatus },
-  { NULL, NULL }
-};
-
-static int
-LuaHttpSsnAbort(lua_State * lua)
-{
-  LuaHttpSession * ssn;
-
-  ssn = LuaHttpSession::get(lua, 1);
-  TSHttpSsnReenable(ssn->ssn, TS_EVENT_HTTP_ERROR);
-
-  return 1;
-}
-
-static int
-LuaHttpSsnContinue(lua_State * lua)
-{
-  LuaHttpSession * ssn;
-
-  ssn = LuaHttpSession::get(lua, 1);
-  TSHttpSsnReenable(ssn->ssn, TS_EVENT_HTTP_CONTINUE);
-
-  return 1;
-}
-
-static int
-LuaHttpSsnRegister(lua_State * lua)
-{
-  LuaHttpSession * ssn;
-  int tableref;
-
-  ssn = LuaHttpSession::get(lua, 1);
-  luaL_checktype(lua, 2, LUA_TTABLE);
-
-  // Keep a reference to the hooks table in ssn->hooks.
-  tableref = luaL_ref(lua, LUA_REGISTRYINDEX);
-
-  // On the other side of the denux, we need the hook, and the table.
-  if (LuaRegisterHttpHooks(lua, ssn->ssn, LuaHttpSsnHookAdd, tableref)) {
-    LuaSetArgReference(ssn->ssn, tableref);
-    return 1;
-  }
-
-  return 0;
-}
-
-static const luaL_Reg HTTPSSN[] =
-{
-  { "register", LuaHttpSsnRegister },
-  { "abort", LuaHttpSsnAbort },
-  { "continue", LuaHttpSsnContinue },
-  { NULL, NULL }
-};
-
-static int
-TSLuaDebug(lua_State * lua)
-{
-  const char * tag = luaL_checkstring(lua, 1);
-  const char * message = luaL_checkstring(lua, 2);
-
-  TSDebug(tag, "%s", message);
-  return 0;
-}
-
-static const luaL_Reg LUAEXPORTS[] =
-{
-  { "debug", TSLuaDebug },
-  { NULL, NULL}
-};
-
-LuaRemapRequest *
-LuaPushRemapRequestInfo(lua_State * lua, TSHttpTxn txn, TSRemapRequestInfo * rri)
-{
-  return push_userdata_object<LuaRemapRequest>(lua, rri, txn);
-}
-
-LuaHttpTransaction *
-LuaPushHttpTransaction(lua_State * lua, TSHttpTxn txn)
-{
-  return push_userdata_object<LuaHttpTransaction>(lua, txn);
-}
-
-LuaHttpSession *
-LuaPushHttpSession(lua_State * lua, TSHttpSsn ssn)
-{
-  return push_userdata_object<LuaHttpSession>(lua, ssn);
-}
-
-int
-LuaApiInit(lua_State * lua)
-{
-  LuaLogDebug("initializing TS API");
-
-  lua_newtable(lua);
-
-  // Register functions in the "ts" module.
-  luaL_register(lua, NULL, LUAEXPORTS);
-
-  // Push constants into the "ts" module.
-  LuaSetConstantField(lua, "VERSION", TSTrafficServerVersionGet());
-  LuaSetConstantField(lua, "MAJOR_VERSION", TSTrafficServerVersionGetMajor());
-  LuaSetConstantField(lua, "MINOR_VERSION", TSTrafficServerVersionGetMinor());
-  LuaSetConstantField(lua, "PATCH_VERSION", TSTrafficServerVersionGetPatch());
-
-  LuaSetConstantField(lua, "CACHE_LOOKUP_MISS", TS_CACHE_LOOKUP_MISS);
-  LuaSetConstantField(lua, "CACHE_LOOKUP_HIT_STALE", TS_CACHE_LOOKUP_HIT_STALE);
-  LuaSetConstantField(lua, "CACHE_LOOKUP_HIT_FRESH", TS_CACHE_LOOKUP_HIT_FRESH);
-  LuaSetConstantField(lua, "CACHE_LOOKUP_SKIPPED", TS_CACHE_LOOKUP_SKIPPED);
-
-  // Register TSRemapRequestInfo metatable.
-  LuaPushMetatable(lua, "ts.meta.rri", RRI);
-  // Pop the metatable.
-  lua_pop(lua, 1);
-
-  // Register the remap headers metatable.
-  LuaPushMetatable(lua, "ts.meta.rri.headers", HEADERS);
-  // Pop the metatable.
-  lua_pop(lua, 1);
-
-  // Register TSHttpTxn metatable.
-  LuaPushMetatable(lua, "ts.meta.http.txn", HTTPTXN);
-  // Pop the metatable.
-  lua_pop(lua, 1);
-
-  // Register TSHttpSsn metatable.
-  LuaPushMetatable(lua, "ts.meta.http.ssn", HTTPSSN);
-  // Pop the metatable.
-  lua_pop(lua, 1);
-
-  TSReleaseAssert(lua_istable(lua, -1) == 1);
-  return 1;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/lapi.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/lapi.h b/plugins/experimental/lua/lapi.h
deleted file mode 100644
index 2218330..0000000
--- a/plugins/experimental/lua/lapi.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#ifndef LUA_LAPI_H_
-#define LUA_LAPI_H_
-
-#include <lua.hpp>
-
-struct LuaHttpTransaction;
-struct LuaHttpSession;
-
-struct LuaRemapRequest
-{
-  TSRemapRequestInfo *  rri;
-  TSHttpTxn             txn;
-  TSRemapStatus         status;
-
-  LuaRemapRequest(TSRemapRequestInfo * r, TSHttpTxn t) : rri(r), txn(t), status(TSREMAP_NO_REMAP) {}
-  LuaRemapRequest() : rri(NULL), txn(NULL), status(TSREMAP_NO_REMAP) {}
-  ~LuaRemapRequest() {}
-
-  static LuaRemapRequest * get(lua_State * lua, int index);
-  static LuaRemapRequest * alloc(lua_State *, TSRemapRequestInfo *, TSHttpTxn);
-};
-
-// Initialize the 'ts' module.
-int LuaApiInit(lua_State * lua);
-// Initialize the 'ts.config' module.
-int LuaConfigApiInit(lua_State * lua);
-// Initialize the 'ts.hook' module.
-int LuaHookApiInit(lua_State * lua);
-
-// Push a copy of the given URL.
-bool LuaPushUrl(lua_State * lua, TSMBuffer buffer, TSMLoc url);
-
-// Push a wrapper object for the given TSRemapRequestInfo.
-LuaRemapRequest *
-LuaPushRemapRequestInfo(lua_State * lua, TSHttpTxn txn, TSRemapRequestInfo * rri);
-
-// Push a TSHttpTxn userdata object.
-LuaHttpTransaction *
-LuaPushHttpTransaction(lua_State * lua, TSHttpTxn txn);
-
-// Push a TSHttpSsn userdata object.
-LuaHttpSession *
-LuaPushHttpSession(lua_State * lua, TSHttpSsn ssn);
-
-#endif // LUA_LAPI_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/lconfig.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/lconfig.cc b/plugins/experimental/lua/lconfig.cc
deleted file mode 100644
index 292829a..0000000
--- a/plugins/experimental/lua/lconfig.cc
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#include "ts/ts.h"
-#include "ts/remap.h"
-#include "ink_defs.h"
-
-#include "lapi.h"
-#include "lutil.h"
-
-// ts.config.override(txn, key, value)
-//
-// Override a configuration entry for this transaction.
-static int
-TSLuaConfigOverride(lua_State * lua)
-{
-  LuaRemapRequest *       rq;
-  TSOverridableConfigKey  key;
-  union {
-    lua_Number  number;
-    lua_Integer integer;
-    struct { const char * str; size_t len; } lstring;
-  } value;
-
-
-  // XXX For now, this only works on remap request objects. When we expose a TSHttpTxn object in Lua, we should
-  // dynamically support passing one of those in as well.
-  rq = LuaRemapRequest::get(lua, 1);
-
-  key = (TSOverridableConfigKey)luaL_checkint(lua, 2);
-
-  switch(lua_type(lua, 3)) {
-    case LUA_TBOOLEAN:
-      TSHttpTxnConfigIntSet(rq->txn, key, lua_toboolean(lua, 3) ? 1 : 0);
-      break;
-    case LUA_TNUMBER:
-      // There's no API that will tell us the correct type to use for numberic override options. Let's try int first,
-      // since that's the common case. If that fails we can try float.
-      value.integer = luaL_checkinteger(lua, 3);
-      if (TSHttpTxnConfigIntSet(rq->txn, key, value.integer) == TS_ERROR) {
-        value.number = luaL_checknumber(lua, 3);
-        TSHttpTxnConfigFloatSet(rq->txn, key, value.number);
-      }
-
-      break;
-    case LUA_TSTRING:
-      value.lstring.str = lua_tolstring(lua, 3, &value.lstring.len);
-      TSHttpTxnConfigStringSet(rq->txn, key, value.lstring.str, value.lstring.len);
-      break;
-  }
-
-  return 0;
-}
-
-static const luaL_Reg LUAEXPORTS[] =
-{
-  { "override", TSLuaConfigOverride },
-  { NULL, NULL}
-};
-
-int
-LuaConfigApiInit(lua_State * lua)
-{
-  LuaLogDebug("initializing TS Config API");
-
-  lua_newtable(lua);
-
-  // Register functions in the "ts.config" module.
-  luaL_register(lua, NULL, LUAEXPORTS);
-
-#define DEFINE_CONFIG_KEY(NAME) LuaSetConstantField(lua, #NAME, TS_CONFIG_ ## NAME)
-  DEFINE_CONFIG_KEY(URL_REMAP_PRISTINE_HOST_HDR);
-  DEFINE_CONFIG_KEY(HTTP_CHUNKING_ENABLED);
-  DEFINE_CONFIG_KEY(HTTP_NEGATIVE_CACHING_ENABLED);
-  DEFINE_CONFIG_KEY(HTTP_NEGATIVE_CACHING_LIFETIME);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_WHEN_TO_REVALIDATE);
-  DEFINE_CONFIG_KEY(HTTP_KEEP_ALIVE_ENABLED_IN);
-  DEFINE_CONFIG_KEY(HTTP_KEEP_ALIVE_ENABLED_OUT);
-  DEFINE_CONFIG_KEY(HTTP_KEEP_ALIVE_POST_OUT);
-  DEFINE_CONFIG_KEY(HTTP_SHARE_SERVER_SESSIONS);
-  DEFINE_CONFIG_KEY(NET_SOCK_RECV_BUFFER_SIZE_OUT);
-  DEFINE_CONFIG_KEY(NET_SOCK_SEND_BUFFER_SIZE_OUT);
-  DEFINE_CONFIG_KEY(NET_SOCK_OPTION_FLAG_OUT);
-  DEFINE_CONFIG_KEY(HTTP_FORWARD_PROXY_AUTH_TO_PARENT);
-  DEFINE_CONFIG_KEY(HTTP_ANONYMIZE_REMOVE_FROM);
-  DEFINE_CONFIG_KEY(HTTP_ANONYMIZE_REMOVE_REFERER);
-  DEFINE_CONFIG_KEY(HTTP_ANONYMIZE_REMOVE_USER_AGENT);
-  DEFINE_CONFIG_KEY(HTTP_ANONYMIZE_REMOVE_COOKIE);
-  DEFINE_CONFIG_KEY(HTTP_ANONYMIZE_REMOVE_CLIENT_IP);
-  DEFINE_CONFIG_KEY(HTTP_ANONYMIZE_INSERT_CLIENT_IP);
-  DEFINE_CONFIG_KEY(HTTP_RESPONSE_SERVER_ENABLED);
-  DEFINE_CONFIG_KEY(HTTP_INSERT_SQUID_X_FORWARDED_FOR);
-  DEFINE_CONFIG_KEY(HTTP_SERVER_TCP_INIT_CWND);
-  DEFINE_CONFIG_KEY(HTTP_SEND_HTTP11_REQUESTS);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_HTTP);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_IGNORE_CLIENT_NO_CACHE);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_IGNORE_CLIENT_CC_MAX_AGE);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_IMS_ON_CLIENT_NO_CACHE);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_IGNORE_SERVER_NO_CACHE);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_CACHE_RESPONSES_TO_COOKIES);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_IGNORE_AUTHENTICATION);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_CACHE_URLS_THAT_LOOK_DYNAMIC);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_REQUIRED_HEADERS);
-  DEFINE_CONFIG_KEY(HTTP_INSERT_REQUEST_VIA_STR);
-  DEFINE_CONFIG_KEY(HTTP_INSERT_RESPONSE_VIA_STR);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_HEURISTIC_MIN_LIFETIME);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_HEURISTIC_MAX_LIFETIME);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_GUARANTEED_MIN_LIFETIME);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_GUARANTEED_MAX_LIFETIME);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_MAX_STALE_AGE);
-  DEFINE_CONFIG_KEY(HTTP_KEEP_ALIVE_NO_ACTIVITY_TIMEOUT_IN);
-  DEFINE_CONFIG_KEY(HTTP_KEEP_ALIVE_NO_ACTIVITY_TIMEOUT_OUT);
-  DEFINE_CONFIG_KEY(HTTP_TRANSACTION_NO_ACTIVITY_TIMEOUT_IN);
-  DEFINE_CONFIG_KEY(HTTP_TRANSACTION_NO_ACTIVITY_TIMEOUT_OUT);
-  DEFINE_CONFIG_KEY(HTTP_TRANSACTION_ACTIVE_TIMEOUT_OUT);
-  DEFINE_CONFIG_KEY(HTTP_ORIGIN_MAX_CONNECTIONS);
-  DEFINE_CONFIG_KEY(HTTP_CONNECT_ATTEMPTS_MAX_RETRIES);
-  DEFINE_CONFIG_KEY(HTTP_CONNECT_ATTEMPTS_MAX_RETRIES_DEAD_SERVER);
-  DEFINE_CONFIG_KEY(HTTP_CONNECT_ATTEMPTS_RR_RETRIES);
-  DEFINE_CONFIG_KEY(HTTP_CONNECT_ATTEMPTS_TIMEOUT);
-  DEFINE_CONFIG_KEY(HTTP_POST_CONNECT_ATTEMPTS_TIMEOUT);
-  DEFINE_CONFIG_KEY(HTTP_DOWN_SERVER_CACHE_TIME);
-  DEFINE_CONFIG_KEY(HTTP_DOWN_SERVER_ABORT_THRESHOLD);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_FUZZ_TIME);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_FUZZ_MIN_TIME);
-  DEFINE_CONFIG_KEY(HTTP_DOC_IN_CACHE_SKIP_DNS);
-  DEFINE_CONFIG_KEY(HTTP_RESPONSE_SERVER_STR);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_HEURISTIC_LM_FACTOR);
-  DEFINE_CONFIG_KEY(HTTP_CACHE_FUZZ_PROBABILITY);
-  DEFINE_CONFIG_KEY(NET_SOCK_PACKET_MARK_OUT);
-  DEFINE_CONFIG_KEY(NET_SOCK_PACKET_TOS_OUT);
-  DEFINE_CONFIG_KEY(HTTP_INSERT_AGE_IN_RESPONSE);
-#undef DEFINE_CONFIG_KEY
-
-  return 1;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/lutil.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/lutil.cc b/plugins/experimental/lua/lutil.cc
deleted file mode 100644
index 6971fb7..0000000
--- a/plugins/experimental/lua/lutil.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#include "ts/ts.h"
-#include "ts/remap.h"
-#include "ink_defs.h"
-
-#include "lapi.h"
-#include "lutil.h"
-#include <pthread.h>
-#include <unistd.h>
-
-int LuaHttpArgIndex;
-
-#if !defined(LUAJIT_VERSION)
-static void *
-LuaAllocate(void * ud, void * ptr, size_t /* osize ATS_UNUSED */, size_t nsize)
-{
-  TSReleaseAssert(ud == NULL);
-
-  if (nsize == 0) {
-    TSfree(ptr);
-    return NULL;
-  }
-
-  return TSrealloc(ptr, nsize);
-}
-#endif
-
-lua_State *
-LuaNewState()
-{
-  return LuaPluginNewState();
-}
-
-lua_State *
-LuaPluginNewState(void)
-{
-  lua_State * lua;
-
-  // lua_newstate() is a stub in LuaJIT 64-bit.
-#if defined(LUAJIT_VERSION)
-  lua = luaL_newstate();
-#else
-  lua = lua_newstate(LuaAllocate, NULL);
-#endif
-  if (lua == NULL) {
-    return NULL;
-  }
-
-  LuaLoadLibraries(lua);
-  LuaRegisterLibrary(lua, "ts", LuaApiInit);
-  LuaRegisterLibrary(lua, "ts.config", LuaConfigApiInit);
-  LuaRegisterLibrary(lua, "ts.hook", LuaHookApiInit);
-
-  return lua;
-}
-
-void
-LuaPushMetatable(lua_State * lua, const char * name, const luaL_Reg * exports)
-{
-  luaL_newmetatable(lua, name);
-  lua_pushvalue(lua, -1);
-  lua_setfield(lua, -2, "__index");
-  luaL_register(lua, NULL, exports);
-}
-
-void
-LuaRegisterLibrary(lua_State * lua, const char * name, lua_CFunction loader)
-{
-  // Pull up the preload table.
-  lua_getglobal(lua, "package");
-  lua_getfield(lua, -1, "preload");
-
-  lua_pushcfunction(lua, loader);
-  lua_setfield(lua, -2, name);
-
-  // Pop the 'package' and 'preload' tables.
-  lua_pop(lua, 2);
-}
-
-void
-LuaLoadLibraries(lua_State * lua)
-{
-#define REGISTER_LIBRARY(name) LuaRegisterLibrary(lua, #name, luaopen_ ## name)
-
-    lua_cpcall(lua, luaopen_base, NULL);
-    lua_cpcall(lua, luaopen_package, NULL);
-
-    REGISTER_LIBRARY(io);
-    REGISTER_LIBRARY(os);
-    REGISTER_LIBRARY(table);
-    REGISTER_LIBRARY(string);
-    REGISTER_LIBRARY(math);
-    REGISTER_LIBRARY(debug);
-
-    // XXX LuaJIT recommends calling luaL_openlibs() here. No explanation of why.
-
-#undef REGISTER_LIBRARY
-}
-
-void
-LuaSetConstantField(lua_State * lua, const char * name, int value)
-{
-  lua_pushinteger(lua, value);
-  lua_setfield(lua, -2, name);
-}
-
-void
-LuaSetConstantField(lua_State * lua, const char * name, const char * value)
-{
-  lua_pushstring(lua, value);
-  lua_setfield(lua, -2, name);
-}
-
-void
-LuaDebugStack(lua_State * lua)
-{
-  int top = lua_gettop(lua);
-
-  for (int i = 1; i <= top; i++) {
-    LuaLogDebug("stack[%d] %s", i, ltypeof(lua, i));
-  }
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/lutil.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/lutil.h b/plugins/experimental/lua/lutil.h
deleted file mode 100644
index 90818d3..0000000
--- a/plugins/experimental/lua/lutil.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#ifndef LUA_LUTIL_H_
-#define LUA_LUTIL_H_
-
-#include <lua.hpp>
-#include <vector>
-#include <string>
-#include <memory>
-#include <pthread.h>
-#include "ink_defs.h"
-
-// Global argument index for TSHttpSsnArgGet and TSHttpTxnArgGet.
-extern int LuaHttpArgIndex;
-
-#define LuaLogDebug(fmt, ...) do { \
-    if (unlikely(TSIsDebugTagSet("lua"))) { \
-        TSDebug("lua", "%s: " fmt, __func__, ##__VA_ARGS__); \
-    } \
-} while (0)
-
-// In DEBUG mode, log errors to the debug channel. This is handy for making Lua runtime
-// errors show up on stdout along with the rest of the debug loggin.
-#if DEBUG
-#define LuaLogError(fmt, ...) LuaLogDebug(fmt, ##__VA_ARGS__)
-#else
-#define LuaLogError(fmt, ...) TSError(fmt, ##__VA_ARGS__)
-#endif
-
-// Debug log the Lua stack.
-void LuaDebugStack(lua_State *);
-
-// Return the type name string for the given index.
-static inline const char *
-ltypeof(lua_State * lua, int index) {
-  return lua_typename(lua, lua_type(lua, index));
-}
-
-template <typename T> T * tsnew() {
-  void * ptr = TSmalloc(sizeof(T));
-  return new(ptr) T();
-}
-
-template <typename T> void tsdelete(T * ptr) {
-  if (ptr) {
-    ptr->~T();
-    TSfree(ptr);
-  }
-}
-
-// Allocate an object with lua_newuserdata() and call the default constructor.
-template <typename T> T * LuaNewUserData(lua_State * lua) {
-  void * ptr = lua_newuserdata(lua, sizeof(T));
-  return new(ptr) T();
-}
-
-void LuaPushMetatable(lua_State * lua, const char * name, const luaL_Reg * exports);
-void LuaLoadLibraries(lua_State * lua);
-void LuaRegisterLibrary(lua_State * lua, const char * name, lua_CFunction loader);
-
-// Set the named field in the table on the top of the stack.
-void LuaSetConstantField(lua_State * lua, const char * name, int value);
-void LuaSetConstantField(lua_State * lua, const char * name, const char * value);
-
-// Allocate a new lua_State.
-lua_State * LuaNewState();
-lua_State * LuaPluginNewState(void);
-
-#endif // LUA_LUTIL_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/plugin.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/plugin.cc b/plugins/experimental/lua/plugin.cc
deleted file mode 100644
index 1c96e3b..0000000
--- a/plugins/experimental/lua/plugin.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#include <ts/ts.h>
-#include "lutil.h"
-#include "hook.h"
-#include "state.h"
-
-extern "C" void
-TSPluginInit(int argc, const char * argv[])
-{
-  TSPluginRegistrationInfo  info;
-  instanceid_t              instanceid;
-
-  info.plugin_name = (char *)"lua";
-  info.vendor_name = (char *)"Apache Software Foundation";
-  info.support_email = (char *)"dev@trafficserver.apache.org";
-
-  if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
-      LuaLogError("Plugin registration failed");
-  }
-
-  // Allocate a TSHttpTxn argument index for handling per-transaction hooks.
-  TSReleaseAssert(TSHttpArgIndexReserve("lua", "lua", &LuaHttpArgIndex) == TS_SUCCESS);
-
-  // Register a new Lua plugin instance, skipping the first argument (which is the plugin name).
-  instanceid = LuaPluginRegister((unsigned)argc - 1, (const char **)argv + 1);
-  TSReleaseAssert(instanceid == 0);
-}
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/remap.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/remap.cc b/plugins/experimental/lua/remap.cc
deleted file mode 100644
index ac42075..0000000
--- a/plugins/experimental/lua/remap.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#include "ts/ts.h"
-#include "ts/remap.h"
-#include "ink_defs.h"
-
-#include "lapi.h"
-#include "lutil.h"
-#include "state.h"
-#include <unistd.h>
-#include <pthread.h>
-
-static pthread_mutex_t PluginInstanceLock = PTHREAD_MUTEX_INITIALIZER;
-
-static TSRemapStatus
-LuaPluginRemap(lua_State * lua, TSHttpTxn txn, TSRemapRequestInfo * rri)
-{
-  LuaRemapRequest * rq;
-
-  lua_getglobal(lua, "remap");
-  if (lua_isnil(lua, -1)) {
-    // No "remap" callback, better continue.
-    return TSREMAP_NO_REMAP;
-  }
-
-  LuaLogDebug("handling request %p on thread 0x%llx", rri, (unsigned long long)pthread_self());
-
-  // XXX We can also cache the RemapRequestInfo in the Lua state. We we just need to reset
-  // the rri pointer and status.
-  rq = LuaPushRemapRequestInfo(lua, txn, rri);
-
-  if (lua_pcall(lua, 1, 0, 0) != 0) {
-    LuaLogDebug("remap failed: %s", lua_tostring(lua, -1));
-    lua_pop(lua, 1);
-    return TSREMAP_ERROR;
-  }
-
-  // XXX can we guarantee that rq has not been garbage collected?
-  return rq->status;
-}
-
-TSReturnCode
-TSRemapInit(TSRemapInterface * /* api_info ATS_UNUSED */, char * /* errbuf ATS_UNUSED */,
-            int /* errbuf_size ATS_UNUSED */)
-{
-  LuaLogDebug("loading lua plugin");
-
-  // Allocate a TSHttpTxn argument index for handling per-transaction hooks.
-  TSReleaseAssert(TSHttpArgIndexReserve("lua", "lua", &LuaHttpArgIndex) == TS_SUCCESS);
-
-  return TS_SUCCESS;
-}
-
-TSReturnCode
-TSRemapNewInstance(int argc, char * argv[], void ** ih, char * /* errbuf ATS_UNUSED */, int /* errsz ATS_UNUSED */)
-{
-  instanceid_t instanceid;
-
-  pthread_mutex_lock(&PluginInstanceLock);
-
-  // Register a new Lua plugin instance, skipping the first two arguments (which are the remap URLs).
-  instanceid = LuaPluginRegister((unsigned)argc - 2, (const char **)argv + 2);
-  *ih = (void *)(intptr_t)instanceid;
-
-  pthread_mutex_unlock(&PluginInstanceLock);
-
-  LuaLogDebug("created Lua remap instance %u", instanceid);
-  return TS_SUCCESS;
-}
-
-void
-TSRemapDeleteInstance(void * ih)
-{
-  instanceid_t instanceid = (intptr_t)ih;
-
-  pthread_mutex_lock(&PluginInstanceLock);
-  LuaPluginUnregister(instanceid);
-  pthread_mutex_unlock(&PluginInstanceLock);
-}
-
-TSRemapStatus
-TSRemapDoRemap(void * ih, TSHttpTxn txn, TSRemapRequestInfo * rri)
-{
-  ScopedLuaState lstate((intptr_t)ih);
-
-  TSReleaseAssert(lstate);
-  return LuaPluginRemap(lstate->lua, txn, rri);
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/state.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/state.cc b/plugins/experimental/lua/state.cc
deleted file mode 100644
index 502e6fd..0000000
--- a/plugins/experimental/lua/state.cc
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#include "ts/ts.h"
-#include "ts/remap.h"
-#include "ink_defs.h"
-
-#include "state.h"
-#include "hook.h"
-#include "lutil.h"
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#define INVALID_INSTANCE_ID (instanceid_t)(-1)
-
-// InitDemuxTable() requires an initializer for every hook. Make sure that we don't
-// get out of sync with the number of hooks.
-extern void * __static_assert_hook_count[TS_HTTP_LAST_HOOK == 17 ? 0 : -1];
-
-typedef int (*LuaHookDemuxer)(TSHttpHookID, TSCont, TSEvent, void *);
-
-template <TSHttpHookID hookid, LuaHookDemuxer demuxer> int
-DemuxSpecificHook(TSCont cont, TSEvent event, void * edata) {
-  return demuxer(hookid, cont, event, edata);
-}
-
-template <LuaHookDemuxer demuxer> void
-InitDemuxTable(LuaPluginInstance::demux_table_t& table)
-{
-#define MakeLuaHook(demuxer, hookid) TSContCreate(DemuxSpecificHook<hookid, demuxer>, NULL)
-
-  table[TS_HTTP_READ_REQUEST_HDR_HOOK]  = MakeLuaHook(demuxer, TS_HTTP_READ_REQUEST_HDR_HOOK);
-  table[TS_HTTP_OS_DNS_HOOK]            = MakeLuaHook(demuxer, TS_HTTP_OS_DNS_HOOK);
-  table[TS_HTTP_SEND_REQUEST_HDR_HOOK]  = MakeLuaHook(demuxer, TS_HTTP_SEND_REQUEST_HDR_HOOK);
-  table[TS_HTTP_READ_CACHE_HDR_HOOK]    = MakeLuaHook(demuxer, TS_HTTP_READ_CACHE_HDR_HOOK);
-  table[TS_HTTP_READ_RESPONSE_HDR_HOOK] = MakeLuaHook(demuxer, TS_HTTP_READ_RESPONSE_HDR_HOOK);
-  table[TS_HTTP_SEND_RESPONSE_HDR_HOOK] = MakeLuaHook(demuxer, TS_HTTP_SEND_RESPONSE_HDR_HOOK);
-  table[TS_HTTP_REQUEST_TRANSFORM_HOOK] = MakeLuaHook(demuxer, TS_HTTP_REQUEST_TRANSFORM_HOOK);
-  table[TS_HTTP_RESPONSE_TRANSFORM_HOOK]= MakeLuaHook(demuxer, TS_HTTP_RESPONSE_TRANSFORM_HOOK);
-  table[TS_HTTP_SELECT_ALT_HOOK]        = MakeLuaHook(demuxer, TS_HTTP_SELECT_ALT_HOOK);
-  table[TS_HTTP_TXN_START_HOOK]         = MakeLuaHook(demuxer, TS_HTTP_TXN_START_HOOK);
-  table[TS_HTTP_TXN_CLOSE_HOOK]         = MakeLuaHook(demuxer, TS_HTTP_TXN_CLOSE_HOOK);
-  table[TS_HTTP_SSN_START_HOOK]         = MakeLuaHook(demuxer, TS_HTTP_SSN_START_HOOK);
-  table[TS_HTTP_SSN_CLOSE_HOOK]         = MakeLuaHook(demuxer, TS_HTTP_SSN_CLOSE_HOOK);
-  table[TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK] = MakeLuaHook(demuxer, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK);
-  table[TS_HTTP_PRE_REMAP_HOOK]         = MakeLuaHook(demuxer, TS_HTTP_PRE_REMAP_HOOK);
-  table[TS_HTTP_POST_REMAP_HOOK]        = MakeLuaHook(demuxer, TS_HTTP_POST_REMAP_HOOK);
-  table[TS_HTTP_RESPONSE_CLIENT_HOOK]   = MakeLuaHook(demuxer, TS_HTTP_RESPONSE_CLIENT_HOOK);
-}
-
-// Global storage for Lua plugin instances. We vend instanceid_t's as an index into
-// this array.
-static std::vector<LuaPluginInstance *> LuaPluginStorage;
-
-template <typename T> struct is_integral_type {
-  enum { value = 0, is_pointer = 0 };
-};
-
-template <typename T> struct is_integral_type<T *> {
-  enum { value = 1, is_pointer = 1 };
-};
-
-template <> struct is_integral_type<int> { enum { value = 1, is_pointer = 0 }; };
-template <> struct is_integral_type<unsigned> { enum { value = 1, is_pointer = 0 }; };
-template <> struct is_integral_type<long> { enum { value = 1, is_pointer = 0 }; };
-template <> struct is_integral_type<unsigned long> { enum { value = 1, is_pointer = 0 }; };
-
-static unsigned
-nproc()
-{
-  long count;
-
-  count = sysconf(_SC_NPROCESSORS_ONLN);
-  return (unsigned)std::max(count, 1l);
-}
-
-static unsigned
-thread_id()
-{
-  pthread_t self = pthread_self();
-
-  if (is_integral_type<pthread_t>::value) {
-    // If it's a pointer, then the lower bits are probably zero because it's
-    // likely to be 8 or 16 byte aligned.
-    if (is_integral_type<pthread_t>::is_pointer) {
-      return (unsigned)((intptr_t)self >> 4);
-    }
-    return (unsigned)(intptr_t)self;
-  } else {
-    // XXX make this work on FreeBSD!
-    TSReleaseAssert(0 && "unsupported platform");
-    return 0;
-  }
-}
-
-LuaPluginInstance::LuaPluginInstance()
-  : instanceid(INVALID_INSTANCE_ID), paths(), states()
-{
-}
-
-LuaPluginInstance::~LuaPluginInstance()
-{
-  this->invalidate();
-}
-
-void
-LuaPluginInstance::invalidate()
-{
-  for (unsigned i = 0; i < this->states.size(); ++ i) {
-    tsdelete(this->states[i]);
-  }
-
-  this->states.clear();
-  this->paths.clear();
-  this->instanceid = INVALID_INSTANCE_ID;
-
-  for (unsigned i = 0; i < countof(this->demux.global); ++i) {
-    TSContDestroy(this->demux.global[i]);
-    TSContDestroy(this->demux.ssn[i]);
-    TSContDestroy(this->demux.txn[i]);
-    this->demux.global[i] = this->demux.ssn[i] = this->demux.txn[i] = NULL;
-  }
-
-}
-
-void
-LuaPluginInstance::init(unsigned argc, const char ** argv)
-{
-  for (unsigned i = 0; i < argc; ++i) {
-    this->paths.push_back(argv[i]);
-  }
-
-  // Make sure we have enough threads to make concurrent access to lua
-  // states unlikely.
-  this->states.resize(nproc() * 2);
-
-  InitDemuxTable<LuaDemuxGlobalHook>(this->demux.global);
-  InitDemuxTable<LuaDemuxSsnHook>(this->demux.ssn);
-  InitDemuxTable<LuaDemuxTxnHook>(this->demux.txn);
-
-  for (unsigned i = 0; i < countof(this->demux.global); ++i) {
-    TSContDataSet(this->demux.global[i], (void *)(uintptr_t)this->instanceid);
-    TSContDataSet(this->demux.ssn[i], (void *)(uintptr_t)this->instanceid);
-    TSContDataSet(this->demux.txn[i], (void *)(uintptr_t)this->instanceid);
-  }
-
-}
-
-instanceid_t
-LuaPluginRegister(unsigned argc, const char ** argv)
-{
-  instanceid_t instanceid = INVALID_INSTANCE_ID;
-  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] == NULL) {
-      // This slot looks ok, let's try to claim it.
-      instanceid = i;
-      break;
-    }
-  }
-
-  // Take the current instanceid, incrementing it for next time.
-  if (instanceid == INVALID_INSTANCE_ID) {
-    instanceid = LuaPluginStorage.size();
-    LuaPluginStorage.resize(LuaPluginStorage.size() + 1);
-  }
-
-  // Mark this plugin instance as in use.
-  plugin = LuaPluginStorage[instanceid] = tsnew<LuaPluginInstance>();
-  plugin->instanceid = instanceid;
-
-  // The path list should be empty if we correctly released it last time this
-  // instance ID was used.
-  TSReleaseAssert(plugin->paths.empty());
-  LuaPluginStorage[instanceid]->init(argc, argv);
-
-  // Allocate the Lua states, then separately initialize by evaluating all the Lua files.
-  for (unsigned i = 0; i < plugin->states.size(); ++i) {
-    plugin->states[i] = tsnew<LuaThreadState>();
-    plugin->states[i]->alloc(plugin, i);
-  }
-
-  for (unsigned i = 0; i < LuaPluginStorage[instanceid]->states.size(); ++i) {
-    plugin->states[i]->init(plugin);
-  }
-
-  return instanceid;
-}
-
-void
-LuaPluginUnregister(instanceid_t instanceid)
-{
-  TSReleaseAssert(instanceid < LuaPluginStorage.size());
-  tsdelete(LuaPluginStorage[instanceid]);
-  LuaPluginStorage[instanceid] = NULL;
-}
-
-LuaThreadState::LuaThreadState()
-  : lua(NULL), instance(NULL)
-{
-  pthread_mutexattr_t attr;
-
-  // We need a recursive mutex so that we can safely reacquire it from Lua code.
-  TSReleaseAssert(pthread_mutexattr_init(&attr) == 0);
-  TSReleaseAssert(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) == 0);
-  TSReleaseAssert(pthread_mutex_init(&this->mutex, &attr) == 0);
-
-  for (unsigned i = 0; i < countof(this->hookrefs); ++i) {
-    this->hookrefs[i] = LUA_NOREF;
-  }
-
-  pthread_mutexattr_destroy(&attr);
-}
-
-LuaThreadState::~LuaThreadState()
-{
-  this->release();
-  pthread_mutex_destroy(&this->mutex);
-}
-
-bool
-LuaThreadState::alloc(LuaPluginInstance * plugin, unsigned threadid)
-{
-  this->lua = LuaNewState();
-  this->instance = plugin;
-
-  // Push the instanceid into a global integer. We will use this later to rendevous
-  // with the lthread from the lua_State. We have to set the instanceid global before
-  // executing any Lua code, because that will almost certainly call back into the plugin
-  // ad reguire the instance id to be set.
-  lua_pushinteger(this->lua, plugin->instanceid);
-  lua_setfield(this->lua, LUA_REGISTRYINDEX, "__instanceid");
-
-  lua_pushinteger(this->lua, threadid);
-  lua_setfield(this->lua, LUA_REGISTRYINDEX, "__threadid");
-
-  return true;
-}
-
-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;
-    }
-
-    if (luaL_dofile(this->lua, p->c_str()) != 0) {
-      // If the load failed, it should have pushed an error message.
-      LuaLogError("failed to load Lua file %s: %s", p->c_str(), lua_tostring(lua, -1));
-      return false;
-    }
-  }
-
-  return true;
-}
-
-void
-LuaThreadState::release()
-{
-  if (this->lua) {
-    lua_close(this->lua);
-    this->lua = NULL;
-  }
-}
-
-std::pair<LuaThreadState *, LuaPluginInstance *>
-LuaThreadStateAcquire(lua_State * lua)
-{
-  LuaThreadState * lthread;
-  LuaPluginInstance * instance;
-  instanceid_t instanceid;
-  unsigned threadid;
-
-  lua_getfield(lua, LUA_REGISTRYINDEX, "__instanceid");
-  instanceid = (instanceid_t)luaL_checkinteger(lua, -1);
-
-  lua_getfield(lua, LUA_REGISTRYINDEX, "__threadid");
-  threadid = (unsigned)luaL_checkinteger(lua, -1);
-
-  TSReleaseAssert(instanceid < LuaPluginStorage.size());
-
-  instance = LuaPluginStorage[instanceid];
-
-  TSReleaseAssert(threadid < instance->states.size());
-  lthread = instance->states[threadid];
-
-  LuaLogDebug("%u/%p acquired state %u from plugin instance %u on thread %u",
-      instanceid, lthread->lua, threadid, instanceid, thread_id());
-
-  lua_pop(lua, 2);
-
-  // Since we already hav a lua_State, we must already be holding the lock. But acquire
-  // and release come in matched pairs, so we need a recursive lock to release.
-  TSReleaseAssert(pthread_mutex_lock(&lthread->mutex) == 0);
-  return std::make_pair(lthread, instance);
-}
-
-std::pair<LuaThreadState *, LuaPluginInstance *>
-LuaThreadStateAcquire(instanceid_t instanceid)
-{
-  LuaThreadState * lthread;
-  LuaPluginInstance * instance;
-  unsigned which;
-
-  TSReleaseAssert(instanceid < LuaPluginStorage.size());
-
-  instance = LuaPluginStorage[instanceid];
-
-  // Index the set of LuaThreadStates with the thread ID. We might want to do a proper
-  // hash on this to prevent false sharing.
-  which = thread_id() % instance->states.size();
-  lthread = instance->states[which];
-
-  LuaLogDebug("%u/%p acquired state %u from plugin instance %u on thread %u",
-      instanceid, lthread->lua, which, instanceid, thread_id());
-
-  TSReleaseAssert(pthread_mutex_lock(&lthread->mutex) == 0);
-  return std::make_pair(lthread, instance);
-}
-
-void
-LuaThreadStateRelease(LuaThreadState * lthread)
-{
-  TSReleaseAssert(pthread_mutex_unlock(&lthread->mutex) == 0);
-}


[16/50] [abbrv] git commit: TS-2820: Adding another check for crash

Posted by bc...@apache.org.
TS-2820: Adding another check for crash


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

Branch: refs/heads/5.0.x
Commit: 971d8eb4da6242cffec34caac04ee95267dc541e
Parents: 0c30d4d
Author: Brian Geffon <br...@apache.org>
Authored: Tue May 27 11:58:22 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Tue May 27 11:58:22 2014 -0700

----------------------------------------------------------------------
 lib/atscppapi/src/TransformationPlugin.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/971d8eb4/lib/atscppapi/src/TransformationPlugin.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/TransformationPlugin.cc b/lib/atscppapi/src/TransformationPlugin.cc
index cbe681b..8c21ea9 100644
--- a/lib/atscppapi/src/TransformationPlugin.cc
+++ b/lib/atscppapi/src/TransformationPlugin.cc
@@ -158,7 +158,7 @@ int handleTransformationPluginRead(TSCont contp, TransformationPluginState *stat
         if (!state->input_complete_dispatched_) {
          state->transformation_plugin_.handleInputComplete();
          state->input_complete_dispatched_ = true;
-         if (vio_cont) {
+         if (vio_cont && 0 != TSVIOBufferGet(write_vio)) {
            TSContCall(vio_cont, static_cast<TSEvent>(TS_EVENT_VCONN_WRITE_COMPLETE), write_vio);
          }
         }


[17/50] [abbrv] git commit: TS-2839 tsxs does not work on OSX (Darwin).

Posted by bc...@apache.org.
TS-2839 tsxs does not work on OSX (Darwin).


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

Branch: refs/heads/5.0.x
Commit: d1061cc97bc3cc78aaf8f4b4f2c5f3b222cce2bd
Parents: 971d8eb
Author: Masakazu Kitajo <mk...@yahoo-corp.jp>
Authored: Tue May 27 16:53:35 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue May 27 16:53:35 2014 -0600

----------------------------------------------------------------------
 CHANGES       | 3 +++
 tools/tsxs.in | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d1061cc9/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 55f8193..8ec7fae 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2839] tsxs does not work on OSX (Darwin).
+   Author: Masakazu Kitajo <m4...@gmail.com>
+
   *) [TS-2820] Add check to Transformations in C++ api to prevent closing
       connections twice.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d1061cc9/tools/tsxs.in
----------------------------------------------------------------------
diff --git a/tools/tsxs.in b/tools/tsxs.in
index a224914..ef7b0f1 100755
--- a/tools/tsxs.in
+++ b/tools/tsxs.in
@@ -122,7 +122,7 @@ case $host in
         MODULELD="$CC -bundle -flat_namespace -undefined suppress"
         MODULELDXX="$CXX -bundle -flat_namespace -undefined suppress"
         MODULEEXT=bundle
-        RLDFLAG="-Wl,--rpath="
+        RLDFLAG="-Wl,-rpath="
         ;;
 *-*-solaris*)
         PICFLAGS="-fpic"


[45/50] [abbrv] git commit: TS-2792 Large request header causes unexpected remap.

Posted by bc...@apache.org.
TS-2792 Large request header causes unexpected remap.


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

Branch: refs/heads/5.0.x
Commit: e8b88aff8a5cc2c23161e2cf1e33d3ee4ddc401e
Parents: 715e4a2
Author: Masakazu Kitajo <mk...@yahoo-corp.jp>
Authored: Fri May 30 10:48:08 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Fri May 30 10:54:12 2014 -0600

----------------------------------------------------------------------
 CHANGES                        | 3 +++
 proxy/http/remap/UrlRewrite.cc | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8b88aff/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index dc132b3..49cfaf4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2792] Large request header causes unexpected remap.
+   Author: Masakazu Kitajo <m4...@gmail.com>
+
   *) [TS-2834] header_rewrite: Add Internal transaction and client-IP
    conditions.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e8b88aff/proxy/http/remap/UrlRewrite.cc
----------------------------------------------------------------------
diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc
index e2d15ee..7a7bb73 100644
--- a/proxy/http/remap/UrlRewrite.cc
+++ b/proxy/http/remap/UrlRewrite.cc
@@ -299,7 +299,6 @@ url_rewrite_remap_request(const UrlMappingContainer& mapping_container, URL *req
   int toHostLen;
   int toSchemeLen;
 
-  requestPath = request_url->path_get(&requestPathLen);
   map_from->path_get(&fromPathLen);
 
   toHost = map_to->host_get(&toHostLen);
@@ -312,6 +311,8 @@ url_rewrite_remap_request(const UrlMappingContainer& mapping_container, URL *req
   request_url->port_set(map_to->port_get_raw());
   request_url->scheme_set(toScheme, toSchemeLen);
 
+  requestPath = request_url->path_get(&requestPathLen);
+
   // Should be +3, little extra padding won't hurt. Use the stack allocation
   // for better performance (bummer that arrays of variable length is not supported
   // on Solaris CC.


[26/50] [abbrv] git commit: Update RAT exclude

Posted by bc...@apache.org.
Update RAT exclude


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

Branch: refs/heads/5.0.x
Commit: f125090f6e1d1d519294b3e7fa17f8d02f766da4
Parents: c25f17c
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed May 28 15:43:49 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed May 28 16:03:37 2014 -0600

----------------------------------------------------------------------
 ci/rat-regex.txt | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f125090f/ci/rat-regex.txt
----------------------------------------------------------------------
diff --git a/ci/rat-regex.txt b/ci/rat-regex.txt
index 446a962..42592d9 100644
--- a/ci/rat-regex.txt
+++ b/ci/rat-regex.txt
@@ -8,6 +8,7 @@ config.nice
 config.status
 libtool
 blib
+stamp-h1
 .*\.txt$
 .*\.cfg$
 .*\.in$


[50/50] [abbrv] git commit: TS-2865: Fix warnings in collapsed connection plugin

Posted by bc...@apache.org.
TS-2865: Fix warnings in collapsed connection plugin


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

Branch: refs/heads/5.0.x
Commit: 59aca28fe1515fef801ce953288a805da41eb1c3
Parents: b776404
Author: Bryan Call <bc...@apache.org>
Authored: Fri May 30 13:47:08 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Fri May 30 13:47:08 2014 -0700

----------------------------------------------------------------------
 CHANGES                                         |  2 ++
 .../collapsed_connection.cc                     | 25 ++++++++++----------
 2 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/59aca28f/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 948df744c..1a7817b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2865] Fix warnings in collapsed connection plugin
+
   *) [TS-2580] SSL Connection reset by peer errors in 4.2.0-rc0
 
   *) [TS-2783] Update documentation defaults, and fix RecordsConfig.cc.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/59aca28f/plugins/experimental/collapsed_connection/collapsed_connection.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/collapsed_connection.cc b/plugins/experimental/collapsed_connection/collapsed_connection.cc
index b2ce76f..9e62b0f 100644
--- a/plugins/experimental/collapsed_connection/collapsed_connection.cc
+++ b/plugins/experimental/collapsed_connection/collapsed_connection.cc
@@ -30,6 +30,7 @@
 #include <ts/remap.h>
 #include <ts/experimental.h>
 #include "MurmurHash3.h"
+#include <inttypes.h>
 
 #include "P_collapsed_connection.h"
 
@@ -436,7 +437,7 @@ insertNewHashEntry(CcTxnData * txn_data)
     size = getCurrentHashEntries(active_hash_map);
     TSMutexUnlock(plugin_data->mutex);
     if (false != map_ret.second) {
-      TSDebug(PLUGIN_NAME, "[%zu] hash_key inserted, active_hash_map.size = %zd", txn_data->seq_id, size);
+      TSDebug(PLUGIN_NAME, "[%" PRIu64 "] hash_key inserted, active_hash_map.size = %zd", txn_data->seq_id, size);
       ret = CC_INSERT;
     } else if (CC_PASS == map_ret.first->second) {
       TSDebug(PLUGIN_NAME, "hash value = %d, previous request mark it non-cacheable", map_ret.first->second);
@@ -446,7 +447,7 @@ insertNewHashEntry(CcTxnData * txn_data)
       ret = CC_LOCKED;
     }
   } else {
-    TSDebug(PLUGIN_NAME, "[%zu] Unable to get mutex", txn_data->seq_id);
+    TSDebug(PLUGIN_NAME, "[%" PRIu64 "] Unable to get mutex", txn_data->seq_id);
   }
 
   if (CC_INSERT != ret && CC_PASS != ret) {
@@ -503,19 +504,19 @@ updateOrRemoveHashEntry(CcTxnData * txn_data)
       size = getCurrentHashEntries(active_hash_map);
       TSMutexUnlock(plugin_data->mutex);
 
-      TSDebug(PLUGIN_NAME, "[%zu] hashEntry updated, active_hash_map.size = %zd", txn_data->seq_id, size);
+      TSDebug(PLUGIN_NAME, "[%" PRIu64 "] hashEntry updated, active_hash_map.size = %zd", txn_data->seq_id, size);
       txn_data->cc_state = CC_PASSED;
     } else {
       addOrCheckKeepPassRecords(0, 0);
       size = getCurrentHashEntries(active_hash_map);
       TSMutexUnlock(plugin_data->mutex);
 
-      TSDebug(PLUGIN_NAME, "[%zu] hashEntry removed, active_hash_map.size = %zd", txn_data->seq_id, size);
+      TSDebug(PLUGIN_NAME, "[%" PRIu64 "] hashEntry removed, active_hash_map.size = %zd", txn_data->seq_id, size);
       txn_data->cc_state = CC_DONE;
     }
     ret = TS_SUCCESS;
   } else {
-    TSDebug(PLUGIN_NAME, "[%zu] Unable to get mutex", txn_data->seq_id);
+    TSDebug(PLUGIN_NAME, "[%" PRIu64 "] Unable to get mutex", txn_data->seq_id);
   }
 
   return ret;
@@ -623,7 +624,7 @@ static int
 retryCacheUrlLock(TSCont contp, TSEvent /* event ATS_UNUSED */, void * /* edata ATS_UNUSED */)
 {
   TryLockData *data = reinterpret_cast < TryLockData * >(TSContDataGet(contp));
-  TSDebug(PLUGIN_NAME, "[%zu] event = %d retry", data->txn_data->seq_id, data->event);
+  TSDebug(PLUGIN_NAME, "[%" PRIu64 "] event = %d retry", data->txn_data->seq_id, data->event);
   collapsedConnectionMainHandler(NULL, data->event, data->txn_data->txnp);
   TSfree(data);
   TSContDataSet(contp, NULL);
@@ -712,7 +713,7 @@ freeCcTxnData(CcTxnData * txn_data)
     TSHttpTxnArgSet(txn_data->txnp, plugin_data->txn_slot, NULL);
     TSHttpTxnReenable(txn_data->txnp, TS_EVENT_HTTP_CONTINUE);
   }
-  TSDebug(PLUGIN_NAME, "[%zu] txn_data released", txn_data->seq_id);
+  TSDebug(PLUGIN_NAME, "[%" PRIu64 "] txn_data released", txn_data->seq_id);
   TSfree(txn_data);
 }
 
@@ -831,12 +832,12 @@ testResponseCacheable(CcTxnData * txn_data)
   resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
 
   if (TS_HTTP_STATUS_OK != resp_status) {
-    TSDebug(PLUGIN_NAME, "[%zu] response status is not 200 OK, ignore it", txn_data->seq_id);
+    TSDebug(PLUGIN_NAME, "[%" PRIu64 "] response status is not 200 OK, ignore it", txn_data->seq_id);
     txn_data->cc_state = CC_REMOVE;
   } else {
     CcPluginData *plugin_data = getCcPlugin();
     if (!isResponseCacheable(bufp, hdr_loc)) {
-      TSDebug(PLUGIN_NAME, "[%zu] response is not public cacheable, let all requests pass", txn_data->seq_id);
+      TSDebug(PLUGIN_NAME, "[%" PRIu64 "] response is not public cacheable, let all requests pass", txn_data->seq_id);
 
       txn_data->cc_state = CC_PASS;
       TSStatIntIncrement(plugin_data->tol_non_cacheable_reqs, 1);
@@ -876,10 +877,10 @@ testCacheLookupResult(CcTxnData * txn_data)
 
   if (TS_CACHE_LOOKUP_HIT_FRESH == status || TS_CACHE_LOOKUP_SKIPPED == status) {
     if (TS_CACHE_LOOKUP_HIT_FRESH == status) {
-      TSDebug(PLUGIN_NAME, "[%zu] cache lookup hit fresh", txn_data->seq_id);
+      TSDebug(PLUGIN_NAME, "[%" PRIu64 "] cache lookup hit fresh", txn_data->seq_id);
     } else if (TS_CACHE_LOOKUP_SKIPPED == status) {
       // client request is not lookupable(no-cache) or in proxy mode only
-      TSDebug(PLUGIN_NAME, "[%zu] cache lookup skipped", txn_data->seq_id);
+      TSDebug(PLUGIN_NAME, "[%" PRIu64 "] cache lookup skipped", txn_data->seq_id);
     }
     txn_data->cc_state = CC_REMOVE;
     // whether success or not, we'll remove it at TXN_CLOSE stage anyway
@@ -906,7 +907,7 @@ collapsedConnectionMainHandler(TSCont /* contp ATS_UNUSED */, TSEvent event, voi
 
   if (NULL != txn_data) {
     TSDebug(PLUGIN_NAME,
-            "[%zu], event = %d, txn_data-> hash_key = %u, cc_state = %d",
+            "[%" PRIu64 "], event = %d, txn_data-> hash_key = %u, cc_state = %d",
             txn_data->seq_id, event, txn_data->hash_key, txn_data->cc_state);
 
     switch (event) {


[43/50] [abbrv] git commit: TS-2804 Fix build on platforms where alloca.h is in a different spot

Posted by bc...@apache.org.
TS-2804 Fix build on platforms where alloca.h is in a different spot


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

Branch: refs/heads/5.0.x
Commit: 515f312b69398762a4b4eb935d3276ffd404fce6
Parents: 11c329f
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu May 29 15:10:45 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu May 29 15:10:49 2014 -0600

----------------------------------------------------------------------
 plugins/experimental/regex_revalidate/regex_revalidate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/515f312b/plugins/experimental/regex_revalidate/regex_revalidate.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/regex_revalidate/regex_revalidate.c b/plugins/experimental/regex_revalidate/regex_revalidate.c
index 4f6baa0..eb41f4c 100644
--- a/plugins/experimental/regex_revalidate/regex_revalidate.c
+++ b/plugins/experimental/regex_revalidate/regex_revalidate.c
@@ -20,6 +20,7 @@
  */
 
 #include "ink_defs.h"
+#include "ink_platform.h"
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -27,7 +28,6 @@
 #include <string.h>
 #include <stdbool.h>
 #include <getopt.h>
-#include <alloca.h>
 #include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>


[03/50] [abbrv] git commit: TS-2555: more features for ts_lua - support function to add global hook, use TSError, support TSSkipRemappingSet

Posted by bc...@apache.org.
TS-2555: more features for ts_lua - support function to add global hook, use TSError, support TSSkipRemappingSet


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

Branch: refs/heads/5.0.x
Commit: 14c484b414ea3be02bc5aebee650cb626fc6cc58
Parents: e5b33fa
Author: Kit Chan <ki...@apache.org>
Authored: Sun May 25 00:16:57 2014 -0700
Committer: Kit Chan <ki...@apache.org>
Committed: Sun May 25 00:16:57 2014 -0700

----------------------------------------------------------------------
 doc/reference/plugins/ts_lua.en.rst             |  81 ++++++-
 .../ts_lua/example/test_closure.lua             |  23 ++
 plugins/experimental/ts_lua/ts_lua.c            | 224 ++++++++++---------
 plugins/experimental/ts_lua/ts_lua_common.h     |   5 +-
 plugins/experimental/ts_lua/ts_lua_hook.c       | 176 ++++++++++-----
 plugins/experimental/ts_lua/ts_lua_http.c       |  21 +-
 .../experimental/ts_lua/ts_lua_http_intercept.c |   8 +-
 plugins/experimental/ts_lua/ts_lua_package.c    |   4 +-
 plugins/experimental/ts_lua/ts_lua_transform.c  |   2 +-
 plugins/experimental/ts_lua/ts_lua_util.c       | 118 ++++++++--
 10 files changed, 473 insertions(+), 189 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/doc/reference/plugins/ts_lua.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/ts_lua.en.rst b/doc/reference/plugins/ts_lua.en.rst
index 8e8c329..c7bcf12 100644
--- a/doc/reference/plugins/ts_lua.en.rst
+++ b/doc/reference/plugins/ts_lua.en.rst
@@ -81,14 +81,14 @@ write this in remap.config:
 
 ::
 
-    map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/XXX/libtslua.so @pparam=/XXX/test_hdr.lua
+    map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/XXX/tslua.so @pparam=/XXX/test_hdr.lua
 
 Sometimes we want to receive parameters and process them in the script, we should realize '__init__' function in the lua
 script, and we can write this in remap.config:
 
 ::
 
-    map http://a.x.cn/ http://b.x.cn/ @plugin=/X/libtslua.so @pparam=/X/sethost.lua @pparam=a.st.cn
+    map http://a.x.cn/ http://b.x.cn/ @plugin=/X/tslua.so @pparam=/X/sethost.lua @pparam=a.st.cn
 
 This module can also act as a global plugin of Traffic Server. In this case we should provide one of these functions in
 each lua script:
@@ -184,10 +184,10 @@ ts.hook
 -------
 **syntax:** *ts.hook(HOOK_POINT, FUNCTION)*
 
-**context:** do_remap or do_global_* or later
+**context:** global or do_remap or do_global_* or later
 
 **description**: Hooks are points in http transaction processing where we can step in and do some work. FUNCTION will be
-called called when the http transaction steps in to HOOK_POINT.
+called when the http transaction steps in to HOOK_POINT.
 
 Here is an example
 
@@ -212,6 +212,30 @@ Then the client will get the response like this:
     Connection: Keep-Alive
     ...
 
+You can create global hook as well
+
+::
+
+    function do_some_work()
+       ts.debug('do_some_work')
+       return 0  
+    end
+
+    ts.hook(TS_LUA_HOOK_READ_REQUEST_HDR, do_some_work)
+
+Or you can do it this way
+
+    ts.hook(TS_LUA_HOOK_READ_REQUEST_HDR, 
+        function()
+            ts.debug('do_some_work')
+            return 0
+        end
+    )
+
+Also the return value of the function will control how the transaction will be re-enabled. Return value of 0 will cause
+the transaction to be re-enabled normally (TS_EVENT_HTTP_CONTINUE). Return value of 1 will be using TS_EVENT_HTTP_ERROR
+instead.
+
 `TOP <#ts-lua-plugin>`_
 
 Hook point constants
@@ -234,7 +258,7 @@ Hook point constants
     TS_LUA_REQUEST_TRANSFORM
     TS_LUA_RESPONSE_TRANSFORM
 
-These constants are usually used in [ts.hook](#tshook) method call.
+These constants are usually used in ts.hook method call.
 
 `TOP <#ts-lua-plugin>`_
 
@@ -1402,6 +1426,43 @@ This function is usually called after we hook TS_LUA_RESPONSE_TRANSFORM.
 
 `TOP <#ts-lua-plugin>`_
 
+ts.http.set_remapping_set
+-------------------------
+**syntax:** *ts.http.set_remapping_set(BOOL)*
+
+**context:** do_global_read_request
+
+**description**: This function can be used to tell trafficserver to skip doing remapping
+
+Here is an example:
+
+::
+
+    function do_global_read_request()
+        ts.http.set_remapping_set(0);
+        ts.client_request.header['Host'] = 'www.yahoo.com'
+        return 0
+    end
+
+This function is usually called in do_global_read_request function
+
+ts.http.is_internal_request
+---------------------------
+**syntax:** *ts.http.is_internal_request()*
+
+** context:** do_remap or do_global_* or later
+
+** description**: This function can be used to tell is a request is internal or not
+
+Here is an example:
+
+::
+
+    function do_global_read_request()
+        local internal = ts.http.is_internal_request()
+        ts.debug(internal)
+        return 0
+    end
 
 ts.add_package_path
 -------------------
@@ -1706,7 +1767,8 @@ ts.server_intercept
 
 **description:** Intercepts the server request and acts as the origin server.
 
-We should construct the response for the server request, so the request will be processed within FUNCTION in case of miss for the cache lookup.
+We should construct the response for the server request, so the request will be processed within FUNCTION in case of
+miss for the cache lookup.
 
 Here is an example:
 
@@ -2004,6 +2066,13 @@ Todo
 * ts.cache_xxx
 * `support lua-5.2 <https://github.com/portl4t/ts-lua/wiki/support-Lua-5.2>`_
 
+Currently when we use ts_lua as a global plugin, each global hook is using a separate lua state for the same
+transaction. This can be wasteful. Also the state cannot be reused for the same transaction across the global hooks. The
+alternative will be to use a TXN_START hook to create a lua state first and then add each global hook in the lua script
+as transaction hook instead. But this will have problem down the road when we need to have multiple plugins to work
+together in some proper orderings. In the future, we should consider different approach, such as creating and
+maintaining the lua state in the ATS core. 
+
 `TOP <#ts-lua-plugin>`_
 
 More docs

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/plugins/experimental/ts_lua/example/test_closure.lua
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/example/test_closure.lua b/plugins/experimental/ts_lua/example/test_closure.lua
new file mode 100644
index 0000000..edd973d
--- /dev/null
+++ b/plugins/experimental/ts_lua/example/test_closure.lua
@@ -0,0 +1,23 @@
+--  Licensed to the Apache Software Foundation (ASF) under one
+--  or more contributor license agreements.  See the NOTICE file
+--  distributed with this work for additional information
+--  regarding copyright ownership.  The ASF licenses this file
+--  to you under the Apache License, Version 2.0 (the
+--  "License"); you may not use this file except in compliance
+--  with the License.  You may obtain a copy of the License at
+--
+--  http://www.apache.org/licenses/LICENSE-2.0
+--
+--  Unless required by applicable law or agreed to in writing, software
+--  distributed under the License is distributed on an "AS IS" BASIS,
+--  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+--  See the License for the specific language governing permissions and
+--  limitations under the License.
+
+ts.hook(TS_LUA_HOOK_READ_REQUEST_HDR, 
+    function()
+       ts.debug('read_request')
+       return 0
+    end
+)
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/plugins/experimental/ts_lua/ts_lua.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua.c b/plugins/experimental/ts_lua/ts_lua.c
index cde8902..49930b7 100644
--- a/plugins/experimental/ts_lua/ts_lua.c
+++ b/plugins/experimental/ts_lua/ts_lua.c
@@ -80,7 +80,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
 
   ts_lua_instance_conf *conf = TSmalloc(sizeof(ts_lua_instance_conf));
   if (!conf) {
-    fprintf(stderr, "[%s] TSmalloc failed !!\n", __FUNCTION__);
+    strncpy(errbuf, "[TSRemapNewInstance] TSmalloc failed!!", errbuf_size - 1);
     return TS_ERROR;
   }
 
@@ -98,7 +98,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
   ret = ts_lua_add_module(conf, ts_lua_main_ctx_array, TS_LUA_MAX_STATE_COUNT, argc - 2, &argv[2]);
 
   if (ret != 0) {
-    fprintf(stderr, "[%s] ts_lua_add_module failed\n", __FUNCTION__);
+    strncpy(errbuf, "[TSRemapNewInstance] ts_lua_add_module failed", errbuf_size - 1);
     return TS_ERROR;
   }
 
@@ -145,6 +145,12 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo * rri)
   http_ctx->client_request_hdrp = rri->requestHdrp;
   http_ctx->client_request_url = rri->requestUrl;
   http_ctx->remap = 1;
+  http_ctx->has_hook = 0;
+
+  contp = TSContCreate(ts_lua_http_cont_handler, NULL);
+  TSContDataSet(contp, http_ctx);
+  http_ctx->main_contp = contp;
+
   l = http_ctx->lua;
 
   lua_getglobal(l, TS_LUA_FUNCTION_REMAP);
@@ -153,18 +159,21 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo * rri)
     return TSREMAP_NO_REMAP;
   }
 
-  contp = TSContCreate(ts_lua_http_cont_handler, NULL);
-  TSContDataSet(contp, http_ctx);
-  http_ctx->main_contp = contp;
-
   if (lua_pcall(l, 0, 1, 0) != 0) {
-    fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+    TSError("lua_pcall failed: %s", lua_tostring(l, -1));
   }
 
   ret = lua_tointeger(l, -1);
   lua_pop(l, 1);
 
-  TSHttpTxnHookAdd(rh, TS_HTTP_TXN_CLOSE_HOOK, contp);
+  if(http_ctx->has_hook) {
+    TSDebug(TS_LUA_DEBUG_TAG, "[%s] has txn hook -> adding txn close hook handler to release resources", __FUNCTION__);
+    TSHttpTxnHookAdd(rh, TS_HTTP_TXN_CLOSE_HOOK, contp);
+  } else {    
+    TSDebug(TS_LUA_DEBUG_TAG, "[%s] no txn hook -> release resources now", __FUNCTION__);
+    ts_lua_destroy_http_ctx(http_ctx); 
+    TSContDestroy(contp);
+  }
 
   TSMutexUnlock(main_ctx->mutexp);
 
@@ -172,19 +181,36 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo * rri)
 }
 
 static int
-globalHookHandler(TSCont contp, TSEvent event, void *edata)
+globalHookHandler(TSCont contp, TSEvent event ATS_UNUSED, void *edata)
 {
   TSHttpTxn txnp = (TSHttpTxn) edata;
 
-  int ret = 0;
+  TSMBuffer bufp;
+  TSMLoc hdr_loc;
+  TSMLoc url_loc;
+
+  int ret;
+  uint64_t req_id;
+  TSCont txn_contp;
 
   lua_State *l;
 
-  ts_lua_http_ctx *http_ctx = (ts_lua_http_ctx *) TSContDataGet(contp);
+  ts_lua_main_ctx *main_ctx;
+  ts_lua_http_ctx *http_ctx;
+
+  ts_lua_instance_conf *conf = (ts_lua_instance_conf *) TSContDataGet(contp);
 
-  TSMBuffer bufp;
-  TSMLoc hdr_loc;
-  TSMLoc url_loc;
+  req_id = __sync_fetch_and_add(&ts_lua_g_http_next_id, 1);
+
+  main_ctx = &ts_lua_g_main_ctx_array[req_id % TS_LUA_MAX_STATE_COUNT];
+
+  TSDebug(TS_LUA_DEBUG_TAG, "[%s] req_id: %" PRId64, __FUNCTION__, req_id);
+  TSMutexLock(main_ctx->mutexp);
+
+  http_ctx = ts_lua_create_http_ctx(main_ctx, conf);
+  http_ctx->txnp = txnp;
+  http_ctx->remap = 0;
+  http_ctx->has_hook = 0;
 
   if (!http_ctx->client_request_bufp) {
     if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) == TS_SUCCESS) {
@@ -202,6 +228,10 @@ globalHookHandler(TSCont contp, TSEvent event, void *edata)
     return 0;
   }
 
+  txn_contp = TSContCreate(ts_lua_http_cont_handler, NULL);
+  TSContDataSet(txn_contp, http_ctx);
+  http_ctx->main_contp = txn_contp;
+
   l = http_ctx->lua;
 
   switch (event) {
@@ -266,190 +296,172 @@ globalHookHandler(TSCont contp, TSEvent event, void *edata)
   }
 
   if (lua_pcall(l, 0, 1, 0) != 0) {
-    fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+    TSError("lua_pcall failed: %s", lua_tostring(l, -1));
   }
 
   ret = lua_tointeger(l, -1);
   lua_pop(l, 1);
 
-  TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
-  return ret;
+  if(http_ctx->has_hook) {
+    // add a hook to release resources for context
+    TSDebug(TS_LUA_DEBUG_TAG, "[%s] has txn hook -> adding txn close hook handler to release resources", __FUNCTION__);
+    TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, txn_contp);
+  } else {
+    TSDebug(TS_LUA_DEBUG_TAG, "[%s] no txn hook -> release resources now", __FUNCTION__);
+    ts_lua_destroy_http_ctx(http_ctx);
+    TSContDestroy(txn_contp);
+  }
+
+  TSMutexUnlock(main_ctx->mutexp);
+
+  if(ret) {
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_ERROR);
+  } else {
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+  }
+
+  return 0;
 }
 
-static int
-transactionStartHookHandler(TSCont contp, TSEvent event ATS_UNUSED, void *edata)
+void
+TSPluginInit(int argc, const char *argv[])
 {
-  TSHttpTxn txnp = (TSHttpTxn) edata;
+  int ret = 0;
+  ts_lua_g_main_ctx_array = TSmalloc(sizeof(ts_lua_main_ctx) * TS_LUA_MAX_STATE_COUNT);
+  memset(ts_lua_g_main_ctx_array, 0, sizeof(ts_lua_main_ctx) * TS_LUA_MAX_STATE_COUNT);
 
-  uint64_t req_id;
-  TSCont txn_contp;
-  TSCont global_contp;
+  ret = ts_lua_create_vm(ts_lua_g_main_ctx_array, TS_LUA_MAX_STATE_COUNT);
 
-  ts_lua_main_ctx *main_ctx;
-  ts_lua_http_ctx *http_ctx;
+  if (ret) {
+    ts_lua_destroy_vm(ts_lua_g_main_ctx_array, TS_LUA_MAX_STATE_COUNT);
+    TSfree(ts_lua_g_main_ctx_array);
+    return;
+  }
 
-  ts_lua_instance_conf *conf = (ts_lua_instance_conf *) TSContDataGet(contp);
+  if (argc < 2) {
+    TSError("[%s] lua script file required !!", __FUNCTION__);
+    return;
+  }
 
-  req_id = __sync_fetch_and_add(&ts_lua_g_http_next_id, 1);
+  if (strlen(argv[1]) >= TS_LUA_MAX_SCRIPT_FNAME_LENGTH - 16) {
+    TSError("[%s] lua script file name too long !!", __FUNCTION__);
+    return;
+  }
 
-  main_ctx = &ts_lua_g_main_ctx_array[req_id % TS_LUA_MAX_STATE_COUNT];
+  ts_lua_instance_conf *conf = TSmalloc(sizeof(ts_lua_instance_conf));
+  if (!conf) {
+    TSError("[%s] TSmalloc failed !!", __FUNCTION__);
+    return;
+  }
+  memset(conf, 0, sizeof(ts_lua_instance_conf));
 
-  TSDebug(TS_LUA_DEBUG_TAG, "[%s] req_id: %" PRId64, __FUNCTION__, req_id);
-  TSMutexLock(main_ctx->mutexp);
+  sprintf(conf->script, "%s", argv[1]);
 
-  http_ctx = ts_lua_create_http_ctx(main_ctx, conf);
-  http_ctx->txnp = txnp;
-  http_ctx->remap = 0;
+  ts_lua_init_instance(conf);
 
-  txn_contp = TSContCreate(ts_lua_http_cont_handler, NULL);
-  TSContDataSet(txn_contp, http_ctx);
-  http_ctx->main_contp = txn_contp;
+  ret = ts_lua_add_module(conf, ts_lua_g_main_ctx_array, TS_LUA_MAX_STATE_COUNT, argc - 1, (char **) &argv[1]);
 
-  global_contp = TSContCreate(globalHookHandler, NULL);
-  TSContDataSet(global_contp, http_ctx);
+  if (ret != 0) {
+    TSError("[%s] ts_lua_add_module failed", __FUNCTION__);
+    return;
+  }
+
+  TSCont global_contp = TSContCreate(globalHookHandler, NULL);
+  if (!global_contp) {
+    TSError("[%s] could not create transaction start continuation", __FUNCTION__);
+    return;
+  }
+  TSContDataSet(global_contp, conf);
 
   //adding hook based on whether the lua global function exists.
+  ts_lua_main_ctx *main_ctx = &ts_lua_g_main_ctx_array[0];
+  ts_lua_http_ctx *http_ctx = ts_lua_create_http_ctx(main_ctx, conf);
   lua_State *l = http_ctx->lua;
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_SEND_REQUEST);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_REQUEST_HDR_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_SEND_REQUEST_HDR_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "send_request_hdr_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_READ_RESPONSE);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "read_response_hdr_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_SEND_RESPONSE);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_SEND_RESPONSE_HDR_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "send_response_hdr_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_CACHE_LOOKUP_COMPLETE);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "cache_lookup_complete_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_READ_REQUEST);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_READ_REQUEST_HDR_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "read_request_hdr_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_TXN_START);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_START_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "txn_start_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_PRE_REMAP);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_PRE_REMAP_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_PRE_REMAP_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "pre_remap_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_POST_REMAP);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_POST_REMAP_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_POST_REMAP_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "post_remap_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_SELECT_ALT);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_SELECT_ALT_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_SELECT_ALT_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "select_alt_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_OS_DNS);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_OS_DNS_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_OS_DNS_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "os_dns_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_READ_CACHE);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_READ_CACHE_HDR_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_READ_CACHE_HDR_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "read_cache_hdr_hook added");
   }
   lua_pop(l, 1);
 
   lua_getglobal(l, TS_LUA_FUNCTION_G_TXN_CLOSE);
   if (lua_type(l, -1) == LUA_TFUNCTION) {
-    TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_TXN_CLOSE_HOOK, global_contp);
     TSDebug(TS_LUA_DEBUG_TAG, "txn_close_hook added");
   }
   lua_pop(l, 1);
 
-  // add a hook to release resources for context
-  TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, txn_contp);
-
-  TSMutexUnlock(main_ctx->mutexp);
-
-  TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
-  return 0;
-}
-
-void
-TSPluginInit(int argc, const char *argv[])
-{
-  int ret = 0;
-  ts_lua_g_main_ctx_array = TSmalloc(sizeof(ts_lua_main_ctx) * TS_LUA_MAX_STATE_COUNT);
-  memset(ts_lua_g_main_ctx_array, 0, sizeof(ts_lua_main_ctx) * TS_LUA_MAX_STATE_COUNT);
-
-  ret = ts_lua_create_vm(ts_lua_g_main_ctx_array, TS_LUA_MAX_STATE_COUNT);
-
-  if (ret) {
-    ts_lua_destroy_vm(ts_lua_g_main_ctx_array, TS_LUA_MAX_STATE_COUNT);
-    TSfree(ts_lua_g_main_ctx_array);
-    return;
-  }
-
-  if (argc < 2) {
-    TSError("[%s] lua script file required !!", __FUNCTION__);
-    return;
-  }
-
-  if (strlen(argv[1]) >= TS_LUA_MAX_SCRIPT_FNAME_LENGTH - 16) {
-    TSError("[%s] lua script file name too long !!", __FUNCTION__);
-    return;
-  }
-
-  ts_lua_instance_conf *conf = TSmalloc(sizeof(ts_lua_instance_conf));
-  if (!conf) {
-    TSError("[%s] TSmalloc failed !!", __FUNCTION__);
-    return;
-  }
-
-  sprintf(conf->script, "%s", argv[1]);
-
-  ret = ts_lua_add_module(conf, ts_lua_g_main_ctx_array, TS_LUA_MAX_STATE_COUNT, argc - 1, (char **) &argv[1]);
-
-  if (ret != 0) {
-    TSError("[%s] ts_lua_add_module failed", __FUNCTION__);
-    return;
-  }
-
-  TSCont txn_start_contp = TSContCreate(transactionStartHookHandler, NULL);
-  if (!txn_start_contp) {
-    TSError("[%s] could not create transaction start continuation", __FUNCTION__);
-    return;
-  }
-  TSContDataSet(txn_start_contp, conf);
-  TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, txn_start_contp);
+  ts_lua_destroy_http_ctx(http_ctx);
 
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/plugins/experimental/ts_lua/ts_lua_common.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_common.h b/plugins/experimental/ts_lua/ts_lua_common.h
index 96f07b1..6c245f3 100644
--- a/plugins/experimental/ts_lua/ts_lua_common.h
+++ b/plugins/experimental/ts_lua/ts_lua_common.h
@@ -77,10 +77,6 @@
 
 #define TS_LUA_MAKE_VAR_ITEM(X)                 {X, #X}
 
-#define ee(...)     fprintf(stderr, "Lua *** %s: ", __func__); \
-                            fprintf(stderr, __VA_ARGS__);   \
-                            fprintf(stderr, " @ %s line %d.\n", __FILE__, __LINE__)
-
 /* for http config or cntl var */
 typedef struct
 {
@@ -140,6 +136,7 @@ typedef struct
   int ref;
 
   int remap;
+  int has_hook;
 
 } ts_lua_http_ctx;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/plugins/experimental/ts_lua/ts_lua_hook.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_hook.c b/plugins/experimental/ts_lua/ts_lua_hook.c
index 6fb3985..1b27cf1 100644
--- a/plugins/experimental/ts_lua/ts_lua_hook.c
+++ b/plugins/experimental/ts_lua/ts_lua_hook.c
@@ -108,95 +108,169 @@ ts_lua_add_hook(lua_State * L)
   switch (entry) {
 
   case TS_LUA_HOOK_CACHE_LOOKUP_COMPLETE:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_CACHE_LOOKUP_COMPLETE);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_CACHE_LOOKUP_COMPLETE);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_CACHE_LOOKUP_COMPLETE);
+    }
     break;
 
   case TS_LUA_HOOK_SEND_REQUEST_HDR:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SEND_REQUEST_HDR_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_SEND_REQUEST);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SEND_REQUEST_HDR_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_SEND_REQUEST);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_SEND_REQUEST);
+    }
     break;
 
   case TS_LUA_HOOK_READ_RESPONSE_HDR:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_READ_RESPONSE);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_READ_RESPONSE);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_READ_RESPONSE);
+    }
     break;
 
   case TS_LUA_HOOK_SEND_RESPONSE_HDR:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_SEND_RESPONSE);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_SEND_RESPONSE);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_SEND_RESPONSE);
+    }
     break;
 
   case TS_LUA_HOOK_READ_REQUEST_HDR:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_REQUEST_HDR_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_READ_REQUEST);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_REQUEST_HDR_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_READ_REQUEST);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_READ_REQUEST);
+    }
     break;
 
   case TS_LUA_HOOK_TXN_START:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_TXN_START_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_TXN_START);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_TXN_START_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_TXN_START);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_TXN_START);
+    }
     break;
 
   case TS_LUA_HOOK_PRE_REMAP:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_PRE_REMAP_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_PRE_REMAP);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_PRE_REMAP_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_PRE_REMAP);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_PRE_REMAP);
+    }
     break;
 
   case TS_LUA_HOOK_POST_REMAP:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_POST_REMAP_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_POST_REMAP);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_POST_REMAP_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_POST_REMAP);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_POST_REMAP);
+    }    
     break;
 
   case TS_LUA_HOOK_OS_DNS:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_OS_DNS_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_OS_DNS);
+    if (http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_OS_DNS_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_OS_DNS);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_OS_DNS);
+    }
     break;
 
   case TS_LUA_HOOK_SELECT_ALT:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SELECT_ALT_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_SELECT_ALT);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SELECT_ALT_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_SELECT_ALT);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_SELECT_ALT);
+    }
     break;
 
   case TS_LUA_HOOK_READ_CACHE_HDR:
-    TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_CACHE_HDR_HOOK, http_ctx->main_contp);
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_READ_CACHE);
+    if(http_ctx) {
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_CACHE_HDR_HOOK, http_ctx->main_contp);
+      http_ctx->has_hook = 1;
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_READ_CACHE);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_READ_CACHE);
+    }
     break;
 
   case TS_LUA_HOOK_TXN_CLOSE:
-    // we don't need to add a hook because we already have added one by default
-    lua_pushvalue(L, 2);
-    lua_setglobal(L, TS_LUA_FUNCTION_TXN_CLOSE);
+    if(http_ctx) {
+      // we don't need to add a hook because we already have added one by default
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_TXN_CLOSE);
+    } else {
+      lua_pushvalue(L, 2);
+      lua_setglobal(L, TS_LUA_FUNCTION_G_TXN_CLOSE);
+    }
     break;
 
   case TS_LUA_REQUEST_TRANSFORM:
   case TS_LUA_RESPONSE_TRANSFORM:
-    transform_ctx = (ts_lua_transform_ctx *) TSmalloc(sizeof(ts_lua_transform_ctx));
-    memset(transform_ctx, 0, sizeof(ts_lua_transform_ctx));
-    transform_ctx->hctx = http_ctx;
-
-    connp = TSTransformCreate(ts_lua_transform_entry, http_ctx->txnp);
-    TSContDataSet(connp, transform_ctx);
-
-    if (entry == TS_LUA_REQUEST_TRANSFORM) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_REQUEST_TRANSFORM_HOOK, connp);
-    } else {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
+    if(http_ctx) {
+      http_ctx->has_hook = 1;
+      transform_ctx = (ts_lua_transform_ctx *) TSmalloc(sizeof(ts_lua_transform_ctx));
+      memset(transform_ctx, 0, sizeof(ts_lua_transform_ctx));
+      transform_ctx->hctx = http_ctx;
+
+      connp = TSTransformCreate(ts_lua_transform_entry, http_ctx->txnp);
+      TSContDataSet(connp, transform_ctx);
+
+      if (entry == TS_LUA_REQUEST_TRANSFORM) {
+        TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_REQUEST_TRANSFORM_HOOK, connp);
+      } else {
+        TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
+      }
+
+      lua_pushlightuserdata(L, transform_ctx);
+      lua_pushvalue(L, 2);
+      lua_rawset(L, LUA_GLOBALSINDEX);
     }
-
-    lua_pushlightuserdata(L, transform_ctx);
-    lua_pushvalue(L, 2);
-    lua_rawset(L, LUA_GLOBALSINDEX);
     break;
 
   default:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/plugins/experimental/ts_lua/ts_lua_http.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http.c b/plugins/experimental/ts_lua/ts_lua_http.c
index 9ceb3e8..0ceb0bb 100644
--- a/plugins/experimental/ts_lua/ts_lua_http.c
+++ b/plugins/experimental/ts_lua/ts_lua_http.c
@@ -55,7 +55,7 @@ static int ts_lua_http_resp_cache_transformed(lua_State * L);
 static int ts_lua_http_resp_cache_untransformed(lua_State * L);
 
 static int ts_lua_http_is_internal_request(lua_State * L);
-
+static int ts_lua_http_skip_remapping_set(lua_State * L);
 
 void
 ts_lua_inject_http_api(lua_State * L)
@@ -113,6 +113,9 @@ ts_lua_inject_http_misc_api(lua_State * L)
 {
   lua_pushcfunction(L, ts_lua_http_is_internal_request);
   lua_setfield(L, -2, "is_internal_request");
+
+  lua_pushcfunction(L, ts_lua_http_skip_remapping_set);
+  lua_setfield(L, -2, "skip_remapping_set");
 }
 
 static void
@@ -262,3 +265,19 @@ ts_lua_http_is_internal_request(lua_State * L)
 
   return 1;
 }
+
+static int
+ts_lua_http_skip_remapping_set(lua_State * L)
+{
+  int action;
+  ts_lua_http_ctx *http_ctx;
+
+  http_ctx = ts_lua_get_http_ctx(L);
+
+  action = luaL_checkinteger(L, 1);
+
+  TSSkipRemappingSet(http_ctx->txnp, action);
+
+  return 0;
+}
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/plugins/experimental/ts_lua/ts_lua_http_intercept.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http_intercept.c b/plugins/experimental/ts_lua/ts_lua_http_intercept.c
index 21e142a..6693d7c 100644
--- a/plugins/experimental/ts_lua/ts_lua_http_intercept.c
+++ b/plugins/experimental/ts_lua/ts_lua_http_intercept.c
@@ -60,11 +60,12 @@ ts_lua_http_intercept(lua_State * L)
   ts_lua_http_ctx *http_ctx;
 
   http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx->has_hook = 1;
 
   type = lua_type(L, 1);
 
   if (type != LUA_TFUNCTION) {
-    fprintf(stderr, "[%s] param in ts.http.intercept should be a function\n", __FUNCTION__);
+    TSError("[%s] param in ts.http.intercept should be a function", __FUNCTION__);
     return 0;
   }
 
@@ -88,11 +89,12 @@ ts_lua_http_server_intercept(lua_State * L)
   ts_lua_http_ctx *http_ctx;
 
   http_ctx = ts_lua_get_http_ctx(L);
+  http_ctx->has_hook = 1;
 
   type = lua_type(L, 1);
 
   if (type != LUA_TFUNCTION) {
-    fprintf(stderr, "[%s] param in ts.http.server_intercept should be a function\n", __FUNCTION__);
+    TSError("[%s] param in ts.http.server_intercept should be a function", __FUNCTION__);
     return 0;
   }
 
@@ -260,7 +262,7 @@ ts_lua_http_intercept_run_coroutine(ts_lua_http_intercept_ctx * ictx, int n)
     break;
 
   default:                     // error
-    fprintf(stderr, "lua_resume failed: %s\n", lua_tostring(L, -1));
+    TSError("lua_resume failed: %s", lua_tostring(L, -1));
     return -1;
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/plugins/experimental/ts_lua/ts_lua_package.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_package.c b/plugins/experimental/ts_lua/ts_lua_package.c
index 3d77f23..ab5096d 100644
--- a/plugins/experimental/ts_lua/ts_lua_package.c
+++ b/plugins/experimental/ts_lua/ts_lua_package.c
@@ -156,7 +156,7 @@ ts_lua_add_package_path_items(lua_State * L, ts_lua_package_path * pp, int n)
 
   for (i = 0; i < n; i++) {
     if (new_path_len + pp[i].len + 1 >= sizeof(new_path)) {
-      fprintf(stderr, "extended package.path is too long.\n");
+      TSError("extended package.path is too long.");
       return -1;
     }
 
@@ -277,7 +277,7 @@ ts_lua_add_package_cpath_items(lua_State * L, ts_lua_package_path * pp, int n)
 
   for (i = 0; i < n; i++) {
     if (new_path_len + pp[i].len + 1 >= sizeof(new_path)) {
-      fprintf(stderr, "extended package.cpath is too long.\n");
+      TSError("extended package.cpath is too long.");
       return -1;
     }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/plugins/experimental/ts_lua/ts_lua_transform.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_transform.c b/plugins/experimental/ts_lua/ts_lua_transform.c
index f196ea6..b480c86 100644
--- a/plugins/experimental/ts_lua/ts_lua_transform.c
+++ b/plugins/experimental/ts_lua/ts_lua_transform.c
@@ -131,7 +131,7 @@ ts_lua_transform_handler(TSCont contp, ts_lua_transform_ctx * transform_ctx)
     }
 
     if (lua_pcall(L, 2, 2, 0)) {
-      fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(L, -1));
+      TSError("lua_pcall failed: %s", lua_tostring(L, -1));
     }
 
     ret = lua_tointeger(L, -1); /* 0 is not finished, 1 is finished */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/14c484b4/plugins/experimental/ts_lua/ts_lua_util.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_util.c b/plugins/experimental/ts_lua/ts_lua_util.c
index 36c5cfa..5304531 100644
--- a/plugins/experimental/ts_lua/ts_lua_util.c
+++ b/plugins/experimental/ts_lua/ts_lua_util.c
@@ -126,21 +126,23 @@ ts_lua_add_module(ts_lua_instance_conf * conf, ts_lua_main_ctx * arr, int n, int
 
     if (conf->content) {
       if (luaL_loadstring(L, conf->content)) {
-        fprintf(stderr, "[%s] luaL_loadstring %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
+        TSError("[%s] luaL_loadstring %s failed: %s", __FUNCTION__, conf->script, lua_tostring(L, -1));
         lua_pop(L, 1);
         TSMutexUnlock(arr[i].mutexp);
         return -1;
       }
 
-    } else if (luaL_loadfile(L, conf->script)) {
-      fprintf(stderr, "[%s] luaL_loadfile %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
-      lua_pop(L, 1);
-      TSMutexUnlock(arr[i].mutexp);
-      return -1;
+    } else if (conf->script) { 
+      if (luaL_loadfile(L, conf->script)) {
+        TSError("[%s] luaL_loadfile %s failed: %s", __FUNCTION__, conf->script, lua_tostring(L, -1));
+        lua_pop(L, 1);
+        TSMutexUnlock(arr[i].mutexp);
+        return -1;
+      }
     }
 
     if (lua_pcall(L, 0, 0, 0)) {
-      fprintf(stderr, "[%s] lua_pcall %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
+      TSError("[%s] lua_pcall %s failed: %s", __FUNCTION__, conf->script, lua_tostring(L, -1));
       lua_pop(L, 1);
       TSMutexUnlock(arr[i].mutexp);
       return -1;
@@ -160,7 +162,7 @@ ts_lua_add_module(ts_lua_instance_conf * conf, ts_lua_main_ctx * arr, int n, int
       }
 
       if (lua_pcall(L, 1, 1, 0)) {
-        fprintf(stderr, "[%s] lua_pcall %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
+        TSError("[%s] lua_pcall %s failed: %s", __FUNCTION__, conf->script, lua_tostring(L, -1));
         lua_pop(L, 1);
         TSMutexUnlock(arr[i].mutexp);
         return -1;
@@ -178,7 +180,6 @@ ts_lua_add_module(ts_lua_instance_conf * conf, ts_lua_main_ctx * arr, int n, int
       lua_pop(L, 1);            /* pop nil */
     }
 
-
     lua_pushlightuserdata(L, conf);
     lua_pushvalue(L, LUA_GLOBALSINDEX);
     lua_rawset(L, LUA_REGISTRYINDEX);   /* L[REG][conf] = L[GLOBAL] */
@@ -214,7 +215,7 @@ ts_lua_del_module(ts_lua_instance_conf * conf, ts_lua_main_ctx * arr, int n)
     if (lua_type(L, -1) == LUA_TFUNCTION) {
 
       if (lua_pcall(L, 0, 0, 0)) {
-        fprintf(stderr, "[%s] lua_pcall %s failed: %s\n", __FUNCTION__, conf->script, lua_tostring(L, -1));
+        TSError("[%s] lua_pcall %s failed: %s", __FUNCTION__, conf->script, lua_tostring(L, -1));
       }
 
     } else {
@@ -541,7 +542,7 @@ ts_lua_http_cont_handler(TSCont contp, TSEvent event, void *edata)
 
     if (lua_type(l, -1) == LUA_TFUNCTION) {
       if (lua_pcall(l, 0, 1, 0)) {
-        fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
       }
 
       ret = lua_tointeger(l, -1);
@@ -555,7 +556,7 @@ ts_lua_http_cont_handler(TSCont contp, TSEvent event, void *edata)
 
     if (lua_type(l, -1) == LUA_TFUNCTION) {
       if (lua_pcall(l, 0, 1, 0)) {
-        fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
       }
 
       ret = lua_tointeger(l, -1);
@@ -569,7 +570,7 @@ ts_lua_http_cont_handler(TSCont contp, TSEvent event, void *edata)
 
     if (lua_type(l, -1) == LUA_TFUNCTION) {
       if (lua_pcall(l, 0, 1, 0)) {
-        fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
       }
 
       ret = lua_tointeger(l, -1);
@@ -583,7 +584,7 @@ ts_lua_http_cont_handler(TSCont contp, TSEvent event, void *edata)
 
     if (lua_type(l, -1) == LUA_TFUNCTION) {
       if (lua_pcall(l, 0, 1, 0)) {
-        fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
       }
 
       ret = lua_tointeger(l, -1);
@@ -597,7 +598,85 @@ ts_lua_http_cont_handler(TSCont contp, TSEvent event, void *edata)
 
     if (lua_type(l, -1) == LUA_TFUNCTION) {
       if (lua_pcall(l, 0, 1, 0)) {
-        fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
+      }
+
+      ret = lua_tointeger(l, -1);
+    }
+
+    break;
+
+  case TS_EVENT_HTTP_READ_REQUEST_HDR:
+
+    lua_getglobal(l, TS_LUA_FUNCTION_READ_REQUEST);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
+      }
+
+      ret = lua_tointeger(l, -1);
+    }
+
+    break;
+
+  case TS_EVENT_HTTP_TXN_START:
+
+    lua_getglobal(l, TS_LUA_FUNCTION_TXN_START);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
+      }
+
+      ret = lua_tointeger(l, -1);
+    }
+
+    break;
+
+  case TS_EVENT_HTTP_PRE_REMAP:
+
+    lua_getglobal(l, TS_LUA_FUNCTION_PRE_REMAP);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
+      }
+    
+      ret = lua_tointeger(l, -1);
+    }
+
+    break;
+
+  case TS_EVENT_HTTP_OS_DNS:
+
+    lua_getglobal(l, TS_LUA_FUNCTION_OS_DNS);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
+      }
+
+      ret = lua_tointeger(l, -1);
+    }
+
+    break;
+
+  case TS_EVENT_HTTP_SELECT_ALT:
+
+    lua_getglobal(l, TS_LUA_FUNCTION_SELECT_ALT);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
+      }
+
+      ret = lua_tointeger(l, -1);
+    }
+
+    break;
+
+  case TS_EVENT_HTTP_READ_CACHE_HDR:
+
+    lua_getglobal(l, TS_LUA_FUNCTION_READ_CACHE);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
       }
 
       ret = lua_tointeger(l, -1);
@@ -606,6 +685,15 @@ ts_lua_http_cont_handler(TSCont contp, TSEvent event, void *edata)
     break;
 
   case TS_EVENT_HTTP_TXN_CLOSE:
+    lua_getglobal(l, TS_LUA_FUNCTION_TXN_CLOSE);
+    if (lua_type(l, -1) == LUA_TFUNCTION) {
+      if (lua_pcall(l, 0, 1, 0)) {
+        TSError("lua_pcall failed: %s", lua_tostring(l, -1));
+      }
+
+      ret = lua_tointeger(l, -1);
+    }
+
     ts_lua_destroy_http_ctx(http_ctx);
     TSContDestroy(contp);
     break;


[08/50] [abbrv] git commit: TS-2844: Documentation update for esi plugin

Posted by bc...@apache.org.
TS-2844: Documentation update for esi plugin


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

Branch: refs/heads/5.0.x
Commit: 0896896aac9e402777dc72cf0e19f1bcf0681e16
Parents: b304cf0
Author: Kit Chan <ki...@apache.org>
Authored: Sun May 25 02:21:44 2014 -0700
Committer: Kit Chan <ki...@apache.org>
Committed: Sun May 25 02:21:44 2014 -0700

----------------------------------------------------------------------
 doc/reference/plugins/esi.en.rst | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0896896a/doc/reference/plugins/esi.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/esi.en.rst b/doc/reference/plugins/esi.en.rst
index 4b37455..fc71d45 100644
--- a/doc/reference/plugins/esi.en.rst
+++ b/doc/reference/plugins/esi.en.rst
@@ -65,8 +65,8 @@ This plugin is only built if the configure option ::
 
     --enable-experimental-plugins
 
-is given at build time. Note that this plugin is built and installed in combination with the ESI module, since they
-share common code.
+is given at build time. Note that this plugin is built and installed in combination with the combo handler module, since
+they share common code.
 
 Enabling ESI
 ============
@@ -95,7 +95,7 @@ Enabling ESI
 
     map http://abc.com/esi.php http://xyz.com/esi.php
 
-4. Your response should contain ESI markup and a response header of .X-Esi: 1'. e.g. using PHP,
+4. Your response should contain ESI markup and a response header of 'X-Esi: 1'. e.g. using PHP,
 
 ::
 
@@ -132,9 +132,9 @@ Useful Note
 ===========
 
 1. You can provide proper cache control header and the ESI response and ESI include response can be cached separately.
-It is extremely useful for rendering page with multiple modules. The page layout can be a ESI response with multiple ESI
-include, each for different module. The page layour ESI response can be cached and each individual ESI include can also
-be cached with different duration. 
+   It is extremely useful for rendering page with multiple modules. The page layout can be a ESI response with multiple
+   ESI include include, each for different module. The page layour ESI response can be cached and each individual ESI
+   include can also be cached with different duration. 
 
 2. You might want to compile the code without using ESI_PACKED_NODE_SUPPORT because it may not work in some corner cases
 


[21/50] [abbrv] git commit: Make HTTPVersion methods const where appropriate

Posted by bc...@apache.org.
Make HTTPVersion methods const where appropriate


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

Branch: refs/heads/5.0.x
Commit: 92de605c4e859da7d783b5320026dac7402b8882
Parents: c304b48
Author: James Peach <jp...@apache.org>
Authored: Tue May 27 21:42:38 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Tue May 27 21:42:38 2014 -0700

----------------------------------------------------------------------
 proxy/hdrs/HTTP.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/92de605c/proxy/hdrs/HTTP.h
----------------------------------------------------------------------
diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h
index d5c8bd6..1605165 100644
--- a/proxy/hdrs/HTTP.h
+++ b/proxy/hdrs/HTTP.h
@@ -490,19 +490,19 @@ class HTTPVersion
 {
 public:
   HTTPVersion();
-  HTTPVersion(int32_t version);
+  explicit HTTPVersion(int32_t version);
   HTTPVersion(int ver_major, int ver_minor);
 
   void set(HTTPVersion ver);
   void set(int ver_major, int ver_minor);
 
   HTTPVersion & operator =(const HTTPVersion & hv);
-  int operator ==(const HTTPVersion & hv);
-  int operator !=(const HTTPVersion & hv);
-  int operator >(const HTTPVersion & hv);
-  int operator <(const HTTPVersion & hv);
-  int operator >=(const HTTPVersion & hv);
-  int operator <=(const HTTPVersion & hv);
+  int operator ==(const HTTPVersion & hv) const;
+  int operator !=(const HTTPVersion & hv) const;
+  int operator >(const HTTPVersion & hv) const;
+  int operator <(const HTTPVersion & hv) const;
+  int operator >=(const HTTPVersion & hv) const;
+  int operator <=(const HTTPVersion & hv) const;
 
 public:
     int32_t m_version;
@@ -741,7 +741,7 @@ HTTPVersion::operator =(const HTTPVersion & hv)
   -------------------------------------------------------------------------*/
 
 inline int
-HTTPVersion::operator ==(const HTTPVersion & hv)
+HTTPVersion::operator ==(const HTTPVersion & hv) const
 {
   return (m_version == hv.m_version);
 }
@@ -750,7 +750,7 @@ HTTPVersion::operator ==(const HTTPVersion & hv)
   -------------------------------------------------------------------------*/
 
 inline int
-HTTPVersion::operator !=(const HTTPVersion & hv)
+HTTPVersion::operator !=(const HTTPVersion & hv) const
 {
   return (m_version != hv.m_version);
 }
@@ -759,7 +759,7 @@ HTTPVersion::operator !=(const HTTPVersion & hv)
   -------------------------------------------------------------------------*/
 
 inline int
-HTTPVersion::operator >(const HTTPVersion & hv)
+HTTPVersion::operator >(const HTTPVersion & hv) const
 {
   return (m_version > hv.m_version);
 }
@@ -768,7 +768,7 @@ HTTPVersion::operator >(const HTTPVersion & hv)
   -------------------------------------------------------------------------*/
 
 inline int
-HTTPVersion::operator <(const HTTPVersion & hv)
+HTTPVersion::operator <(const HTTPVersion & hv) const
 {
   return (m_version < hv.m_version);
 }
@@ -777,7 +777,7 @@ HTTPVersion::operator <(const HTTPVersion & hv)
   -------------------------------------------------------------------------*/
 
 inline int
-HTTPVersion::operator >=(const HTTPVersion & hv)
+HTTPVersion::operator >=(const HTTPVersion & hv) const
 {
   return (m_version >= hv.m_version);
 }
@@ -786,7 +786,7 @@ HTTPVersion::operator >=(const HTTPVersion & hv)
   -------------------------------------------------------------------------*/
 
 inline int
-HTTPVersion::operator <=(const HTTPVersion & hv)
+HTTPVersion::operator <=(const HTTPVersion & hv) const
 {
   return (m_version <= hv.m_version);
 }


[14/50] [abbrv] git commit: TS-2820: Crash in transformations

Posted by bc...@apache.org.
TS-2820: Crash in transformations


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

Branch: refs/heads/5.0.x
Commit: 92a2c62281d93b2ab92b38ebf907d30e24ba355b
Parents: 27e7c17
Author: Brian Geffon <br...@apache.org>
Authored: Tue May 27 11:13:32 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Tue May 27 11:13:32 2014 -0700

----------------------------------------------------------------------
 lib/atscppapi/src/TransformationPlugin.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/92a2c622/lib/atscppapi/src/TransformationPlugin.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/TransformationPlugin.cc b/lib/atscppapi/src/TransformationPlugin.cc
index 90c0b19..cbe681b 100644
--- a/lib/atscppapi/src/TransformationPlugin.cc
+++ b/lib/atscppapi/src/TransformationPlugin.cc
@@ -171,7 +171,7 @@ int handleTransformationPluginRead(TSCont contp, TransformationPluginState *stat
       if (!state->input_complete_dispatched_) {
        state->transformation_plugin_.handleInputComplete();
        state->input_complete_dispatched_ = true;
-       if (vio_cont) {
+       if (vio_cont && 0 != TSVIOBufferGet(write_vio)) {
          TSContCall(vio_cont, static_cast<TSEvent>(TS_EVENT_VCONN_WRITE_COMPLETE), write_vio);
        }
       }


[44/50] [abbrv] git commit: fixing spelling mistakes for ts_lua documentation

Posted by bc...@apache.org.
fixing spelling mistakes for ts_lua documentation


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

Branch: refs/heads/5.0.x
Commit: 715e4a23873c8e39cb47dc1b0bd35e48fedc4601
Parents: 515f312
Author: Kit Chan <ki...@apache.org>
Authored: Fri May 30 07:47:57 2014 +0000
Committer: Kit Chan <ki...@apache.org>
Committed: Fri May 30 07:47:57 2014 +0000

----------------------------------------------------------------------
 doc/reference/plugins/ts_lua.en.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/715e4a23/doc/reference/plugins/ts_lua.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/ts_lua.en.rst b/doc/reference/plugins/ts_lua.en.rst
index c7bcf12..3e190c0 100644
--- a/doc/reference/plugins/ts_lua.en.rst
+++ b/doc/reference/plugins/ts_lua.en.rst
@@ -1426,9 +1426,9 @@ This function is usually called after we hook TS_LUA_RESPONSE_TRANSFORM.
 
 `TOP <#ts-lua-plugin>`_
 
-ts.http.set_remapping_set
+ts.http.skip_remapping_set
 -------------------------
-**syntax:** *ts.http.set_remapping_set(BOOL)*
+**syntax:** *ts.http.skip_remapping_set(BOOL)*
 
 **context:** do_global_read_request
 
@@ -1439,7 +1439,7 @@ Here is an example:
 ::
 
     function do_global_read_request()
-        ts.http.set_remapping_set(0);
+        ts.http.skip_remapping_set(1);
         ts.client_request.header['Host'] = 'www.yahoo.com'
         return 0
     end


[41/50] [abbrv] git commit: TS-2095: autoconf warnings related to unordered_map

Posted by bc...@apache.org.
TS-2095: autoconf warnings related to unordered_map


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

Branch: refs/heads/5.0.x
Commit: 89f19acec7ecaeebe13bc0229f463efaf1543047
Parents: 896ce4d
Author: Bryan Call <bc...@apache.org>
Authored: Thu May 29 13:40:19 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Thu May 29 13:40:19 2014 -0700

----------------------------------------------------------------------
 CHANGES      | 2 ++
 configure.ac | 1 +
 2 files changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/89f19ace/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index dc132b3..5166281 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2095] autoconf warnings related to unordered_map
+
   *) [TS-2834] header_rewrite: Add Internal transaction and client-IP
    conditions.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/89f19ace/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 29520c1..2cbb5af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -566,6 +566,7 @@ AX_CXX_COMPILE_STDCXX_11( [noext], [enable_cxx_11_support=yes], [
 AM_CONDITIONAL([BUILD_HAVE_CXX_11], [ test "x${enable_cxx_11_support}" = "xyes" ])
 if test "x${enable_cxx_11_support}" = "xyes" ; then
   AC_DEFINE(HAVE_CXX_11, 1, [Whether the compiler support C++11])
+  TS_ADDTO(CPPFLAGS, [-std=c++11])
 fi
 
 # While we are in C++ mode, check for the GNU hash_map extension.


[02/50] [abbrv] git commit: TS-2841 Set the URL for mathjax. Author: Masakazu Kitajo.

Posted by bc...@apache.org.
TS-2841 Set the URL for mathjax. Author: Masakazu Kitajo.


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

Branch: refs/heads/5.0.x
Commit: e5b33faa475b6666e5386d2ae656e3063af85baf
Parents: ca09fb2
Author: Leif Hedstrom <zw...@apache.org>
Authored: Sat May 24 16:22:04 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Sat May 24 16:22:04 2014 -0600

----------------------------------------------------------------------
 doc/conf.py | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e5b33faa/doc/conf.py
----------------------------------------------------------------------
diff --git a/doc/conf.py b/doc/conf.py
index bafdcac..a2d2297 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -369,3 +369,4 @@ epub_copyright = u'2013, dev@trafficserver.apache.org'
 
 # Allow duplicate toc entries.
 #epub_tocdup = True
+mathjax_path = 'https://docs.trafficserver.apache.org/__RTD/MathJax.js'


[40/50] [abbrv] git commit: TS-2834 Refactor the getIP() code, and rename the condition to CLIENT-IP. Also added a little bit of docs.

Posted by bc...@apache.org.
TS-2834 Refactor the getIP() code, and rename the condition to
CLIENT-IP. Also added a little bit of docs.

Long term, we should figure out how to unify conditions and
the expander in a way that it integrates with the internal
log token expansions.

This closes #91


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

Branch: refs/heads/5.0.x
Commit: 896ce4d33468a1e2094b103a720eee38fafa26df
Parents: 05f64b6
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu May 29 14:10:34 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu May 29 14:30:13 2014 -0600

----------------------------------------------------------------------
 CHANGES                                     |  3 ++
 doc/reference/plugins/header_rewrite.en.rst |  2 +
 plugins/header_rewrite/Makefile.am          |  6 ++-
 plugins/header_rewrite/conditions.cc        | 44 +++++++----------
 plugins/header_rewrite/expander.cc          | 28 -----------
 plugins/header_rewrite/factory.cc           |  2 +-
 plugins/header_rewrite/lulu.cc              | 63 ++++++++++++++++++++++++
 plugins/header_rewrite/lulu.h               |  7 +++
 8 files changed, 99 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/896ce4d3/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index ab72cd1..dc132b3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2834] header_rewrite: Add Internal transaction and client-IP
+   conditions.
+
   *) [TS-2855] Add the TSHttpIsInternalSession API.
 
   *) [TS-2859] Remove DBG macros to not generate warnings from GCC 4.9.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/896ce4d3/doc/reference/plugins/header_rewrite.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/header_rewrite.en.rst b/doc/reference/plugins/header_rewrite.en.rst
index 1df31d2..af71ab1 100644
--- a/doc/reference/plugins/header_rewrite.en.rst
+++ b/doc/reference/plugins/header_rewrite.en.rst
@@ -117,6 +117,8 @@ only be evaluated if the condition(s) are met::
   cond %{PATH} operand                          [condition_flags]
   cond %{PARAMS} operand                        [condition_flags]
   cond %{QUERY} operand                         [condition_flags]
+  cond %{INTERNAL-TRANSACTION}                  [condition_flags]
+  cond %{CLIENT-IP}                             [condition_flags]
 
 The difference between HEADER and CLIENT-HEADER is that HEADER adapts to the
 hook it's running in, whereas CLIENT-HEADER always applies to the client

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/896ce4d3/plugins/header_rewrite/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/Makefile.am b/plugins/header_rewrite/Makefile.am
index ee17870..4ba0875 100644
--- a/plugins/header_rewrite/Makefile.am
+++ b/plugins/header_rewrite/Makefile.am
@@ -24,8 +24,10 @@ pkglib_LTLIBRARIES = header_rewrite.la
 header_rewrite_la_SOURCES = \
   condition.cc \
   conditions.cc \
+  expander.cc \
   factory.cc \
   header_rewrite.cc \
+  lulu.cc \
   matcher.cc \
   operator.cc \
   operators.cc \
@@ -33,8 +35,8 @@ header_rewrite_la_SOURCES = \
   regex_helper.cc \
   resources.cc \
   ruleset.cc \
-  statement.cc \
-  expander.cc
+  statement.cc
+
 header_rewrite_la_LDFLAGS = $(BOOST_LDFLAGS) $(TS_PLUGIN_LDFLAGS)
 
 endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/896ce4d3/plugins/header_rewrite/conditions.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index 721a781..6bc97fa 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -384,7 +384,8 @@ ConditionDBM::eval(const Resources& res)
 
 
 // ConditionCookie: request or response header
-void ConditionCookie::initialize(Parser& p)
+void
+ConditionCookie::initialize(Parser& p)
 {
   Condition::initialize(p);
 
@@ -396,7 +397,8 @@ void ConditionCookie::initialize(Parser& p)
   require_resources(RSRC_CLIENT_REQUEST_HEADERS);
 }
 
-void ConditionCookie::append_value(std::string& s, const Resources& res)
+void
+ConditionCookie::append_value(std::string& s, const Resources& res)
 {
   TSMBuffer bufp = res.client_bufp;
   TSMLoc hdr_loc = res.client_hdr_loc;
@@ -436,7 +438,8 @@ out_release_field:
   TSHandleMLocRelease(bufp, hdr_loc, field_loc);
 }
 
-bool ConditionCookie::eval(const Resources& res)
+bool
+ConditionCookie::eval(const Resources& res)
 {
   std::string s;
 
@@ -446,12 +449,14 @@ bool ConditionCookie::eval(const Resources& res)
   return rval;
 }
 
-bool ConditionInternalTransaction::eval(const Resources& res)
+bool
+ConditionInternalTransaction::eval(const Resources& res)
 {
   return TSHttpIsInternalRequest(res.txnp) == TS_SUCCESS;
 }
 
-void ConditionClientIp::initialize(Parser &p)
+void
+ConditionClientIp::initialize(Parser &p)
 {
   Condition::initialize(p);
 
@@ -461,34 +466,23 @@ void ConditionClientIp::initialize(Parser &p)
   _matcher = match;
 }
 
-bool ConditionClientIp::eval(const Resources &res)
+bool
+ConditionClientIp::eval(const Resources &res)
 {
   std::string s;
+
   append_value(s, res);
   bool rval = static_cast<const Matchers<std::string>*>(_matcher)->test(s);
+  TSDebug(PLUGIN_NAME, "Evaluating CLIENT-IP(): %s: rval: %d", s.c_str(), rval);
   return rval;
 }
 
-void ConditionClientIp::append_value(std::string &s, const Resources &res)
+void
+ConditionClientIp::append_value(std::string &s, const Resources &res)
 {
-  const sockaddr *sockaddress = TSHttpTxnClientAddrGet(res.txnp);
-  if (sockaddress == NULL) {
-    return;
-  }
-
-  char buf[INET6_ADDRSTRLEN] = { 0 };
+  char ip[INET6_ADDRSTRLEN];
 
-  if (sockaddress->sa_family == AF_INET)
-  {
-    inet_ntop(AF_INET, &(((struct sockaddr_in *) sockaddress)->sin_addr), buf, INET_ADDRSTRLEN);
-  }
-  else if (sockaddress->sa_family == AF_INET6)
-  {
-    inet_ntop(AF_INET6, &(((struct sockaddr_in6 *) sockaddress)->sin6_addr), buf, INET6_ADDRSTRLEN);
-  }
-  else
-  {
-    return;
+  if (getIP(TSHttpTxnClientAddrGet(res.txnp), ip)) {
+    s.append(ip);
   }
-  s.append(buf);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/896ce4d3/plugins/header_rewrite/expander.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/expander.cc b/plugins/header_rewrite/expander.cc
index c4a581c..7ab69a7 100644
--- a/plugins/header_rewrite/expander.cc
+++ b/plugins/header_rewrite/expander.cc
@@ -29,34 +29,6 @@
 #include "parser.h"
 #include "expander.h"
 
-// Helper function to cleanly get the IP as a string.
-std::string
-getIP(sockaddr const* s_sockaddr)
-{
-  if (s_sockaddr == NULL)
-    return "";
-
-  char res[INET6_ADDRSTRLEN] = { '\0' };
-
-  switch (s_sockaddr->sa_family) {
-  case AF_INET:
-    {
-      const struct sockaddr_in *s_sockaddr_in = reinterpret_cast<const struct sockaddr_in *>(s_sockaddr);
-      inet_ntop(AF_INET, &s_sockaddr_in->sin_addr, res, INET_ADDRSTRLEN);
-    }
-    break;
-  case AF_INET6:
-    {
-      const struct sockaddr_in6 *s_sockaddr_in6 = reinterpret_cast<const struct sockaddr_in6 *>(s_sockaddr);
-      inet_ntop(AF_INET6, &s_sockaddr_in6->sin6_addr, res, INET6_ADDRSTRLEN);
-    }
-    break;
-  }
-
-  return res;
-}
-
-
 // Main expander method
 std::string
 VariableExpander::expand(const Resources& res)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/896ce4d3/plugins/header_rewrite/factory.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/factory.cc b/plugins/header_rewrite/factory.cc
index c1b8a2e..b9e2fa8 100644
--- a/plugins/header_rewrite/factory.cc
+++ b/plugins/header_rewrite/factory.cc
@@ -109,7 +109,7 @@ condition_factory(const std::string& cond)
     c = new ConditionDBM();
   } else if (c_name == "INTERNAL-TRANSACTION") {
     c = new ConditionInternalTransaction();
-  } else if (c_name == "%<chi>") {
+  } else if (c_name == "CLIENT-IP") {
     c = new ConditionClientIp();
   } else {
     TSError("%s: unknown condition: %s", PLUGIN_NAME, c_name.c_str());

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/896ce4d3/plugins/header_rewrite/lulu.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/lulu.cc b/plugins/header_rewrite/lulu.cc
new file mode 100644
index 0000000..9db1f56
--- /dev/null
+++ b/plugins/header_rewrite/lulu.cc
@@ -0,0 +1,63 @@
+/*
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+
+#include <string>
+
+#include "ts/ts.h"
+#include "lulu.h"
+
+// Helper function to cleanly get the IP as a string.
+char*
+getIP(sockaddr const* s_sockaddr, char res[INET6_ADDRSTRLEN])
+{
+  res[0] = '\0';
+
+  if (s_sockaddr == NULL) {
+    return NULL;
+  }
+
+  switch (s_sockaddr->sa_family) {
+  case AF_INET:
+    {
+      const struct sockaddr_in *s_sockaddr_in = reinterpret_cast<const struct sockaddr_in *>(s_sockaddr);
+      inet_ntop(AF_INET, &s_sockaddr_in->sin_addr, res, INET_ADDRSTRLEN);
+    }
+    break;
+  case AF_INET6:
+    {
+      const struct sockaddr_in6 *s_sockaddr_in6 = reinterpret_cast<const struct sockaddr_in6 *>(s_sockaddr);
+      inet_ntop(AF_INET6, &s_sockaddr_in6->sin6_addr, res, INET6_ADDRSTRLEN);
+    }
+    break;
+  }
+
+  return res[0] ? res : NULL;
+}
+
+// Return it as a std::string instead (more expensive, but sometimes convenient)
+std::string
+getIP(sockaddr const* s_sockaddr)
+{
+  char res[INET6_ADDRSTRLEN] = { '\0' };
+
+  if (getIP(s_sockaddr, res)) {
+    return res;
+  }
+
+  return "";
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/896ce4d3/plugins/header_rewrite/lulu.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/lulu.h b/plugins/header_rewrite/lulu.h
index 2226848..df6226a 100644
--- a/plugins/header_rewrite/lulu.h
+++ b/plugins/header_rewrite/lulu.h
@@ -15,6 +15,7 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 */
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 //
 // Implement the classes for the various types of hash keys we support.
@@ -22,9 +23,15 @@
 #ifndef __LULU_H__
 #define __LULU_H__ 1
 
+#include <string>
+
 #include "ink_defs.h"
 #include "ink_platform.h"
 
+std::string getIP(sockaddr const* s_sockaddr);
+char* getIP(sockaddr const* s_sockaddr, char res[INET6_ADDRSTRLEN]);
+
+
 // Memory barriers
 #if defined(__i386__)
 #define mb()  __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )


[49/50] [abbrv] git commit: TS-2580: SSL Connection reset by peer errors in 4.2.0-rc0 Fixed build error

Posted by bc...@apache.org.
TS-2580: SSL Connection reset by peer errors in 4.2.0-rc0
Fixed build error


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

Branch: refs/heads/5.0.x
Commit: b776404f101b50a98c3e77b414dd9075434b40f2
Parents: 9297edb
Author: Bryan Call <bc...@apache.org>
Authored: Fri May 30 13:13:10 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Fri May 30 13:13:10 2014 -0700

----------------------------------------------------------------------
 iocore/net/SSLNetVConnection.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b776404f/iocore/net/SSLNetVConnection.cc
----------------------------------------------------------------------
diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index 61aaa3e..67aabbc 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -155,7 +155,7 @@ ssl_read_from_net(SSLNetVConnection * sslvc, EThread * lthread, int64_t &ret)
           // not EOF
           event = SSL_READ_ERROR;
           ret = errno;
-          Debug(ssl, "[SSL_NetVConnection::ssl_read_from_net] SSL_ERROR_SYSCALL, underlying IO error: %s", strerror(errno));
+          Debug("ssl", "[SSL_NetVConnection::ssl_read_from_net] SSL_ERROR_SYSCALL, underlying IO error: %s", strerror(errno));
         } else {
           // then EOF observed, treat it as EOS
           event = SSL_READ_EOS;


[32/50] [abbrv] git commit: TS-2857: Cleanup SPDY and SSL stat names

Posted by bc...@apache.org.
TS-2857: Cleanup SPDY and SSL stat names


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

Branch: refs/heads/5.0.x
Commit: d65bc70a5de9f73b61357212e26f88d3d3fb2f25
Parents: d6cdbfd
Author: Bryan Call <bc...@apache.org>
Authored: Wed May 28 20:02:14 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Wed May 28 20:02:14 2014 -0700

----------------------------------------------------------------------
 CHANGES                         |  2 ++
 proxy/http/HttpClientSession.cc |  2 +-
 proxy/http/HttpConfig.cc        |  4 ++--
 proxy/http/HttpConfig.h         |  2 +-
 proxy/spdy/SpdyClientSession.cc | 12 ++++++------
 proxy/spdy/SpdyCommon.cc        | 16 ++++++++--------
 proxy/spdy/SpdyCommon.h         |  8 ++++----
 7 files changed, 24 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d65bc70a/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 237a519..172adbd 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2857] Cleanup SPDY and SSL stat names
+
   *) [TS-2856] Remove proxy.config.spdy.verbose_in and use diags instead
 
   *) [TS-2391] Traffic Server tries to reverse resolve 127.0.0.1

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d65bc70a/proxy/http/HttpClientSession.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpClientSession.cc b/proxy/http/HttpClientSession.cc
index 3f00cd4..1239113 100644
--- a/proxy/http/HttpClientSession.cc
+++ b/proxy/http/HttpClientSession.cc
@@ -192,7 +192,7 @@ HttpClientSession::new_connection(NetVConnection * new_vc, bool backdoor, MIOBuf
   conn_decrease = true;
   HTTP_INCREMENT_DYN_STAT(http_total_client_connections_stat);
   if (static_cast<HttpProxyPort::TransportType>(new_vc->attributes) == HttpProxyPort::TRANSPORT_SSL) {
-    HTTP_INCREMENT_DYN_STAT(https_connection_count_stat);
+    HTTP_INCREMENT_DYN_STAT(https_total_client_connections_stat);
   }
 
   /* inbound requests stat should be incremented here, not after the

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d65bc70a/proxy/http/HttpConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 62d6304..d5184ae 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -1202,8 +1202,8 @@ register_stat_callbacks()
                      "proxy.process.https.incoming_requests",
                      RECD_COUNTER, RECP_PERSISTENT, (int) https_incoming_requests_stat, RecRawStatSyncCount);
   RecRegisterRawStat(http_rsb, RECT_PROCESS,
-                     "proxy.process.https.connection_count",
-                     RECD_COUNTER, RECP_PERSISTENT, (int) https_connection_count_stat, RecRawStatSyncCount);
+                     "proxy.process.https.total_client_connections",
+                     RECD_COUNTER, RECP_PERSISTENT, (int) https_total_client_connections_stat, RecRawStatSyncCount);
 }
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d65bc70a/proxy/http/HttpConfig.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index 4805097..e30257b 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -338,7 +338,7 @@ enum
   http_response_status_5xx_count_stat,
 
   https_incoming_requests_stat,
-  https_connection_count_stat,
+  https_total_client_connections_stat,
 
   http_stat_count
 };

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d65bc70a/proxy/spdy/SpdyClientSession.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyClientSession.cc b/proxy/spdy/SpdyClientSession.cc
index 665510a..cec15e6 100644
--- a/proxy/spdy/SpdyClientSession.cc
+++ b/proxy/spdy/SpdyClientSession.cc
@@ -60,14 +60,14 @@ SpdyRequest::init(SpdyClientSession *sm, int id)
   MD5_Init(&recv_md5);
   start_time = TShrtime();
 
-  SpdyStatIncrCount(Config::STAT_ACTIVE_STREAM_COUNT, sm);
-  SpdyStatIncrCount(Config::STAT_TOTAL_STREAM_COUNT, sm);
+  SpdyStatIncrCount(Config::STAT_CURRENT_CLIENT_STREAM_COUNT, sm);
+  SpdyStatIncrCount(Config::STAT_TOTAL_CLIENT_STREAM_COUNT, sm);
 }
 
 void
 SpdyRequest::clear()
 {
-  SpdyStatDecrCount(Config::STAT_ACTIVE_STREAM_COUNT, spdy_sm);
+  SpdyStatDecrCount(Config::STAT_CURRENT_CLIENT_STREAM_COUNT, spdy_sm);
 
   if (fetch_sm)
     TSFetchDestroy(fetch_sm);
@@ -100,8 +100,8 @@ SpdyClientSession::init(NetVConnection * netvc, spdy::SessionVersion vers)
   // session start event in case of a time out generating a decrement
   // with no increment. It seems a lesser thing to have the thread counts
   // a little off but globally consistent.
-  SpdyStatIncrCount(Config::STAT_ACTIVE_SESSION_COUNT, netvc);
-  SpdyStatIncrCount(Config::STAT_TOTAL_CONNECTION_COUNT, netvc);
+  SpdyStatIncrCount(Config::STAT_CURRENT_CLIENT_SESSION_COUNT, netvc);
+  SpdyStatIncrCount(Config::STAT_TOTAL_CLIENT_CONNECTION_COUNT, netvc);
 
   ink_release_assert(r == 0);
   sm_id = atomic_inc(g_sm_id);
@@ -118,7 +118,7 @@ SpdyClientSession::clear()
 {
   int last_event = event;
 
-  SpdyStatDecrCount(Config::STAT_ACTIVE_SESSION_COUNT, this);
+  SpdyStatDecrCount(Config::STAT_CURRENT_CLIENT_SESSION_COUNT, this);
 
   //
   // SpdyRequest depends on SpdyClientSession,

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d65bc70a/proxy/spdy/SpdyCommon.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCommon.cc b/proxy/spdy/SpdyCommon.cc
index 7e45b9c..3eb01c4 100644
--- a/proxy/spdy/SpdyCommon.cc
+++ b/proxy/spdy/SpdyCommon.cc
@@ -27,11 +27,11 @@
 Config SPDY_CFG;
 
 // statistic names
-static char const * const SPDY_STAT_ACTIVE_SESSION_NAME = "proxy.process.spdy.active_sessions";
-static char const * const SPDY_STAT_ACTIVE_STREAM_NAME = "proxy.process.spdy.active_streams";
-static char const * const SPDY_STAT_TOTAL_STREAM_NAME = "proxy.process.spdy.total_streams";
+static char const * const SPDY_STAT_CURRENT_CLIENT_SESSION_NAME = "proxy.process.spdy.current_client_sessions";
+static char const * const SPDY_STAT_CURRENT_CLIENT_STREAM_NAME = "proxy.process.spdy.current_client_streams";
+static char const * const SPDY_STAT_TOTAL_CLIENT_STREAM_NAME = "proxy.process.spdy.total_client_streams";
 static char const * const SPDY_STAT_TOTAL_TIME_NAME = "proxy.process.spdy.total_time";
-static char const * const SPDY_STAT_TOTAL_CONNECTION_NAME = "proxy.process.spdy.connection_count";
+static char const * const SPDY_STAT_TOTAL_CLIENT_CONNECTION_NAME = "proxy.process.spdy.total_client_connections";
 
 string
 http_date(time_t t)
@@ -54,11 +54,11 @@ spdy_config_load()
 
   // Get our statistics up
   SPDY_CFG.rsb = RecAllocateRawStatBlock(static_cast<int>(Config::N_STATS));
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_ACTIVE_SESSION_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_ACTIVE_SESSION_COUNT), RecRawStatSyncCount);
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_ACTIVE_STREAM_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_ACTIVE_STREAM_COUNT), RecRawStatSyncCount);
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_STREAM_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_STREAM_COUNT), RecRawStatSyncCount);
+  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_CURRENT_CLIENT_SESSION_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_CURRENT_CLIENT_SESSION_COUNT), RecRawStatSyncCount);
+  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_CURRENT_CLIENT_STREAM_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_CURRENT_CLIENT_STREAM_COUNT), RecRawStatSyncCount);
+  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_CLIENT_STREAM_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_CLIENT_STREAM_COUNT), RecRawStatSyncCount);
   RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_TIME_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_STREAM_TIME), RecRawStatSyncSum);
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_CONNECTION_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_CONNECTION_COUNT), RecRawStatSyncCount);
+  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_CLIENT_CONNECTION_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_CLIENT_CONNECTION_COUNT), RecRawStatSyncCount);
 
   return 0;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d65bc70a/proxy/spdy/SpdyCommon.h
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCommon.h b/proxy/spdy/SpdyCommon.h
index b1b37c9..f772d06 100644
--- a/proxy/spdy/SpdyCommon.h
+++ b/proxy/spdy/SpdyCommon.h
@@ -69,11 +69,11 @@ struct Config {
   // Statistics
   /// This is the stat slot index for each statistic.
   enum StatIndex {
-    STAT_ACTIVE_SESSION_COUNT, ///< Current # of active SPDY sessions.
-    STAT_ACTIVE_STREAM_COUNT, ///< Current # of active SPDY streams.
-    STAT_TOTAL_STREAM_COUNT, ///< Total number of streams created.
+    STAT_CURRENT_CLIENT_SESSION_COUNT, ///< Current # of active SPDY sessions.
+    STAT_CURRENT_CLIENT_STREAM_COUNT, ///< Current # of active SPDY streams.
+    STAT_TOTAL_CLIENT_STREAM_COUNT, ///< Total number of streams created.
     STAT_TOTAL_STREAM_TIME,  //< Total stream time
-    STAT_TOTAL_CONNECTION_COUNT, //< Total connections running spdy
+    STAT_TOTAL_CLIENT_CONNECTION_COUNT, //< Total connections running spdy
 
     N_STATS ///< Terminal counter, NOT A STAT INDEX.
   };


[34/50] [abbrv] git commit: TS-2857: Cleanup SPDY and SSL stat names

Posted by bc...@apache.org.
TS-2857: Cleanup SPDY and SSL stat names


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

Branch: refs/heads/5.0.x
Commit: f6e9da4aa2ec5e2ad96b1ebc3f34ee20bb7afbef
Parents: 2ddcc68
Author: Bryan Call <bc...@apache.org>
Authored: Wed May 28 21:28:42 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Wed May 28 21:28:42 2014 -0700

----------------------------------------------------------------------
 proxy/spdy/SpdyClientSession.cc | 2 +-
 proxy/spdy/SpdyCommon.cc        | 4 ++--
 proxy/spdy/SpdyCommon.h         | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f6e9da4a/proxy/spdy/SpdyClientSession.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyClientSession.cc b/proxy/spdy/SpdyClientSession.cc
index cec15e6..331362c 100644
--- a/proxy/spdy/SpdyClientSession.cc
+++ b/proxy/spdy/SpdyClientSession.cc
@@ -399,7 +399,7 @@ spdy_read_fetch_body_callback(spdylay_session * /*session*/, int32_t stream_id,
   if (already < (int64_t)length) {
     if (req->event == TS_FETCH_EVENT_EXT_BODY_DONE) {
       TSHRTime end_time = TShrtime();
-      SpdyStatIncr(Config::STAT_TOTAL_STREAM_TIME, sm, end_time - req->start_time);
+      SpdyStatIncr(Config::STAT_TOTAL_TRANSACTIONS_TIME, sm, end_time - req->start_time);
       Debug("spdy", "----Request[%" PRIu64 ":%d] %s %lld %d", sm->sm_id, req->stream_id,
             req->url.c_str(), (end_time - req->start_time)/TS_HRTIME_MSECOND,
             req->fetch_data_len);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f6e9da4a/proxy/spdy/SpdyCommon.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCommon.cc b/proxy/spdy/SpdyCommon.cc
index 3eb01c4..2adabdb 100644
--- a/proxy/spdy/SpdyCommon.cc
+++ b/proxy/spdy/SpdyCommon.cc
@@ -30,7 +30,7 @@ Config SPDY_CFG;
 static char const * const SPDY_STAT_CURRENT_CLIENT_SESSION_NAME = "proxy.process.spdy.current_client_sessions";
 static char const * const SPDY_STAT_CURRENT_CLIENT_STREAM_NAME = "proxy.process.spdy.current_client_streams";
 static char const * const SPDY_STAT_TOTAL_CLIENT_STREAM_NAME = "proxy.process.spdy.total_client_streams";
-static char const * const SPDY_STAT_TOTAL_TIME_NAME = "proxy.process.spdy.total_time";
+static char const * const SPDY_STAT_TOTAL_TRANSACTIONS_TIME_NAME = "proxy.process.spdy.total_transactions_time";
 static char const * const SPDY_STAT_TOTAL_CLIENT_CONNECTION_NAME = "proxy.process.spdy.total_client_connections";
 
 string
@@ -57,7 +57,7 @@ spdy_config_load()
   RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_CURRENT_CLIENT_SESSION_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_CURRENT_CLIENT_SESSION_COUNT), RecRawStatSyncCount);
   RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_CURRENT_CLIENT_STREAM_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_CURRENT_CLIENT_STREAM_COUNT), RecRawStatSyncCount);
   RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_CLIENT_STREAM_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_CLIENT_STREAM_COUNT), RecRawStatSyncCount);
-  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_TIME_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_STREAM_TIME), RecRawStatSyncSum);
+  RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_TRANSACTIONS_TIME_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_TRANSACTIONS_TIME), RecRawStatSyncSum);
   RecRegisterRawStat(SPDY_CFG.rsb, RECT_PROCESS, SPDY_STAT_TOTAL_CLIENT_CONNECTION_NAME, RECD_INT, RECP_NON_PERSISTENT, static_cast<int>(Config::STAT_TOTAL_CLIENT_CONNECTION_COUNT), RecRawStatSyncCount);
 
   return 0;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f6e9da4a/proxy/spdy/SpdyCommon.h
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCommon.h b/proxy/spdy/SpdyCommon.h
index f772d06..61a8234 100644
--- a/proxy/spdy/SpdyCommon.h
+++ b/proxy/spdy/SpdyCommon.h
@@ -72,7 +72,7 @@ struct Config {
     STAT_CURRENT_CLIENT_SESSION_COUNT, ///< Current # of active SPDY sessions.
     STAT_CURRENT_CLIENT_STREAM_COUNT, ///< Current # of active SPDY streams.
     STAT_TOTAL_CLIENT_STREAM_COUNT, ///< Total number of streams created.
-    STAT_TOTAL_STREAM_TIME,  //< Total stream time
+    STAT_TOTAL_TRANSACTIONS_TIME,  //< Total stream time
     STAT_TOTAL_CLIENT_CONNECTION_COUNT, //< Total connections running spdy
 
     N_STATS ///< Terminal counter, NOT A STAT INDEX.


[27/50] [abbrv] git commit: Add a comment on not using the Insert() APIs, but Set() instead

Posted by bc...@apache.org.
Add a comment on not using the Insert() APIs, but Set() instead


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

Branch: refs/heads/5.0.x
Commit: d24e76b6a34e40becd4f001c48ef9684ab096aed
Parents: f125090
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed May 28 15:51:15 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed May 28 16:03:37 2014 -0600

----------------------------------------------------------------------
 proxy/api/ts/ts.h | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d24e76b6/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 30f14ce..4978903 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -1015,6 +1015,7 @@ extern "C"
 
   tsapi TSReturnCode TSMimeHdrFieldValueAppend(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int idx,
                                                   const char* value, int length);
+  /* These Insert() APIs should be considered. Use the corresponding Set() API instead */
   tsapi TSReturnCode TSMimeHdrFieldValueStringInsert(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int idx,
                                                         const char* value, int length);
   tsapi TSReturnCode TSMimeHdrFieldValueIntInsert(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int idx, int value);


[39/50] [abbrv] git commit: TS-2834 header_rewrite: internal transaction and client IP conditions

Posted by bc...@apache.org.
TS-2834 header_rewrite: internal transaction and client IP conditions


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

Branch: refs/heads/5.0.x
Commit: 05f64b6ebcf35b1916ff6663fac57e4d5b3049fa
Parents: 52682da
Author: Manjesh Nilange <ma...@yahoo.com>
Authored: Thu May 22 15:01:55 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu May 29 14:29:54 2014 -0600

----------------------------------------------------------------------
 plugins/header_rewrite/conditions.cc | 49 ++++++++++++++++++++++++++++++-
 plugins/header_rewrite/conditions.h  | 19 ++++++++++++
 plugins/header_rewrite/factory.cc    |  4 +++
 3 files changed, 71 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/05f64b6e/plugins/header_rewrite/conditions.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index 9010152..721a781 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -21,13 +21,13 @@
 //
 #include <sys/time.h>
 #include <unistd.h>
+#include <arpa/inet.h>
 
 #include "ts/ts.h"
 
 #include "conditions.h"
 #include "lulu.h"
 
-
 // ConditionStatus
 void
 ConditionStatus::initialize(Parser& p)
@@ -445,3 +445,50 @@ bool ConditionCookie::eval(const Resources& res)
   TSDebug(PLUGIN_NAME, "Evaluating COOKIE(%s): %s: rval: %d", _qualifier.c_str(), s.c_str(), rval);
   return rval;
 }
+
+bool ConditionInternalTransaction::eval(const Resources& res)
+{
+  return TSHttpIsInternalRequest(res.txnp) == TS_SUCCESS;
+}
+
+void ConditionClientIp::initialize(Parser &p)
+{
+  Condition::initialize(p);
+
+  Matchers<std::string>* match = new Matchers<std::string>(_cond_op);
+  match->set(p.get_arg());
+
+  _matcher = match;
+}
+
+bool ConditionClientIp::eval(const Resources &res)
+{
+  std::string s;
+  append_value(s, res);
+  bool rval = static_cast<const Matchers<std::string>*>(_matcher)->test(s);
+  return rval;
+}
+
+void ConditionClientIp::append_value(std::string &s, const Resources &res)
+{
+  const sockaddr *sockaddress = TSHttpTxnClientAddrGet(res.txnp);
+  if (sockaddress == NULL) {
+    return;
+  }
+
+  char buf[INET6_ADDRSTRLEN] = { 0 };
+
+  if (sockaddress->sa_family == AF_INET)
+  {
+    inet_ntop(AF_INET, &(((struct sockaddr_in *) sockaddress)->sin_addr), buf, INET_ADDRSTRLEN);
+  }
+  else if (sockaddress->sa_family == AF_INET6)
+  {
+    inet_ntop(AF_INET6, &(((struct sockaddr_in6 *) sockaddress)->sin6_addr), buf, INET6_ADDRSTRLEN);
+  }
+  else
+  {
+    return;
+  }
+  s.append(buf);
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/05f64b6e/plugins/header_rewrite/conditions.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.h b/plugins/header_rewrite/conditions.h
index deb3142..55e0106 100644
--- a/plugins/header_rewrite/conditions.h
+++ b/plugins/header_rewrite/conditions.h
@@ -330,4 +330,23 @@ private:
   TSMutex _mutex;
 };
 
+class ConditionInternalTransaction : public Condition
+{
+public:
+  void append_value(std::string &/* s ATS_UNUSED */, const Resources &/* res ATS_UNUSED */) { }
+
+protected:
+  bool eval(const Resources &res);
+};
+
+class ConditionClientIp : public Condition
+{
+public:
+  void initialize(Parser& p);
+  void append_value(std::string &s, const Resources &res);
+
+protected:
+  bool eval(const Resources &res);
+};
+
 #endif // __CONDITIONS_H

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/05f64b6e/plugins/header_rewrite/factory.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/factory.cc b/plugins/header_rewrite/factory.cc
index 66087fc..c1b8a2e 100644
--- a/plugins/header_rewrite/factory.cc
+++ b/plugins/header_rewrite/factory.cc
@@ -107,6 +107,10 @@ condition_factory(const std::string& cond)
     c = new ConditionUrl(true);
   } else if (c_name == "DBM") {
     c = new ConditionDBM();
+  } else if (c_name == "INTERNAL-TRANSACTION") {
+    c = new ConditionInternalTransaction();
+  } else if (c_name == "%<chi>") {
+    c = new ConditionClientIp();
   } else {
     TSError("%s: unknown condition: %s", PLUGIN_NAME, c_name.c_str());
     return NULL;


[42/50] [abbrv] git commit: Revert "TS-2095: autoconf warnings related to unordered_map"

Posted by bc...@apache.org.
Revert "TS-2095: autoconf warnings related to unordered_map"

This reverts commit 89f19acec7ecaeebe13bc0229f463efaf1543047.


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

Branch: refs/heads/5.0.x
Commit: 11c329f2a2bc25c13a6c1f943f88a124ac1421bf
Parents: 89f19ac
Author: Bryan Call <bc...@apache.org>
Authored: Thu May 29 13:50:39 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Thu May 29 13:50:39 2014 -0700

----------------------------------------------------------------------
 CHANGES      | 2 --
 configure.ac | 1 -
 2 files changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/11c329f2/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 5166281..dc132b3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,6 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
-  *) [TS-2095] autoconf warnings related to unordered_map
-
   *) [TS-2834] header_rewrite: Add Internal transaction and client-IP
    conditions.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/11c329f2/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 2cbb5af..29520c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -566,7 +566,6 @@ AX_CXX_COMPILE_STDCXX_11( [noext], [enable_cxx_11_support=yes], [
 AM_CONDITIONAL([BUILD_HAVE_CXX_11], [ test "x${enable_cxx_11_support}" = "xyes" ])
 if test "x${enable_cxx_11_support}" = "xyes" ; then
   AC_DEFINE(HAVE_CXX_11, 1, [Whether the compiler support C++11])
-  TS_ADDTO(CPPFLAGS, [-std=c++11])
 fi
 
 # While we are in C++ mode, check for the GNU hash_map extension.


[35/50] [abbrv] git commit: TS-2858 Build failures on OmniOS

Posted by bc...@apache.org.
TS-2858 Build failures on OmniOS


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

Branch: refs/heads/5.0.x
Commit: 1cb12a93a0df96e5c38e77076bcc1337e4caaa31
Parents: f6e9da4
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu May 29 12:07:09 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu May 29 12:10:19 2014 -0600

----------------------------------------------------------------------
 CHANGES                                                  | 3 +++
 configure.ac                                             | 6 ++++--
 lib/Makefile.am                                          | 9 ++++++---
 plugins/experimental/regex_revalidate/regex_revalidate.c | 7 ++++++-
 proxy/Makefile.am                                        | 2 +-
 5 files changed, 20 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1cb12a93/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 172adbd..dbfc39b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2858] Build failures on OmniOS. Also add some LuaJIT flags as per
+   Theo's and Daniel's recommendations.
+
   *) [TS-2857] Cleanup SPDY and SSL stat names
 
   *) [TS-2856] Remove proxy.config.spdy.verbose_in and use diags instead

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1cb12a93/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index a324025..fa69263 100644
--- a/configure.ac
+++ b/configure.ac
@@ -652,6 +652,7 @@ case $host_os in
       *amd64*)
         TS_ADDTO(CFLAGS, -m64)
         TS_ADDTO(CXXFLAGS, -m64)
+        TS_ADDTO(LUA_LDFLAGS, -m64)
         ;;
     esac
     ;;
@@ -1399,11 +1400,12 @@ AX_LIB_READLINE
 # http://luajit.org/install.html.
 case $host_os_def in
   darwin)
-    LUA_LUAJIT_LDFLAGS="-Wl,-pagezero_size,10000 -Wl,-image_base,100000000"
+    TS_LUAJIT_LDFLAGS="-Wl,-pagezero_size,10000 -Wl,-image_base,100000000"
     ;;
 esac
 
-AC_SUBST(LUA_LUAJIT_LDFLAGS)
+AC_SUBST(TS_LUAJIT_LDFLAGS)
+AC_SUBST(LUA_LDFLAGS)
 
 # We should be able to build http_load if epoll(2) is available.
 AM_CONDITIONAL([BUILD_HTTP_LOAD], [test x"$ac_cv_func_epoll_ctl" = x"yes"])

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1cb12a93/lib/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 6d8dee6..cf45bd6 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -36,13 +36,16 @@ endif
 #  - Copy the luajit source tree if we're doing out-of-source builds
 #  - Upon clean, remove the luajit tree from the out-of-source build tree
 #
-# ToDo: Can we do this without copying the source? I tried setting the VPATH, but
-#       it did not work. Can we make more intelligent build targets, avoiding [ test ] ?
+# Note: The LUA_LDFLAGS is a bit of a hack, since LuaJIT on OmniOS needs
+#       the -m64 flag. See configure.ac.
+#
+LUA_CFLAGS=$(CFLAGS) -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN
+
 all-local:
 	@echo "Making all in luajit"
 	test -d "$(top_srcdir)/$(subdir)/luajit/src" || (cd "$(top_srcdir)" && git submodule update --init)
 	test -d "$(top_builddir)/$(subdir)/luajit/src" || cp -rf "$(srcdir)/luajit" "$(top_builddir)/$(subdir)/"
-	cd luajit && $(MAKE) $(AM_MAKEFLAGS) PREFIX="$(prefix)" CC="$(CC)" CFLAGS="$(CFLAGS)"
+	cd luajit && $(MAKE) $(AM_MAKEFLAGS) PREFIX="$(prefix)" CC="$(CC)" CFLAGS="$(LUA_CFLAGS)" LDFLAGS="@LUA_LDFLAGS@"
 
 clean-local:
 	test "$(top_srcdir)" != "$(top_builddir)" || (cd "$(top_builddir)/$(subdir)/luajit" && make clean)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1cb12a93/plugins/experimental/regex_revalidate/regex_revalidate.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/regex_revalidate/regex_revalidate.c b/plugins/experimental/regex_revalidate/regex_revalidate.c
index 11edebf..4f6baa0 100644
--- a/plugins/experimental/regex_revalidate/regex_revalidate.c
+++ b/plugins/experimental/regex_revalidate/regex_revalidate.c
@@ -32,9 +32,14 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <pcre.h>
 #include <ts/ts.h>
 
+#ifdef HAVE_PCRE_PCRE_H
+#  include <pcre/pcre.h>
+#else
+#  include <pcre.h>
+#endif
+
 #define LOG_PREFIX        "regex_revalidate"
 #define CONFIG_TMOUT      60000
 #define FREE_TMOUT        300000

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1cb12a93/proxy/Makefile.am
----------------------------------------------------------------------
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index 755c894..739840a 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -235,7 +235,7 @@ traffic_server_LDADD = \
 
 # On Darwin LuaJIT requires magic link options, otherwise it will crash in luaL_openlibs() at startup. See
 # http://luajit.org/install.html.
-traffic_server_LDFLAGS += @LUA_LUAJIT_LDFLAGS@
+traffic_server_LDFLAGS += @TS_LUAJIT_LDFLAGS@
 
 traffic_logcat_SOURCES = logcat.cc
 traffic_logcat_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@


[11/50] [abbrv] git commit: TS-2804: Use TSConfigDir.

Posted by bc...@apache.org.
TS-2804: Use TSConfigDir.


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

Branch: refs/heads/5.0.x
Commit: d4ed204fc947ba6692a58f1c768dee238d38249c
Parents: 930ce49
Author: Justin Laue <ju...@fp-x.com>
Authored: Tue May 13 16:10:01 2014 -0600
Committer: Phil Sorber <so...@apache.org>
Committed: Mon May 26 14:32:34 2014 -0600

----------------------------------------------------------------------
 plugins/experimental/regex_revalidate/regex_revalidate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d4ed204f/plugins/experimental/regex_revalidate/regex_revalidate.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/regex_revalidate/regex_revalidate.c b/plugins/experimental/regex_revalidate/regex_revalidate.c
index 9e62a1a..11edebf 100644
--- a/plugins/experimental/regex_revalidate/regex_revalidate.c
+++ b/plugins/experimental/regex_revalidate/regex_revalidate.c
@@ -228,9 +228,9 @@ load_config(plugin_state_t *pstate, invalidate_t **ilist)
 
     if (pstate->config_file[0] != '/')
     {
-        path_len = strlen(TSPluginDirGet()) + strlen(pstate->config_file) + 2;
+        path_len = strlen(TSConfigDirGet()) + strlen(pstate->config_file) + 2;
         path = alloca(path_len);
-        snprintf(path, path_len, "%s/%s", TSPluginDirGet(), pstate->config_file);
+        snprintf(path, path_len, "%s/%s", TSConfigDirGet(), pstate->config_file);
     }
     else
         path = pstate->config_file;


[38/50] [abbrv] git commit: TS-2855: add TSHttpIsInternalSession API

Posted by bc...@apache.org.
TS-2855: add TSHttpIsInternalSession API

Add TSHttpIsInternalSession API to be symmetric with
TSHttpIsInternalRequest.


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

Branch: refs/heads/5.0.x
Commit: 52682da919945fce6097d5fa50e024a6f7fb5da6
Parents: e7586df
Author: James Peach <jp...@apache.org>
Authored: Wed May 28 16:51:46 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu May 29 12:33:26 2014 -0700

----------------------------------------------------------------------
 CHANGES                                         |  2 +
 .../api/TSHttpIsInternalRequest.en.rst          | 59 ++++++++++++++++++++
 plugins/tcpinfo/tcpinfo.cc                      |  5 ++
 proxy/InkAPI.cc                                 | 18 ++++--
 proxy/api/ts/ts.h                               |  1 +
 5 files changed, 79 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/52682da9/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 7e70311..ab72cd1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2855] Add the TSHttpIsInternalSession API.
+
   *) [TS-2859] Remove DBG macros to not generate warnings from GCC 4.9.
 
   *) [TS-2858] Build failures on OmniOS. Also add some LuaJIT flags as per

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/52682da9/doc/reference/api/TSHttpIsInternalRequest.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/TSHttpIsInternalRequest.en.rst b/doc/reference/api/TSHttpIsInternalRequest.en.rst
new file mode 100644
index 0000000..2ac5b2d
--- /dev/null
+++ b/doc/reference/api/TSHttpIsInternalRequest.en.rst
@@ -0,0 +1,59 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+       http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+.. default-domain:: c
+
+=======================
+TSHttpIsInternalRequest
+=======================
+
+Test whether a request is internally-generated.
+
+Synopsis
+========
+`#include <ts/ts.h>`
+
+.. function:: TSReturnCode TSHttpIsInternalRequest(TSHttpTxn txnp)
+.. function:: TSReturnCode TSHttpIsInternalSession(TSHttpSsn ssnp)
+
+Description
+===========
+
+:func:`TSHttpIsInternalRequest` tests whether a HTTP transaction
+was originated within Traffic Server.
+
+:func:`TSHttpIsInternalSession` tests whether a HTTP session
+was originated within Traffic Server.
+
+Return Values
+=============
+
+Both these APIs returns a :type:`TSReturnCode`, indicating whether the
+object was internal (:data:`TS_SUCCESS`) or not (:data:`TS_ERROR`).
+
+Examples
+========
+
+The ESI plugin uses :func:`TSHttpIsInternalRequest` to ignore requests that is
+had generated while fetching portions of an ESI document:
+
+.. literalinclude:: ../../../plugins/experimental/esi/esi.cc
+  :language: c
+  :lines: 1395-1398
+
+See also
+========
+:manpage:`TSAPI(3ts)`

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/52682da9/plugins/tcpinfo/tcpinfo.cc
----------------------------------------------------------------------
diff --git a/plugins/tcpinfo/tcpinfo.cc b/plugins/tcpinfo/tcpinfo.cc
index 65ad25b..481f553 100644
--- a/plugins/tcpinfo/tcpinfo.cc
+++ b/plugins/tcpinfo/tcpinfo.cc
@@ -234,6 +234,11 @@ tcp_info_hook(TSCont contp, TSEvent event, void *edata)
     goto done;
   }
 
+  // Don't try to sample internal requests. TCP metrics for loopback are not interesting.
+  if (TSHttpIsInternalSession(ssnp) == TS_SUCCESS) {
+    goto done;
+  }
+
   // no need to run rand if we are always going log (100%)
   if (config->sample < 1000) {
     random = rand() % 1000;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/52682da9/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 3811292..00501b2 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7387,22 +7387,28 @@ TSFetchRespHdrMLocGet(TSFetchSM fetch_sm)
 }
 
 TSReturnCode
-TSHttpIsInternalRequest(TSHttpTxn txnp)
+TSHttpIsInternalSession(TSHttpSsn ssnp)
 {
-  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
-
-  TSHttpSsn ssnp = TSHttpTxnSsnGet(txnp);
   HttpClientSession *cs = (HttpClientSession *) ssnp;
-  if (!cs)
+  if (!cs) {
     return TS_ERROR;
+  }
 
   NetVConnection *vc = cs->get_netvc();
-  if (!vc)
+  if (!vc) {
     return TS_ERROR;
+  }
 
   return vc->get_is_internal_request() ? TS_SUCCESS : TS_ERROR;
 }
 
+TSReturnCode
+TSHttpIsInternalRequest(TSHttpTxn txnp)
+{
+  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+  return TSHttpIsInternalSession(TSHttpTxnSsnGet(txnp));
+}
+
 
 TSReturnCode
 TSAIORead(int fd, off_t offset, char* buf, size_t buffSize, TSCont contp)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/52682da9/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 4978903..e00aa68 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -1623,6 +1623,7 @@ extern "C"
 
   /* Check if HTTP State machine is internal or not */
   tsapi TSReturnCode TSHttpIsInternalRequest(TSHttpTxn txnp);
+  tsapi TSReturnCode TSHttpIsInternalSession(TSHttpSsn ssnp);
 
   /* --------------------------------------------------------------------------
      HTTP alternate selection */


[13/50] [abbrv] git commit: Bump lighttpd version

Posted by bc...@apache.org.
Bump lighttpd version


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

Branch: refs/heads/5.0.x
Commit: 27e7c177d221bd153025bc0fc9467bd661ddc18f
Parents: d4ed204
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue May 27 08:48:49 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue May 27 08:48:49 2014 -0600

----------------------------------------------------------------------
 tools/lighttpd_mod_generator/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/27e7c177/tools/lighttpd_mod_generator/Makefile
----------------------------------------------------------------------
diff --git a/tools/lighttpd_mod_generator/Makefile b/tools/lighttpd_mod_generator/Makefile
index d1f722d..c1ce5be 100644
--- a/tools/lighttpd_mod_generator/Makefile
+++ b/tools/lighttpd_mod_generator/Makefile
@@ -18,7 +18,7 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-VERSION=1.4.30
+VERSION=1.4.35
 
 all: mod_generator.so
 


[30/50] [abbrv] git commit: TS-2856: Remove proxy.config.spdy.verbose_in and use diags instead

Posted by bc...@apache.org.
TS-2856: Remove proxy.config.spdy.verbose_in and use diags instead


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

Branch: refs/heads/5.0.x
Commit: d0f4d5c47272dd2ab87fc3db6271553864822887
Parents: d22f989
Author: Bryan Call <bc...@apache.org>
Authored: Wed May 28 17:29:10 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Wed May 28 17:29:10 2014 -0700

----------------------------------------------------------------------
 CHANGES                                           | 2 ++
 doc/reference/configuration/records.config.en.rst | 5 -----
 mgmt/RecordsConfig.cc                             | 2 --
 proxy/spdy/SpdyClientSession.cc                   | 4 ++--
 proxy/spdy/SpdyCommon.cc                          | 1 -
 proxy/spdy/SpdyCommon.h                           | 1 -
 6 files changed, 4 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d0f4d5c4/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 50ce778..237a519 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2856] Remove proxy.config.spdy.verbose_in and use diags instead
+
   *) [TS-2391] Traffic Server tries to reverse resolve 127.0.0.1
 
   *) [TS-2837] Dangling pointer in URLImpl which may cause core dump

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d0f4d5c4/doc/reference/configuration/records.config.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/configuration/records.config.en.rst b/doc/reference/configuration/records.config.en.rst
index df8dcd4..21a1407 100644
--- a/doc/reference/configuration/records.config.en.rst
+++ b/doc/reference/configuration/records.config.en.rst
@@ -2264,11 +2264,6 @@ SPDY Configuration
 
    .. note:: Reloading this value affects only new SPDY connections, not existing connects.
 
-.. ts:cv:: CONFIG proxy.config.spdy.verbose_in INT 0
-   :reloadable:
-
-   Set the verbose flag for SPDY streams on inbound connections. ``0`` means disable, any other value is enable.
-
 Scheduled Update Configuration
 ==============================
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d0f4d5c4/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index b94e44c..8f80480 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -1937,8 +1937,6 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.spdy.initial_window_size_in", RECD_INT, "65536", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.spdy.verbose_in", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
-  ,
   {RECT_CONFIG, "proxy.config.spdy.accept_no_activity_timeout", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d0f4d5c4/proxy/spdy/SpdyClientSession.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyClientSession.cc b/proxy/spdy/SpdyClientSession.cc
index 47f57c3..665510a 100644
--- a/proxy/spdy/SpdyClientSession.cc
+++ b/proxy/spdy/SpdyClientSession.cc
@@ -389,7 +389,7 @@ spdy_read_fetch_body_callback(spdylay_session * /*session*/, int32_t stream_id,
 
   Debug("spdy", "    stream_id:%d, call:%d, length:%ld, already:%" PRId64,
         stream_id, g_call_cnt, length, already);
-  if (SPDY_CFG.spdy.verbose)
+  if (is_debug_tag_set("spdy"))
     MD5_Update(&req->recv_md5, buf, already);
 
   TSVIOReenable(sm->write_vio);
@@ -404,7 +404,7 @@ spdy_read_fetch_body_callback(spdylay_session * /*session*/, int32_t stream_id,
             req->url.c_str(), (end_time - req->start_time)/TS_HRTIME_MSECOND,
             req->fetch_data_len);
       unsigned char digest[MD5_DIGEST_LENGTH];
-      if (SPDY_CFG.spdy.verbose ) {
+      if (is_debug_tag_set("spdy")) {
         MD5_Final(digest, &req->recv_md5);
         Debug("spdy", "----recv md5sum: ");
         for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d0f4d5c4/proxy/spdy/SpdyCommon.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCommon.cc b/proxy/spdy/SpdyCommon.cc
index d5687f4..7e45b9c 100644
--- a/proxy/spdy/SpdyCommon.cc
+++ b/proxy/spdy/SpdyCommon.cc
@@ -46,7 +46,6 @@ int
 spdy_config_load()
 {
   REC_EstablishStaticConfigInt32(SPDY_CFG.spdy.max_concurrent_streams, "proxy.config.spdy.max_concurrent_streams_in");
-  REC_EstablishStaticConfigBool(SPDY_CFG.spdy.verbose, "proxy.config.spdy.verbose_in");
   REC_EstablishStaticConfigInt32(SPDY_CFG.no_activity_timeout_in, "proxy.config.spdy.no_activity_timeout_in");
   REC_EstablishStaticConfigInt32(SPDY_CFG.accept_no_activity_timeout, "proxy.config.spdy.accept_no_activity_timeout");
   REC_EstablishStaticConfigInt32(SPDY_CFG.spdy.initial_window_size, "proxy.config.spdy.initial_window_size_in");

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d0f4d5c4/proxy/spdy/SpdyCommon.h
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCommon.h b/proxy/spdy/SpdyCommon.h
index 330a979..b1b37c9 100644
--- a/proxy/spdy/SpdyCommon.h
+++ b/proxy/spdy/SpdyCommon.h
@@ -56,7 +56,6 @@ using namespace std;
 #define atomic_dec(a)   atomic_fetch_and_sub(a, 1)
 
 struct SpdyConfig {
-  bool verbose;
   int32_t max_concurrent_streams;
   int32_t initial_window_size;
   spdylay_session_callbacks callbacks;


[28/50] [abbrv] git commit: TS-2837: Dangling pointer in URLImpl which may cause core dump Reviewed: Bryan Call

Posted by bc...@apache.org.
TS-2837: Dangling pointer in URLImpl which may cause core dump
Reviewed: Bryan Call


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

Branch: refs/heads/5.0.x
Commit: f4e9fd61953de3647351aa0ccb2775091cdbf701
Parents: b0ed3da
Author: Kang Li <ka...@yahoo-inc.com>
Authored: Wed May 28 15:11:48 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Wed May 28 15:11:48 2014 -0700

----------------------------------------------------------------------
 CHANGES           | 2 ++
 proxy/hdrs/URL.cc | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f4e9fd61/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 84a8ccc..134d5cd 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2837] Dangling pointer in URLImpl which may cause core dump
+
   *) [TS-2842] Can't set SPDY inactivity timeout with traffic_line
 
   *) [TS-2618] IOBufferBlock::realloc()'s bounds check is wrong.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f4e9fd61/proxy/hdrs/URL.cc
----------------------------------------------------------------------
diff --git a/proxy/hdrs/URL.cc b/proxy/hdrs/URL.cc
index e9b64cd..6a6195f 100644
--- a/proxy/hdrs/URL.cc
+++ b/proxy/hdrs/URL.cc
@@ -356,7 +356,7 @@ URLImpl::move_strings(HdrStrHeap * new_heap)
   HDR_MOVE_STR(m_ptr_params, m_len_params);
   HDR_MOVE_STR(m_ptr_query, m_len_query);
   HDR_MOVE_STR(m_ptr_fragment, m_len_fragment);
-//    HDR_MOVE_STR(m_ptr_printed_string, m_len_printed_string);
+  HDR_MOVE_STR(m_ptr_printed_string, m_len_printed_string);
 }
 
 size_t


[07/50] [abbrv] git commit: TS-2555: update README.md for ts_lua plugin

Posted by bc...@apache.org.
TS-2555: update README.md for ts_lua plugin


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

Branch: refs/heads/5.0.x
Commit: b304cf0c16a7f8e47d10e499874c283fa3ba420b
Parents: 84517e5
Author: Kit Chan <ki...@apache.org>
Authored: Sun May 25 01:05:43 2014 -0700
Committer: Kit Chan <ki...@apache.org>
Committed: Sun May 25 01:05:43 2014 -0700

----------------------------------------------------------------------
 plugins/experimental/ts_lua/README.md | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b304cf0c/plugins/experimental/ts_lua/README.md
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/README.md b/plugins/experimental/ts_lua/README.md
index 6efbbd1..4e1c447 100644
--- a/plugins/experimental/ts_lua/README.md
+++ b/plugins/experimental/ts_lua/README.md
@@ -3,7 +3,3 @@ Name
 
 ts-lua - Embed the Power of Lua into TrafficServer.
 
-Documentation
-======
-http://trafficserver.readthedocs.org/en/latest/reference/plugins/ts_lua.en.html
-


[47/50] [abbrv] git commit: TS-2783 Update documentation defaults, and fix RecordsConfig.cc

Posted by bc...@apache.org.
TS-2783 Update documentation defaults, and fix RecordsConfig.cc


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

Branch: refs/heads/5.0.x
Commit: 879bedcebeca8a354d2ee910183c8ed241c10f79
Parents: 3e81811
Author: Leif Hedstrom <zw...@apache.org>
Authored: Fri May 30 13:36:44 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Fri May 30 13:36:44 2014 -0600

----------------------------------------------------------------------
 CHANGES                                         |   2 +
 doc/admin/security-options.en.rst               |   1 -
 .../ja/LC_MESSAGES/admin/security-options.en.po |   4 -
 .../configuration/records.config.en.rst         | 130 +++++++++----------
 lib/perl/lib/Apache/TS/AdminClient.pm           |   1 -
 mgmt/RecordsConfig.cc                           |   8 +-
 proxy/config/records.config.default.in          |   1 +
 7 files changed, 68 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/879bedce/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index cfca250..3b25d18 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2783] Update documentation defaults, and fix RecordsConfig.cc.
+
   *) [TS-1981] Url remap method filtering is broken with invalid method.
    Author: Thach Tran <tr...@gmail.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/879bedce/doc/admin/security-options.en.rst
----------------------------------------------------------------------
diff --git a/doc/admin/security-options.en.rst b/doc/admin/security-options.en.rst
index d9534ec..3806d4f 100644
--- a/doc/admin/security-options.en.rst
+++ b/doc/admin/security-options.en.rst
@@ -213,7 +213,6 @@ In order to accomplish this, we:
 1. Edit the following variables in the :ref:`records-config-ssl-termination` section of
    :file:`records.config`:
 
-   -  :ts:cv:`proxy.config.ssl.auth.enabled`
    -  :ts:cv:`proxy.config.http.server_ports`
    -  :ts:cv:`proxy.config.ssl.client.verify.server`
    -  :ts:cv:`proxy.config.ssl.client.cert.filename`

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/879bedce/doc/locale/ja/LC_MESSAGES/admin/security-options.en.po
----------------------------------------------------------------------
diff --git a/doc/locale/ja/LC_MESSAGES/admin/security-options.en.po b/doc/locale/ja/LC_MESSAGES/admin/security-options.en.po
index 1ba236e..a099dfc 100644
--- a/doc/locale/ja/LC_MESSAGES/admin/security-options.en.po
+++ b/doc/locale/ja/LC_MESSAGES/admin/security-options.en.po
@@ -456,10 +456,6 @@ msgstr ""
 ":file:`records.config`: の :ref:`records-config-ssl-termination` の章にある"
 "次の変数を編集してください。"
 
-#: ../../admin/security-options.en.rst:216
-msgid ":ts:cv:`proxy.config.ssl.auth.enabled`"
-msgstr ":ts:cv:`proxy.config.ssl.auth.enabled`"
-
 #: ../../admin/security-options.en.rst:218
 msgid ":ts:cv:`proxy.config.ssl.client.verify.server`"
 msgstr ":ts:cv:`proxy.config.ssl.client.verify.server`"

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/879bedce/doc/reference/configuration/records.config.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/configuration/records.config.en.rst b/doc/reference/configuration/records.config.en.rst
index 21a1407..4c6526c 100644
--- a/doc/reference/configuration/records.config.en.rst
+++ b/doc/reference/configuration/records.config.en.rst
@@ -185,13 +185,13 @@ System Variables
 
 A value of ``0`` means no signal will be sent.
 
-.. ts:cv:: CONFIG proxy.config.cop.linux_min_memfree_kb INT 10240
+.. ts:cv:: CONFIG proxy.config.cop.linux_min_memfree_kb INT 0
 
    The minimum amount of free memory space allowed before Traffic Server stops
    the :program:`traffic_server` and :program:`traffic_manager` processes to 
    prevent the system from hanging.
 
-.. ts:cv:: CONFIG proxy.config.cop.linux_min_swapfree_kb INT 10240
+.. ts:cv:: CONFIG proxy.config.cop.linux_min_swapfree_kb INT 0
 
    The minimum amount of free swap space allowed before Traffic Server stops
    the :program:`traffic_server` and :program:`traffic_manager` processes to 
@@ -223,11 +223,11 @@ A value of ``0`` means no signal will be sent.
 
    *XXX* What does this do?
 
-.. ts:cv:: CONFIG proxy.config.accept_threads INT 0
+.. ts:cv:: CONFIG proxy.config.accept_threads INT 1
 
    When enabled (``1``), runs a separate thread for accept processing. If disabled (``0``), then only 1 thread can be created.
 
-.. ts:cv:: CONFIG proxy.config.thread.default.stacksize  INT 1096908
+.. ts:cv:: CONFIG proxy.config.thread.default.stacksize  INT 1048576
 
    The new default thread stack size, for all threads. The original default is set at 1 MB.
 
@@ -256,7 +256,7 @@ Value Effect
 Network
 =======
 
-.. ts:cv:: CONFIG proxy.config.net.connections_throttle INT 10000
+.. ts:cv:: CONFIG proxy.config.net.connections_throttle INT 30000
 
    The total number of client and origin server connections that the server
    can handle simultaneously. This is in fact the max number of file
@@ -626,7 +626,7 @@ Value Effect
    The Server: string that ATS will insert in a response header (if requested, see above). Note that the current version number is
    always appended to this string.
 
-.. ts:cv:: CONFIG proxy.config.http.enable_url_expandomatic INT 1
+.. ts:cv:: CONFIG proxy.config.http.enable_url_expandomatic INT 0
    :reloadable:
 
    Enables (``1``) or disables (``0``) ``.com`` domain expansion. This configures the Traffic Server to resolve unqualified hostnames by
@@ -652,10 +652,12 @@ Value Effect
        Server can use ``keep-alive`` connections without pipelining to
        origin servers.
 
-.. ts:cv:: CONFIG proxy.config.http.share_server_sessions INT 1
+.. ts:cv:: CONFIG proxy.config.http.share_server_sessions INT 2
    :deprecated:
 
-   Enables (``1``) or disables (``0``) the reuse of server sessions.
+   Enables (``1``) or disables (``0``) the reuse of server sessions. The
+   default (``2``) is similar to enabled, except it creates a server session
+   pool per network thread. This has the best performance characteristics.
 
 .. ts:cv:: CONFIG proxy.config.http.server_session_sharing.match STRING both
 
@@ -744,11 +746,11 @@ suffice. It is possible to do this crudely with this flag by
 enabling it and then use identity URL mappings to re-disable it for
 specific domains.
 
-.. ts:cv:: CONFIG proxy.config.http.keep_alive_enabled_in  INT 0
+.. ts:cv:: CONFIG proxy.config.http.keep_alive_enabled_in  INT 1
 
    Enables (``1``) or disables (``0``) incoming keep-alive connections.
 
-.. ts:cv:: CONFIG proxy.config.http.keep_alive_enabled_out  INT 0
+.. ts:cv:: CONFIG proxy.config.http.keep_alive_enabled_out  INT 1
 
    Enables (``1``) or disables (``0``) outgoing keep-alive connections.
 
@@ -757,7 +759,7 @@ specific domains.
         requests when nearing the connection limit, that is controlled by
         :ts:cv:`proxy.config.http.server_max_connections`.
 
-.. ts:cv:: CONFIG proxy.config.http.keep_alive_post_out  INT 0
+.. ts:cv:: CONFIG proxy.config.http.keep_alive_post_out  INT 1
 
    Controls wether new POST requests re-use keep-alive sessions (``1``) or
    create new connections per request (``0``).
@@ -813,22 +815,22 @@ Parent Proxy Configuration
 HTTP Connection Timeouts
 ========================
 
-.. ts:cv:: CONFIG proxy.config.http.keep_alive_no_activity_timeout_in INT 10
+.. ts:cv:: CONFIG proxy.config.http.keep_alive_no_activity_timeout_in INT 115
    :reloadable:
 
    Specifies how long Traffic Server keeps connections to clients open for a subsequent request after a transaction ends.
 
-.. ts:cv:: CONFIG proxy.config.http.keep_alive_no_activity_timeout_out INT 10
+.. ts:cv:: CONFIG proxy.config.http.keep_alive_no_activity_timeout_out INT 120
    :reloadable:
 
    Specifies how long Traffic Server keeps connections to origin servers open for a subsequent transfer of data after a transaction ends.
 
-.. ts:cv:: CONFIG proxy.config.http.transaction_no_activity_timeout_in INT 120
+.. ts:cv:: CONFIG proxy.config.http.transaction_no_activity_timeout_in INT 30
    :reloadable:
 
    Specifies how long Traffic Server keeps connections to clients open if a transaction stalls.
 
-.. ts:cv:: CONFIG proxy.config.http.transaction_no_activity_timeout_out INT 120
+.. ts:cv:: CONFIG proxy.config.http.transaction_no_activity_timeout_out INT 30
    :reloadable:
 
    Specifies how long Traffic Server keeps connections to origin servers open if the transaction stalls.
@@ -854,12 +856,12 @@ The default value of ``0`` specifies that there is no timeout.
 
    The timeout interval in seconds before Traffic Server closes a connection that has no activity.
 
-.. ts:cv:: CONFIG proxy.config.http.background_fill_active_timeout INT 60
+.. ts:cv:: CONFIG proxy.config.http.background_fill_active_timeout INT 0
    :reloadable:
 
    Specifies how long Traffic Server continues a background fill before giving up and dropping the origin server connection.
 
-.. ts:cv:: CONFIG proxy.config.http.background_fill_completed_threshold FLOAT 0.50000
+.. ts:cv:: CONFIG proxy.config.http.background_fill_completed_threshold FLOAT 0.0
    :reloadable:
 
    The proportion of total document size already transferred when a client aborts at which the proxy continues fetching the document
@@ -873,7 +875,7 @@ Origin Server Connect Attempts
 
    The maximum number of connection retries Traffic Server can make when the origin server is not responding.
 
-.. ts:cv:: CONFIG proxy.config.http.connect_attempts_max_retries_dead_server INT 2
+.. ts:cv:: CONFIG proxy.config.http.connect_attempts_max_retries_dead_server INT 3
    :reloadable:
 
    The maximum number of connection retries Traffic Server can make when the origin server is unavailable.
@@ -901,7 +903,7 @@ Origin Server Connect Attempts
    needed to set up a new connection from
    the next request at the expense of added (inactive) connections. To enable, set to one (``1``).
 
-.. ts:cv:: CONFIG proxy.config.http.connect_attempts_rr_retries INT 2
+.. ts:cv:: CONFIG proxy.config.http.connect_attempts_rr_retries INT 3
    :reloadable:
 
    The maximum number of failed connection attempts allowed before a round-robin entry is marked as 'down' if a server
@@ -918,7 +920,7 @@ Origin Server Connect Attempts
    The timeout value (in seconds) for an origin server connection when the client request is a ``POST`` or ``PUT``
    request.
 
-.. ts:cv:: CONFIG proxy.config.http.down_server.cache_time INT 900
+.. ts:cv:: CONFIG proxy.config.http.down_server.cache_time INT 300
    :reloadable:
 
    Specifies how long (in seconds) Traffic Server remembers that an origin server was unreachable.
@@ -946,13 +948,13 @@ Congestion Control
 
    Transaction buffering / flow control is enabled if this is set to a non-zero value. Otherwise no flow control is done.
 
-.. ts:cv:: CONFIG proxy.config.http.flow_control.high_water INT 65536
+.. ts:cv:: CONFIG proxy.config.http.flow_control.high_water INT 0
    :metric: bytes
 
    The high water mark for transaction buffer control. External source I/O is halted when the total buffer space in use
    by the transaction exceeds this value.
 
-.. ts:cv:: CONFIG proxy.config.http.flow_control.low_water INT 65536
+.. ts:cv:: CONFIG proxy.config.http.flow_control.low_water INT 0
    :metric: bytes
 
    The low water mark for transaction buffer control. External source I/O is resumed when the total buffer space in use
@@ -1028,21 +1030,17 @@ Proxy User Variables
 
    When enabled (``1``), Traffic Server inserts ``Client-IP`` headers to retain the client IP address.
 
-.. ts:cv:: CONFIG proxy.config.http.append_xforwards_header INT 0
-
-   When enabled (``1``), Traffic Server appends ``X-Forwards`` headers to outgoing requests.
-
 .. ts:cv:: CONFIG proxy.config.http.anonymize_other_header_list STRING NULL
    :reloadable:
 
    Comma separated list of headers Traffic Server should remove from outgoing requests.
 
-.. ts:cv:: CONFIG proxy.config.http.insert_squid_x_forwarded_for INT 0
+.. ts:cv:: CONFIG proxy.config.http.insert_squid_x_forwarded_for INT 1
    :reloadable:
 
    When enabled (``1``), Traffic Server adds the client IP address to the ``X-Forwarded-For`` header.
 
-.. ts:cv:: CONFIG proxy.config.http.normalize_ae_gzip INT 0
+.. ts:cv:: CONFIG proxy.config.http.normalize_ae_gzip INT 1
    :reloadable:
 
    Enable (``1``) to normalize all ``Accept-Encoding:`` headers to one of the following:
@@ -1072,13 +1070,13 @@ Security
 Cache Control
 =============
 
-.. ts:cv:: CONFIG proxy.config.cache.enable_read_while_writer INT 0
+.. ts:cv:: CONFIG proxy.config.cache.enable_read_while_writer INT 1
    :reloadable:
 
    Enables (``1``) or disables (``0``) ability to a read cached object while the another connection is completing the write to cache for
    the same object. Several other configuration values need to be set for this to become active. See :ref:`reducing-origin-server-requests-avoiding-the-thundering-herd`
 
-.. ts:cv:: CONFIG proxy.config.cache.force_sector_size INT 512
+.. ts:cv:: CONFIG proxy.config.cache.force_sector_size INT 0
    :reloadable:
 
    Forces the use of a specific hardware sector size (512 - 8192 bytes).
@@ -1096,12 +1094,12 @@ Cache Control
    with a ``Location`` header but no document body. This only works if the
    origin response also has a ``Content-Length`` header.
 
-.. ts:cv:: CONFIG proxy.config.http.cache.ignore_client_no_cache INT 0
+.. ts:cv:: CONFIG proxy.config.http.cache.ignore_client_no_cache INT 1
    :reloadable:
 
    When enabled (``1``), Traffic Server ignores client requests to bypass the cache.
 
-.. ts:cv:: CONFIG proxy.config.http.cache.ims_on_client_no_cache INT 0
+.. ts:cv:: CONFIG proxy.config.http.cache.ims_on_client_no_cache INT 1
    :reloadable:
 
    When enabled (``1``), Traffic Server issues a conditional request to the origin server if an incoming request has a ``No-Cache`` header.
@@ -1111,7 +1109,7 @@ Cache Control
 
    When enabled (``1``), Traffic Server ignores origin server requests to bypass the cache.
 
-.. ts:cv:: CONFIG proxy.config.http.cache.cache_responses_to_cookies INT 3
+.. ts:cv:: CONFIG proxy.config.http.cache.cache_responses_to_cookies INT 1
    :reloadable:
 
    Specifies how cookies are cached:
@@ -1154,10 +1152,7 @@ Cache Control
    Traffic Server always revalidates the cached content and uses the
    client's ``If-Modified-Since`` header for the proxy request.
 
-.. ts:cv:: CONFIG proxy.config.http.cache.when_to_add_no_cache_to_msie_requests INT 0
-   :deprecated:
-
-.. ts:cv:: CONFIG proxy.config.http.cache.required_headers INT 0
+.. ts:cv:: CONFIG proxy.config.http.cache.required_headers INT 2
    :reloadable:
 
    The type of headers required in a request for the request to be cacheable.
@@ -1250,7 +1245,7 @@ Cache Control
       you can also enable this configuration with a ``1``.
 
 
-.. ts:cv:: CONFIG proxy.config.http.cache.ignore_client_cc_max_age INT 0
+.. ts:cv:: CONFIG proxy.config.http.cache.ignore_client_cc_max_age INT 1
    :reloadable:
 
    When enabled (``1``), Traffic Server ignores any ``Cache-Control:
@@ -1261,7 +1256,7 @@ Cache Control
 
    Specifies the maximum object size that will be cached. ``0`` is unlimited.
 
-.. ts:cv:: CONFIG proxy.config.cache.permit.pinning INT 0
+.. ts:cv:: CONFIG proxy.config.cache.permit.pinning INT 1
    :reloadable:
 
    When enabled (``1``), Traffic Server will keep certain HTTP objects in the cache for a certain time as specified in cache.config.
@@ -1357,7 +1352,7 @@ Heuristic Expiration
    The maximum amount of time an HTTP object without an expiration date can remain fresh in the cache before is
    considered to be stale.
 
-.. ts:cv:: CONFIG proxy.config.http.cache.heuristic_lm_factor FLOAT 0.10000
+.. ts:cv:: CONFIG proxy.config.http.cache.heuristic_lm_factor FLOAT 0.10
    :reloadable:
 
    The aging factor for freshness computations. Traffic Server stores an object for this percentage of the time that
@@ -1369,7 +1364,7 @@ Heuristic Expiration
    How often Traffic Server checks for an early refresh, during the period before the document stale time. The interval
    specified must be in seconds. See :ref:`fuzzy-revalidation`
 
-.. ts:cv:: CONFIG proxy.config.http.cache.fuzz.probability FLOAT 0.00500
+.. ts:cv:: CONFIG proxy.config.http.cache.fuzz.probability FLOAT 0.005
    :reloadable:
 
    The probability that a refresh is made on a document during the specified fuzz time.
@@ -1411,7 +1406,7 @@ Customizable User Response Pages
    -  ``1`` = enable customizable user response pages in the default directory only
    -  ``2`` = enable language-targeted user response pages
 
-.. ts:cv:: CONFIG proxy.config.body_factory.enable_logging INT 1
+.. ts:cv:: CONFIG proxy.config.body_factory.enable_logging INT 0
 
    Enables (``1``) or disables (``0``) logging for customizable response pages. When enabled, Traffic Server records a message in
    the error log each time a customized response page is used or modified.
@@ -1437,7 +1432,7 @@ Customizable User Response Pages
 DNS
 ===
 
-.. ts:cv:: CONFIG proxy.config.dns.search_default_domains INT 1
+.. ts:cv:: CONFIG proxy.config.dns.search_default_domains INT 0
    :Reloadable:
 
    Enables (``1``) or disables (``0``) local domain expansion.
@@ -1472,7 +1467,7 @@ hostname to ``host_x.y.com``.
    standard ``resolv.conf`` file, this option allows an administrator to manage the set of resolvers in an external configuration file,
    without affecting how the rest of the operating system uses DNS.
 
-.. ts:cv:: CONFIG proxy.config.dns.round_robin_nameservers INT 0
+.. ts:cv:: CONFIG proxy.config.dns.round_robin_nameservers INT 1
    :reloadable:
 
    Enables (``1``) or disables (``0``) DNS server round-robin.
@@ -1520,7 +1515,7 @@ HostDB
    The value of this variable must be increased if you increase the size of the
    `proxy.config.hostdb.size`_ variable.
 
-.. ts:cv:: CONFIG proxy.config.hostdb.size INT 200000
+.. ts:cv:: CONFIG proxy.config.hostdb.size INT 120000
 
    The maximum number of entries that can be stored in the database.
 
@@ -1572,7 +1567,7 @@ uses the same origin server for the same client, for as long as the origin serve
 set to :arg:`N` the IP address is rotated if more than :arg:`N` seconds have past since the first time the
 current address was used.
 
-.. ts:cv:: CONFIG proxy.config.hostdb.ip_resolve STRING ipv4;ipv6
+.. ts:cv:: CONFIG proxy.config.hostdb.ip_resolve STRING NULL
 
    Set the host resolution style.
 
@@ -1649,7 +1644,7 @@ Logging Configuration
 
    The maximum amount of time before data in the buffer is flushed to disk.
 
-.. ts:cv:: CONFIG proxy.config.log.max_space_mb_for_logs INT 2500
+.. ts:cv:: CONFIG proxy.config.log.max_space_mb_for_logs INT 25000
    :metric: megabytes
    :reloadable:
 
@@ -1675,7 +1670,7 @@ Logging Configuration
    in the logging directory contribute to the space used, even if they are not log files. you may need to consider this
    when you enable full remote logging, and bump to the same size as proxy.config.log.max_space_mb_for_logs.
 
-.. ts:cv:: CONFIG proxy.config.log.max_space_mb_headroom INT 10
+.. ts:cv:: CONFIG proxy.config.log.max_space_mb_headroom INT 1000
    :metric: megabytes
    :reloadable:
 
@@ -1708,7 +1703,7 @@ Logging Configuration
    write permission for others, even if specified in the configuration file. Permissions for existing log files are not changed when the
    configuration is changed.
 
-.. ts:cv:: CONFIG proxy.config.log.custom_logs_enabled INT 0
+.. ts:cv:: CONFIG proxy.config.log.custom_logs_enabled INT 1
    :reloadable:
 
    Enables (``1``) or disables (``0``) custom logging.
@@ -1716,9 +1711,10 @@ Logging Configuration
 .. ts:cv:: CONFIG proxy.config.log.squid_log_enabled INT 1
    :reloadable:
 
-   Enables (``1``) or disables (``0``) the `squid log file format <../working-log-files/log-formats#SquidFormat>`_.
+   Enables (``1``) or disables (``0``) the `squid log file format
+   <../working-log-files/log-formats#SquidFormat>`_. 
 
-.. ts:cv:: CONFIG proxy.config.log.squid_log_is_ascii INT 1
+.. ts:cv:: CONFIG proxy.config.log.squid_log_is_ascii INT 0
    :reloadable:
 
    The squid log file type:
@@ -1761,9 +1757,10 @@ Logging Configuration
 .. ts:cv:: CONFIG proxy.config.log.extended_log_enabled INT 0
    :reloadable:
 
-   Enables (``1``) or disables (``0``) the `Netscape extended log file format <../working-log-files/log-formats#NetscapeFormats>`_.
+   Enables (``1``) or disables (``0``) the `Netscape extended log file format
+   <../working-log-files/log-formats#NetscapeFormats>`_. 
 
-.. ts:cv:: CONFIG proxy.confg.log.extended_log_is_ascii INT 1
+.. ts:cv:: CONFIG proxy.config.log.extended_log_is_ascii INT 1
 
    The `Netscape extended log <../working-log-files/log-formats#NetscapeFormats>`_ file type:
 
@@ -1779,14 +1776,11 @@ Logging Configuration
 
    The `Netscape extended log <../working-log-files/log-formats#NetscapeFormats>`_ file header text.
 
-.. ts:cv:: CONFIG proxy.config.log.extended_log_is_ascii INT 0
-
-   Set whether the extend log is written as ASCII (text) or binary.
-
 .. ts:cv:: CONFIG proxy.config.log.extended2_log_enabled INT 0
    :reloadable:
 
-   Enables (``1``) or disables (``0``) the `Netscape Extended-2 log file format <../working-log-files/log-formats#NetscapeFormats>`_.
+   Enables (``1``) or disables (``0``) the `Netscape Extended-2 log file
+   format <../working-log-files/log-formats#NetscapeFormats>`_. 
 
 .. ts:cv:: CONFIG proxy.config.log.extended2_log_is_ascii INT 1
    :reloadable:
@@ -1946,7 +1940,7 @@ Diagnostic Logging Configuration
 
         CONFIG proxy.config.diags.output.debug STRING SL
 
-.. ts:cv:: CONFIG proxy.config.diags.show_location INT 0
+.. ts:cv:: CONFIG proxy.config.diags.show_location INT 1
 
    Annotates diagnostic messages with the source code location.
 
@@ -1954,7 +1948,7 @@ Diagnostic Logging Configuration
 
    Enables logging for diagnostic messages whose log level is `diag` or `debug`.
 
-.. ts:cv:: CONFIG proxy.config.diags.debug.tags STRING NULL
+.. ts:cv:: CONFIG proxy.config.diags.debug.tags STRING http.*|dns.*
 
    Each Traffic Server `diag` and `debug` level message is annotated
    with a subsytem tag. This configuration contains a regular
@@ -1997,8 +1991,10 @@ URL Remap Rules
 .. ts:cv:: CONFIG proxy.config.url_remap.default_to_server_pac INT 0
    :reloadable:
 
-   Enables (``1``) or disables (``0``) requests for a PAC file on the proxy service port (8080 by default) to be redirected to the PAC
-   port. For this type of redirection to work, the variable `proxy.config.reverse_proxy.enabled`_ must be set to ``1``.
+   Enables (``1``) or disables (``0``) requests for a PAC file on the proxy
+   service port (8080 by default) to be redirected to the PAC 
+   port. For this type of redirection to work, the variable
+   `proxy.config.reverse_proxy.enabled`_ must be set to ``1``. 
 
 .. ts:cv:: CONFIG proxy.config.url_remap.default_to_server_pac_port INT -1
    :reloadable:
@@ -2023,7 +2019,7 @@ URL Remap Rules
    :file:`remap.config` file. If a request does not match, then the browser
    will receive an error.
 
-.. ts:cv:: CONFIG proxy.config.url_remap.pristine_host_hdr INT 1
+.. ts:cv:: CONFIG proxy.config.url_remap.pristine_host_hdr INT 0
    :reloadable:
 
    Set this variable to ``1`` if you want to retain the client host
@@ -2120,10 +2116,6 @@ SSL Termination
    The filename of the certificate authority that client certificates
    will be verified against.
 
-.. ts:cv:: CONFIG proxy.config.ssl.auth.enabled INT 0
-
-   TBD
-
 .. ts:cv:: CONFIG proxy.config.ssl.max_record_size INT 0
 
   This configuration specifies the maximum number of bytes to write
@@ -2332,7 +2324,7 @@ Sockets
 
    Sets the receive buffer size for connections from the client to Traffic Server.
 
-.. ts:cv:: CONFIG proxy.config.net.sock_option_flag_in INT 0
+.. ts:cv:: CONFIG proxy.config.net.sock_option_flag_in INT 0x0
 
    Turns different options "on" for the socket handling client connections:::
 
@@ -2354,7 +2346,7 @@ Sockets
    Sets the receive buffer size for connections from Traffic Server to
    the origin server.
 
-.. ts:cv:: CONFIG proxy.config.net.sock_option_flag_out INT 1
+.. ts:cv:: CONFIG proxy.config.net.sock_option_flag_out INT 0x1
 
    Turns different options "on" for the origin server socket:::
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/879bedce/lib/perl/lib/Apache/TS/AdminClient.pm
----------------------------------------------------------------------
diff --git a/lib/perl/lib/Apache/TS/AdminClient.pm b/lib/perl/lib/Apache/TS/AdminClient.pm
index 4c72786..84cd954 100644
--- a/lib/perl/lib/Apache/TS/AdminClient.pm
+++ b/lib/perl/lib/Apache/TS/AdminClient.pm
@@ -470,7 +470,6 @@ The Apache Traffic Server Administration Manual will explain what these strings
  proxy.config.http.cache.vary_default_images
  proxy.config.http.cache.vary_default_other
  proxy.config.http.cache.vary_default_text
- proxy.config.http.cache.when_to_add_no_cache_to_msie_requests
  proxy.config.http.cache.when_to_revalidate
  proxy.config.http.chunking_enabled
  proxy.config.http.congestion_control.default.client_wait_interval

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/879bedce/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 8f80480..32d5062 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -178,7 +178,7 @@ RecordElement RecordsConfig[] = {
   //##############################################################################
   {RECT_CONFIG, "proxy.config.diags.debug.enabled", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.diags.debug.tags", RECD_STRING, NULL, RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  {RECT_CONFIG, "proxy.config.diags.debug.tags", RECD_STRING, "http.*|dns.*", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.diags.action.enabled", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
@@ -368,7 +368,7 @@ RecordElement RecordsConfig[] = {
   //       #
   {RECT_CONFIG, "proxy.config.http.enabled", RECD_INT, "1", RECU_RESTART_TM, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.http.server_ports", RECD_STRING, NULL, RECU_RESTART_TM, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  {RECT_CONFIG, "proxy.config.http.server_ports", RECD_STRING, "8080", RECU_RESTART_TM, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.http.server_port", RECD_INT, "-1", RECU_RESTART_TM, RR_NULL, RECC_INT, "[0-65535]", RECA_NULL}
   ,
@@ -780,7 +780,7 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.net.sock_recv_buffer_size_in", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.net.sock_send_buffer_size_in", RECD_INT, "0x0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  {RECT_CONFIG, "proxy.config.net.sock_send_buffer_size_in", RECD_INT, "0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.net.sock_option_flag_in", RECD_INT, "0x0", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
@@ -1087,7 +1087,7 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.log.max_secs_per_buffer", RECD_INT, "5", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.log.max_space_mb_for_logs", RECD_INT, "2500", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
+  {RECT_CONFIG, "proxy.config.log.max_space_mb_for_logs", RECD_INT, "25000", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.log.max_space_mb_for_orphan_logs", RECD_INT, "25", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/879bedce/proxy/config/records.config.default.in
----------------------------------------------------------------------
diff --git a/proxy/config/records.config.default.in b/proxy/config/records.config.default.in
index 9120089..8299b86 100644
--- a/proxy/config/records.config.default.in
+++ b/proxy/config/records.config.default.in
@@ -158,6 +158,7 @@ CONFIG proxy.config.url_remap.pristine_host_hdr INT 0
 ##############################################################################
 CONFIG proxy.config.ssl.client.verify.server INT 0
 CONFIG proxy.config.ssl.client.CA.cert.filename STRING NULL
+CONFIG proxy.config.ssl.server.cipher_suite STRING ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2
 
 ##############################################################################
 # ICP Configuration. Docs:


[37/50] [abbrv] git commit: TS-2859: remove DBG macros to not generate warnings from GCC 4.9

Posted by bc...@apache.org.
TS-2859: remove DBG macros to not generate warnings from GCC 4.9


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

Branch: refs/heads/5.0.x
Commit: e7586dfee7a04b44e3c378a484cc1e776e847b27
Parents: e9ac7f6
Author: Marcin Juszkiewicz <mj...@redhat.com>
Authored: Thu May 29 12:15:43 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu May 29 12:16:53 2014 -0700

----------------------------------------------------------------------
 CHANGES           |  2 ++
 lib/ts/ink_defs.h | 22 ----------------------
 2 files changed, 2 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e7586dfe/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index dbfc39b..7e70311 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2859] Remove DBG macros to not generate warnings from GCC 4.9.
+
   *) [TS-2858] Build failures on OmniOS. Also add some LuaJIT flags as per
    Theo's and Daniel's recommendations.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e7586dfe/lib/ts/ink_defs.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_defs.h b/lib/ts/ink_defs.h
index b5e8122..ad728a5 100644
--- a/lib/ts/ink_defs.h
+++ b/lib/ts/ink_defs.h
@@ -131,28 +131,6 @@ countof(const T (&)[N]) {
 #define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
 #endif
 
-/* Debugging
-*/
-#ifdef NDEBUG
-
-#define FDBG
-#define DBG(s)
-#define DBG1(s,a)
-#define DBG2(s,a1,a2)
-#define DBG3(s,a1,a2,a3)
-#define DBG4(s,a1,a2,a3,a4)
-
-#else
-
-#define FDBG                if (debug_level==1) printf("debug "__FILE__":%d %s : entered\n" ,__LINE__,__FUNCTION__)
-#define DBG(s)              if (debug_level==1) printf("debug "__FILE__":%d %s :" s ,__LINE__,__FUNCTION__)
-#define DBG1(s,a)           if (debug_level==1) printf("debug "__FILE__":%d %s :" s ,__LINE__,__FUNCTION__, a)
-#define DBG2(s,a1,a2)       if (debug_level==1) printf("debug "__FILE__":%d %s :" s ,__LINE__,__FUNCTION__, a1,a2)
-#define DBG3(s,a1,a2,a3)    if (debug_level==1) printf("debug "__FILE__":%d %s :" s ,__LINE__,__FUNCTION__, a1,a2,a3)
-#define DBG4(s,a1,a2,a3,a4) if (debug_level==1) printf("debug "__FILE__":%d %s :" s ,__LINE__,__FUNCTION__, a1,a2,a3,a4)
-
-#endif
-
 /* Types
 */
 typedef void *(*VPVP_PFN) (void *);


[29/50] [abbrv] git commit: TS-2391: Traffic Server tries to reverse resolve 127.0.0.1

Posted by bc...@apache.org.
TS-2391: Traffic Server tries to reverse resolve 127.0.0.1


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

Branch: refs/heads/5.0.x
Commit: d22f9891043bca75df2f44a36c7464d45f72936e
Parents: f4e9fd6
Author: Bryan Call <bc...@apache.org>
Authored: Wed May 28 16:48:23 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Wed May 28 16:48:23 2014 -0700

----------------------------------------------------------------------
 CHANGES                    | 2 ++
 proxy/http/HttpTransact.cc | 6 ++----
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d22f9891/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 134d5cd..50ce778 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2391] Traffic Server tries to reverse resolve 127.0.0.1
+
   *) [TS-2837] Dangling pointer in URLImpl which may cause core dump
 
   *) [TS-2842] Can't set SPDY inactivity timeout with traffic_line

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d22f9891/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index ee59a8a..9efb233 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -1408,8 +1408,7 @@ HttpTransact::HandleRequest(State* s)
   if (s->dns_info.lookup_name[0] <= '9' &&
       s->dns_info.lookup_name[0] >= '0' &&
       (!s->state_machine->enable_redirection || !s->redirect_info.redirect_in_process) &&
-     // (s->state_machine->authAdapter.needs_rev_dns() ||
-      ( host_rule_in_CacheControlTable() || s->parent_params->ParentTable->hostMatch)) {
+      s->parent_params->ParentTable->hostMatch) {
     s->force_dns = 1;
   }
   //YTS Team, yamsat Plugin
@@ -1834,8 +1833,7 @@ HttpTransact::OSDNSLookup(State* s)
     TRANSACT_RETURN(how_to_open_connection(s), HttpTransact::HandleResponse);
   } else if (s->dns_info.lookup_name[0] <= '9' &&
              s->dns_info.lookup_name[0] >= '0' &&
-             //(s->state_machine->authAdapter.needs_rev_dns() ||
-             (host_rule_in_CacheControlTable() || s->parent_params->ParentTable->hostMatch) &&
+             s->parent_params->ParentTable->hostMatch &&
              !s->http_config_param->no_dns_forward_to_parent) {
     // note, broken logic: ACC fudges the OR stmt to always be true,
     // 'AuthHttpAdapter' should do the rev-dns if needed, not here .


[33/50] [abbrv] git commit: TS-2604: collapsed connection plugin

Posted by bc...@apache.org.
TS-2604: collapsed connection plugin


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

Branch: refs/heads/5.0.x
Commit: 2ddcc688403eabf71cde47855d9f1377196583be
Parents: d65bc70
Author: Ethan Lai <yz...@yahoo.com>
Authored: Wed May 28 20:39:12 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Wed May 28 20:39:12 2014 -0700

----------------------------------------------------------------------
 configure.ac                                    |    4 +
 plugins/experimental/Makefile.am                |    1 +
 .../experimental/collapsed_connection/LICENSE   |  203 +++
 .../collapsed_connection/Makefile.am            |   25 +
 .../collapsed_connection/MurmurHash3.cc         |  234 ++++
 .../collapsed_connection/MurmurHash3.h          |   20 +
 .../experimental/collapsed_connection/NOTICE    |    9 +
 .../P_collapsed_connection.h                    |  123 ++
 .../experimental/collapsed_connection/README    |   71 ++
 .../collapsed_connection.cc                     | 1156 ++++++++++++++++++
 .../collapsed_connection/default.config         |    5 +
 .../experimental/collapsed_connection/state.dot |   40 +
 12 files changed, 1891 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 9bbd6a1..a324025 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1800,6 +1800,9 @@ AS_IF([test "x$enable_experimental_plugins" = xyes],
 AM_CONDITIONAL([BUILD_REMAP_STATS_PLUGIN],
   [ test "x$enable_experimental_plugins" = "xyes" -a "x$ac_cv_header_search_h" = "xyes" -a "x$ac_cv_type_struct_hsearch_data" = "xyes" -a "x$ac_cv_func_hcreate_r" = "xyes" -a "x$ac_cv_func_hsearch_r" = "xyes" ])
 
+AM_CONDITIONAL([BUILD_COLLAPSED_CONNECTION_PLUGIN],
+  [ test "x$enable_experimental_plugins" = "xyes" -a "x${enable_collapsed_connection_plugin}" != "xno" ])
+
 #
 # use modular IOCORE
 #
@@ -1910,6 +1913,7 @@ AC_CONFIG_FILES([
   plugins/experimental/balancer/Makefile
   plugins/experimental/buffer_upload/Makefile
   plugins/experimental/channel_stats/Makefile
+  plugins/experimental/collapsed_connection/Makefile
   plugins/experimental/custom_redirect/Makefile
   plugins/experimental/escalate/Makefile
   plugins/experimental/esi/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/Makefile.am b/plugins/experimental/Makefile.am
index 5830406..05ca267 100644
--- a/plugins/experimental/Makefile.am
+++ b/plugins/experimental/Makefile.am
@@ -22,6 +22,7 @@ SUBDIRS = \
  balancer \
  buffer_upload \
  channel_stats \
+ collapsed_connection \
  custom_redirect \
  escalate \
  esi \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/LICENSE
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/LICENSE b/plugins/experimental/collapsed_connection/LICENSE
new file mode 100644
index 0000000..3eebad2
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/LICENSE
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright (C) 2014 Yahoo! Inc.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/Makefile.am b/plugins/experimental/collapsed_connection/Makefile.am
new file mode 100644
index 0000000..6269cda
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/Makefile.am
@@ -0,0 +1,25 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+include $(top_srcdir)/build/plugins.mk
+
+if BUILD_COLLAPSED_CONNECTION_PLUGIN
+
+pkglib_LTLIBRARIES = collapsed_connection.la
+collapsed_connection_la_SOURCES = collapsed_connection.cc MurmurHash3.cc
+collapsed_connection_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)
+
+endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/MurmurHash3.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/MurmurHash3.cc b/plugins/experimental/collapsed_connection/MurmurHash3.cc
new file mode 100644
index 0000000..228ba9e
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/MurmurHash3.cc
@@ -0,0 +1,234 @@
+//-----------------------------------------------------------------------------
+// MurmurHash3 was written by Austin Appleby, and is placed in the public
+// domain. The author hereby disclaims copyright to this source code.
+
+// Note - The x86 and x64 versions do _not_ produce the same results, as the
+// algorithms are optimized for their respective platforms. You can still
+// compile and run any of them on any platform, but your performance with the
+// non-native version will be less than optimal.
+
+#include "MurmurHash3.h"
+
+//-----------------------------------------------------------------------------
+#define	FORCE_INLINE inline __attribute__((always_inline))
+
+inline uint32_t rotl32 ( uint32_t x, int8_t r )
+{
+  return (x << r) | (x >> (32 - r));
+}
+
+inline uint64_t rotl64 ( uint64_t x, int8_t r )
+{
+  return (x << r) | (x >> (64 - r));
+}
+
+#define	ROTL32(x,y)	rotl32(x,y)
+#define ROTL64(x,y)	rotl64(x,y)
+
+#define BIG_CONSTANT(x) (x##LLU)
+
+
+//-----------------------------------------------------------------------------
+// Block read - if your platform needs to do endian-swapping or can only
+// handle aligned reads, do the conversion here
+
+FORCE_INLINE uint32_t getblock32 ( const uint32_t * p, int i )
+{
+  return p[i];
+}
+
+FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
+{
+  return p[i];
+}
+
+//-----------------------------------------------------------------------------
+// Finalization mix - force all bits of a hash block to avalanche
+
+FORCE_INLINE uint32_t fmix32 ( uint32_t h )
+{
+  h ^= h >> 16;
+  h *= 0x85ebca6b;
+  h ^= h >> 13;
+  h *= 0xc2b2ae35;
+  h ^= h >> 16;
+
+  return h;
+}
+
+//----------
+
+FORCE_INLINE uint64_t fmix64 ( uint64_t k )
+{
+  k ^= k >> 33;
+  k *= BIG_CONSTANT(0xff51afd7ed558ccd);
+  k ^= k >> 33;
+  k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
+  k ^= k >> 33;
+
+  return k;
+}
+
+//-----------------------------------------------------------------------------
+
+void MurmurHash3_x86_32 ( const void * key, int len,
+                          uint32_t seed, void * out )
+{
+  const uint8_t * data = (const uint8_t*)key;
+  const int nblocks = len / 4;
+
+  uint32_t h1 = seed;
+
+  const uint32_t c1 = 0xcc9e2d51;
+  const uint32_t c2 = 0x1b873593;
+
+  //----------
+  // body
+
+  const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
+
+  for(int i = -nblocks; i; i++)
+  {
+    uint32_t k1 = getblock32(blocks,i);
+
+    k1 *= c1;
+    k1 = ROTL32(k1,15);
+    k1 *= c2;
+
+    h1 ^= k1;
+    h1 = ROTL32(h1,13);
+    h1 = h1*5+0xe6546b64;
+  }
+
+  //----------
+  // tail
+
+  const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
+
+  uint32_t k1 = 0;
+
+  switch(len & 3)
+  {
+  case 3: k1 ^= tail[2] << 16;
+  case 2: k1 ^= tail[1] << 8;
+  case 1: k1 ^= tail[0];
+          k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
+  };
+
+  //----------
+  // finalization
+
+  h1 ^= len;
+
+  h1 = fmix32(h1);
+
+  *(uint32_t*)out = h1;
+}
+
+//-----------------------------------------------------------------------------
+
+void MurmurHash3_x86_128 ( const void * key, const int len,
+                           uint32_t seed, void * out )
+{
+  const uint8_t * data = (const uint8_t*)key;
+  const int nblocks = len / 16;
+
+  uint32_t h1 = seed;
+  uint32_t h2 = seed;
+  uint32_t h3 = seed;
+  uint32_t h4 = seed;
+
+  const uint32_t c1 = 0x239b961b;
+  const uint32_t c2 = 0xab0e9789;
+  const uint32_t c3 = 0x38b34ae5;
+  const uint32_t c4 = 0xa1e38b93;
+
+  //----------
+  // body
+
+  const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
+
+  for(int i = -nblocks; i; i++)
+  {
+    uint32_t k1 = getblock32(blocks,i*4+0);
+    uint32_t k2 = getblock32(blocks,i*4+1);
+    uint32_t k3 = getblock32(blocks,i*4+2);
+    uint32_t k4 = getblock32(blocks,i*4+3);
+
+    k1 *= c1; k1  = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
+
+    h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b;
+
+    k2 *= c2; k2  = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
+
+    h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747;
+
+    k3 *= c3; k3  = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
+
+    h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35;
+
+    k4 *= c4; k4  = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
+
+    h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17;
+  }
+
+  //----------
+  // tail
+
+  const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
+
+  uint32_t k1 = 0;
+  uint32_t k2 = 0;
+  uint32_t k3 = 0;
+  uint32_t k4 = 0;
+
+  switch(len & 15)
+  {
+  case 15: k4 ^= tail[14] << 16;
+  case 14: k4 ^= tail[13] << 8;
+  case 13: k4 ^= tail[12] << 0;
+           k4 *= c4; k4  = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
+
+  case 12: k3 ^= tail[11] << 24;
+  case 11: k3 ^= tail[10] << 16;
+  case 10: k3 ^= tail[ 9] << 8;
+  case  9: k3 ^= tail[ 8] << 0;
+           k3 *= c3; k3  = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
+
+  case  8: k2 ^= tail[ 7] << 24;
+  case  7: k2 ^= tail[ 6] << 16;
+  case  6: k2 ^= tail[ 5] << 8;
+  case  5: k2 ^= tail[ 4] << 0;
+           k2 *= c2; k2  = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
+
+  case  4: k1 ^= tail[ 3] << 24;
+  case  3: k1 ^= tail[ 2] << 16;
+  case  2: k1 ^= tail[ 1] << 8;
+  case  1: k1 ^= tail[ 0] << 0;
+           k1 *= c1; k1  = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
+  };
+
+  //----------
+  // finalization
+
+  h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len;
+
+  h1 += h2; h1 += h3; h1 += h4;
+  h2 += h1; h3 += h1; h4 += h1;
+
+  h1 = fmix32(h1);
+  h2 = fmix32(h2);
+  h3 = fmix32(h3);
+  h4 = fmix32(h4);
+
+  h1 += h2; h1 += h3; h1 += h4;
+  h2 += h1; h3 += h1; h4 += h1;
+
+  ((uint32_t*)out)[0] = h1;
+  ((uint32_t*)out)[1] = h2;
+  ((uint32_t*)out)[2] = h3;
+  ((uint32_t*)out)[3] = h4;
+}
+
+//-----------------------------------------------------------------------------
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/MurmurHash3.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/MurmurHash3.h b/plugins/experimental/collapsed_connection/MurmurHash3.h
new file mode 100644
index 0000000..cf11c84
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/MurmurHash3.h
@@ -0,0 +1,20 @@
+//-----------------------------------------------------------------------------
+// MurmurHash3 was written by Austin Appleby, and is placed in the public
+// domain. The author hereby disclaims copyright to this source code.
+
+#ifndef _MURMURHASH3_H_
+#define _MURMURHASH3_H_
+
+//-----------------------------------------------------------------------------
+#include <stdint.h>
+
+//-----------------------------------------------------------------------------
+
+void MurmurHash3_x86_32  ( const void * key, int len, uint32_t seed, void * out );
+
+void MurmurHash3_x86_128 ( const void * key, int len, uint32_t seed, void * out );
+
+//-----------------------------------------------------------------------------
+
+#endif // _MURMURHASH3_H_
+//-----------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/NOTICE
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/NOTICE b/plugins/experimental/collapsed_connection/NOTICE
new file mode 100644
index 0000000..6fef4b1
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/NOTICE
@@ -0,0 +1,9 @@
+=======================================================================
+NOTICE file for use with, and corresponding to Section 4 of,            
+the Apache License, Version 2.0,                                  
+in this case for the collapsed connection plugin project.               
+=======================================================================
+
+   This product includes software developed by
+   Yahoo! Inc. (www.yahoo.com)
+   Copyright (c) 2014 Yahoo! Inc.  All rights reserved.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/P_collapsed_connection.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/P_collapsed_connection.h b/plugins/experimental/collapsed_connection/P_collapsed_connection.h
new file mode 100644
index 0000000..9e1f159
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/P_collapsed_connection.h
@@ -0,0 +1,123 @@
+/** @file
+
+  Implements Collapsed connection
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include <stdint.h>
+#include <map>
+#include <list>
+#include <utility>
+
+#ifndef ATS_COLLAPSED_CONNECTION_PLUGIN_H_
+#define ATS_COLLAPSED_CONNECTION_PLUGIN_H_
+
+#define PLUGIN_NAME     "collapsed_connection"
+#define PLUGIN_VENDOR   "Yahoo! Inc"
+#define PLUGIN_SUPPORT  "yzlai@yahoo-inc.com"
+
+#define DEFAULT_INSERT_LOCK_RETRY_TIME  10
+#define DEFAULT_MAX_LOCK_RETRY_TIMEOUT  2000
+#define DEFAULT_KEEP_PASS_RECORD_TIME   5000
+
+typedef enum
+{
+  CcEnabled,
+  CcRequiredHeader,
+  CcInsertLockRetryTime,
+  CcMaxLockRetryTimeout,
+  CcKeepPassRecordTime,
+} CcConfigKey;
+
+typedef enum
+{
+  CC_NONE,
+  CC_LOCKED,
+  CC_INSERT,
+  CC_PASS,
+  CC_PASSED,
+  CC_REMOVE,
+  CC_DONE,
+} CcTxnState;
+
+struct PassRecord
+{
+  int64_t timeout;
+  uint32_t hash_key;
+};
+
+typedef std::map<uint32_t, int8_t> UintMap;
+typedef std::list<PassRecord> UsecList;
+
+typedef struct
+{
+  bool enabled;
+  TSMgmtString required_header;
+  int required_header_len;
+  TSMgmtInt insert_lock_retry_time;
+  TSMgmtInt max_lock_retry_timeout;
+  TSMgmtInt keep_pass_record_time;
+} CcPluginConfig;
+
+typedef struct
+{
+  UintMap *active_hash_map;
+  TSMutex mutex;
+  uint64_t seq_id;
+  int txn_slot;
+  CcPluginConfig *global_config;
+  UsecList *keep_pass_list;
+  TSHRTime last_gc_time;
+  bool read_while_writer;
+  int tol_global_hook_reqs;
+  int tol_remap_hook_reqs;
+  int tol_collapsed_reqs;
+  int tol_non_cacheable_reqs;
+  int tol_got_passed_reqs;
+  int cur_hash_entries;
+  int cur_keep_pass_entries;
+  int max_hash_entries;
+  int max_keep_pass_entries;
+} CcPluginData;
+
+typedef struct
+{
+  uint64_t seq_id;
+  TSHttpTxn txnp;
+  TSCont contp;
+  CcPluginConfig *config;
+  uint32_t hash_key;
+  CcTxnState cc_state;
+  TSHRTime wait_time;
+} CcTxnData;
+
+typedef struct
+{
+  TSEvent event;
+  CcTxnData *txn_data;
+} TryLockData;
+
+// hash seed for MurmurHash3_x86_32, must be a prime number
+const unsigned int c_hashSeed = 27240313;
+
+static CcPluginData *getCcPlugin();
+static int collapsedConnectionMainHandler(TSCont contp, TSEvent event, void *edata);
+
+#endif // ATS_COLLAPSED_CONNECTION_PLUGIN_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/README
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/README b/plugins/experimental/collapsed_connection/README
new file mode 100644
index 0000000..1eed602
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/README
@@ -0,0 +1,71 @@
+ATS (Apache Traffic Server) Collapsed Connection Handling Plugin
+------------------------------------------------------------------------------
+
+This plugin collapses connections with identical CacheUrl/EffectiveUrl.
+
+If an entry was created for a given CacheUrl/EffectiveUrl in our global hashTable,
+successive GET requests with identical CacheUrl/EffectiveUrl will be blocked in 
+POST_REMAP hook until the hash entry was removed.  (POST_REMAP hook is the last 
+hook before 'cache lookup')
+
+For requests going into 'cache lookup' stage,
+  if CacheLookupStatus is HIT_FRESH,
+    hash entry will be removed at earliest possible time.
+
+For requests going into 'read server response header' stage,
+  if response is not 200 OK,
+    hash entry will be removed at earliest possible time.
+  if response is public cacheable, (by checking 'Expires' header and 'Cache-Control' header with 'public' & 'max-age=...' values),
+    if proxy.config.cache.enable_read_while_writer is enabled,
+      hash entry will be removed at earliest possible time.
+    else
+      hash entry will be removed in TXN_CLOSE hook. 
+  if response is not public cacheable,
+    we will update hash entry with a special value to let successive requests pass collapsed check,
+    this special hash entry will be removed in TXN_CLOSE hook if value of keep_pass_record_time is 0,
+    else it will be added into a list with timeout and removed by later collapsed requests.
+
+To view full state diagram, please view state.png
+
+
+CONFIGURATION
+
+To have trafficserver use this plugin, add a line for 'collapsed_connection.so' in the 'plugin.config' file.
+The plugin can be configured with only 1 argument, which is location of its configuration file.
+
+Example plugin.config:
+    collapsed_connection.so conf/collapsed_connection/check_X_CC_header.config
+
+This plugin can be added in remap.config as well.
+Thus, it can have different configurations or only be enabled/disabled for specific remap rules.
+If the only argument for this plugin is "0" or "1", it means just "disable" or "enable" this plugin with default config value.
+
+Example remap.config:
+    map http://no-collapse1.www.example.com/ http://www.example.com/ @plugin=connection_collapsing.so @pparam=0
+    map http://no-collapse2.www.example.com/ http://www.example.com/ @plugin=connection_collapsing.so @pparam=conf/collapsed_connection/disable.config
+
+Its configuration file can have 5 configurable options:
+    CONFIG proxy.config.http.collapsed_connection.enabled INT 1
+    CONFIG proxy.config.http.collapsed_connection.required_header STRING NULL
+    CONFIG proxy.config.http.collapsed_connection.insert_lock_retry_time INT 10
+    CONFIG proxy.config.http.collapsed_connection.max_lock_retry_timeout INT 2000
+    CONFIG proxy.config.http.collapsed_connection.keep_pass_record_time INT 5000
+
+Meaning of these configurable options:
+    enabled
+        enable collapsing or not, useful in remap rules if we want to disable/enable specific remap rules.
+    required_header
+        only collapse requests with 'required_header' http header present.
+    insert_lock_retry_time
+        if hash entry was locked, retry to get lock after insert_lock_retry_time millisecond.
+    max_lock_retry_timeout
+        if request was unable to get lock more than max_lock_retry_timeout millisecond, it will be unblocked anyway.
+    keep_pass_record_time
+        if response is not public cacheable,
+        the pass sentinel will be kept in hash table for at least keep_pass_record_time millisecond before be removed.
+
+
+3rd party open source code
+----------------------------------------------------------------------------------
+MurmurHash3 by Austin Appleby, https://code.google.com/p/smhasher/wiki/MurmurHash3
+   * Calculate hash key for CacheUrl

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/collapsed_connection.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/collapsed_connection.cc b/plugins/experimental/collapsed_connection/collapsed_connection.cc
new file mode 100644
index 0000000..b2ce76f
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/collapsed_connection.cc
@@ -0,0 +1,1156 @@
+/** @file
+
+  Implements Collapsed connection
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <ts/ts.h>
+#include <ts/remap.h>
+#include <ts/experimental.h>
+#include "MurmurHash3.h"
+
+#include "P_collapsed_connection.h"
+
+/**
+ * Helper function for the config parser
+ *  copied from plugins/conf_remap/conf_remap.cc
+ *
+ * @param const char *str config data type
+ *
+ * @return TSRecordDataType config data type
+ */
+inline TSRecordDataType
+str_to_datatype(const char *str)
+{
+  TSRecordDataType type = TS_RECORDDATATYPE_NULL;
+
+  if (!str || !*str)
+    return TS_RECORDDATATYPE_NULL;
+
+  if (!strcmp(str, "INT")) {
+    type = TS_RECORDDATATYPE_INT;
+  } else if (!strcmp(str, "STRING")) {
+    type = TS_RECORDDATATYPE_STRING;
+  }
+
+  return type;
+}
+
+/**
+ * Find collapsed_connection transaction config option
+ *  modified from InkAPI.cc:TSHttpTxnConfigFind
+ *
+ * @param const char       *name  name of config options
+ * @param int              length length of *name
+ * @param CcConfigKey      *conf  config key
+ * @param TSRecordDataType *type  config option data type
+ *
+ * @return CcTxnState hashEntry added, should be ignore and pass, or fail
+ */
+static TSReturnCode
+CcHttpTxnConfigFind(const char *name, int length, CcConfigKey * conf, TSRecordDataType * type)
+{
+  *type = TS_RECORDDATATYPE_NULL;
+
+  if (length == -1)
+    length = strlen(name);
+
+  switch (length) {
+  case 46:
+    if (!strncmp(name, "proxy.config.http.collapsed_connection.enabled", length)) {
+      *conf = CcEnabled;
+      *type = TS_RECORDDATATYPE_INT;
+    }
+    break;
+  case 54:
+    if (!strncmp(name, "proxy.config.http.collapsed_connection.required_header", length)) {
+      *conf = CcRequiredHeader;
+      *type = TS_RECORDDATATYPE_STRING;
+    }
+    break;
+  case 60:
+    if (!strncmp(name, "proxy.config.http.collapsed_connection.keep_pass_record_time", length)) {
+      *conf = CcKeepPassRecordTime;
+      *type = TS_RECORDDATATYPE_INT;
+    }
+    break;
+  case 61:
+    if (!strncmp(name, "proxy.config.http.collapsed_connection.insert_lock_retry_time", length)) {
+      *conf = CcInsertLockRetryTime;
+      *type = TS_RECORDDATATYPE_INT;
+    } else if (!strncmp(name, "proxy.config.http.collapsed_connection.max_lock_retry_timeout", length)) {
+      *conf = CcMaxLockRetryTimeout;
+      *type = TS_RECORDDATATYPE_INT;
+    }
+    break;
+  default:
+    break;
+  }
+
+  return ((*type != TS_RECORDDATATYPE_NULL) ? TS_SUCCESS : TS_ERROR);
+}
+
+/**
+ * Initial collapsed_connection plugin with config file
+ *  modified from plugins/conf_remap/conf_remap.cc, RemapConfigs::parse_file
+ *
+ * @param const char *fn filename of config file
+ *
+ * @return CcPluginConfig *config object
+ */
+static CcPluginConfig *
+initConfig(const char *fn)
+{
+  CcPluginData *plugin_data = getCcPlugin();
+  CcPluginConfig *config = static_cast < CcPluginConfig * >(TSmalloc(sizeof(CcPluginConfig)));
+
+  // Default config
+  if (NULL == plugin_data || NULL == plugin_data->global_config) {
+    config->enabled = true;
+    config->required_header = NULL;
+    config->insert_lock_retry_time = DEFAULT_INSERT_LOCK_RETRY_TIME;
+    config->max_lock_retry_timeout = DEFAULT_MAX_LOCK_RETRY_TIMEOUT;
+    config->keep_pass_record_time = DEFAULT_KEEP_PASS_RECORD_TIME;
+  } else {
+    // Inherit from global config
+    CcPluginConfig *global_config = plugin_data->global_config;
+
+    config->enabled = global_config->enabled;
+    config->required_header = TSstrdup(global_config->required_header);
+    config->insert_lock_retry_time = global_config->insert_lock_retry_time;
+    config->max_lock_retry_timeout = global_config->max_lock_retry_timeout;
+    config->keep_pass_record_time = global_config->keep_pass_record_time;
+  }
+
+  if (NULL != fn) {
+    if (1 == strlen(fn)) {
+      if (0 == strcmp("0", fn)) {
+        config->enabled = false;
+      } else if (0 == strcmp("1", fn)) {
+        config->enabled = true;
+      } else {
+        TSError("parameter '%s' ignored", fn);
+      }
+    } else {
+      int line_num = 0;
+      TSFile file;
+      char buf[8192];
+      CcConfigKey name;
+      TSRecordDataType type, expected_type;
+
+      if (NULL == (file = TSfopen(fn, "r"))) {
+        TSError("could not open config file %s", fn);
+      } else {
+        while (NULL != TSfgets(file, buf, sizeof(buf))) {
+          char *ln, *tok;
+          char *s = buf;
+
+          ++line_num;           // First line is #1 ...
+          while (isspace(*s))
+            ++s;
+          tok = strtok_r(s, " \t", &ln);
+
+          // check for blank lines and comments
+          if ((!tok) || (tok && ('#' == *tok)))
+            continue;
+
+          if (strncmp(tok, "CONFIG", 6)) {
+            TSError("file %s, line %d: non-CONFIG line encountered", fn, line_num);
+            continue;
+          }
+          // Find the configuration name
+          tok = strtok_r(NULL, " \t", &ln);
+          if (CcHttpTxnConfigFind(tok, -1, &name, &expected_type) != TS_SUCCESS) {
+            TSError("file %s, line %d: no records.config name given", fn, line_num);
+            continue;
+          }
+          // Find the type (INT or STRING only)
+          tok = strtok_r(NULL, " \t", &ln);
+          if (TS_RECORDDATATYPE_NULL == (type = str_to_datatype(tok))) {
+            TSError("file %s, line %d: only INT and STRING types supported", fn, line_num);
+            continue;
+          }
+
+          if (type != expected_type) {
+            TSError("file %s, line %d: mismatch between provide data type, and expected type", fn, line_num);
+            continue;
+          }
+          // Find the value (which depends on the type above)
+          if (ln) {
+            while (isspace(*ln))
+              ++ln;
+            if ('\0' == *ln) {
+              tok = NULL;
+            } else {
+              tok = ln;
+              while (*ln != '\0')
+                ++ln;
+              --ln;
+              while (isspace(*ln) && (ln > tok))
+                --ln;
+              ++ln;
+              *ln = '\0';
+            }
+          } else {
+            tok = NULL;
+          }
+          if (!tok) {
+            TSError("file %s, line %d: the configuration must provide a value", fn, line_num);
+            continue;
+          }
+          // Now store the new config
+          switch (name) {
+          case CcRequiredHeader:
+            if (NULL != config->required_header) {
+              TSfree(config->required_header);
+            }
+            if (4 == strlen(tok) && 0 == strcmp(tok, "NULL")) {
+              config->required_header = NULL;
+            } else {
+              config->required_header = TSstrdup(tok);
+            }
+            break;
+          case CcEnabled:
+            config->enabled = strtoll(tok, NULL, 10);
+            break;
+          case CcInsertLockRetryTime:
+            config->insert_lock_retry_time = strtoll(tok, NULL, 10);
+            break;
+          case CcMaxLockRetryTimeout:
+            config->max_lock_retry_timeout = strtoll(tok, NULL, 10);
+            break;
+          case CcKeepPassRecordTime:
+            config->keep_pass_record_time = strtoll(tok, NULL, 10);
+            break;
+          default:
+            break;
+          }
+        }
+
+        TSfclose(file);
+      }
+    }
+  }
+  if (config->required_header) {
+    config->required_header_len = strlen(config->required_header);
+  } else {
+    config->required_header_len = 0;
+  }
+
+  TSDebug(PLUGIN_NAME, "enabled = %d", static_cast < int >(config->enabled));
+  TSDebug(PLUGIN_NAME, "required_header = %s", config->required_header);
+  TSDebug(PLUGIN_NAME, "insert_lock_retry_time = %d", static_cast < int >(config->insert_lock_retry_time));
+  TSDebug(PLUGIN_NAME, "max_lock_retry_timeout = %d", static_cast < int >(config->max_lock_retry_timeout));
+  TSDebug(PLUGIN_NAME, "keep_pass_record_time = %d", static_cast < int >(config->keep_pass_record_time));
+
+  return config;
+}
+
+/**
+ * Update and get current size in map
+ *  it's ok to use static variable here because already protected by plugin_data->mutex
+ *
+ * @param UintMap *map Hash Map
+ *
+ * @return int64_t current Hash Map size
+ */
+static int64_t
+getCurrentHashEntries(UintMap * map)
+{
+  static int64_t cur = 0;
+  static int64_t max = 0;
+  int64_t size = map->size();
+  int64_t diff = size - cur;
+
+  cur = size;
+  if (diff != 0) {
+    CcPluginData *plugin_data = getCcPlugin();
+
+    TSStatIntSet(plugin_data->cur_hash_entries, cur);
+    if (cur > max) {
+      TSStatIntSet(plugin_data->max_hash_entries, cur);
+      max = cur;
+    }
+  }
+
+  return cur;
+}
+
+/**
+ * Update and get current size in list
+ *  it's ok to use static variable here because already protected by plugin_data->mutex
+ *
+ * @param UsecList *list List
+ *
+ * @return int64_t current List size
+ */
+static int64_t
+getCurrentKeepPassEntries(UsecList * list)
+{
+  CcPluginData *plugin_data = getCcPlugin();
+  static int64_t cur = 0;
+  static int64_t max = 0;
+  int64_t size = list->size();
+  int64_t diff = size - cur;
+
+  cur = size;
+  if (diff != 0) {
+    TSStatIntSet(plugin_data->cur_keep_pass_entries, cur);
+    if (cur > max) {
+      TSStatIntSet(plugin_data->max_keep_pass_entries, cur);
+      max = cur;
+    }
+  }
+
+  return cur;
+}
+
+/**
+ * Add Or Check keep pass records from list
+ *
+ * @param uint32_t hash_key new hash_key to add
+ * @param int64_t  timeout  timeout of this record
+ *
+ * @return TSReturnCode success or not
+ */
+static TSReturnCode
+addOrCheckKeepPassRecords(uint32_t hash_key, int64_t timeout)
+{
+  CcPluginData *plugin_data = getCcPlugin();
+  UintMap *active_hash_map = plugin_data->active_hash_map;
+  UsecList *keep_pass_list = plugin_data->keep_pass_list;
+  std::list < PassRecord >::iterator it;
+  PassRecord passRecord;
+  bool added = true;
+  TSHRTime cur_ms = TShrtime() / TS_HRTIME_MSECOND;     // TS-2200, ats_dev-4.1+
+
+  // Only gc per 0.1ms
+  if (0 == hash_key && timeout == 0) {
+    if (cur_ms - plugin_data->last_gc_time < 100) {
+      return TS_SUCCESS;
+    }
+  }
+
+  passRecord.timeout = cur_ms + timeout;
+  passRecord.hash_key = hash_key;
+
+  if (hash_key > 0) {
+    bool push_back = false;
+
+    if (keep_pass_list->empty()) {
+      push_back = true;
+    } else {
+      PassRecord & lastRecord = *(keep_pass_list->end());
+
+      if (lastRecord.timeout <= passRecord.timeout) {
+        push_back = true;
+      }
+    }
+
+    if (push_back) {
+      keep_pass_list->push_back(passRecord);
+      getCurrentKeepPassEntries(keep_pass_list);
+      TSDebug(PLUGIN_NAME,
+              "push_back pass entry with timeout = %zd, hash_key = %u", passRecord.timeout, passRecord.hash_key);
+    } else {
+      added = false;
+    }
+  }
+
+  for (it = keep_pass_list->begin(); it != keep_pass_list->end(); ++it) {
+    PassRecord & thisRecord = *it;
+
+    if (thisRecord.timeout <= cur_ms) {
+      UintMap::iterator pos = active_hash_map->find(thisRecord.hash_key);
+      if (pos != active_hash_map->end()) {
+        active_hash_map->erase(pos);
+        getCurrentHashEntries(active_hash_map);
+      }
+      keep_pass_list->erase(it++);
+      getCurrentKeepPassEntries(keep_pass_list);
+      TSDebug(PLUGIN_NAME,
+              "remove pass entry with timeout = %zd, hash_key = %u", thisRecord.timeout, thisRecord.hash_key);
+    } else if (false == added) {
+      if (thisRecord.timeout >= passRecord.timeout) {
+        keep_pass_list->insert(it, passRecord);
+        getCurrentKeepPassEntries(keep_pass_list);
+        TSDebug(PLUGIN_NAME,
+                "insert pass entry with timeout = %zd, hash_key = %u", passRecord.timeout, passRecord.hash_key);
+        added = true;
+        break;
+      }
+    } else {
+      break;
+    }
+  }
+  plugin_data->last_gc_time = cur_ms;
+
+  return TS_SUCCESS;
+}
+
+/**
+ * Insert new hashEntry into hashTable
+ *
+ * @param CcTxnData *txn_data transaction data
+ *
+ * @return CcTxnState hashEntry added, should be ignore and pass, or fail
+ */
+static CcTxnState
+insertNewHashEntry(CcTxnData * txn_data)
+{
+  CcPluginData *plugin_data = getCcPlugin();
+  CcTxnState ret = CC_NONE;
+  UintMap *active_hash_map = plugin_data->active_hash_map;
+
+  if (0 == txn_data->hash_key) {
+    return ret;
+  }
+
+  if (TS_SUCCESS == TSMutexLockTry(plugin_data->mutex)) {
+    std::pair < std::map < uint32_t, int8_t >::iterator, bool > map_ret;
+    int64_t size = 0;
+    addOrCheckKeepPassRecords(0, 0);
+    map_ret = active_hash_map->insert(std::make_pair(txn_data->hash_key, CC_INSERT));
+    size = getCurrentHashEntries(active_hash_map);
+    TSMutexUnlock(plugin_data->mutex);
+    if (false != map_ret.second) {
+      TSDebug(PLUGIN_NAME, "[%zu] hash_key inserted, active_hash_map.size = %zd", txn_data->seq_id, size);
+      ret = CC_INSERT;
+    } else if (CC_PASS == map_ret.first->second) {
+      TSDebug(PLUGIN_NAME, "hash value = %d, previous request mark it non-cacheable", map_ret.first->second);
+      ret = CC_PASS;
+    } else {
+      TSDebug(PLUGIN_NAME, "hash value = %d, hash_key already exists, wait next schedule", map_ret.first->second);
+      ret = CC_LOCKED;
+    }
+  } else {
+    TSDebug(PLUGIN_NAME, "[%zu] Unable to get mutex", txn_data->seq_id);
+  }
+
+  if (CC_INSERT != ret && CC_PASS != ret) {
+    TSHRTime cur_ms = TShrtime() / TS_HRTIME_MSECOND;   // TS-2200, ats_dev-4.1+
+
+    if (0 == txn_data->wait_time) {
+      txn_data->wait_time = cur_ms;
+    } else if (cur_ms - txn_data->wait_time > txn_data->config->max_lock_retry_timeout) {
+      txn_data->wait_time = cur_ms - txn_data->wait_time;
+      // Pass cache lock
+      ret = CC_PASS;
+      TSDebug(PLUGIN_NAME, "timeout (%zd > %d), pass plugin",
+              txn_data->wait_time, static_cast < int32_t > (txn_data->config->max_lock_retry_timeout));
+    }
+  } else if (0 != txn_data->wait_time) {
+    txn_data->wait_time = TShrtime() / 1000000 - txn_data->wait_time;
+    TSDebug(PLUGIN_NAME, "waited for %zd ms", txn_data->wait_time);
+  }
+
+  return ret;
+}
+
+/**
+ * Update or remove hashEntry from hashTable
+ *
+ * @param CcTxnData *txn_data transaction data
+ *
+ * @return TSReturnCode Success or failure
+ */
+static TSReturnCode
+updateOrRemoveHashEntry(CcTxnData * txn_data)
+{
+  TSReturnCode ret = TS_ERROR;
+  CcPluginData *plugin_data = getCcPlugin();
+  UintMap *active_hash_map = plugin_data->active_hash_map;
+
+  if (0 == txn_data->hash_key || CC_PASSED == txn_data->cc_state) {
+    return TS_SUCCESS;
+  }
+
+  if (CC_PASS != txn_data->cc_state && CC_REMOVE != txn_data->cc_state) {
+    return ret;
+  }
+
+  if (TS_SUCCESS == TSMutexLockTry(plugin_data->mutex)) {
+    UintMap::iterator pos = active_hash_map->find(txn_data->hash_key);
+    int64_t size = 0;
+    if (pos != active_hash_map->end()) {
+      active_hash_map->erase(pos);
+    }
+    if (CC_PASS == txn_data->cc_state) {
+      active_hash_map->insert(std::make_pair(txn_data->hash_key, CC_PASS));
+      addOrCheckKeepPassRecords(txn_data->hash_key, txn_data->config->keep_pass_record_time);
+      size = getCurrentHashEntries(active_hash_map);
+      TSMutexUnlock(plugin_data->mutex);
+
+      TSDebug(PLUGIN_NAME, "[%zu] hashEntry updated, active_hash_map.size = %zd", txn_data->seq_id, size);
+      txn_data->cc_state = CC_PASSED;
+    } else {
+      addOrCheckKeepPassRecords(0, 0);
+      size = getCurrentHashEntries(active_hash_map);
+      TSMutexUnlock(plugin_data->mutex);
+
+      TSDebug(PLUGIN_NAME, "[%zu] hashEntry removed, active_hash_map.size = %zd", txn_data->seq_id, size);
+      txn_data->cc_state = CC_DONE;
+    }
+    ret = TS_SUCCESS;
+  } else {
+    TSDebug(PLUGIN_NAME, "[%zu] Unable to get mutex", txn_data->seq_id);
+  }
+
+  return ret;
+}
+
+/**
+ * Get hash_key from CacheUrl
+ *
+ * @param TSHttpTxn txnp    Transaction ptr
+ * @param TSMBuffer bufp    TS memory buffer
+ * @param TSMLoc    hdr_loc TS memory loc
+ *
+ * @return uint32_t hash_key
+ */
+static uint32_t
+getCacheUrlHashKey(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc /* hdr_loc ATS_UNUSED */)
+{
+  TSMLoc url_loc = TS_NULL_MLOC;
+  int url_len;
+  char *url = NULL;
+  uint32_t hash_key = 0;
+
+  if (TS_SUCCESS != TSUrlCreate(bufp, &url_loc)) {
+    TSDebug(PLUGIN_NAME, "unable to create url");
+    return 0;
+  }
+
+  if (TS_SUCCESS == TSHttpTxnCacheLookupUrlGet(txnp, bufp, url_loc)) {
+    url = TSUrlStringGet(bufp, url_loc, &url_len);
+  } else {
+    TSDebug(PLUGIN_NAME, "use EffectiveUrl as CacheLookupUrl instead");
+    url = TSHttpTxnEffectiveUrlStringGet(txnp, &url_len);
+  }
+
+  MurmurHash3_x86_32(url, url_len, c_hashSeed, &hash_key);
+  TSDebug(PLUGIN_NAME, "CacheLookupUrl = %s, hash_key = %u", url, hash_key);
+  TSfree(url);
+  TSHandleMLocRelease(bufp, TS_NULL_MLOC, url_loc);
+
+  return hash_key;
+}
+
+/**
+ * Is response public cacheable or not
+ *  try to find Expires and Cache-Control: public, max-age=... headers from server response
+ *
+ * @param TSMBuffer bufp    TS memory buffer
+ * @param TSMLoc    hdr_loc TS memory loc
+ *
+ * @return bool
+ */
+static bool
+isResponseCacheable(TSMBuffer bufp, TSMLoc hdr_loc)
+{
+  bool cacheable = false;
+  bool found_public = false;
+  bool found_maxage = false;
+  bool found_expire = false;
+  TSMLoc field_loc = TS_NULL_MLOC;
+
+  if (0 != (field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_EXPIRES, TS_MIME_LEN_EXPIRES))) {
+    found_expire = true;
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+  }
+
+  if (0 != (field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CACHE_CONTROL, TS_MIME_LEN_CACHE_CONTROL))) {
+    int field_cnt = TSMimeHdrFieldValuesCount(bufp, hdr_loc, field_loc);
+
+    for (int i = 0; i < field_cnt; i++) {
+      int len = 0;
+      const char *val = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, i, &len);
+      if (0 == i) {
+        TSDebug(PLUGIN_NAME, "Cache-Control: %s", val);
+      }
+      if (len == TS_HTTP_LEN_PUBLIC && 0 == strncasecmp(val, TS_HTTP_VALUE_PUBLIC, TS_HTTP_LEN_PUBLIC)) {
+        found_public = true;
+      }
+      if (len > TS_HTTP_LEN_MAX_AGE && 0 == strncasecmp(val, TS_HTTP_VALUE_MAX_AGE, TS_HTTP_LEN_MAX_AGE)) {
+        found_maxage = true;
+      }
+    }
+    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+  }
+
+  if (found_public && (found_expire || found_maxage)) {
+    TSDebug(PLUGIN_NAME, "Response is public cacheable");
+    cacheable = true;
+  } else {
+    TSDebug(PLUGIN_NAME, "Response is non-cacheable");
+  }
+
+  return cacheable;
+}
+
+/**
+ * Retry CacheUrl lock event handler
+ *
+ * @param TSCont  contp  Continuation ptr
+ * @param TSEvent event  TS event
+ * @param void    *edata event Data
+ *
+ * @return int
+ */
+static int
+retryCacheUrlLock(TSCont contp, TSEvent /* event ATS_UNUSED */, void * /* edata ATS_UNUSED */)
+{
+  TryLockData *data = reinterpret_cast < TryLockData * >(TSContDataGet(contp));
+  TSDebug(PLUGIN_NAME, "[%zu] event = %d retry", data->txn_data->seq_id, data->event);
+  collapsedConnectionMainHandler(NULL, data->event, data->txn_data->txnp);
+  TSfree(data);
+  TSContDataSet(contp, NULL);
+  TSContDestroy(contp);
+
+  return 0;
+}
+
+/**
+ * Add TS Cont Schedule to retry mutex lock/update
+ *
+ * @param CcTxnData *txn_data transaction data
+ * @param TSEvent   event     TS Event
+ * @param TSHRTime  timeout   schedule timeout
+ *
+ * @return void
+ */
+static void
+addMutexRetry(CcTxnData * txn_data, TSEvent event, TSHRTime timeout)
+{
+  TSCont contp = TSContCreate(retryCacheUrlLock, NULL);
+  TryLockData *data = static_cast < TryLockData * >(TSmalloc(sizeof(TryLockData)));
+
+  data->event = event;
+  data->txn_data = txn_data;
+  TSContDataSet(contp, data);
+  TSContSchedule(contp, timeout, TS_THREAD_POOL_DEFAULT);
+}
+
+/**
+ * Try to get Collapsed Connection transaction data
+ *  if is first entry hook, allocate it
+ *  else try to get it back from TxnArg
+ *
+ * @param TSHttpTxn txnp   Transaction ptr
+ * @param bool      create Should create new CcTxnData if NULL
+ * @param bool      remap  Calling from remap
+ *
+ * @return *CcTxnData
+ */
+static CcTxnData *
+getCcTxnData(TSHttpTxn txnp, bool create, bool remap)
+{
+  CcPluginData *plugin_data = getCcPlugin();
+  CcTxnData *txn_data = NULL;
+
+  txn_data = reinterpret_cast < CcTxnData * >(TSHttpTxnArgGet(txnp, plugin_data->txn_slot));
+  if (NULL == txn_data && true == create) {
+    txn_data = static_cast < CcTxnData * >(TSmalloc(sizeof(CcTxnData)));
+    txn_data->config = plugin_data->global_config;
+    txn_data->seq_id = plugin_data->seq_id++;
+    txn_data->txnp = txnp;
+    txn_data->contp = NULL;
+    txn_data->hash_key = 0;
+    txn_data->cc_state = CC_NONE;
+    txn_data->wait_time = 0;
+    TSHttpTxnArgSet(txnp, plugin_data->txn_slot, txn_data);
+    if (remap) {
+      TSStatIntIncrement(plugin_data->tol_remap_hook_reqs, 1);
+    } else {
+      TSStatIntIncrement(plugin_data->tol_global_hook_reqs, 1);
+    }
+    TSDebug(PLUGIN_NAME, "txn_data created, active_hash_map.size = %zu", plugin_data->active_hash_map->size());
+  }
+
+  return txn_data;
+}
+
+/**
+ * Free Collapsed Connection transaction data
+ *
+ * @param CcTxnData *txn_data transaction data
+ *
+ * @return void
+ */
+static void
+freeCcTxnData(CcTxnData * txn_data)
+{
+  CcPluginData *plugin_data = getCcPlugin();
+
+  if (txn_data->contp) {
+    TSContDataSet(txn_data->contp, NULL);
+    TSContDestroy(txn_data->contp);
+  }
+  if (txn_data->txnp) {
+    TSHttpTxnArgSet(txn_data->txnp, plugin_data->txn_slot, NULL);
+    TSHttpTxnReenable(txn_data->txnp, TS_EVENT_HTTP_CONTINUE);
+  }
+  TSDebug(PLUGIN_NAME, "[%zu] txn_data released", txn_data->seq_id);
+  TSfree(txn_data);
+}
+
+/**
+ * Lookup CacheUrl in hashTable and lock it in hashTable for collapsed connection
+ *
+ * @param CcTxnData *txn_data transaction data
+ * @param TSEvent   event     TS event
+ *
+ * @return TSReturnCode
+ */
+static TSReturnCode
+lookupAndTryLockCacheUrl(CcTxnData * txn_data, TSEvent event)
+{
+  CcTxnState ret;
+  CcPluginData *plugin_data = getCcPlugin();
+
+  if (0 == txn_data->hash_key) {
+    // New request, check is GET method and gen hash_key
+    TSMBuffer bufp = (TSMBuffer) NULL;
+    TSMLoc hdr_loc = TS_NULL_MLOC;
+    int method_len;
+    const char *method = NULL;
+
+    if (TS_SUCCESS != TSHttpTxnClientReqGet(txn_data->txnp, &bufp, &hdr_loc)) {
+      TSDebug(PLUGIN_NAME, "unable to get client request");
+      freeCcTxnData(txn_data);
+      return TS_ERROR;
+    }
+
+    if (txn_data->config->required_header_len > 0) {
+      TSMLoc field_loc = TSMimeHdrFieldFind(bufp,
+                                            hdr_loc,
+                                            txn_data->config->required_header,
+                                            txn_data->config->required_header_len);
+      if (!field_loc) {
+        TSDebug(PLUGIN_NAME, "%s header not found, ignore it", txn_data->config->required_header);
+        TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+        freeCcTxnData(txn_data);
+        return TS_SUCCESS;
+      }
+      TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+    }
+
+    method = TSHttpHdrMethodGet(bufp, hdr_loc, &method_len);
+    if (TS_HTTP_LEN_GET != method_len || 0 != memcmp(method, TS_HTTP_METHOD_GET, TS_HTTP_LEN_GET)) {
+      TSDebug(PLUGIN_NAME, "method is not GET, ignore it");
+      TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+      freeCcTxnData(txn_data);
+      return TS_SUCCESS;
+    }
+
+    txn_data->hash_key = getCacheUrlHashKey(txn_data->txnp, bufp, hdr_loc);
+    TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+    if (0 == txn_data->hash_key) {
+      freeCcTxnData(txn_data);
+      return TS_ERROR;
+    }
+    TSStatIntIncrement(plugin_data->tol_collapsed_reqs, 1);
+  }
+
+  /*
+   * CC_NONE:   unable to get mutex, try next time
+   * CC_PASS:   previous request mark it non-cacheable, pass, do NOT collapse
+   * CC_LOCKED: hash entry found, wait for release
+   * CC_INSERT: hash entry added, must remove it after receiving response
+   */
+  ret = insertNewHashEntry(txn_data);
+  if (CC_NONE == ret || CC_LOCKED == ret) {
+    addMutexRetry(txn_data, event, txn_data->config->insert_lock_retry_time);
+  } else if (CC_PASS == ret) {
+    TSStatIntIncrement(plugin_data->tol_got_passed_reqs, 1);
+    freeCcTxnData(txn_data);
+  } else if (CC_INSERT == ret) {
+    if (!txn_data->contp) {
+      // txn contp is already created from remap, but only global contp for global hook
+      txn_data->contp = TSContCreate(collapsedConnectionMainHandler, NULL);
+    }
+    txn_data->cc_state = ret;
+    TSHttpTxnHookAdd(txn_data->txnp, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, txn_data->contp);
+    TSHttpTxnHookAdd(txn_data->txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, txn_data->contp);
+    TSHttpTxnHookAdd(txn_data->txnp, TS_HTTP_TXN_CLOSE_HOOK, txn_data->contp);
+    TSHttpTxnReenable(txn_data->txnp, TS_EVENT_HTTP_CONTINUE);
+  } else {
+    TSAssert(!"Unexpected return code");
+  }
+
+  return TS_SUCCESS;
+}
+
+/**
+ * Test origin server response is STATUS_OK & Cacheable or not
+ *  if ! STATUS_OK, try to remove it from hashTable
+ *  if ! cacheable, try to mark it uncacheable in hashTable to let further request pass
+ *  if read_while_writer, try to remove it from hashTable
+ *
+ * @param CcTxnData *txn_data transaction data
+ *
+ * @return TSReturnCode
+ */
+static TSReturnCode
+testResponseCacheable(CcTxnData * txn_data)
+{
+  TSMBuffer bufp = (TSMBuffer) NULL;
+  TSMLoc hdr_loc = TS_NULL_MLOC;
+  TSHttpStatus resp_status;
+
+  if (0 == txn_data->hash_key) {
+    return TS_ERROR;
+  }
+
+  if (TS_SUCCESS != TSHttpTxnServerRespGet(txn_data->txnp, &bufp, &hdr_loc)) {
+    TSDebug(PLUGIN_NAME, "unable to get server response");
+    return TS_ERROR;
+  }
+  resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
+
+  if (TS_HTTP_STATUS_OK != resp_status) {
+    TSDebug(PLUGIN_NAME, "[%zu] response status is not 200 OK, ignore it", txn_data->seq_id);
+    txn_data->cc_state = CC_REMOVE;
+  } else {
+    CcPluginData *plugin_data = getCcPlugin();
+    if (!isResponseCacheable(bufp, hdr_loc)) {
+      TSDebug(PLUGIN_NAME, "[%zu] response is not public cacheable, let all requests pass", txn_data->seq_id);
+
+      txn_data->cc_state = CC_PASS;
+      TSStatIntIncrement(plugin_data->tol_non_cacheable_reqs, 1);
+    } else if (plugin_data->read_while_writer) {
+      txn_data->cc_state = CC_REMOVE;
+    }
+  }
+  TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
+
+  if (CC_PASS == txn_data->cc_state || CC_REMOVE == txn_data->cc_state) {
+    if (TS_SUCCESS != updateOrRemoveHashEntry(txn_data)) {
+      // It's ok to unable to update/remove it here, can update it at next stage
+      TSHttpTxnHookAdd(txn_data->txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, txn_data->contp);
+    }
+  }
+
+  return TS_SUCCESS;
+}
+
+/**
+ * Test cache lookup result is hit_fresh or not
+ *  if hit_fresh, try to remove it from hashTable
+ *
+ * @param CcTxnData *txn_data transaction data
+ *
+ * @return TSReturnCode
+ */
+static TSReturnCode
+testCacheLookupResult(CcTxnData * txn_data)
+{
+  int status = 0;
+
+  if (TS_SUCCESS != TSHttpTxnCacheLookupStatusGet(txn_data->txnp, &status)) {
+    TSDebug(PLUGIN_NAME, "unable to get cache lookup result");
+    return TS_ERROR;
+  }
+
+  if (TS_CACHE_LOOKUP_HIT_FRESH == status || TS_CACHE_LOOKUP_SKIPPED == status) {
+    if (TS_CACHE_LOOKUP_HIT_FRESH == status) {
+      TSDebug(PLUGIN_NAME, "[%zu] cache lookup hit fresh", txn_data->seq_id);
+    } else if (TS_CACHE_LOOKUP_SKIPPED == status) {
+      // client request is not lookupable(no-cache) or in proxy mode only
+      TSDebug(PLUGIN_NAME, "[%zu] cache lookup skipped", txn_data->seq_id);
+    }
+    txn_data->cc_state = CC_REMOVE;
+    // whether success or not, we'll remove it at TXN_CLOSE stage anyway
+    updateOrRemoveHashEntry(txn_data);
+  }
+
+  return TS_SUCCESS;
+}
+
+/**
+ * CollapsedConnection event handler
+ *
+ * @param TSCont  contp  Continuation ptr
+ * @param TSEvent event  TS event
+ * @param void    *edata TS Http transaction
+ *
+ * @return int
+ */
+static int
+collapsedConnectionMainHandler(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
+{
+  TSHttpTxn txnp = reinterpret_cast < TSHttpTxn > (edata);
+  CcTxnData *txn_data = getCcTxnData(txnp, TS_EVENT_HTTP_POST_REMAP == event, false);
+
+  if (NULL != txn_data) {
+    TSDebug(PLUGIN_NAME,
+            "[%zu], event = %d, txn_data-> hash_key = %u, cc_state = %d",
+            txn_data->seq_id, event, txn_data->hash_key, txn_data->cc_state);
+
+    switch (event) {
+    case TS_EVENT_HTTP_POST_REMAP:
+      // hook in global but disabled in remap
+      if (0 == txn_data->config->enabled) {
+        freeCcTxnData(txn_data);
+        return TS_SUCCESS;
+      }
+      lookupAndTryLockCacheUrl(txn_data, event);
+      break;
+    case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
+      testCacheLookupResult(txn_data);
+      TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+      break;
+    case TS_EVENT_HTTP_READ_RESPONSE_HDR:
+      testResponseCacheable(txn_data);
+      TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+      break;
+    case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
+      // whether success or not, we'll remove it at TXN_CLOSE stage anyway
+      updateOrRemoveHashEntry(txn_data);
+      TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+      break;
+    case TS_EVENT_HTTP_TXN_CLOSE:
+      if (CC_DONE == txn_data->cc_state) {
+        freeCcTxnData(txn_data);
+        TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+      } else if (CC_PASS == txn_data->cc_state || CC_PASSED == txn_data->cc_state) {
+        // keep pass sentinel for config->keep_pass_record_time
+        if (txn_data->config->keep_pass_record_time > 0) {
+          if (CC_PASS == txn_data->cc_state && TS_SUCCESS != updateOrRemoveHashEntry(txn_data)) {
+            addMutexRetry(txn_data, event, 0);
+          } else {
+            freeCcTxnData(txn_data);
+          }
+        } else {
+          txn_data->cc_state = CC_REMOVE;
+        }
+      }
+      if (CC_INSERT == txn_data->cc_state || CC_REMOVE == txn_data->cc_state) {
+        txn_data->cc_state = CC_REMOVE;
+        if (TS_SUCCESS == updateOrRemoveHashEntry(txn_data)) {
+          freeCcTxnData(txn_data);
+        } else {
+          // We're at the last stage, must remove hashEntry anyway
+          addMutexRetry(txn_data, event, 0);
+        }
+      }
+      break;
+    default:
+      TSAssert(!"Unexpected event");
+      break;
+    }
+  } else {
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+  }
+
+  return 0;
+}
+
+/**
+ * Try to get Collapsed Connection plugin data
+ *  if is first entry hook, allocate it
+ *
+ * @return *CcPluginData
+ */
+static CcPluginData *
+getCcPlugin()
+{
+  static CcPluginData *data = NULL;
+
+  if (NULL == data) {
+    TSMgmtInt read_while_writer = 0;
+    data = static_cast < CcPluginData * >(TSmalloc(sizeof(CcPluginData)));
+    data->mutex = TSMutexCreate();
+    data->active_hash_map = new UintMap();
+    data->keep_pass_list = new UsecList();
+    data->seq_id = 0;
+    data->global_config = NULL;
+    TSHttpArgIndexReserve(PLUGIN_NAME, "reserve txn_data slot", &(data->txn_slot));
+
+    if (TS_SUCCESS == TSMgmtIntGet("proxy.config.cache.enable_read_while_writer",
+                                   &read_while_writer) && read_while_writer > 0) {
+      data->read_while_writer = true;
+    }
+
+    data->tol_global_hook_reqs =
+      TSStatCreate("collapsed_connection.total.global.reqs",
+                   TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+    data->tol_remap_hook_reqs =
+      TSStatCreate("collapsed_connection.total.remap.reqs",
+                   TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+    data->tol_collapsed_reqs =
+      TSStatCreate("collapsed_connection.total.collapsed.reqs",
+                   TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+    data->tol_non_cacheable_reqs =
+      TSStatCreate("collapsed_connection.total.noncacheable.reqs",
+                   TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+    data->tol_got_passed_reqs =
+      TSStatCreate("collapsed_connection.total.got_passed.reqs",
+                   TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+    data->cur_hash_entries =
+      TSStatCreate("collapsed_connection.current.hash.entries",
+                   TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+    data->cur_keep_pass_entries =
+      TSStatCreate("collapsed_connection.current.keep_pass.entries",
+                   TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+    data->max_hash_entries =
+      TSStatCreate("collapsed_connection.max.hash.entries",
+                   TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+    data->max_keep_pass_entries =
+      TSStatCreate("collapsed_connection.max.keep_pass.entries",
+                   TS_RECORDDATATYPE_INT, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
+  }
+
+  return data;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Initialize the TSRemapAPI plugin.
+//
+TSReturnCode
+TSRemapInit(TSRemapInterface * api_info, char *errbuf, int errbuf_size)
+{
+  if (!api_info) {
+    strncpy(errbuf, "[TSRemapInit] - Invalid TSRemapInterface argument", errbuf_size - 1);
+    return TS_ERROR;
+  }
+
+  if (api_info->size < sizeof(TSRemapInterface)) {
+    strncpy(errbuf, "[TSRemapInit] - Incorrect size of TSRemapInterface structure", errbuf_size - 1);
+    return TS_ERROR;
+  }
+
+  if (api_info->tsremap_version < TSREMAP_VERSION) {
+    snprintf(errbuf, errbuf_size - 1, "[TSRemapInit] - Incorrect API version %ld.%ld",
+             api_info->tsremap_version >> 16, (api_info->tsremap_version & 0xffff));
+    return TS_ERROR;
+  }
+
+  CcPluginData *plugin_data = getCcPlugin();
+
+  TSDebug(PLUGIN_NAME, "Remap plugin is succesfully initialized, txn_slot = %d", plugin_data->txn_slot);
+  return TS_SUCCESS;
+}
+
+TSReturnCode
+TSRemapNewInstance(int argc, char *argv[], void **ih, char *, int)
+{
+  if (argc > 2) {
+    *ih = static_cast < CcPluginConfig * >(initConfig(argv[2]));
+  } else {
+    *ih = static_cast < CcPluginConfig * >(initConfig(NULL));
+  }
+
+  return TS_SUCCESS;
+}
+
+void
+TSRemapDeleteInstance(void *ih)
+{
+  CcPluginConfig *config = static_cast < CcPluginConfig * >(ih);
+
+  if (NULL != config->required_header) {
+    TSfree(config->required_header);
+  }
+
+  TSfree(config);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// This is the main "entry" point for the plugin, called for every request.
+//
+TSRemapStatus
+TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo * /* rri ATS_UNUSED */)
+{
+  TSHttpTxn txnp = static_cast < TSHttpTxn > (rh);
+  CcPluginData *plugin_data = getCcPlugin();
+  CcTxnData *txn_data = getCcTxnData(txnp, true, true);
+
+  txn_data->config = reinterpret_cast < CcPluginConfig * >(ih);
+
+  if (!plugin_data->global_config || !plugin_data->global_config->enabled) {
+    if (txn_data->config->enabled) {
+      TSCont contp = TSContCreate(collapsedConnectionMainHandler, NULL);
+      TSHttpTxnHookAdd(txnp, TS_HTTP_POST_REMAP_HOOK, contp);
+
+      txn_data->contp = contp;
+      TSHttpTxnArgSet(txnp, plugin_data->txn_slot, txn_data);
+    } else {
+      // global & remap were both disabled
+      txn_data->txnp = NULL;
+      freeCcTxnData(txn_data);
+    }
+  } else {
+    // if globally enabled, set txn_data for remap config
+    TSHttpTxnArgSet(txnp, plugin_data->txn_slot, txn_data);
+  }
+
+  return TSREMAP_NO_REMAP;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Initialize the TSAPI plugin for the global hooks we support.
+//
+void
+TSPluginInit(int argc, const char *argv[])
+{
+  TSPluginRegistrationInfo info;
+  TSMgmtInt http_cache = 0;
+  TSCont contp = NULL;
+
+  info.plugin_name = const_cast < char *>(PLUGIN_NAME);
+  info.vendor_name = const_cast < char *>(PLUGIN_VENDOR);
+  info.support_email = const_cast < char *>(PLUGIN_SUPPORT);
+
+  if (TS_SUCCESS != TSPluginRegister(TS_SDK_VERSION_3_0, &info)) {
+    TSError("Plugin registration failed");
+    return;
+  }
+
+  if (TS_SUCCESS != TSMgmtIntGet("proxy.config.http.cache.http", &http_cache) || 0 == http_cache) {
+    TSError("Http cache is disabled, plugin would not work");
+    return;
+  }
+
+  if (!(contp = TSContCreate(collapsedConnectionMainHandler, NULL))) {
+    TSError("Could not create continuation");
+    return;
+  }
+
+  CcPluginData *plugin_data = getCcPlugin();
+  if (argc > 1) {
+    plugin_data->global_config = initConfig(argv[1]);
+  } else {
+    plugin_data->global_config = initConfig(NULL);
+  }
+
+  if (plugin_data->global_config->enabled) {
+    // Last API hook before cache lookup
+    TSHttpHookAdd(TS_HTTP_POST_REMAP_HOOK, contp);
+    TSDebug(PLUGIN_NAME, "TS_HTTP_POST_REMAP_HOOK added, txn_slot = %d", plugin_data->txn_slot);
+  } else {
+    TSDebug(PLUGIN_NAME, "plugin generally disabled");
+  }
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/default.config
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/default.config b/plugins/experimental/collapsed_connection/default.config
new file mode 100644
index 0000000..ce37b71
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/default.config
@@ -0,0 +1,5 @@
+CONFIG proxy.config.http.collapsed_connection.enabled INT 1
+CONFIG proxy.config.http.collapsed_connection.required_header STRING NULL
+CONFIG proxy.config.http.collapsed_connection.insert_lock_retry_time INT 10
+CONFIG proxy.config.http.collapsed_connection.max_lock_retry_timeout INT 2000
+CONFIG proxy.config.http.collapsed_connection.keep_pass_record_time INT 5000

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ddcc688/plugins/experimental/collapsed_connection/state.dot
----------------------------------------------------------------------
diff --git a/plugins/experimental/collapsed_connection/state.dot b/plugins/experimental/collapsed_connection/state.dot
new file mode 100644
index 0000000..5ce368e
--- /dev/null
+++ b/plugins/experimental/collapsed_connection/state.dot
@@ -0,0 +1,40 @@
+digraph collapsed_connection {
+  accept -> TS_HTTP_POST_REMAP_HOOK;
+  TS_HTTP_POST_REMAP_HOOK -> "check request method (and header)";
+
+  "check request method (and header)" -> "get CacheUrl hash_key using MurmurHash3" [label = "GET request (required_header present)"];
+  "check request method (and header)" -> "pass request" [label = "others"];
+  "get CacheUrl hash_key using MurmurHash3" -> "check hash_key from hashTable";
+  "check hash_key from hashTable" -> "lock URL in hashTable" [label = "not found"];
+  "check hash_key from hashTable" -> "pass request" [label = "found, but marked pass"];
+  "check hash_key from hashTable" -> "check hash_key from hashTable" [label = "locked or unable to get mutex, wait insert_lock_retry_time"];
+  "lock URL in hashTable" -> TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK;
+  TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK -> "remove URL from hashTable(1)" [label = "hit_fresh or skipped"];
+  TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK -> "request origin server" [label = "miss or stale"];
+  "request origin server" -> TS_HTTP_READ_RESPONSE_HDR_HOOK;
+  TS_HTTP_READ_RESPONSE_HDR_HOOK -> "remove URL from hashTable(1)" [label = "not 200/OK response"];
+  TS_HTTP_READ_RESPONSE_HDR_HOOK -> "check read_while_writer config";
+  "check read_while_writer config" -> "remove URL from hashTable(1)" [label = "enabled"];
+  "check read_while_writer config" -> TS_HTTP_TXN_CLOSE_HOOK [label = "disabled"];
+  TS_HTTP_READ_RESPONSE_HDR_HOOK -> "mark pass in hashTable" [label = "non-cacheable"];
+  "remove URL from hashTable(1)" -> TS_HTTP_TXN_CLOSE_HOOK;
+  "mark pass in hashTable" -> TS_HTTP_TXN_CLOSE_HOOK;
+  "pass request" -> TS_HTTP_TXN_CLOSE_HOOK;
+  TS_HTTP_TXN_CLOSE_HOOK -> "remove URL from hashTable(2)";
+  TS_HTTP_TXN_CLOSE_HOOK -> "check keep_pass_record_time" [label = "non-cacheable"];
+  "check keep_pass_record_time" -> "add into KeepPassList" [label = "> 0"];
+  "check keep_pass_record_time" -> "remove URL from hashTable(2)" [label = "= 0"];
+  "add into KeepPassList" -> "transaction close";
+  "remove URL from hashTable(2)" -> "transaction close";
+  "transaction close" -> accept;
+
+  TS_HTTP_POST_REMAP_HOOK [shape = box];
+  TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK[shape = box];
+  TS_HTTP_READ_RESPONSE_HDR_HOOK [shape = box];
+  TS_HTTP_TXN_CLOSE_HOOK [shape = box];
+
+  "check request method (and header)" [shape = diamond];
+  "check hash_key from hashTable" [shape = diamond];
+  "check read_while_writer config" [shape = diamond];
+  "check keep_pass_record_time" [shape = diamond];
+}


[10/50] [abbrv] git commit: remove unused MathJax extension, sort extensions one per line

Posted by bc...@apache.org.
remove unused MathJax extension, sort extensions one per line


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

Branch: refs/heads/5.0.x
Commit: 0df9621a86f18aec6f74d37bb98b2aef378a0a29
Parents: 0c50120
Author: Igor Galić <i....@brainsware.org>
Authored: Mon May 26 12:20:02 2014 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Mon May 26 12:20:02 2014 +0200

----------------------------------------------------------------------
 doc/conf.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0df9621a/doc/conf.py
----------------------------------------------------------------------
diff --git a/doc/conf.py b/doc/conf.py
index a2d2297..b4f59ae 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -45,7 +45,16 @@ from manpages import man_pages
 
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.graphviz', 'sphinx.ext.intersphinx', 'sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', 'traffic-server' ]
+extensions = [
+  'sphinx.ext.graphviz',
+  'sphinx.ext.intersphinx',
+  'sphinx.ext.autodoc',
+  'sphinx.ext.todo',
+  'sphinx.ext.coverage',
+  'sphinx.ext.pngmath',
+  'sphinx.ext.viewcode',
+  'traffic-server',
+]
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']


[22/50] [abbrv] git commit: TS-2618] IOBufferBlock::realloc()'s bounds check is wrong.

Posted by bc...@apache.org.
TS-2618] IOBufferBlock::realloc()'s bounds check is wrong.

Original suggestions from William Bardwell.


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

Branch: refs/heads/5.0.x
Commit: 3e35848dc793aec663d03faa56080c7d03d6fd9b
Parents: 92de605
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed May 28 09:34:46 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed May 28 09:35:35 2014 -0600

----------------------------------------------------------------------
 CHANGES                         | 2 ++
 iocore/eventsystem/P_IOBuffer.h | 5 ++---
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3e35848d/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 7e85d7f..2dbba8a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2618] IOBufferBlock::realloc()'s bounds check is wrong.
+
   *) [TS-2850] Fix logging of response header length.
 
   *) [TS-2839] tsxs does not work on OSX (Darwin).

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3e35848d/iocore/eventsystem/P_IOBuffer.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/P_IOBuffer.h b/iocore/eventsystem/P_IOBuffer.h
index 20e1405..55b8add 100644
--- a/iocore/eventsystem/P_IOBuffer.h
+++ b/iocore/eventsystem/P_IOBuffer.h
@@ -530,10 +530,9 @@ IOBufferBlock::realloc_xmalloc(int64_t buf_size)
 TS_INLINE void
 IOBufferBlock::realloc(int64_t i)
 {
-  if (i == data->_size_index)
-    return;
-  if (i >= (int64_t) sizeof(ioBufAllocator))
+  if ((i == data->_size_index) || (i >= (int64_t)countof(ioBufAllocator))) {
     return;
+  }
 
   ink_release_assert(i > data->_size_index && i != BUFFER_SIZE_NOT_ALLOCATED);
   void *b = ioBufAllocator[i].alloc_void();


[09/50] [abbrv] git commit: TS-2344: 404 error was logged while url redirect request was processed correctly Added missing file

Posted by bc...@apache.org.
TS-2344: 404 error was logged while url redirect request was processed correctly
Added missing file


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

Branch: refs/heads/5.0.x
Commit: 0c5012028577f7326b3f89eb505759ab454ab00f
Parents: 0896896
Author: Ethan Lai <yz...@yahoo.com>
Authored: Sun May 25 16:50:58 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Sun May 25 16:50:58 2014 -0700

----------------------------------------------------------------------
 .../body_factory/default/redirect#moved_permanently   | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c501202/proxy/config/body_factory/default/redirect#moved_permanently
----------------------------------------------------------------------
diff --git a/proxy/config/body_factory/default/redirect#moved_permanently b/proxy/config/body_factory/default/redirect#moved_permanently
new file mode 100644
index 0000000..a5c5036
--- /dev/null
+++ b/proxy/config/body_factory/default/redirect#moved_permanently
@@ -0,0 +1,14 @@
+<HTML>
+<HEAD>
+<TITLE>Document Has Moved</TITLE>
+</HEAD>
+
+<BODY BGCOLOR="white" FGCOLOR="black">
+<H1>Document Has Moved</H1>
+<HR>
+
+<FONT FACE="Helvetica,Arial"><B>
+Description: The document you requested has moved to a new location.  The new location is "%<{Location}psh>".
+</B></FONT>
+<HR>
+</BODY>


[19/50] [abbrv] git commit: Updated builds, added Coverity script

Posted by bc...@apache.org.
Updated builds, added Coverity script


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

Branch: refs/heads/5.0.x
Commit: 8c1c05e368cb30618ab31d0cc8a5324fd908bdd0
Parents: 9a72566
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue May 27 19:39:09 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue May 27 19:39:09 2014 -0600

----------------------------------------------------------------------
 ci/jenkins/bin/clang-analyzer.sh |  4 ++--
 ci/jenkins/bin/coverity.sh       | 41 +++++++++++++++++++++++++++++++++++
 ci/jenkins/bin/environment.sh    |  3 +++
 ci/jenkins/bin/in_tree.sh        |  3 ++-
 ci/jenkins/bin/out_of_tree.sh    |  5 +++--
 ci/jenkins/bin/rat.sh            |  4 ++++
 6 files changed, 55 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c1c05e3/ci/jenkins/bin/clang-analyzer.sh
----------------------------------------------------------------------
diff --git a/ci/jenkins/bin/clang-analyzer.sh b/ci/jenkins/bin/clang-analyzer.sh
index eac0fe2..259f6fb 100755
--- a/ci/jenkins/bin/clang-analyzer.sh
+++ b/ci/jenkins/bin/clang-analyzer.sh
@@ -20,7 +20,7 @@ source /home/jenkins/bin/environment.sh
 cd "${WORKSPACE}/src"
 
 autoreconf -fi
-./configure --enable-experimental-plugins
-scan-build -o /home/jenkins/clang-analyzer --html-title="ATS master branch"  ${ATS_MAKE} -j6
+./configure --enable-experimental-plugins --enable-cppapi
+scan-build -o /home/jenkins/clang-analyzer --html-title="ATS master branch"  ${ATS_MAKE} -j4
 
 ${ATS_MAKE} distclean

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c1c05e3/ci/jenkins/bin/coverity.sh
----------------------------------------------------------------------
diff --git a/ci/jenkins/bin/coverity.sh b/ci/jenkins/bin/coverity.sh
new file mode 100755
index 0000000..6c043dd
--- /dev/null
+++ b/ci/jenkins/bin/coverity.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+source /home/jenkins/bin/environment.sh
+cd "${WORKSPACE}/src"
+
+# Get the Coverity tools into our path
+export PATH=/home/coverity/bin:${PATH}
+
+COV_TARBALL=/tmp/trafficserver-${TODAY}.tgz
+COV_VERSION=$(git rev-parse --short HEAD)
+
+autoreconf -fi
+./configure --enable-experimental-plugins --enable-cppapi
+
+cov-build --dir cov-int ${ATS_MAKE} -j4
+tar czvf ${COV_TARBALL} cov-int
+
+# Now submit this artifact
+/home/admin/bin/cov-submit.sh ${COV_TARBALL} ${COV_VERSION}
+
+# Cleanup
+rm -rf cov-int
+rm ${COV_TARBALL}
+
+${ATS_MAKE} distclean

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c1c05e3/ci/jenkins/bin/environment.sh
----------------------------------------------------------------------
diff --git a/ci/jenkins/bin/environment.sh b/ci/jenkins/bin/environment.sh
index 2136e01..633a9c0 100755
--- a/ci/jenkins/bin/environment.sh
+++ b/ci/jenkins/bin/environment.sh
@@ -27,6 +27,9 @@ ATS_MAKE=make
 test "${JOB_NAME#freebsd*}" != "${JOB_NAME}" && ATS_MAKE="gmake"
 export ATS_MAKE
 
+# Useful for timestamps etc. for daily runs
+export TODAY=$(/bin/date +'%m%d%Y')
+
 # Extract the current branch (default to master). ToDo: Can we do this better ?
 ATS_BRANCH=master
 test "${JOB_NAME#*-4.2.x}" != "${JOB_NAME}" && ATS_BRANCH=4.2.x

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c1c05e3/ci/jenkins/bin/in_tree.sh
----------------------------------------------------------------------
diff --git a/ci/jenkins/bin/in_tree.sh b/ci/jenkins/bin/in_tree.sh
index 2668ff5..c78495e 100755
--- a/ci/jenkins/bin/in_tree.sh
+++ b/ci/jenkins/bin/in_tree.sh
@@ -17,9 +17,10 @@
 #  limitations under the License.
 
 source /home/jenkins/bin/environment.sh
-cd "${WORKSPACE}/src_in-tree"
 
 if test "${JOB_NAME#*type=in_tree}" != "${JOB_NAME}"; then
+    cd "${WORKSPACE}/src_in-tree"
+
     # Just use the configure from the snapshot.sh
     ${ATS_MAKE} -j4
     ${ATS_MAKE} check

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c1c05e3/ci/jenkins/bin/out_of_tree.sh
----------------------------------------------------------------------
diff --git a/ci/jenkins/bin/out_of_tree.sh b/ci/jenkins/bin/out_of_tree.sh
index 73598a7..0e16529 100755
--- a/ci/jenkins/bin/out_of_tree.sh
+++ b/ci/jenkins/bin/out_of_tree.sh
@@ -17,11 +17,12 @@
 #  limitations under the License.
 
 source /home/jenkins/bin/environment.sh
-cd "${WORKSPACE}/src_out-of-tree"
 
 if test "${JOB_NAME#*type=out_of_tree}" != "${JOB_NAME}"; then
+    cd "${WORKSPACE}/src_out-of-tree"
+
     # This runs its own configure, so don't use the one from snapshot.sh
-    ${ATS_MAKE} distclean
+    ${ATS_MAKE} -i distclean
     mkdir -p BUILDS && cd BUILDS
     ../configure \
 	--enable-ccache \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8c1c05e3/ci/jenkins/bin/rat.sh
----------------------------------------------------------------------
diff --git a/ci/jenkins/bin/rat.sh b/ci/jenkins/bin/rat.sh
index 18a0490..2b51df4 100755
--- a/ci/jenkins/bin/rat.sh
+++ b/ci/jenkins/bin/rat.sh
@@ -20,6 +20,10 @@ source /home/jenkins/bin/environment.sh
 cd "${WORKSPACE}/src"
 
 autoreconf -if && ./configure
+
+# WTF
+rm -f lib/ts/stamp-h1
+
 ${ATS_MAKE} rat | tee RAT.txt
 mv RAT.txt /home/jenkins/RAT/rat-${ATS_BRANCH}.txt.new
 mv /home/jenkins/RAT/rat-${ATS_BRANCH}.txt.new /home/jenkins/RAT/rat-${ATS_BRANCH}.txt


[24/50] [abbrv] git commit: TS-2842: Can't set SPDY inactivity timeout with traffic_line Reviewed: Bryan Call

Posted by bc...@apache.org.
TS-2842: Can't set SPDY inactivity timeout with traffic_line
Reviewed: Bryan Call


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

Branch: refs/heads/5.0.x
Commit: c25f17c9bef3d5e2fabf6c2b71565966ded8dbb3
Parents: 8a2166a
Author: Sudheer Vinukonda <su...@yahoo-inc.com>
Authored: Wed May 28 15:01:45 2014 -0700
Committer: Bryan Call <bc...@apache.org>
Committed: Wed May 28 15:01:45 2014 -0700

----------------------------------------------------------------------
 CHANGES               |  2 ++
 mgmt/RecordsConfig.cc | 15 ++++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c25f17c9/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 2dbba8a..84a8ccc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2842] Can't set SPDY inactivity timeout with traffic_line
+
   *) [TS-2618] IOBufferBlock::realloc()'s bounds check is wrong.
 
   *) [TS-2850] Fix logging of response header length.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c25f17c9/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 32b1848..b94e44c 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -1931,11 +1931,16 @@ RecordElement RecordsConfig[] = {
   //# SPDY global configuration.
   //#
   //############
-  {RECT_CONFIG, "proxy.config.spdy.max_concurrent_streams_in", RECD_INT, "100", RECU_DYNAMIC, RR_NULL, RECC_INT, NULL, RECA_NULL},
-  {RECT_CONFIG, "proxy.config.spdy.no_activity_timeout_in", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_INT, NULL, RECA_NULL},
-  {RECT_CONFIG, "proxy.config.spdy.initial_window_size_in", RECD_INT, "65536", RECU_DYNAMIC, RR_NULL, RECC_INT, NULL, RECA_NULL},
-  {RECT_CONFIG, "proxy.config.spdy.verbose_in", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, NULL, RECA_NULL},
-  {RECT_CONFIG, "proxy.config.spdy.accept_no_activity_timeout", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_INT, NULL, RECA_NULL},
+  {RECT_CONFIG, "proxy.config.spdy.max_concurrent_streams_in", RECD_INT, "100", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
+  ,
+  {RECT_CONFIG, "proxy.config.spdy.no_activity_timeout_in", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
+  ,
+  {RECT_CONFIG, "proxy.config.spdy.initial_window_size_in", RECD_INT, "65536", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
+  ,
+  {RECT_CONFIG, "proxy.config.spdy.verbose_in", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
+  ,
+  {RECT_CONFIG, "proxy.config.spdy.accept_no_activity_timeout", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
+  ,
 
   //# Add LOCAL Records Here
   {RECT_LOCAL, "proxy.local.incoming_ip_to_bind", RECD_STRING, NULL, RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}


[23/50] [abbrv] git commit: TS-2839 Additional fix for tsxs. I'm not sure if this will break on "gnu" ld, but it works with XCode ld.

Posted by bc...@apache.org.
TS-2839 Additional fix for tsxs. I'm not sure if this
will break on "gnu" ld, but it works with XCode ld.

Suggestions from James Peach.


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

Branch: refs/heads/5.0.x
Commit: 8a2166ab71d0178f43baa6b63daaa3f83344c08f
Parents: 3e35848
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed May 28 10:02:45 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed May 28 10:05:52 2014 -0600

----------------------------------------------------------------------
 tools/tsxs.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8a2166ab/tools/tsxs.in
----------------------------------------------------------------------
diff --git a/tools/tsxs.in b/tools/tsxs.in
index ec66ab7..d5de492 100755
--- a/tools/tsxs.in
+++ b/tools/tsxs.in
@@ -122,7 +122,7 @@ case $host in
         MODULELD="$CC -bundle -flat_namespace -undefined suppress"
         MODULELDXX="$CXX -bundle -flat_namespace -undefined suppress"
         MODULEEXT=bundle
-        RLDFLAG="-Wl,-rpath "
+        RLDFLAG="-Wl,-rpath,"
         ;;
 *-*-solaris*)
         PICFLAGS="-fpic"


[15/50] [abbrv] git commit: TS-2820: Crash in transformations

Posted by bc...@apache.org.
TS-2820: Crash in transformations


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

Branch: refs/heads/5.0.x
Commit: 0c30d4d813c35bf354058dca22f2adf5e8c769fa
Parents: 92a2c62
Author: Brian Geffon <br...@apache.org>
Authored: Tue May 27 11:14:10 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Tue May 27 11:14:10 2014 -0700

----------------------------------------------------------------------
 CHANGES | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c30d4d8/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 8f28973..55f8193 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2820] Add check to Transformations in C++ api to prevent closing
+      connections twice.
+
   *) [TS-2804] Add regex_revalidate plugin to explerimental plugins directory.
 
   *) [TS-2528] Use <stdbool.h> in the public mgmtapi.h interface. This follows


[36/50] [abbrv] git commit: Fix indentation in configure.ac, NO TABS!

Posted by bc...@apache.org.
Fix indentation in configure.ac, NO TABS!


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

Branch: refs/heads/5.0.x
Commit: e9ac7f6d9fbd525c817e3feea8206e1e6625a244
Parents: 1cb12a9
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu May 29 12:09:57 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu May 29 12:10:19 2014 -0600

----------------------------------------------------------------------
 configure.ac | 138 +++++++++++++++++++++++++++---------------------------
 1 file changed, 69 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e9ac7f6d/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index fa69263..29520c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -334,11 +334,11 @@ AC_ARG_ENABLE([tproxy],
   [AS_HELP_STRING([--enable-tproxy[[=ARG]]],
                   [Use TPROXY to enable connection transparency.
                    'auto' or omitted for local system default,
-		   'no' to disable,
-		   'force' to use built in default,
-		   number to use as IP_TRANSPARENT sockopt.
-		   [default=auto]
-		  ])
+                   'no' to disable,
+                   'force' to use built in default,
+                   number to use as IP_TRANSPARENT sockopt.
+                   [default=auto]
+                  ])
   ],
   [],
   [enable_tproxy="auto"]
@@ -369,10 +369,10 @@ AC_SUBST(use_freelist)
 if test "x${enable_freelist}" = "xyes"; then
   AC_MSG_CHECKING([whether to enable reclaimable freelist])
   AC_ARG_ENABLE([reclaimable-freelist],
-		[AS_HELP_STRING([--enable-reclaimable-freelist],
-				[enable reclaimable freelist support (effective only when freelist is enabled)])],
-		[],
-		[enable_reclaimable_freelist="no"])
+                [AS_HELP_STRING([--enable-reclaimable-freelist],
+                                [enable reclaimable freelist support (effective only when freelist is enabled)])],
+                [],
+                [enable_reclaimable_freelist="no"])
   AC_MSG_RESULT([$enable_reclaimable_freelist])
 else
   enable_reclaimable_freelist="no"
@@ -385,9 +385,9 @@ AC_SUBST(use_reclaimable_freelist)
 #
 AC_MSG_CHECKING([whether to enable spdy])
 AC_ARG_ENABLE([spdy],
-	[AS_HELP_STRING([--enable-spdy], [turn on spdy protocol])],
-	[],
-	[enable_spdy="no"])
+        [AS_HELP_STRING([--enable-spdy], [turn on spdy protocol])],
+        [],
+        [enable_spdy="no"])
 AC_MSG_RESULT([$enable_spdy])
 TS_ARG_ENABLE_VAR([has], [spdy])
 AC_SUBST(has_spdy)
@@ -728,10 +728,10 @@ AS_IF([test -n "$YACC"],
         `
         AS_IF([test "x$bison_version_check" != "xyes"],
           [ YACC=''
-	    AS_IF([test -z "$bison_version_check"],
-	      [bison_version_check='no version data']
-	    )
-	  ]
+            AS_IF([test -z "$bison_version_check"],
+              [bison_version_check='no version data']
+            )
+          ]
         )
       ],
       [ YACC=''
@@ -752,10 +752,10 @@ AS_IF([test -n "$LEX"],
         `
         AS_IF([test "x$flex_version_check" != "xyes"],
           [ LEX=''
-	    AS_IF([test -z "$flex_version_check"],
-	      [flex_version_check='no version data']
-	    )
-	  ]
+            AS_IF([test -z "$flex_version_check"],
+              [flex_version_check='no version data']
+            )
+          ]
         )
       ],
       [ LEX=''
@@ -794,15 +794,15 @@ AX_PROG_PERL_MODULES([ExtUtils::MakeMaker], AM_CONDITIONAL([BUILD_PERL_LIB], [tr
 AC_MSG_CHECKING([checking whether to auto-set compiler optimization flags])
 has_optimizer_flags=`echo "$CFLAGS $CXXFLAGS" | ${AWK} '$0 !~ /-O.?/{print "no"}'`
 AS_IF([test "x${has_optimizer_flags}" = "xno"],
-	[
-		optimizing_flags='-O3'
-		AC_MSG_RESULT([yes ${optimizing_flags}])
-	],
-	[
-		has_optimizer_flags='yes'
-		optimizing_flags=''
-		AC_MSG_RESULT([no])
-	]
+        [
+                optimizing_flags='-O3'
+                AC_MSG_RESULT([yes ${optimizing_flags}])
+        ],
+        [
+                has_optimizer_flags='yes'
+                optimizing_flags=''
+                AC_MSG_RESULT([no])
+        ]
 )
 
 AM_CONDITIONAL([BUILD_HAVE_LIBCXX], [ false ])
@@ -1050,8 +1050,8 @@ AC_MSG_NOTICE([Build for host OS: $host_os, arch: $host_cpu, optimization: $host
 if test "x$enable_ccache" = "xyes"; then
     AC_CHECK_PROG([CCACHE],[ccache],[ccache],[])
     if test "x${CCACHE}" = "xccache"; then
-	CC="$CCACHE $CC"
-	CXX="$CCACHE $CXX"
+        CC="$CCACHE $CC"
+        CXX="$CCACHE $CXX"
     fi
 fi
 
@@ -1458,8 +1458,8 @@ TS_FLAG_HEADERS([sys/epoll.h \
                   stdbool.h \
                   net/ppp_defs.h \
                   ifaddrs.h\
-		  readline/readline.h \
-		  editline/readline.h ])
+                  readline/readline.h \
+                  editline/readline.h ])
 
 AC_SUBST(sys_epollh)
 AC_SUBST(sys_eventh)
@@ -1632,17 +1632,17 @@ AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len], [], [], [#include <netinet/in.h>
 
 if test "x${ac_cv_member_struct_sockaddr_sa_len}" = xyes; then
     AC_DEFINE(HAVE_STRUCT_SOCKADDR_SA_LEN, 1,
-	    [Whether struct sockaddr_in has the sa_len member])
+            [Whether struct sockaddr_in has the sa_len member])
 fi
 
 if test "x${ac_cv_member_struct_sockaddr_in_sin_len}" = xyes ; then
 AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN_SIN_LEN, 1,
-	    [Whether struct sockaddr_in has the sin_len member])
+            [Whether struct sockaddr_in has the sin_len member])
 fi
 
 if test "x${ac_cv_member_struct_sockaddr_in6_sin6_len}" = xyes; then
     AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN, 1,
-	    [Whether struct sockaddr_in6 has the sin6_len member])
+            [Whether struct sockaddr_in6 has the sin6_len member])
 fi
 
 if test "x${with_profiler}" = "xyes"; then
@@ -1702,43 +1702,43 @@ AS_IF([test "x$enable_tproxy" != "xno"], [
     AC_MSG_CHECKING([for TPROXY sockopt IP_TRANSPARENT])
     case "$enable_tproxy" in
       [[0-9][0-9]*])
-	ip_transparent=$enable_tproxy
-	use_tproxy=1
-	AC_MSG_RESULT([forced to $ip_transparent])
-	;;
+        ip_transparent=$enable_tproxy
+        use_tproxy=1
+        AC_MSG_RESULT([forced to $ip_transparent])
+        ;;
       force)
-	ip_transparent=19
-	use_tproxy=1
-	AC_MSG_RESULT([forced to $ip_transparent])
-	;;
+        ip_transparent=19
+        use_tproxy=1
+        AC_MSG_RESULT([forced to $ip_transparent])
+        ;;
       yes|auto)
         AS_IF([test -r $tproxy_header], [
-	  ip_transparent=`$AWK "/^#define[ \t]+IP_TRANSPARENT[ \t]+[0-9]+/{print \\$3}" $tproxy_header`
-	  AS_IF([test "x$ip_transparent" != "x"], [
-	    use_tproxy=1
-	    AC_MSG_RESULT([set to $ip_transparent])
-	  ],[
-	    ip_transparent=0
-	    AS_IF([test "x$enable_tproxy" = xauto], [
-	     AC_MSG_RESULT([no])
-	    ],[
-	      AC_MSG_RESULT([failed])
-	      AC_MSG_FAILURE([tproxy feature enabled but the sockopt value was not found in $tproxy_header. Try one of$tproxy_usage_default$tproxy_usage_numeric$tproxy_usage_disable])
-	    ])
-	  ])
-	],[
-	  AS_IF([test "x$enable_tproxy" = xauto], [
-	    AC_MSG_RESULT([no])
-	  ],[
-	    AC_MSG_RESULT([failed])
-	    AC_MSG_FAILURE([tproxy feature enabled but the header file $tproxy_header was not readable. Try one of$tproxy_usage_default$tproxy_usage_numeric$tproxy_usage_disable])
-	  ])
-	])
-	;;
+          ip_transparent=`$AWK "/^#define[ \t]+IP_TRANSPARENT[ \t]+[0-9]+/{print \\$3}" $tproxy_header`
+          AS_IF([test "x$ip_transparent" != "x"], [
+            use_tproxy=1
+            AC_MSG_RESULT([set to $ip_transparent])
+          ],[
+            ip_transparent=0
+            AS_IF([test "x$enable_tproxy" = xauto], [
+             AC_MSG_RESULT([no])
+            ],[
+              AC_MSG_RESULT([failed])
+              AC_MSG_FAILURE([tproxy feature enabled but the sockopt value was not found in $tproxy_header. Try one of$tproxy_usage_default$tproxy_usage_numeric$tproxy_usage_disable])
+            ])
+          ])
+        ],[
+          AS_IF([test "x$enable_tproxy" = xauto], [
+            AC_MSG_RESULT([no])
+          ],[
+            AC_MSG_RESULT([failed])
+            AC_MSG_FAILURE([tproxy feature enabled but the header file $tproxy_header was not readable. Try one of$tproxy_usage_default$tproxy_usage_numeric$tproxy_usage_disable])
+          ])
+        ])
+        ;;
       *)
-	AC_MSG_RESULT([failed])
-	AC_MSG_FAILURE([Invalid argument to feature tproxy.$tproxy_usage])
-	;;
+        AC_MSG_RESULT([failed])
+        AC_MSG_FAILURE([Invalid argument to feature tproxy.$tproxy_usage])
+        ;;
       esac
   ])
 ])


[18/50] [abbrv] git commit: TS-2839 Fix missing space

Posted by bc...@apache.org.
TS-2839 Fix missing space


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

Branch: refs/heads/5.0.x
Commit: 9a72566939d323da8f7baaada9a9204edb5d890c
Parents: d1061cc
Author: Masakazu Kitajo <mk...@yahoo-corp.jp>
Authored: Tue May 27 18:54:13 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue May 27 18:54:13 2014 -0600

----------------------------------------------------------------------
 tools/tsxs.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a725669/tools/tsxs.in
----------------------------------------------------------------------
diff --git a/tools/tsxs.in b/tools/tsxs.in
index ef7b0f1..ec66ab7 100755
--- a/tools/tsxs.in
+++ b/tools/tsxs.in
@@ -122,7 +122,7 @@ case $host in
         MODULELD="$CC -bundle -flat_namespace -undefined suppress"
         MODULELDXX="$CXX -bundle -flat_namespace -undefined suppress"
         MODULEEXT=bundle
-        RLDFLAG="-Wl,-rpath="
+        RLDFLAG="-Wl,-rpath "
         ;;
 *-*-solaris*)
         PICFLAGS="-fpic"


[20/50] [abbrv] git commit: TS-2850: Fix logging of response header length

Posted by bc...@apache.org.
TS-2850: Fix logging of response header length


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

Branch: refs/heads/5.0.x
Commit: c304b48127bdcf6a650060700de32f575bafa2c9
Parents: 8c1c05e
Author: Phil Sorber <so...@apache.org>
Authored: Tue May 27 21:09:24 2014 -0600
Committer: Phil Sorber <so...@apache.org>
Committed: Tue May 27 21:09:24 2014 -0600

----------------------------------------------------------------------
 CHANGES                        | 2 ++
 proxy/logging/LogAccessHttp.cc | 5 +----
 2 files changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c304b481/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 8ec7fae..7e85d7f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2850] Fix logging of response header length.
+
   *) [TS-2839] tsxs does not work on OSX (Darwin).
    Author: Masakazu Kitajo <m4...@gmail.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c304b481/proxy/logging/LogAccessHttp.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index b44e684..91534f2 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -658,10 +658,7 @@ int
 LogAccessHttp::marshal_proxy_resp_header_len(char *buf)
 {
   if (buf) {
-    int64_t val = 0;
-    if (m_proxy_response) {
-      val = m_proxy_response->length_get();
-    }
+    int64_t val = m_http_sm->client_response_hdr_bytes;
     marshal_int(buf, val);
   }
   return INK_MIN_ALIGN;


[04/50] [abbrv] TS-2555: update README.md and remove old lua plugin

Posted by bc...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/lua/state.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/state.h b/plugins/experimental/lua/state.h
deleted file mode 100644
index 3cdf810..0000000
--- a/plugins/experimental/lua/state.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-*/
-
-#ifndef LUA_STATE_H_
-#define LUA_STATE_H_
-
-#include <string>
-#include <vector>
-#include <utility>
-#include <pthread.h>
-#include <lua.hpp>
-
-/*
-
-Lua Plugin threading model
-
-For remapping, we need to support multiple indepedent Lua plugin
-instances. Each instance is handled by a LuaPluginInstance object.
-Each plugin instance maintains a pool of lua_States which are
-independent Lua interpeters. The LuaThreadState object owns a single
-lua_State, holding additional hook data that is needed to de-multiplex
-events.
-
-There are two basic code paths to obtaining a LuaThreadState. If
-we already have a lua_State, then we can use the __instanceid and
-__threadid global variables to identify the LuaThreadState object.
-If we don't have a lua_State, then we know the instance ID from the
-hook continuation data (attached per LuaPluginInstance), and we
-choose a state by hashing the thread ID.
-
-  Traffic Server +-> LuaPluginInstance[0]
-                 |   +-> LuaThreadState[0]
-                 |   +-> LuaThreadState[1]
-                 |   +-> LuaThreadState[2]
-                 |   +-> LuaThreadState[3]
-                 |
-                 +-> LuaPluginInstance[1]
-                 |   +-> LuaThreadState[0]
-                 |   +-> LuaThreadState[1]
-                 |   +-> LuaThreadState[2]
-                 |   +-> LuaThreadState[3]
-                 |
-                 +-> LuaPluginInstance[2]
-                     +-> LuaThreadState[0]
-                     +-> LuaThreadState[1]
-                     +-> LuaThreadState[2]
-                     +-> LuaThreadState[3]
-
-*/
-
-typedef uint32_t instanceid_t;
-
-struct LuaThreadState;
-struct LuaPluginInstance;
-
-// Per-thread lua_State. Used to execute Lua-side code in ethreads.
-struct LuaThreadState
-{
-  lua_State *         lua;
-  int                 hookrefs[TS_HTTP_LAST_HOOK];
-  LuaPluginInstance * instance;
-
-  pthread_mutex_t mutex;
-
-  LuaThreadState();
-  ~LuaThreadState();
-
-  bool alloc(LuaPluginInstance *, unsigned);
-  bool init(LuaPluginInstance *);
-  void release();
-
-private:
-  LuaThreadState(const LuaThreadState&); // disable
-  LuaThreadState& operator=(const LuaThreadState&); // disable
-};
-
-struct LuaPluginInstance
-{
-  typedef std::vector<std::string> pathlist_t;
-  typedef TSCont demux_table_t[TS_HTTP_LAST_HOOK];
-
-  LuaPluginInstance();
-  ~LuaPluginInstance();
-
-  void invalidate();
-  void init(unsigned argc, const char ** argv);
-
-  struct {
-    demux_table_t global;
-    demux_table_t txn;
-    demux_table_t ssn;
-  } demux;
-
-  instanceid_t  instanceid;
-  pathlist_t    paths;
-  std::vector<LuaThreadState *> states;
-
-private:
-  LuaPluginInstance(const LuaPluginInstance&); // disable
-  LuaPluginInstance& operator=(const LuaPluginInstance&); // disable
-};
-
-instanceid_t LuaPluginRegister(unsigned argc, const char ** argv);
-void LuaPluginUnregister(instanceid_t instanceid);
-
-// Acquire a locked Lua thread state belonging to the given instance.
-std::pair<LuaThreadState *, LuaPluginInstance *> LuaThreadStateAcquire(instanceid_t);
-std::pair<LuaThreadState *, LuaPluginInstance *> LuaThreadStateAcquire(lua_State *);
-// Return the previously acquired Lua thread state.
-void LuaThreadStateRelease(LuaThreadState *);
-
-struct ScopedLuaState
-{
-  explicit ScopedLuaState(instanceid_t instanceid)
-    : ptr(LuaThreadStateAcquire(instanceid)) {
-  }
-
-  explicit ScopedLuaState(lua_State * lua)
-    : ptr(LuaThreadStateAcquire(lua)) {
-  }
-
-  ~ScopedLuaState() {
-    LuaThreadStateRelease(this->ptr.first);
-  }
-
-  operator bool() const {
-    return this->ptr.first != NULL;
-  }
-
-  LuaThreadState * operator->() const {
-    return this->ptr.first;
-  }
-
-  LuaPluginInstance * instance() const {
-    return this->ptr.second;
-  }
-
-private:
-  std::pair<LuaThreadState *, LuaPluginInstance *> ptr;
-};
-
-#endif // LUA_STATE_H_

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9a3e5de5/plugins/experimental/ts_lua/README.md
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/README.md b/plugins/experimental/ts_lua/README.md
index a0fc7fc..6efbbd1 100644
--- a/plugins/experimental/ts_lua/README.md
+++ b/plugins/experimental/ts_lua/README.md
@@ -3,544 +3,7 @@ Name
 
 ts-lua - Embed the Power of Lua into TrafficServer.
 
-Status
+Documentation
 ======
-This module is being tested under our production environment.
-
-Version
-======
-ts-lua has not been released yet.
-
-Synopsis
-======
-
-**test_hdr.lua**
-
-    function send_response()
-        ts.client_response.header['Rhost'] = ts.ctx['rhost']
-        return 0
-    end
-
-
-    function do_remap()
-        local req_host = ts.client_request.header.Host
-
-        if req_host == nil then
-            return 0
-        end
-
-        ts.ctx['rhost'] = string.reverse(req_host)
-
-        ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
-
-        return 0
-    end
-
-
-
-**test_transform.lua**
-
-    function upper_transform(data, eos)
-        if eos == 1 then
-            return string.upper(data)..'S.H.E.\n', eos
-        else
-            return string.upper(data), eos
-        end
-    end
-
-    function send_response()
-        ts.client_response.header['SHE'] = ts.ctx['tb']['she']
-        return 0
-    end
-
-
-    function do_remap()
-        local req_host = ts.client_request.header.Host
-
-        if req_host == nil then
-            return 0
-        end
-
-        ts.ctx['tb'] = {}
-        ts.ctx['tb']['she'] = 'wo ai yu ye hua'
-
-        ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
-        ts.hook(TS_LUA_RESPONSE_TRANSFORM, upper_transform)
-
-        ts.http.resp_cache_transformed(0)
-        ts.http.resp_cache_untransformed(1)
-        return 0
-    end
-
-
-
-**test_cache_lookup.lua**
-
-    function send_response()
-        ts.client_response.header['Rhost'] = ts.ctx['rhost']
-        ts.client_response.header['CStatus'] = ts.ctx['cstatus']
-    end
-
-
-    function cache_lookup()
-        local cache_status = ts.http.get_cache_lookup_status()
-        ts.ctx['cstatus'] = cache_status
-    end
-
-
-    function do_remap()
-        local req_host = ts.client_request.header.Host
-
-        if req_host == nil then
-            return 0
-        end
-
-        ts.ctx['rhost'] = string.reverse(req_host)
-
-        ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
-        ts.hook(TS_LUA_HOOK_CACHE_LOOKUP_COMPLETE, cache_lookup)
-
-        return 0
-    end
-
-
-
-**test_ret_403.lua**
-
-    function send_response()
-        ts.client_response.header['Now'] = ts.now()
-        return 0
-    end
-
-
-    function do_remap()
-
-        local uri = ts.client_request.get_uri()
-
-        pos, len = string.find(uri, '/css/')
-        if pos ~= nil then
-            ts.http.set_resp(403, "Document access failed :)\n")
-            return 0
-        end
-
-        ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
-
-        return 0
-    end
-
-
-
-**sethost.lua**
-
-    HOSTNAME = ''
-
-    function __init__(argtb)
-
-        if (#argtb) < 1 then
-            print(argtb[0], 'hostname parameter required!!')
-            return -1
-        end
-
-        HOSTNAME = argtb[1]
-    end
-
-    function do_remap()
-        local req_host = ts.client_request.header.Host
-
-        if req_host == nil then
-            return 0
-        end
-
-        ts.client_request.header['Host'] = HOSTNAME
-
-        return 0
-    end
-
-
-**test_intercept.lua**
-
-    require 'os'
-
-    function send_data()
-        local nt = os.time()..' Zheng.\n'
-        local resp =  'HTTP/1.1 200 OK\r\n' ..
-            'Server: ATS/3.2.0\r\n' ..
-            'Content-Type: text/plain\r\n' ..
-            'Content-Length: ' .. string.len(nt) .. '\r\n' ..
-            'Last-Modified: ' .. os.date("%a, %d %b %Y %H:%M:%S GMT", os.time()) .. '\r\n' ..
-            'Connection: keep-alive\r\n' ..
-            'Cache-Control: max-age=7200\r\n' ..
-            'Accept-Ranges: bytes\r\n\r\n' ..
-            nt
-
-        ts.sleep(1)
-        return resp
-    end
-
-    function do_remap()
-        ts.http.intercept(send_data)
-        return 0
-    end
-
-
-**test_server_intercept.lua**
-
-    require 'os'
-
-    function send_data()
-        local nt = os.time()..'\n'
-        local resp =  'HTTP/1.1 200 OK\r\n' ..
-            'Server: ATS/3.2.0\r\n' ..
-            'Content-Type: text/plain\r\n' ..
-            'Content-Length: ' .. string.len(nt) .. '\r\n' ..
-            'Last-Modified: ' .. os.date("%a, %d %b %Y %H:%M:%S GMT", os.time()) .. '\r\n' ..
-            'Connection: keep-alive\r\n' ..
-            'Cache-Control: max-age=30\r\n' ..
-            'Accept-Ranges: bytes\r\n\r\n' ..
-            nt
-        return resp
-    end
-
-    function do_remap()
-        ts.http.server_intercept(send_data)
-        return 0
-    end
-
-
-Description
-======
-This module embeds Lua, via the standard Lua 5.1 interpreter, into Apache Traffic Server. This module acts as remap plugin of Traffic Server, so we should realize **'do_remap'** function in each lua script. We can write this in remap.config:
-
-map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/usr/lib64/trafficserver/plugins/libtslua.so @pparam=/etc/trafficserver/script/test_hdr.lua
-
-Sometimes we want to receive parameters and process them in the script, we should realize **'\__init__'** function in the lua script(sethost.lua is a reference), and we can write this in remap.config:
-
-map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/usr/lib64/trafficserver/plugins/libtslua.so @pparam=/etc/trafficserver/script/sethost.lua @pparam=img03.tbcdn.cn
-
-
-
-TS API for Lua
-======
-Introduction
-------
-The API is exposed to Lua in the form of one standard packages ts. This package is in the default global scope and is always available within lua script.
-
-
-
-ts.now
-------
-**syntax**: *val = ts.now()*
-
-**context**: global
-
-**description**: This function returns the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds.
-
-Here is an example:
-
-    function send_response()
-        ts.client_response.header['Now'] = ts.now()
-        return 0
-    end
-
-
-ts.debug
-------
-**syntax**: *ts.debug(MESSAGE)*
-
-**context**: global
-
-**description**: Log the MESSAGE to traffic.out if debug is enabled.
-
-Here is an example:
-
-    function do_remap()
-       ts.debug('I am in do_remap now.')
-       return 0
-    end
-    
-The debug tag is ts_lua and we should write this in records.config:
-    
-    CONFIG proxy.config.diags.debug.tags STRING ts_lua
-    
-
-ts.hook
-------
-**syntax**: *ts.hook(HOOK_POINT, FUNCTION)*
-
-**context**: do_remap or later
-
-**description**: Hooks are points in http transaction processing where we can step in and do some work.
-FUNCTION will be called when the http transaction steps in to HOOK_POINT.
-
-Here is an example:
-
-    function send_response()
-        s.client_response.header['SHE'] = 'belief'
-    end
-    
-    function do_remap()
-        ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
-    end
-
-Hook point constants
-------
-**context**: do_remap or later
-
-    TS_LUA_HOOK_CACHE_LOOKUP_COMPLETE
-    TS_LUA_HOOK_SEND_REQUEST_HDR
-    TS_LUA_HOOK_READ_RESPONSE_HDR
-    TS_LUA_HOOK_SEND_RESPONSE_HDR
-    TS_LUA_REQUEST_TRANSFORM
-    TS_LUA_RESPONSE_TRANSFORM
-    
-These constants are usually used in ts.hook method call.
-
-
-ts.ctx
-------
-**syntax**: *ts.ctx[KEY]*
-
-**context**: do_remap or later
-
-**description**: This table can be used to store per-request Lua context data and has a life time identical to the current request.
-
-Here is an example:
-
-    function send_response()
-        ts.client_response.header['RR'] = ts.ctx['rhost']
-        return 0
-    end
-    
-    function do_remap()
-        local req_host = ts.client_request.header.Host
-        ts.ctx['rhost'] = string.reverse(req_host)
-        ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
-        return 0
-    end
-
-
-ts.http.get_cache_lookup_status
-------
-**syntax**: *ts.http.get_cache_lookup_status()*
-
-**context**: function @ TS_LUA_HOOK_CACHE_LOOKUP_COMPLETE hook point
-
-**description**: This function can be used to get cache lookup status.
-
-Here is an example:
-
-    function send_response()
-        ts.client_response.header['CStatus'] = ts.ctx['cstatus']
-    end
-    
-    function cache_lookup()
-        local cache_status = ts.http.get_cache_lookup_status()
-        if cache_status == TS_LUA_CACHE_LOOKUP_HIT_FRESH:
-            ts.ctx['cstatus'] = 'hit'
-        else
-            ts.ctx['cstatus'] = 'not hit'
-        end
-    end
-    
-    function do_remap()
-        ts.hook(TS_LUA_HOOK_CACHE_LOOKUP_COMPLETE, cache_lookup)
-        ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
-        return 0
-    end
-
-
-Http cache lookup status constants
-------
-**context**: global
-
-    TS_LUA_CACHE_LOOKUP_MISS (0)
-    TS_LUA_CACHE_LOOKUP_HIT_STALE (1)
-    TS_LUA_CACHE_LOOKUP_HIT_FRESH (2)
-    TS_LUA_CACHE_LOOKUP_SKIPPED (3)
-
-
-ts.http.set_cache_url
-------
-**syntax**: *ts.http.set_cache_url(KEY_URL)*
-
-**context**: do_remap
-
-**description**: This function can be used to modify the cache key for the request.
-
-Here is an example:
-
-    function do_remap()
-        ts.http.set_cache_url('http://127.0.0.1:8080/abc/')
-        return 0
-    end
-
-
-ts.http.resp_cache_transformed
-------
-**syntax**: *ts.http.resp_cache_transformed(BOOL)*
-
-**context**: do_remap or later
-
-**description**: This function can be used to tell trafficserver whether to cache the transformed data.
-
-Here is an example:
-
-    function upper_transform(data, eos)
-        if eos == 1 then
-            return string.upper(data)..'S.H.E.\n', eos
-        else
-            return string.upper(data), eos
-        end
-    end
-    
-    function do_remap()
-        ts.hook(TS_LUA_RESPONSE_TRANSFORM, upper_transform)
-        ts.http.resp_cache_transformed(0)
-        ts.http.resp_cache_untransformed(1)
-        return 0
-    end
-    
-This function is usually called after we hook TS_LUA_RESPONSE_TRANSFORM.
-
-
-ts.http.resp_cache_untransformed
-------
-**syntax**: *ts.http.resp_cache_untransformed(BOOL)*
-
-**context**: do_remap or later
-
-**description**: This function can be used to tell trafficserver whether to cache the untransformed data.
-
-Here is an example:
-
-    function upper_transform(data, eos)
-        if eos == 1 then
-            return string.upper(data)..'S.H.E.\n', eos
-        else
-            return string.upper(data), eos
-        end
-    end
-    
-    function do_remap()
-        ts.hook(TS_LUA_RESPONSE_TRANSFORM, upper_transform)
-        ts.http.resp_cache_transformed(0)
-        ts.http.resp_cache_untransformed(1)
-        return 0
-    end
-    
-This function is usually called after we hook TS_LUA_RESPONSE_TRANSFORM.
-
-
-ts.client_request.client_addr.get_addr
-------
-**syntax**: *ts.client_request.client_addr.get_addr()*
-
-**context**: do_remap or later
-
-**description**: This function can be used to get socket address of the client.
-
-Here is an example:
-
-    function do_remap
-        ip, port, family = ts.client_request.client_addr.get_addr()
-        return 0
-    end
-
-The ts.client_request.client_addr.get_addr function returns three values, ip is a string, port and family is number.
-
-
-ts.client_request.get_method
-------
-**syntax**: *ts.client_request.get_method()*
-
-**context**: do_remap or later
-
-**description**: This function can be used to retrieve the current request's request method name. String like "GET" or 
-"POST" is returned.
-
-
-ts.client_request.set_method
-------
-**syntax**: *ts.client_request.set_method(METHOD_NAME)*
-
-**context**: do_remap
-
-**description**: This function can be used to override the current request's request method with METHOD_NAME.
-
-
-ts.client_request.get_url
-------
-**syntax**: *ts.client_request.get_url()*
-
-**context**: do_remap or later
-
-**description**: This function can be used to retrieve the whole request's url.
-
-
-ts.client_request.get_uri
-------
-**syntax**: *ts.client_request.get_uri()*
-
-**context**: do_remap or later
-
-**description**: This function can be used to retrieve the request's path.
-
-
-ts.client_request.set_uri
-------
-**syntax**: *ts.client_request.set_uri(PATH)*
-
-**context**: do_remap
-
-**description**: This function can be used to override the request's path.
-
-
-ts.client_request.get_uri_args
-------
-**syntax**: *ts.client_request.get_uri_args()*
-
-**context**: do_remap or later
-
-**description**: This function can be used to retrieve the request's query string.
-
-
-ts.client_request.set_uri_args
-------
-**syntax**: *ts.client_request.set_uri_args(QUERY_STRING)*
-
-**context**: do_remap
-
-**description**: This function can be used to override the request's query string.
-
-
-ts.client_request.header.HEADER
-------
-**syntax**: *ts.client_request.header.HEADER = VALUE*
-
-**syntax**: *ts.client_request.header[HEADER] = VALUE*
-
-**syntax**: *VALUE = ts.client_request.header.HEADER*
-
-**context**: do_remap or later
-
-**description**: Set, add to, clear or get the current request's HEADER.
-
-Here is an example:
-
-    function do_remap()
-        local req_host = ts.client_request.header.Host
-        ts.client_request.header['Host'] = 'a.tbcdn.cn'
-    end
-
-
-TODO
-=======
-Short Term
-------
-* non-blocking I/O operation
-* ts.fetch
-
-Long Term
-------
-* ts.regex
+http://trafficserver.readthedocs.org/en/latest/reference/plugins/ts_lua.en.html
 


[31/50] [abbrv] git commit: TS-1866 Remove some DEC specific compiler wonkiness

Posted by bc...@apache.org.
TS-1866 Remove some DEC specific compiler wonkiness


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

Branch: refs/heads/5.0.x
Commit: d6cdbfd528920a3074760455cffe4b694bf6e19e
Parents: d0f4d5c
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed May 28 20:41:25 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed May 28 20:41:25 2014 -0600

----------------------------------------------------------------------
 proxy/ICP.cc | 60 -------------------------------------------------------
 1 file changed, 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d6cdbfd5/proxy/ICP.cc
----------------------------------------------------------------------
diff --git a/proxy/ICP.cc b/proxy/ICP.cc
index caed7c4..6d1cb98 100644
--- a/proxy/ICP.cc
+++ b/proxy/ICP.cc
@@ -563,9 +563,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
           return EVENT_DONE;
         }
       }
-#if !defined(__GNUC__)
-    _end_case_read_active:     // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case READ_DATA:
@@ -615,9 +612,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
           return EVENT_DONE;
         }
       }
-#if !defined(__GNUC__)
-    _end_case_read_data:       // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case READ_DATA_DONE:
@@ -644,9 +638,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
           break;
         }
       }
-#if !defined(__GNUC__)
-    _end_case_read_data_done:  // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case PROCESS_READ_DATA:
@@ -786,9 +777,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
           break;                // move to next_state
         }
       }
-#if !defined(__GNUC__)
-    _end_case_process_data_read:       // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case AWAITING_CACHE_LOOKUP_RESPONSE:
@@ -835,9 +823,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
           break;
         }
       }
-#if !defined(__GNUC__)
-    _end_case_awaiting_cache_lookup_response:  // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case SEND_REPLY:
@@ -873,9 +858,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
           return EVENT_DONE;
         }
       }
-#if !defined(__GNUC__)
-    _end_case_send_reply:      // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case WRITE_DONE:
@@ -904,9 +886,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
           break;                // move to next_state
         }
       }
-#if !defined(__GNUC__)
-    _end_case_write_done:      // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case GET_ICP_REQUEST:
@@ -933,9 +912,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
         RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE);
         break;                  // move to next_state
       }
-#if !defined(__GNUC__)
-    _end_case_get_icp_request: // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case GET_ICP_REQUEST_MUTEX:
@@ -989,9 +965,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
         s->_next_state = READ_NOT_ACTIVE;
         break;                  // move to next_state
       }
-#if !defined(__GNUC__)
-    _end_case_get_icp_request_mutex:   // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case READ_NOT_ACTIVE:
@@ -1018,9 +991,6 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e)
           break;                // restart
         }
       }
-#if !defined(__GNUC__)
-    _end_case_read_not_active: // fix DEC warnings
-#endif
       ink_release_assert(0);    // Should never happen
 
     case READ_PROCESSING_COMPLETE:
@@ -1165,9 +1135,6 @@ ICPRequestCont::ICPRequestEvent(int event, Event * e)
         break;
       }
     }
-#if !defined(__GNUC__)
-  _end_case:                   // fix DEC warnings
-#endif
     ink_release_assert(0);      // should never happen
 
   case ICP_DONE:
@@ -1254,9 +1221,6 @@ ICPRequestCont::ICPStateMachine(int event, void *d)
           break;                // move to next_state
         }
       }
-#if !defined(__GNUC__)
-    _end_case_icp_start:       // fix DEC warnings
-#endif
       ink_release_assert(0);    // should never happen
 
     case ICP_OFF_TERMINATE:
@@ -1275,9 +1239,6 @@ ICPRequestCont::ICPStateMachine(int event, void *d)
         _next_state = ICP_DONE;
         return EVENT_DONE;
       }
-#if !defined(__GNUC__)
-    _end_case_icp_off_terminate:       // fix DEC warnings
-#endif
       ink_release_assert(0);    // should never happen
 
     case ICP_QUEUE_REQUEST:
@@ -1352,9 +1313,6 @@ ICPRequestCont::ICPStateMachine(int event, void *d)
         _next_state = ICP_AWAITING_RESPONSE;
         return EVENT_DONE;
       }
-#if !defined(__GNUC__)
-    _end_case_icp_queue_request:       // fix DEC warnings
-#endif
       ink_release_assert(0);    // should never happen
 
     case ICP_AWAITING_RESPONSE:
@@ -1384,9 +1342,6 @@ ICPRequestCont::ICPStateMachine(int event, void *d)
           return EVENT_DONE;
         }
       }
-#if !defined(__GNUC__)
-    _end_case_icp_awaiting_response:   // fix DEC warnings
-#endif
       ink_release_assert(0);    // should never happen
 
     case ICP_DEQUEUE_REQUEST:
@@ -1399,9 +1354,6 @@ ICPRequestCont::ICPStateMachine(int event, void *d)
         _next_state = ICP_POST_COMPLETION;
         break;                  // move to next_state
       }
-#if !defined(__GNUC__)
-    _end_case_icp_dequeue_request:     // fix DEC warnings
-#endif
       ink_release_assert(0);    // should never happen
 
     case ICP_POST_COMPLETION:
@@ -1421,9 +1373,6 @@ ICPRequestCont::ICPStateMachine(int event, void *d)
         _next_state = ICP_WAIT_SEND_COMPLETE;
         break;                  // move to next_state
       }
-#if !defined(__GNUC__)
-    _end_case_icp_post_completion:     // fix DEC warnings
-#endif
       ink_release_assert(0);    // should never happen
     case ICP_WAIT_SEND_COMPLETE:
       {
@@ -1437,9 +1386,6 @@ ICPRequestCont::ICPStateMachine(int event, void *d)
         }
       }
       break;
-#if !defined(__GNUC__)
-    _end_case_icp_wait_send_complete:  // fix DEC warnings
-#endif
       ink_release_assert(0);    // should never happen
     case ICP_REQUEST_NOT_ACTIVE:
       {
@@ -1455,9 +1401,6 @@ ICPRequestCont::ICPStateMachine(int event, void *d)
         _next_state = ICP_DONE;
         return EVENT_DONE;
       }
-#if !defined(__GNUC__)
-    _end_case_icp_request_not_active:  // fix DEC warnings
-#endif
       ink_release_assert(0);    // should never happen
 
     case ICP_DONE:
@@ -2364,9 +2307,6 @@ ICPProcessor::ReconfigState_t
     }                           // End of switch
 
   }                             // End of while
-#if !defined(__GNUC__)
-_exit_while:                   // fix DEC warnings
-#endif
   return RC_DONE;
 }
 


[25/50] [abbrv] git commit: Remove rat-excludes.txt, it is no longer used

Posted by bc...@apache.org.
Remove rat-excludes.txt, it is no longer used


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

Branch: refs/heads/5.0.x
Commit: b0ed3daa817965c6d8b80de139481f65913ad867
Parents: d24e76b
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed May 28 16:03:33 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed May 28 16:03:37 2014 -0600

----------------------------------------------------------------------
 ci/rat-excludes.txt | 130 -----------------------------------------------
 1 file changed, 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b0ed3daa/ci/rat-excludes.txt
----------------------------------------------------------------------
diff --git a/ci/rat-excludes.txt b/ci/rat-excludes.txt
deleted file mode 100644
index c6fd980..0000000
--- a/ci/rat-excludes.txt
+++ /dev/null
@@ -1,130 +0,0 @@
-ci/
-proxy/config/
-**/*.a
-**/*.so
-**/*.o
-**/*.Po
-**/*.in
-**/*.Plo
-**/*.la
-**/*.lai
-**/*.lo
-**/.dirstamp
-**/Makefile
-**/TODO
-**/*-h1
-.vimrc
-.clang-format
-.gitignore
-**/.gitignore
-.git/
-.indent.pro
-aclocal.m4
-CHANGES
-CRUFT.txt
-autom4te.cache/
-build/
-LAYOUT
-configure
-tags
-libtool
-config.log
-config.status
-config.nice
-configure
-REVIEWERS
-proxy/README-stats.otl
-proxy/http/README.via
-proxy/ClassH.txt
-proxy/DebugStreamLevels.txt
-proxy/trafficserver-release
-proxy/cache_test.config
-proxy/congest/FeatureSpec.txt
-proxy/http/stats.memo
-proxy/issues.txt
-proxy/test_xml_parser
-proxy/tests/logstats.json
-proxy/tests/logstats.summary
-mgmt/cli/cli_detailed_command_list.txt
-mgmt/cli/cli_feature_spec.txt
-example/README.internal
-example/blacklist-1/blacklist.txt
-example/thread-pool/TESTPLAN.txt
-example/thread-pool/test/SynTest/
-example/thread-pool/test/SDKTest/SDKtest_server.config
-example/app-template/records.config
-doc/docbuild/
-doc/dot/
-doc/Doxyfile
-doc/Doxyfile.in
-doc/static/images/press/trafficserver.svg
-lib/tsconfig/test-tsconfig
-lib/tsconfig/TsConfigGrammar.hpp
-lib/ts/ParseRulesCType
-lib/ts/ParseRulesCTypeToLower
-lib/ts/ParseRulesCTypeToUpper
-lib/ts/test_Map
-lib/ts/test_Vec
-lib/ts/test_arena
-lib/ts/test_atomic
-lib/ts/test_freelist
-lib/ts/fastlz.h
-lib/ts/fastlz.c
-lib/ts/stamp-h1
-iocore/fastio/inkfio/inkfio.conf
-iocore/aio/sample.cfg
-iocore/cache/Notes
-iocore/cache/cache_test.config
-iocore/fastio/tools/advbmark/runme
-iocore/net/test_certlookup
-lib/records/test_records.config
-mgmt/stats/spec
-proxy/mime.types
-proxy/msgs/TSMessages.mc
-proxy/msgs/TSMsgs.rc
-test/SDKtest/synth_server/SDKtest_server.config
-test/deft/defs/climatelab.def
-test/deft/defs/localhost.def
-test/plugin/INKHttpHooksTrans/altSelect.notes
-mgmt/cli/hashtable.cc
-lib/ts/ink_res_init.cc
-lib/ts/ink_res_mkquery.cc
-lib/ts/ink_rand.h
-lib/ts/ink_rand.cc
-lib/tsconfig/BisonHeaderToC++.sed
-README-EC2
-REVIEWERS
-lib/perl/MANIFEST
-lib/perl/Makefile-pl
-lib/perl/blib/
-lib/perl/pm_to_blib
-ats-install/
-cop/traffic_cop
-mgmt/api/remote/traffic_api_cli_remote
-mgmt/cli/traffic_line
-mgmt/cli/traffic_shell
-mgmt/traffic_manager
-proxy/traffic_server
-proxy/traffic_logcat
-proxy/traffic_logstats
-proxy/traffic_sac
-lib/tsconfig/test-1.tsconfig
-rc/solaris.txt
-rc/trafficserver.service
-tools/http_load/
-tools/tstop/tstop
-tools/jtest/jtest
-plugins/experimental/stale_while_revalidate/stale_while_revalidate.conf
-plugins/experimental/tcp_info/tcp_info.config
-plugins/experimental/esi/docnode_test
-plugins/experimental/esi/parser_test
-plugins/experimental/esi/processor_test
-plugins/experimental/esi/utils_test
-plugins/experimental/esi/vars_test
-plugins/experimental/esi/README.combo
-iocore/aio/diags.log
-iocore/aio/test_AIO
-iocore/aio/test_AIO.sample
-iocore/eventsystem/diags.log
-iocore/eventsystem/test_Buffer
-iocore/eventsystem/test_Event


[12/50] [abbrv] git commit: TS-2804: Add regex_revalidate plugin to explerimental plugins directory.

Posted by bc...@apache.org.
TS-2804: Add regex_revalidate plugin to explerimental plugins directory.


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

Branch: refs/heads/5.0.x
Commit: 930ce49e34e5f35430787d40c2032b38df430b62
Parents: 0df9621
Author: Phil Sorber <so...@apache.org>
Authored: Tue May 13 16:08:01 2014 -0600
Committer: Phil Sorber <so...@apache.org>
Committed: Mon May 26 14:32:34 2014 -0600

----------------------------------------------------------------------
 CHANGES                                         |   2 +
 configure.ac                                    |   1 +
 plugins/experimental/Makefile.am                |   1 +
 .../experimental/regex_revalidate/Makefile.am   |  21 +
 .../regex_revalidate/regex_revalidate.c         | 589 +++++++++++++++++++
 5 files changed, 614 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/930ce49e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index a45df8a..8f28973 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2804] Add regex_revalidate plugin to explerimental plugins directory.
+
   *) [TS-2528] Use <stdbool.h> in the public mgmtapi.h interface. This follows
    the C99 standard, and we should move other public APIs to it.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/930ce49e/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 23ead6d..9bbd6a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1918,6 +1918,7 @@ AC_CONFIG_FILES([
   plugins/experimental/hipes/Makefile
   plugins/experimental/metalink/Makefile
   plugins/experimental/remap_stats/Makefile
+  plugins/experimental/regex_revalidate/Makefile
   plugins/experimental/s3_auth/Makefile
   plugins/experimental/stale_while_revalidate/Makefile
   plugins/experimental/ts_lua/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/930ce49e/plugins/experimental/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/Makefile.am b/plugins/experimental/Makefile.am
index 6192dfb..5830406 100644
--- a/plugins/experimental/Makefile.am
+++ b/plugins/experimental/Makefile.am
@@ -29,6 +29,7 @@ SUBDIRS = \
  healthchecks \
  hipes \
  metalink \
+ regex_revalidate \
  remap_stats \
  s3_auth \
  stale_while_revalidate \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/930ce49e/plugins/experimental/regex_revalidate/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/regex_revalidate/Makefile.am b/plugins/experimental/regex_revalidate/Makefile.am
new file mode 100644
index 0000000..0fa95d2
--- /dev/null
+++ b/plugins/experimental/regex_revalidate/Makefile.am
@@ -0,0 +1,21 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+include $(top_srcdir)/build/plugins.mk
+
+pkglib_LTLIBRARIES = regex_revalidate.la
+regex_revalidate_la_SOURCES = regex_revalidate.c
+regex_revalidate_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/930ce49e/plugins/experimental/regex_revalidate/regex_revalidate.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/regex_revalidate/regex_revalidate.c b/plugins/experimental/regex_revalidate/regex_revalidate.c
new file mode 100644
index 0000000..9e62a1a
--- /dev/null
+++ b/plugins/experimental/regex_revalidate/regex_revalidate.c
@@ -0,0 +1,589 @@
+/** @file
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include "ink_defs.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+#include <stdbool.h>
+#include <getopt.h>
+#include <alloca.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <pcre.h>
+#include <ts/ts.h>
+
+#define LOG_PREFIX        "regex_revalidate"
+#define CONFIG_TMOUT      60000
+#define FREE_TMOUT        300000
+#define OVECTOR_SIZE      30
+#define LOG_ROLL_INTERVAL 86400
+#define LOG_ROLL_OFFSET   0
+
+static inline void*
+ts_malloc(size_t s)
+{
+    return TSmalloc(s);
+}
+
+static inline void
+ts_free(void *s)
+{
+    return TSfree(s);
+}
+
+typedef struct invalidate_t
+{
+    const char *regex_text;
+    pcre *regex;
+    pcre_extra *regex_extra;
+    time_t epoch;
+    time_t expiry;
+    struct invalidate_t *next;
+} invalidate_t;
+
+typedef struct
+{
+    invalidate_t * volatile invalidate_list;
+    char *config_file;
+    volatile time_t last_load;
+    TSTextLogObject log;
+} plugin_state_t;
+
+static invalidate_t *
+init_invalidate_t(invalidate_t *i)
+{
+    i->regex_text = NULL;
+    i->regex = NULL;
+    i->regex_extra = NULL;
+    i->epoch = 0;
+    i->expiry = 0;
+    i->next = NULL;
+    return i;
+}
+
+static void
+free_invalidate_t(invalidate_t *i)
+{
+    if (i->regex_extra)
+#ifndef PCRE_STUDY_JIT_COMPILE
+        pcre_free(i->regex_extra);
+#else
+        pcre_free_study(i->regex_extra);
+#endif
+    if (i->regex)
+        pcre_free(i->regex);
+    if (i->regex_text)
+        pcre_free_substring(i->regex_text);
+    TSfree(i);
+}
+
+static void
+free_invalidate_t_list(invalidate_t *i)
+{
+    if (i->next)
+        free_invalidate_t_list(i->next);
+    free_invalidate_t(i);
+}
+
+static plugin_state_t *
+init_plugin_state_t(plugin_state_t *pstate)
+{
+    pstate->invalidate_list = NULL;
+    pstate->config_file = NULL;
+    pstate->last_load = 0;
+    pstate->log = NULL;
+    return pstate;
+}
+
+static void
+free_plugin_state_t(plugin_state_t *pstate)
+{
+    if (pstate->invalidate_list)
+        free_invalidate_t_list(pstate->invalidate_list);
+    if (pstate->config_file)
+        TSfree(pstate->config_file);
+    if (pstate->log)
+        TSTextLogObjectDestroy(pstate->log);
+    TSfree(pstate);
+}
+
+static invalidate_t *
+copy_invalidate_t(invalidate_t *i)
+{
+    invalidate_t *iptr;
+    const char *errptr;
+    int erroffset;
+
+    iptr = (invalidate_t *) TSmalloc(sizeof(invalidate_t));
+    iptr->regex_text = TSstrdup(i->regex_text);
+    iptr->regex = pcre_compile(iptr->regex_text, 0, &errptr, &erroffset, NULL); // There is no pcre_copy :-(
+    iptr->regex_extra = pcre_study(iptr->regex, 0, &errptr);                    // Assuming no errors since this worked before :-/
+    iptr->epoch = i->epoch;
+    iptr->expiry = i->expiry;
+    iptr->next = NULL;
+    return iptr;
+}
+
+static invalidate_t *
+copy_config(invalidate_t *old_list)
+{
+    invalidate_t *new_list = NULL;
+    invalidate_t *iptr_old, *iptr_new;
+
+    if (old_list)
+    {
+        new_list = copy_invalidate_t(old_list);
+        iptr_old = old_list->next;
+        iptr_new = new_list;
+        while (iptr_old)
+        {
+            iptr_new->next = copy_invalidate_t(iptr_old);
+            iptr_new = iptr_new->next;
+            iptr_old = iptr_old->next;
+        }
+    }
+
+    return new_list;
+}
+
+static bool
+prune_config(invalidate_t **i)
+{
+    invalidate_t *iptr, *ilast;
+    time_t now;
+    bool pruned = false;
+
+    now = time(NULL);
+
+    if (*i)
+    {
+        iptr = *i;
+        ilast = NULL;
+        while (iptr)
+        {
+            if (difftime(iptr->expiry, now) < 0)
+            {
+                TSDebug(LOG_PREFIX, "Removing %s expiry: %d now: %d", iptr->regex_text, (int) iptr->expiry, (int) now);
+                if (ilast)
+                {
+                    ilast->next = iptr->next;
+                    free_invalidate_t(iptr);
+                    iptr = ilast->next;
+                }
+                else
+                {
+                    *i = iptr->next;
+                    free_invalidate_t(iptr);
+                    iptr = *i;
+                }
+                pruned = true;
+            }
+            else
+            {
+                ilast = iptr;
+                iptr = iptr->next;
+            }
+        }
+    }
+    return pruned;
+}
+
+static bool
+load_config(plugin_state_t *pstate, invalidate_t **ilist)
+{
+    FILE *fs;
+    struct stat s;
+    size_t path_len;
+    char *path;
+    char line[LINE_MAX];
+    time_t now;
+    pcre *config_re;
+    const char *errptr;
+    int erroffset, ovector[OVECTOR_SIZE], rc;
+    int ln = 0;
+    invalidate_t *iptr, *i;
+
+    if (pstate->config_file[0] != '/')
+    {
+        path_len = strlen(TSPluginDirGet()) + strlen(pstate->config_file) + 2;
+        path = alloca(path_len);
+        snprintf(path, path_len, "%s/%s", TSPluginDirGet(), pstate->config_file);
+    }
+    else
+        path = pstate->config_file;
+    if (stat(path, &s) < 0)
+    {
+        TSDebug(LOG_PREFIX, "Could not stat %s", path);
+        return false;
+    }
+    if (s.st_mtime > pstate->last_load)
+    {
+        now = time(NULL);
+        if (!(fs = fopen(path, "r")))
+        {
+            TSDebug(LOG_PREFIX, "Could not open %s for reading", path);
+            return false;
+        }
+        config_re = pcre_compile("^([^#].+?)\\s+(\\d+)\\s*$", 0, &errptr, &erroffset, NULL);
+        while (fgets(line, LINE_MAX, fs) != NULL)
+        {
+            ln++;
+            TSDebug(LOG_PREFIX, "Processing: %d %s", ln, line);
+            rc = pcre_exec(config_re, NULL, line, strlen(line), 0, 0, ovector, OVECTOR_SIZE);
+            if (rc == 3)
+            {
+                i = (invalidate_t *) TSmalloc(sizeof(invalidate_t));
+                init_invalidate_t(i);
+                pcre_get_substring(line, ovector, rc, 1, &i->regex_text);
+                i->epoch = now;
+                i->expiry = atoi(line + ovector[4]);
+                i->regex = pcre_compile(i->regex_text, 0, &errptr, &erroffset, NULL);
+                if (i->expiry <= i->epoch)
+                {
+                    TSDebug(LOG_PREFIX, "Rule is already expired!");
+                    free_invalidate_t(i);
+                }
+                else if (i->regex == NULL)
+                {
+                    TSDebug(LOG_PREFIX, "%s did not compile", i->regex_text);
+                    free_invalidate_t(i);
+                }
+                else
+                {
+                    i->regex_extra = pcre_study(i->regex, 0, &errptr);
+                    if (!*ilist)
+                    {
+                        *ilist = i;
+                        TSDebug(LOG_PREFIX, "Created new list and Loaded %s %d %d", i->regex_text, (int) i->epoch, (int) i->expiry);
+                    }
+                    else
+                    {
+                        iptr = *ilist;
+                        while(1)
+                        {
+                            if (strcmp(i->regex_text, iptr->regex_text) == 0)
+                            {
+                                if (iptr->expiry != i->expiry)
+                                {
+                                    TSDebug(LOG_PREFIX, "Updating duplicate %s", i->regex_text);
+                                    iptr->epoch = i->epoch;
+                                    iptr->expiry = i->expiry;
+                                }
+                                free_invalidate_t(i);
+                                i = NULL;
+                                break;
+                            }
+                            else if (!iptr->next)
+                                break;
+                            else
+                                iptr = iptr->next;
+                        }
+                        if (i)
+                        {
+                            iptr->next = i;
+                            TSDebug(LOG_PREFIX, "Loaded %s %d %d", i->regex_text, (int) i->epoch, (int) i->expiry);
+                        }
+                    }
+                }
+            }
+            else
+                TSDebug(LOG_PREFIX, "Skipping line %d", ln);
+        }
+        pcre_free(config_re);
+        fclose(fs);
+        pstate->last_load = s.st_mtime;
+        return true;
+    }
+    else
+        TSDebug(LOG_PREFIX, "File mod time is not newer: %d >= %d", (int) pstate->last_load, (int) s.st_mtime);
+    return false;
+}
+
+static void
+list_config(plugin_state_t *pstate, invalidate_t *i)
+{
+    invalidate_t *iptr;
+
+    TSDebug(LOG_PREFIX, "Current config:");
+    if (pstate->log)
+        TSTextLogObjectWrite(pstate->log, "Current config:");
+    if (i)
+    {
+        iptr = i;
+        while (iptr)
+        {
+            TSDebug(LOG_PREFIX, "%s epoch: %d expiry: %d", iptr->regex_text, (int) iptr->epoch, (int) iptr->expiry);
+            if (pstate->log)
+                TSTextLogObjectWrite(pstate->log, "%s epoch: %d expiry: %d", iptr->regex_text, (int) iptr->epoch, (int) iptr->expiry);
+            iptr = iptr->next;
+        }
+    }
+    else
+    {
+        TSDebug(LOG_PREFIX, "EMPTY");
+        if (pstate->log)
+            TSTextLogObjectWrite(pstate->log, "EMPTY");
+    }
+}
+
+static int
+free_handler(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
+{
+    invalidate_t *iptr;
+
+    TSDebug(LOG_PREFIX, "Freeing old config");
+    iptr = (invalidate_t *) TSContDataGet(cont);
+    free_invalidate_t_list(iptr);
+    TSContDestroy(cont);
+    return 0;
+}
+
+static int
+config_handler(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
+{
+    plugin_state_t *pstate;
+    invalidate_t *i, *iptr;
+    TSCont free_cont;
+    bool updated;
+
+    TSDebug(LOG_PREFIX, "In config Handler");
+    pstate = (plugin_state_t *) TSContDataGet(cont);
+    i = copy_config(pstate->invalidate_list);
+
+    updated = prune_config(&i);
+    updated = load_config(pstate, &i) || updated;
+
+    if (updated)
+    {
+        list_config(pstate, i);
+        iptr = __sync_val_compare_and_swap(&(pstate->invalidate_list), pstate->invalidate_list, i);
+
+        if (iptr)
+        {
+            free_cont = TSContCreate(free_handler, NULL);
+            TSContDataSet(free_cont, (void *) iptr);
+            TSContSchedule(free_cont, FREE_TMOUT, TS_THREAD_POOL_TASK);
+        }
+    }
+    else
+    {
+        TSDebug(LOG_PREFIX, "No Changes");
+        if (i)
+            free_invalidate_t_list(i);
+    }
+
+    TSContSchedule(cont, CONFIG_TMOUT, TS_THREAD_POOL_TASK);
+    return 0;
+}
+
+static time_t
+get_date_from_cached_hdr(TSHttpTxn txn)
+{
+    TSMBuffer buf;
+    TSMLoc hdr_loc, date_loc;
+    time_t date = 0;
+
+    if (TSHttpTxnCachedRespGet(txn, &buf, &hdr_loc) == TS_SUCCESS)
+    {
+        date_loc = TSMimeHdrFieldFind(buf, hdr_loc, TS_MIME_FIELD_DATE, TS_MIME_LEN_DATE);
+        if (date_loc != TS_NULL_MLOC)
+        {
+            date = TSMimeHdrFieldValueDateGet(buf, hdr_loc, date_loc);
+             TSHandleMLocRelease(buf, hdr_loc, date_loc);
+        }
+        TSHandleMLocRelease(buf, TS_NULL_MLOC, hdr_loc);
+    }
+
+    return date;
+}
+
+static int
+main_handler(TSCont cont, TSEvent event, void *edata)
+{
+    TSHttpTxn txn = (TSHttpTxn) edata;
+    int status;
+    invalidate_t *iptr;
+    plugin_state_t *pstate;
+
+    time_t date = 0, now = 0;
+    char *url = NULL;
+    int url_len = 0;
+
+    switch (event)
+    {
+        case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
+            if (TSHttpTxnCacheLookupStatusGet(txn, &status) == TS_SUCCESS)
+            {
+                if (status == TS_CACHE_LOOKUP_HIT_FRESH)
+                {
+                    pstate = (plugin_state_t *) TSContDataGet(cont);
+                    iptr = pstate->invalidate_list;
+                    while (iptr)
+                    {
+                        if (!date)
+                        {
+                            date = get_date_from_cached_hdr(txn);
+                            now = time(NULL);
+                        }
+                        if ((difftime(iptr->epoch, date) >= 0) && (difftime(iptr->expiry, now) >= 0))
+                        {
+                            if (!url)
+                                url = TSHttpTxnEffectiveUrlStringGet(txn, &url_len);
+                            if (pcre_exec(iptr->regex, iptr->regex_extra, url, url_len, 0, 0, NULL, 0) >= 0)
+                            {
+                                TSHttpTxnCacheLookupStatusSet(txn, TS_CACHE_LOOKUP_HIT_STALE);
+                                iptr = NULL;
+                                TSDebug(LOG_PREFIX, "Forced revalidate - %.*s", url_len, url);
+                            }
+                        }
+                        if (iptr)
+                            iptr = iptr->next;
+                    }
+                    if (url)
+                        TSfree(url);
+                }
+            }
+            break;
+        default:
+            break;
+    }
+
+    TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
+    return 0;
+}
+
+static bool
+check_ts_version()
+{
+    const char *ts_version = TSTrafficServerVersionGet();
+
+    if (ts_version)
+    {
+        int major_ts_version = 0;
+        int minor_ts_version = 0;
+        int micro_ts_version = 0;
+
+        if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &micro_ts_version) != 3)
+        {
+            return false;
+        }
+
+        if ((TS_VERSION_MAJOR == major_ts_version) && (TS_VERSION_MINOR == minor_ts_version) && (TS_VERSION_MICRO == micro_ts_version))
+        {
+            return true;
+        }
+    }
+
+    return false;
+}
+
+void
+TSPluginInit (int argc, const char *argv[])
+{
+    TSPluginRegistrationInfo info;
+    TSCont main_cont, config_cont;
+    plugin_state_t *pstate;
+    invalidate_t *iptr = NULL;
+
+    TSDebug(LOG_PREFIX, "Starting plugin init.");
+
+    pstate = (plugin_state_t *) TSmalloc(sizeof(plugin_state_t));
+    init_plugin_state_t(pstate);
+
+    int c;
+    optind = 1;
+    static const struct option longopts[] = {
+            { "config", required_argument, NULL, 'c' },
+            { "log", required_argument, NULL, 'l' },
+            { NULL, 0, NULL, 0 }
+        };
+
+    while ((c = getopt_long(argc, (char * const*) argv, "c:l:", longopts, NULL)) != -1)
+    {
+        switch (c)
+        {
+            case 'c':
+                pstate->config_file = TSstrdup(optarg);
+                break;
+            case 'l':
+                TSTextLogObjectCreate(optarg, TS_LOG_MODE_ADD_TIMESTAMP, &pstate->log);
+                TSTextLogObjectRollingEnabledSet(pstate->log, 1);
+                TSTextLogObjectRollingIntervalSecSet(pstate->log, LOG_ROLL_INTERVAL);
+                TSTextLogObjectRollingOffsetHrSet(pstate->log, LOG_ROLL_OFFSET);
+                break;
+            default:
+                break;
+        }
+    }
+
+    if (!pstate->config_file)
+    {
+        TSError("Plugin requires a --config option along with a config file name.");
+        free_plugin_state_t(pstate);
+        return;
+    }
+
+    if (!load_config(pstate, &iptr))
+        TSDebug(LOG_PREFIX, "Problem loading config from file %s", pstate->config_file);
+    else
+    {
+        pstate->invalidate_list = iptr;
+        list_config(pstate, iptr);
+    }
+
+    info.plugin_name = LOG_PREFIX;
+    info.vendor_name = "Comcast";
+    info.support_email = "sorber@apache.org";
+
+    if (TSPluginRegister(TS_SDK_VERSION_3_0 , &info) != TS_SUCCESS)
+    {
+        TSError("Plugin registration failed.");
+        free_plugin_state_t(pstate);
+        return;
+    }
+    else
+        TSDebug(LOG_PREFIX, "Plugin registration succeeded.");
+
+    if (!check_ts_version())
+    {
+        TSError("Plugin requires Traffic Server %d.%d.%d", TS_VERSION_MAJOR, TS_VERSION_MINOR, TS_VERSION_MICRO);
+        free_plugin_state_t(pstate);
+        return;
+    }
+
+    pcre_malloc = &ts_malloc;
+    pcre_free = &ts_free;
+
+    main_cont = TSContCreate(main_handler, NULL);
+    TSContDataSet(main_cont, (void *) pstate);
+    TSHttpHookAdd(TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, main_cont);
+
+    config_cont = TSContCreate(config_handler, TSMutexCreate());
+    TSContDataSet(config_cont, (void *) pstate);
+    TSContSchedule(config_cont, CONFIG_TMOUT, TS_THREAD_POOL_TASK);
+
+    TSDebug(LOG_PREFIX, "Plugin Init Complete.");
+}


[06/50] [abbrv] git commit: TS-2844: update documentation for ESI plugin

Posted by bc...@apache.org.
TS-2844: update documentation for ESI plugin


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

Branch: refs/heads/5.0.x
Commit: 84517e5129156ea3325d9337fa2e9158f13dab13
Parents: 9a3e5de
Author: Kit Chan <ki...@apache.org>
Authored: Sun May 25 01:04:24 2014 -0700
Committer: Kit Chan <ki...@apache.org>
Committed: Sun May 25 01:04:24 2014 -0700

----------------------------------------------------------------------
 doc/reference/plugins/esi.en.rst | 132 +++++++++++++++++++++++++++++++++-
 plugins/experimental/esi/README  |  96 -------------------------
 2 files changed, 130 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/84517e51/doc/reference/plugins/esi.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/esi.en.rst b/doc/reference/plugins/esi.en.rst
index 18b050a..4b37455 100644
--- a/doc/reference/plugins/esi.en.rst
+++ b/doc/reference/plugins/esi.en.rst
@@ -1,7 +1,7 @@
 .. _esi-plugin:
 
-ESI Plugin (undocumented)
-*************************
+ESI Plugin
+**********
 
 .. Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
@@ -22,3 +22,131 @@ ESI Plugin (undocumented)
 
 
 This plugin implements the ESI specification.
+
+Specification
+=============
+
+Supportted ESI tags:
+
+::
+
+    esi:include
+    esi:remove
+    esi:comment
+    esi:vars
+    esi:choose
+    esi:when
+    esi:otherwise
+    esi:try
+    esi:attempt
+    esi:except
+    <!--esi ... -->
+
+extended ESI tags: *esi:special-include*
+
+Supported variables:
+
+::
+
+    $(HTTP_HOST)
+    $(HTTP_REFERER)
+    $(HTTP_ACCEPT_LANGUAGE{name})
+    $(HTTP_COOKIE{name}) or $(HTTP_COOKIE{name;subkey})
+    $(QUERY_STRING{name})
+
+Note: the name is the key name such as "username", "id" etc. For cookie support sub-name or sub-key, the format is:
+name;subkey, such as "l;u", "l;t" etc. e.g. such cookie string: l=u=test&t=1350952328, the value of
+$(HTTP_COOKIE{"l;u"}) is test and the value of $(HTTP_COOKIE{"l;t"}) is 1350952328
+
+Compile and Installation
+========================
+
+This plugin is only built if the configure option ::
+
+    --enable-experimental-plugins
+
+is given at build time. Note that this plugin is built and installed in combination with the ESI module, since they
+share common code.
+
+Enabling ESI
+============
+
+1. First we need to set up /usr/local/etc/trafficserver/plugin.config and make sure the following line is present.
+
+::
+
+    esi.so
+
+2. There are four options you can add to the above. 
+
+- "--private-response" will add private cache control and expires header to the processed ESI document. 
+- "--packed-node-support" will enable the support for using packed node, which will improve the performance of parsing
+  cached ESI document. 
+- "--disable-gzip-output" will disable gzipped output, which will NOT gzip the output anyway.
+- "--first-byte-flush" will enable the first byte flush feature, which will flush content to users as soon as the entire
+  ESI document is received and parsed without all ESI includes fetched (the flushing will stop at the ESI include markup
+  till that include is fetched). 
+
+3. We need a mapping for origin server response that contains the ESI markup. Assume that the ATS server is abc.com. And
+   your And your origin server is xyz.com and the response containing ESI markup is http://xyz.com/esi.php. We will need
+   the following line in /usr/local/etc/trafficserver/remap.config
+
+::
+
+    map http://abc.com/esi.php http://xyz.com/esi.php
+
+4. Your response should contain ESI markup and a response header of .X-Esi: 1'. e.g. using PHP,
+
+::
+
+    <?php   header('X-Esi: 1'); ?>
+    <html>
+    <body>
+    Hello, <esi:include src="http://abc.com/date.php"/>
+    </body>
+    </html>
+
+5. You will need a mapping for the src of the ESI include in remap.config if it is not already present.
+
+::
+
+    map http://abc.com/date.php http://xyz.com/date.php
+
+Or if both your ESI response and the ESI include comes from the same origin server, you can have the following line in
+remap.config instead to replace separate map rules for date.php and esi.php
+
+::
+
+    map http://abc.com/ http://xyz.com/
+
+6. Here is a sample PHP for date.php
+
+::
+
+    <?php
+    header ("Cache-control: no-cache");
+    echo date('l jS \of F Y h:i:s A');
+    ?>
+
+Useful Note
+===========
+
+1. You can provide proper cache control header and the ESI response and ESI include response can be cached separately.
+It is extremely useful for rendering page with multiple modules. The page layout can be a ESI response with multiple ESI
+include, each for different module. The page layour ESI response can be cached and each individual ESI include can also
+be cached with different duration. 
+
+2. You might want to compile the code without using ESI_PACKED_NODE_SUPPORT because it may not work in some corner cases
+
+Differences from Spec - http://www.w3.org/TR/esi-lang
+=====================================================
+
+1. <esi:include> does not support "alt" and "onerror" attributes
+
+2. <esi:inline> is not supported
+
+3. You cannot have <esi:try> inside another <esi:try>
+
+4. HTTP_USER_AGENT variable is not supported
+
+5. HTTP_COOKIE supports fetching for sub-key

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/84517e51/plugins/experimental/esi/README
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/README b/plugins/experimental/esi/README
index 36657ed..8d88daa 100644
--- a/plugins/experimental/esi/README
+++ b/plugins/experimental/esi/README
@@ -3,99 +3,3 @@ ESI plugin
 
 This plugin implements the ESI specification.
 
-Supportted ESI tags:
-    esi:include
-    esi:remove
-    esi:comment
-    esi:vars
-    esi:choose
-    esi:when
-    esi:otherwise
-    esi:try
-    esi:attempt
-    esi:except
-    <!--esi ... -->
-
-extended ESI tags:
-    esi:special-include
-
-Supported variables:
-    $(HTTP_HOST)
-    $(HTTP_REFERER)
-    $(HTTP_ACCEPT_LANGUAGE{name})
-    $(HTTP_COOKIE{name}) or $(HTTP_COOKIE{name;subkey})
-    $(QUERY_STRING{name})
-
-  Note: the name is the key name such as "username", "id" etc.
-        cookie support sub-name or sub-key, the format is: name;subkey, such as "l;u", "l;t" etc.
-           fg. such cookie string: l=u=test&t=1350952328, the value of $(HTTP_COOKIE{"l;u"}) is test
-           and the value of $(HTTP_COOKIE{"l;t"}) is 1350952328
-
-
-Compile and Installation
-------------------------
-
-1) Just run "make" in the directory of trafficserver/plugins/experimental/esi/
-
-2) Copy trafficserver/plugins/experimental/esi/.libs/esi.* to /usr/local/libexec/trafficserver/
-
-Enabling ESI
-------------
-
-1) First we need to set up /usr/local/etc/trafficserver/plugin.config and make sure the following line is present
-
-esi.so
-
-There are four options you can add. 
-  "--private-response" will add private cache control and expires header to the processed ESI document. 
-  "--packed-node-support" will enable the support for using packed node, which will improve the performance of parsing cached ESI document. 
-  "--disable-gzip-output" will disable gzipped output, which will NOT gzip the output anyway.
-  "--first-byte-flush" will enable the first byte flush feature, which will flush content to users as soon as the entire ESI document is received and parsed without all ESI includes fetched (the flushing will stop at the ESI include markup till that include is fetched). 
-
-2) We need a mapping for origin server response that contains the ESI markup. Assume that the ATS server is abc.com. And your origin server is xyz.com and the response containing ESI markup is http://xyz.com/esi.php. We will need the following line in /usr/local/etc/trafficserver/remap.config
-
-map http://abc.com/esi.php http://xyz.com/esi.php
-
-3) Your response should contain ESI markup and a response header of .X-Esi: 1'. e.g. using PHP,
-
-<?php   header('X-Esi: 1'); ?>
-<html>
-<body>
-Hello, <esi:include src="http://abc.com/date.php"/>
-</body>
-</html>
-
-4) You will need a mapping for the src of the ESI include in remap.config if it is not already present.
-
-map http://abc.com/date.php http://xyz.com/date.php
-
-Or if both your ESI response and the ESI include comes from the same origin server, you can have the following line in remap.config instead to replace separate map rules for date.php and esi.php
-
-map http://abc.com/ http://xyz.com/
-
-5) Here is a sample PHP for date.php
-
-<?php
-  header ("Cache-control: no-cache");
-  echo date('l jS \of F Y h:i:s A');
-?>
-
-Useful Note
------------
-
-1) You can provide proper cache control header and the ESI response and ESI include response can be cached separately. It is extremely useful for rendering page with multiple modules. The page layout can be a ESI response with multiple ESI include, each for different module. The page layour ESI response can be cached and each individual ESI include can also be cached with different duration. 
-
-2) You might want to compile the code without using ESI_PACKED_NODE_SUPPORT because it may not work in some corner cases
-
-Differences from Spec - http://www.w3.org/TR/esi-lang
------------------------------------------------------
-
-1) <esi:include> does not support "alt" and "onerror" attributes
-
-2) <esi:inline> is not supported
-
-3) You cannot have <esi:try> inside another <esi:try>
-
-4) HTTP_USER_AGENT variable is not supported
-
-5) HTTP_COOKIE supports fetching for sub-key


[46/50] [abbrv] git commit: TS-1981 Url remap method filtering is broken with invalid method.

Posted by bc...@apache.org.
TS-1981 Url remap method filtering is broken with invalid method.


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

Branch: refs/heads/5.0.x
Commit: 3e818112374b5ea4e2d92fb2292bc16a7fdc01ae
Parents: e8b88af
Author: Thach Tran <tr...@gmail.com>
Authored: Fri May 30 11:15:16 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Fri May 30 11:16:21 2014 -0600

----------------------------------------------------------------------
 CHANGES                        |  3 ++
 proxy/http/remap/UrlRewrite.cc | 60 ++++++++++++++++++-------------------
 2 files changed, 32 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3e818112/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 49cfaf4..cfca250 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-1981] Url remap method filtering is broken with invalid method.
+   Author: Thach Tran <tr...@gmail.com>
+
   *) [TS-2792] Large request header causes unexpected remap.
    Author: Masakazu Kitajo <m4...@gmail.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3e818112/proxy/http/remap/UrlRewrite.cc
----------------------------------------------------------------------
diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc
index 7a7bb73..ab61b3b 100644
--- a/proxy/http/remap/UrlRewrite.cc
+++ b/proxy/http/remap/UrlRewrite.cc
@@ -427,43 +427,41 @@ UrlRewrite::PerformACLFiltering(HttpTransact::State *s, url_mapping *map)
   if (map->filter) {
     int i, res, method;
     i = (method = s->hdr_info.client_request.method_get_wksidx()) - HTTP_WKSIDX_CONNECT;
-    if (likely(i >= 0 && i < ACL_FILTER_MAX_METHODS)) {
-      bool client_enabled_flag = true;
-      ink_release_assert(ats_is_ip(&s->client_info.addr));
-      for (acl_filter_rule * rp = map->filter; rp; rp = rp->next) {
-        bool match = true;
-        if (rp->method_valid) {
-          if (rp->method_idx[i] != method)
-            match = false;
+    bool client_enabled_flag = true;
+    ink_release_assert(ats_is_ip(&s->client_info.addr));
+    for (acl_filter_rule * rp = map->filter; rp && client_enabled_flag; rp = rp->next) { // stop as soon as a filter denies
+      bool match = true;
+      if (rp->method_valid) {
+        if (likely(i >= 0 && i < ACL_FILTER_MAX_METHODS)) {
+            match = rp->method_idx[i] == method;
         }
-        if (match && rp->src_ip_valid) {
-          match = false;
-          for (int j = 0; j < rp->src_ip_cnt && !match; j++) {
-            res = rp->src_ip_array[j].contains(s->client_info.addr) ? 1 : 0;
-            if (rp->src_ip_array[j].invert) {
-              if (res != 1)
-                match = true;
-            } else {
-              if (res == 1)
-                match = true;
-            }
-          }
+        else {
+            match = false;
         }
-        if (match && client_enabled_flag) {     //make sure that a previous filter did not DENY
-          Debug("url_rewrite", "matched ACL filter rule, %s request", rp->allow_flag ? "allowing" : "denying");
-          client_enabled_flag = rp->allow_flag ? true : false;
-        } else {
-          if (!client_enabled_flag) {
-            Debug("url_rewrite", "Previous ACL filter rule denied request, continuing to deny it");
+      }
+      if (match && rp->src_ip_valid) {
+        match = false;
+        for (int j = 0; j < rp->src_ip_cnt && !match; j++) {
+          res = rp->src_ip_array[j].contains(s->client_info.addr) ? 1 : 0;
+          if (rp->src_ip_array[j].invert) {
+            if (res != 1)
+              match = true;
           } else {
-            Debug("url_rewrite", "did NOT match ACL filter rule, %s request", rp->allow_flag ? "denying" : "allowing");
-              client_enabled_flag = rp->allow_flag ? false : true;
+            if (res == 1)
+              match = true;
           }
         }
+      }
+      if (match) {
+        Debug("url_rewrite", "matched ACL filter rule, %s request", rp->allow_flag ? "allowing" : "denying");
+        client_enabled_flag = rp->allow_flag ? true : false;
+      } else {
+        Debug("url_rewrite", "did NOT match ACL filter rule, %s request", rp->allow_flag ? "denying" : "allowing");
+        client_enabled_flag = rp->allow_flag ? false : true;
+      }
 
-      }                         /* end of for(rp = map->filter;rp;rp = rp->next) */
-      s->client_connection_enabled = client_enabled_flag;
-    }
+    }                         /* end of for(rp = map->filter;rp;rp = rp->next) */
+    s->client_connection_enabled = client_enabled_flag;
   }
 }