You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2014/04/17 18:44:00 UTC

[01/50] git commit: TS-2622: optimize the function ink_cluster_time

Repository: trafficserver
Updated Branches:
  refs/heads/5.0.x 5e19587e3 -> 721d5cf50


TS-2622: optimize the function ink_cluster_time

  1. remove useless two global variables
  2. use ink_get_hrtime() instead of time(NULL)
  3. remove useless CAS to set variable global_time


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

Branch: refs/heads/5.0.x
Commit: 8aa3af937548942e8130ccdf1400e043870e3a0e
Parents: a8ed22d
Author: Yu Qing <zh...@taobao.com>
Authored: Fri Mar 7 15:21:20 2014 +0800
Committer: James Peach <jp...@apache.org>
Committed: Wed Apr 9 16:25:13 2014 -0700

----------------------------------------------------------------------
 CHANGES                    |  3 +++
 proxy/http/HttpTransact.cc | 22 ++++------------------
 2 files changed, 7 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8aa3af93/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 9f9e7aa..010a6e4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2622] Optimize the ink_cluster_time() function.
+   Author: Yu Qing <zh...@taobao.com>
+
   *) [TS-2701] Silence traffic_cop logging on chown of missing lock files.
 
   *) [TS-2656 Determine server connection scheme immediately before

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8aa3af93/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 0f464e6..c5ee223 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -8333,23 +8333,18 @@ HttpTransact::get_error_string(int erno)
   }
 }
 
-
-volatile ink_time_t global_time;
-volatile int32_t cluster_time_delta;
-
 ink_time_t
 ink_cluster_time(void)
 {
-  ink_time_t old;
-  int highest_delta = 0;
+  int highest_delta;
 
 #ifdef DEBUG
   ink_mutex_acquire(&http_time_lock);
-  ink_time_t local_time = time(NULL);
+  ink_time_t local_time = ink_get_hrtime() / HRTIME_SECOND;
   last_http_local_time = local_time;
   ink_mutex_release(&http_time_lock);
 #else
-  ink_time_t local_time = time(NULL);
+  ink_time_t local_time = ink_get_hrtime() / HRTIME_SECOND;
 #endif
 
   highest_delta = (int) HttpConfig::m_master.cluster_time_delta;
@@ -8366,16 +8361,7 @@ ink_cluster_time(void)
 
   ink_assert(highest_delta >= 0);
 
-  local_time += (ink_time_t) highest_delta;
-  old = global_time;
-
-  while (local_time > global_time) {
-    if (ink_atomic_cas(&global_time, old, local_time))
-      break;
-    old = global_time;
-  }
-
-  return global_time;
+  return local_time + (ink_time_t) highest_delta;
 }
 
 //


[11/50] git commit: Fix escalate plugin build

Posted by zw...@apache.org.
Fix escalate plugin build


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

Branch: refs/heads/5.0.x
Commit: afd37d254600374da06192c69c3e7828bcd9fbf3
Parents: 1147bb3
Author: James Peach <jp...@apache.org>
Authored: Thu Apr 10 12:56:34 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Apr 10 12:57:11 2014 -0700

----------------------------------------------------------------------
 plugins/experimental/escalate/escalate.cc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/afd37d25/plugins/experimental/escalate/escalate.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/escalate/escalate.cc b/plugins/experimental/escalate/escalate.cc
index 6768a70..ebc6e2b 100644
--- a/plugins/experimental/escalate/escalate.cc
+++ b/plugins/experimental/escalate/escalate.cc
@@ -23,6 +23,7 @@
 #include <ts/ts.h>
 #include <ts/remap.h>
 #include <ts/experimental.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <getopt.h>
 #include <string.h>


[25/50] git commit: [TS-2555] correct documentation with the correct plugin usage

Posted by zw...@apache.org.
[TS-2555] correct documentation with the correct plugin usage


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

Branch: refs/heads/5.0.x
Commit: d3b6c1190e2633bc20a8c1cbd49b8ea1a211c21e
Parents: 559ca5d
Author: Kit Chan <ki...@apache.org>
Authored: Sun Apr 13 16:18:32 2014 -0700
Committer: Kit Chan <ki...@apache.org>
Committed: Sun Apr 13 16:18:32 2014 -0700

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d3b6c119/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 50246cc..fbf7674 100644
--- a/doc/reference/plugins/ts_lua.en.rst
+++ b/doc/reference/plugins/ts_lua.en.rst
@@ -248,11 +248,11 @@ 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
+     map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/usr/lib64/trafficserver/plugins/tslua.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
+     map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/usr/lib64/trafficserver/plugins/tslua.so @pparam=/etc/trafficserver/script/sethost.lua @pparam=img03.tbcdn.cn
 
 
 


[34/50] git commit: patch for TS-2719 - atscppapi: Check for error state in intercept

Posted by zw...@apache.org.
patch for TS-2719 - atscppapi: Check for error state in intercept


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

Branch: refs/heads/5.0.x
Commit: 32ea4b1529e7e4664932c0e61304375e9519a40d
Parents: ec24119
Author: Manjesh Nilange <ma...@yahoo.com>
Authored: Tue Apr 15 10:59:13 2014 -0700
Committer: Manjesh Nilange <ma...@yahoo.com>
Committed: Tue Apr 15 10:59:13 2014 -0700

----------------------------------------------------------------------
 lib/atscppapi/src/InterceptPlugin.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/32ea4b15/lib/atscppapi/src/InterceptPlugin.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/InterceptPlugin.cc b/lib/atscppapi/src/InterceptPlugin.cc
index b9aaa7c..cac8f0b 100644
--- a/lib/atscppapi/src/InterceptPlugin.cc
+++ b/lib/atscppapi/src/InterceptPlugin.cc
@@ -161,8 +161,8 @@ InterceptPlugin::~InterceptPlugin() {
 
 bool InterceptPlugin::produce(const void *data, int data_size) {
   ScopedSharedMutexLock scopedLock(getMutex());
-  if (!state_->net_vc_) {
-    LOG_ERROR("Intercept not operational yet");
+  if (!state_->net_vc_ || state_->shut_down_) {
+    LOG_ERROR("Intercept not operational");
     return false;
   }
   if (!state_->output_.buffer_) {
@@ -184,8 +184,8 @@ bool InterceptPlugin::produce(const void *data, int data_size) {
 
 bool InterceptPlugin::setOutputComplete() {
   ScopedSharedMutexLock scopedLock(getMutex());
-  if (!state_->net_vc_) {
-    LOG_ERROR("Intercept not operational yet");
+  if (!state_->net_vc_ || state_->shut_down_) {
+    LOG_ERROR("Intercept not operational");
     return false;
   }
   if (!state_->output_.buffer_) {


[29/50] git commit: TS-2711 Make sure the LUAJIT ldflags are set properly for OSX.

Posted by zw...@apache.org.
TS-2711 Make sure the LUAJIT ldflags are set properly for OSX.


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

Branch: refs/heads/5.0.x
Commit: f290a71a2b0aba5bc6608f0cab886f72a2705d42
Parents: 31f1857
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 15 10:07:41 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Apr 15 10:07:41 2014 -0600

----------------------------------------------------------------------
 configure.ac | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f290a71a/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index b0502a6..0dacfda 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1421,9 +1421,7 @@ AX_LIB_READLINE
 # http://luajit.org/install.html.
 case $host_os in
   darwin)
-    if test "x${enable_lua_support}" = "xLuaJIT"; then
-      LUA_LUAJIT_LDFLAGS="-Wl,-pagezero_size,10000 -Wl,-image_base,100000000"
-    fi
+    LUA_LUAJIT_LDFLAGS="-Wl,-pagezero_size,10000 -Wl,-image_base,100000000"
     ;;
 esac
 


[42/50] git commit: Fix some formatting style.

Posted by zw...@apache.org.
Fix some formatting style.


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

Branch: refs/heads/5.0.x
Commit: bf16745fb8034acca2b77a6820792093bb993be0
Parents: 01be17e
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Apr 16 10:48:51 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed Apr 16 10:48:51 2014 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bf16745f/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 9f8cf54..f578673 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,7 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
-  *) [TS-2555] adding global plugin support to ts_lua plugin
+  *) [TS-2555] Adding global plugin support to ts_lua plugin.
 
   *) [TS-2717] header-rewrite set-redirect not working.
    Author: Igor Brezac
@@ -187,6 +187,7 @@ Changes with Apache Traffic Server 5.0.0
 
   *) [TS-2494] fix the crash that return the stale cached document
    when os is down, even if it`s status is not 200 (ok).
+
   *) [TS-2590] Translate documentation into Japanese.
    Authors: Masaori Koshiba <ma...@gmail.com>
             Masakazu Kitajo <m4...@gmail.com>


[48/50] git commit: [TS-2720] Fixing bug in C++ API Request Transformations

Posted by zw...@apache.org.
[TS-2720] Fixing bug in C++ API Request Transformations


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

Branch: refs/heads/5.0.x
Commit: a4860363a94e7bb51e5de651c5ea07a804915777
Parents: 76a0777
Author: Brian Geffon <br...@apache.org>
Authored: Wed Apr 16 13:13:32 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Wed Apr 16 13:13:32 2014 -0700

----------------------------------------------------------------------
 CHANGES                                         |  2 ++
 .../NullTransformationPlugin.cc                 | 21 +++++++++++++++-----
 lib/atscppapi/src/TransformationPlugin.cc       | 18 ++++++++++++++++-
 .../include/atscppapi/TransformationPlugin.h    |  1 +
 4 files changed, 36 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a4860363/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index ebe5161..8cb41d9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
+  
+  *) [TS-2720] Fix bug with request transformations in C++ api
 
   *) [TS-2717] header-rewrite set-redirect not working.
    Author: Igor Brezac

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a4860363/lib/atscppapi/examples/null_transformation_plugin/NullTransformationPlugin.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/examples/null_transformation_plugin/NullTransformationPlugin.cc b/lib/atscppapi/examples/null_transformation_plugin/NullTransformationPlugin.cc
index 0155d30..5312d3b 100644
--- a/lib/atscppapi/examples/null_transformation_plugin/NullTransformationPlugin.cc
+++ b/lib/atscppapi/examples/null_transformation_plugin/NullTransformationPlugin.cc
@@ -32,9 +32,15 @@ namespace {
 
 class NullTransformationPlugin : public TransformationPlugin {
 public:
-  NullTransformationPlugin(Transaction &transaction)
-    : TransformationPlugin(transaction, RESPONSE_TRANSFORMATION) {
-    registerHook(HOOK_SEND_RESPONSE_HEADERS);
+  NullTransformationPlugin(Transaction &transaction, TransformationPlugin::Type xformType)
+    : TransformationPlugin(transaction, xformType) {
+    registerHook((xformType == TransformationPlugin::REQUEST_TRANSFORMATION) ? 
+                 HOOK_SEND_REQUEST_HEADERS : HOOK_SEND_RESPONSE_HEADERS);
+  }
+
+  void handleSendRequestHeaders(Transaction &transaction) {
+    transaction.getServerRequest().getHeaders()["X-Content-Transformed"] = "1";
+    transaction.resume();
   }
 
   void handleSendResponseHeaders(Transaction &transaction) {
@@ -60,14 +66,19 @@ private:
 class GlobalHookPlugin : public GlobalPlugin {
 public:
   GlobalHookPlugin() {
+    registerHook(HOOK_READ_REQUEST_HEADERS_POST_REMAP);
     registerHook(HOOK_READ_RESPONSE_HEADERS);
   }
 
-  virtual void handleReadResponseHeaders(Transaction &transaction) {
-    transaction.addPlugin(new NullTransformationPlugin(transaction));
+  virtual void handleReadRequestHeadersPostRemap(Transaction &transaction) {
+    transaction.addPlugin(new NullTransformationPlugin(transaction, TransformationPlugin::REQUEST_TRANSFORMATION));
     transaction.resume();
   }
 
+  virtual void handleReadResponseHeaders(Transaction &transaction) {
+    transaction.addPlugin(new NullTransformationPlugin(transaction, TransformationPlugin::RESPONSE_TRANSFORMATION));
+    transaction.resume();
+  }
 };
 
 void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a4860363/lib/atscppapi/src/TransformationPlugin.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/TransformationPlugin.cc b/lib/atscppapi/src/TransformationPlugin.cc
index f859bb3..3e5560a 100644
--- a/lib/atscppapi/src/TransformationPlugin.cc
+++ b/lib/atscppapi/src/TransformationPlugin.cc
@@ -56,6 +56,8 @@ struct atscppapi::TransformationPluginState: noncopyable {
   // sent the input end our write complte.
   bool input_complete_dispatched_;
 
+  std::string request_xform_output_; // in case of request xform, data produced is buffered here
+
   TransformationPluginState(atscppapi::Transaction &transaction, TransformationPlugin &transformation_plugin,
       TransformationPlugin::Type type, TSHttpTxn txn)
     : vconn_(NULL), transaction_(transaction), transformation_plugin_(transformation_plugin), type_(type),
@@ -232,7 +234,7 @@ TransformationPlugin::~TransformationPlugin() {
   delete state_;
 }
 
-size_t TransformationPlugin::produce(const std::string &data) {
+size_t TransformationPlugin::doProduce(const std::string &data) {
   LOG_DEBUG("TransformationPlugin=%p tshttptxn=%p producing output with length=%ld", this, state_->txn_, data.length());
   int64_t write_length = static_cast<int64_t>(data.length());
   if (!write_length) {
@@ -281,7 +283,21 @@ size_t TransformationPlugin::produce(const std::string &data) {
   return static_cast<size_t>(bytes_written);
 }
 
+size_t TransformationPlugin::produce(const std::string &data) {
+  if (state_->type_ == REQUEST_TRANSFORMATION) {
+    state_->request_xform_output_.append(data);
+    return data.size();
+  }
+  else {
+    return doProduce(data);
+  }
+}
+
 size_t TransformationPlugin::setOutputComplete() {
+  if (state_->type_ = REQUEST_TRANSFORMATION) {
+    doProduce(state_->request_xform_output_);
+  }
+
   int connection_closed = TSVConnClosedGet(state_->vconn_);
   LOG_DEBUG("OutputComplete TransformationPlugin=%p tshttptxn=%p vconn=%p connection_closed=%d, total bytes written=%" PRId64, this, state_->txn_, state_->vconn_, connection_closed,state_->bytes_written_);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a4860363/lib/atscppapi/src/include/atscppapi/TransformationPlugin.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/TransformationPlugin.h b/lib/atscppapi/src/include/atscppapi/TransformationPlugin.h
index ef934c3..4c617f7 100644
--- a/lib/atscppapi/src/include/atscppapi/TransformationPlugin.h
+++ b/lib/atscppapi/src/include/atscppapi/TransformationPlugin.h
@@ -121,6 +121,7 @@ protected:
   TransformationPlugin(Transaction &transaction, Type type);
 private:
   TransformationPluginState *state_; /** Internal state for a TransformationPlugin */
+  size_t doProduce(const std::string &);
 };
 
 } /* atscppapi */


[35/50] git commit: Merge branch 'master' of https://github.com/manjeshnilange/trafficserver

Posted by zw...@apache.org.
Merge branch 'master' of https://github.com/manjeshnilange/trafficserver


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

Branch: refs/heads/5.0.x
Commit: 76a07771ab93a6e39dc46b397549b335c7f6ebfe
Parents: f2f57b6 32ea4b1
Author: Brian Geffon <br...@apache.org>
Authored: Tue Apr 15 15:37:11 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Tue Apr 15 15:37:11 2014 -0700

----------------------------------------------------------------------
 lib/atscppapi/src/InterceptPlugin.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------



[06/50] git commit: TS-2692 Add an API to Get the current redirection retry count

Posted by zw...@apache.org.
TS-2692 Add an API to Get the current redirection retry count


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

Branch: refs/heads/5.0.x
Commit: 98c581919958096b7b8a1bfff036bdeff12b7d30
Parents: 6cec1a2
Author: Leif Hedstrom <zw...@apache.org>
Authored: Fri Apr 4 11:55:02 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Apr 10 06:50:21 2014 -0600

----------------------------------------------------------------------
 plugins/experimental/escalate/escalate.cc | 49 ++++++++++++++------------
 proxy/InkAPI.cc                           | 12 ++++++-
 proxy/api/ts/ts.h                         | 43 ++++++++++++++++++++++
 proxy/http/HttpSM.h                       |  2 +-
 4 files changed, 81 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/98c58191/plugins/experimental/escalate/escalate.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/escalate/escalate.cc b/plugins/experimental/escalate/escalate.cc
index d57003a..05a8234 100644
--- a/plugins/experimental/escalate/escalate.cc
+++ b/plugins/experimental/escalate/escalate.cc
@@ -66,42 +66,45 @@ EscalateResponse(TSCont cont, TSEvent event, void* edata)
   TSMBuffer        response;
   TSMLoc           resp_hdr;
 
-  TSDebug(PLUGIN_NAME, "Recieved event %d", (int)event);
   TSReleaseAssert(event == TS_EVENT_HTTP_READ_RESPONSE_HDR);
 
   // First, we need the server response ...
   if (TS_SUCCESS == TSHttpTxnServerRespGet(txn, &response, &resp_hdr)) {
-    // Next, the respose status ...
-    TSHttpStatus status = TSHttpHdrStatusGet(response, resp_hdr);
+    int tries = TSRedirectRetriesGet(txn);
 
-    // If we have an escalation URL for this response code, set the redirection URL and force it
-    // to be followed.
-    EscalationState::hostmap_type::iterator entry = es->hostmap.find((unsigned)status);
+    TSDebug(PLUGIN_NAME, "This is try %d", tries);
+    if (0 == tries) { // ToDo: Future support for more than one retry-URL
+      // Next, the response status ...
+      TSHttpStatus status = TSHttpHdrStatusGet(response, resp_hdr);
 
-    if (entry != es->hostmap.end()) {
-      TSMBuffer request;
-      TSMLoc    req_hdr;
+      // If we have an escalation URL for this response code, set the redirection URL and force it
+      // to be followed.
+      EscalationState::hostmap_type::iterator entry = es->hostmap.find((unsigned)status);
 
-      TSDebug(PLUGIN_NAME, "found an escalation entry for HTTP status %u", (unsigned)status);
-      if (TS_SUCCESS == TSHttpTxnClientReqGet(txn, &request, &req_hdr)) {
-        TSMLoc url;
+      if (entry != es->hostmap.end()) {
+        TSMBuffer request;
+        TSMLoc    req_hdr;
 
-        if (TS_SUCCESS == TSHttpHdrUrlGet(request, req_hdr, &url)) {
-          char* url_str;
-          int url_len;
+        TSDebug(PLUGIN_NAME, "Found an entry for HTTP status %u", (unsigned)status);
+        if (TS_SUCCESS == TSHttpTxnClientReqGet(txn, &request, &req_hdr)) {
+          TSMLoc url;
 
-          // Update the request URL with the new Host to try.
-          TSUrlHostSet(request, url, entry->second.c_str(), entry->second.size());
-          url_str = TSUrlStringGet(request, url, &url_len);
+          if (TS_SUCCESS == TSHttpHdrUrlGet(request, req_hdr, &url)) {
+            char* url_str;
+            int url_len;
 
-          TSDebug(PLUGIN_NAME, "Setting new URL to %.*s", url_len, url_str);
-          TSRedirectUrlSet(txn, url_str, url_len); // Transfers ownership
-        }
-        // Release the response MLoc
+            // Update the request URL with the new Host to try.
+            TSUrlHostSet(request, url, entry->second.c_str(), entry->second.size());
+            url_str = TSUrlStringGet(request, url, &url_len);
+
+            TSDebug(PLUGIN_NAME, "Setting new URL to %.*s", url_len, url_str);
+            TSRedirectUrlSet(txn, url_str, url_len); // Transfers ownership
+          }
+          // Release the request MLoc
         TSHandleMLocRelease(request, TS_NULL_MLOC, req_hdr);
+        }
       }
     }
-
     // Release the response MLoc
     TSHandleMLocRelease(response, TS_NULL_MLOC, resp_hdr);
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/98c58191/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index e4a0b9c..92c37fc 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7134,7 +7134,7 @@ TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len)
     sm->redirect_url_len = 0;
   }
 
-  sm->redirect_url = url;
+  sm->redirect_url = (char*)url;
   sm->redirect_url_len = url_len;
   sm->enable_redirection = true;
 }
@@ -7150,6 +7150,16 @@ TSRedirectUrlGet(TSHttpTxn txnp, int *url_len_ptr)
   return sm->redirect_url;
 }
 
+int
+TSRedirectRetriesGet(TSHttpTxn txnp)
+{
+  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+
+  HttpSM *sm = (HttpSM*)txnp;
+
+  return sm->redirection_tries;
+}
+
 char*
 TSFetchRespGet(TSHttpTxn txnp, int *length)
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/98c58191/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 99098da..eaafda1 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -2227,9 +2227,52 @@ extern "C"
 
   tsapi TSReturnCode TSHttpTxnConfigFind(const char* name, int length, TSOverridableConfigKey* conf, TSRecordDataType* type);
 
+  /**
+     This API informs the core to try to follow redirections (e.g. 301 responses.
+     The new URL would be provided in the standard Location header.
+
+     @param txnp the transaction pointer
+     @param on   turn this on or off (0 or 1)
+
+     @return @c TS_SUCCESS if it succeeded
+  */
   tsapi TSReturnCode TSHttpTxnFollowRedirect(TSHttpTxn txnp, int on);
+  /**
+     This is a generalization of the TSHttpTxnFollowRedirect(), but gives finer
+     control over the behavior. Instead of using the Location: header for the new
+     destination, this API takes the new URL as a parameter. Calling this API
+     transfers the ownership of the URL from the plugin to the core, so you must
+     make sure it is heap allocated, and that you do not free it.
+
+     Calling this API implicitly also enables the "Follow Redirect" feature, so
+     there is no rason to call TSHttpTxnFollowRedirect() as well.
+
+     @param txnp the transaction pointer
+     @param url  a heap allocated string with the URL
+     @param url_len the length of the URL
+  */
   tsapi void TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len);
+  /**
+     Return the current (if set) redirection URL string. This is still owned by the
+     core, and must not be free'd.
+
+     @param txnp the transaction pointer
+     @param url_len_ptr a pointer to where the URL length is to be stored
+
+     @return the url string
+  */
   tsapi const char* TSRedirectUrlGet(TSHttpTxn txnp, int* url_len_ptr);
+  /**
+     Return the number of redirection retries we have done. This starts off
+     at zero, and can be used to select different URLs based on which attempt this
+     is. This can be useful for example when providing a list of URLs to try, and
+     do so in order until one succeeds.
+
+     @param txnp the transaction pointer
+
+     @return the redirect try count
+  */
+  tsapi int TSRedirectRetriesGet(TSHttpTxn txnp);
 
   /* Get current HTTP connection stats */
   tsapi int TSHttpCurrentClientConnectionsGet(void);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/98c58191/proxy/http/HttpSM.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h
index a04742d..f0117c0 100644
--- a/proxy/http/HttpSM.h
+++ b/proxy/http/HttpSM.h
@@ -270,7 +270,7 @@ public:
 
   //YTS Team, yamsat Plugin
   bool enable_redirection;      //To check if redirection is enabled
-  const char *redirect_url;     //url for force redirect (provide users a functionality to redirect to another url when needed)
+  char *redirect_url;     //url for force redirect (provide users a functionality to redirect to another url when needed)
   int redirect_url_len;
   int redirection_tries;        //To monitor number of redirections
   int64_t transfered_bytes;     //Added to calculate POST data


[44/50] git commit: TS-2714: promote the tcp_info plugin to stable as 'tcpinfo'

Posted by zw...@apache.org.
TS-2714: promote the tcp_info plugin to stable as 'tcpinfo'


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

Branch: refs/heads/5.0.x
Commit: 86453b9930827d69e6647770b4073a74a71312ed
Parents: d461c33
Author: James Peach <jp...@apache.org>
Authored: Mon Apr 14 11:56:05 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Apr 16 10:29:11 2014 -0700

----------------------------------------------------------------------
 CHANGES                                       |   2 +
 configure.ac                                  |   2 +-
 doc/reference/plugins/index.en.rst            |   1 +
 doc/reference/plugins/tcpinfo.en.rst          | 122 ++++++
 plugins/Makefile.am                           |   1 +
 plugins/experimental/Makefile.am              |   1 -
 plugins/experimental/tcp_info/Makefile.am     |  22 --
 plugins/experimental/tcp_info/README          |  76 ----
 plugins/experimental/tcp_info/tcp_info.cc     | 424 ---------------------
 plugins/experimental/tcp_info/tcp_info.config |   3 -
 plugins/tcpinfo/Makefile.am                   |  22 ++
 plugins/tcpinfo/tcpinfo.cc                    | 424 +++++++++++++++++++++
 12 files changed, 573 insertions(+), 527 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 932f614..b952ea0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2714] Promote the tcp_info plugin to stable as 'tcpinfo'.
+
   *) [TS-2708] Refactor and modernize the tcp_info plugin.
 
   *) [TS-2555] Adding global plugin support to ts_lua plugin.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 2a19d01..bd3ddcf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1927,6 +1927,7 @@ AC_CONFIG_FILES([
   plugins/libloader/Makefile
   plugins/regex_remap/Makefile
   plugins/stats_over_http/Makefile
+  plugins/tcpinfo/Makefile
   plugins/experimental/Makefile
   plugins/experimental/authproxy/Makefile
   plugins/experimental/background_fetch/Makefile
@@ -1944,7 +1945,6 @@ AC_CONFIG_FILES([
   plugins/experimental/rfc5861/Makefile
   plugins/experimental/s3_auth/Makefile
   plugins/experimental/spdy/Makefile
-  plugins/experimental/tcp_info/Makefile
   plugins/experimental/ts_lua/Makefile
   plugins/experimental/xdebug/Makefile
   proxy/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/doc/reference/plugins/index.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/index.en.rst b/doc/reference/plugins/index.en.rst
index 669b8d2..eff4c5b 100644
--- a/doc/reference/plugins/index.en.rst
+++ b/doc/reference/plugins/index.en.rst
@@ -46,6 +46,7 @@ Apache Traffic Server releases.
   header_rewrite.en
   regex_remap.en
   stats_over_http.en
+  tcpinfo.en
 
 Experimental plugins
 ====================

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/doc/reference/plugins/tcpinfo.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/tcpinfo.en.rst b/doc/reference/plugins/tcpinfo.en.rst
new file mode 100644
index 0000000..688fe45
--- /dev/null
+++ b/doc/reference/plugins/tcpinfo.en.rst
@@ -0,0 +1,122 @@
+.. _tcpinfo-plugin:
+
+TCPInfo Plugin
+**************
+
+.. 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.
+
+This global plugin logs TCP metrics at various points in the HTTP
+processing pipeline. The TCP information is retrieved by the
+:manpage:`getsockopt(2)` function using the ``TCP_INFO`` option.
+This is only supported on systems that support the ``TCP_INFO``
+option, currently Linux and BSD.
+
+Log rolling is enabled automatically, based on the
+:ts:cv:`proxy.config.log.rolling_size_mb` configuration variable.
+
+Plugin Options
+--------------
+
+The following options may be specified in :file:`plugin.config`:
+
+--hooks=LIST
+  This option specifies when TCP information should be logged. The
+  argument is a comma-separated list of the event names listed
+  below. TCP information will be sampled and logged each time the
+  specified set of events occurs.
+
+  ==============  ===============================================
+   Event Name     Triggered when
+  ==============  ===============================================
+   send_resp_hdr  The server begins sending an HTTP response.
+   ssn_close      The TCP connection closes.
+   ssn_start      A new TCP connection is accepted.
+   txn_close      A HTTP transaction is completed.
+   txn_start      A HTTP transaction is initiated.
+  ==============  ===============================================
+
+--log-file=NAME
+  This specifies the base name of the file where TCP information
+  should be logged. If this option is not specified, the name
+  ``tcpinfo`` is used. Traffic Server will automatically append
+  the ``.log`` suffix.
+
+--log-level=LEVEL
+  The log level can be either ``1`` to log only the round trip
+  time estimate, or ``2`` to log the complete set of TCP information.
+
+  The following fields are logged when the log level is ``1``:
+
+  ==========    ==================================================
+  Field Name    Description
+  ==========    ==================================================
+  timestamp     Event timestamp
+  event         Event name (one of the names listed above)
+  client        Client IP address
+  server        Server IP address
+  rtt           Estimated round trip time
+  ==========    ==================================================
+
+  The following fields are logged when the log level is ``2``:
+
+  ==============    ==================================================
+  Field Name        Description
+  ==============    ==================================================
+  timestamp         Event timestamp
+  event             Event name (one of the names listed above)
+  client            Client IP address
+  server            Server IP address
+  rtt               Estimated round trip time
+  rttvar
+  last_sent
+  last_recv
+  snd_ssthresh
+  rcv_ssthresh
+  unacked
+  sacked
+  lost
+  retrans
+  fackets
+  ==============    ==================================================
+
+--sample-rate=COUNT
+
+  This is the number of times per 1000 requests that the data will
+  be logged.  A pseudo-random number generator is used to determine if a
+  request will be logged.  The default value is 1000 and this option is
+  not required to be in the configuration file.  To achieve a log rate
+  of 1% you would set this value to 10.
+
+Examples:
+---------
+
+This example logs the simple TCP information to ``jpeach.log``
+at the start of a TCP connection and once for each HTTP
+transaction thereafter::
+
+  tcp_info.so --log-file=jpeach --log-level=1 --hooks=ssn_start,txn_start
+
+The file ``jpeach.log`` will contain the following log format::
+
+  timestamp event client server rtt
+  20140414.17h40m14s ssn_start 127.0.0.1 127.0.0.1 4000
+  20140414.17h40m14s txn_start 127.0.0.1 127.0.0.1 4000
+  20140414.17h40m16s ssn_start 127.0.0.1 127.0.0.1 4000
+  20140414.17h40m16s txn_start 127.0.0.1 127.0.0.1 4000
+  20140414.17h40m16s ssn_start 127.0.0.1 127.0.0.1 4000
+  20140414.17h40m16s txn_start 127.0.0.1 127.0.0.1 4000

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/plugins/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 6e00ec5..a810f8a 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -24,4 +24,5 @@ SUBDIRS = \
   libloader \
   regex_remap \
   stats_over_http \
+  tcpinfo \
   experimental

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/plugins/experimental/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/Makefile.am b/plugins/experimental/Makefile.am
index 9aac6ad..4b811c1 100644
--- a/plugins/experimental/Makefile.am
+++ b/plugins/experimental/Makefile.am
@@ -33,7 +33,6 @@ SUBDIRS = \
  rfc5861 \
  s3_auth \
  spdy \
- tcp_info \
  ts_lua \
  xdebug
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/plugins/experimental/tcp_info/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/tcp_info/Makefile.am b/plugins/experimental/tcp_info/Makefile.am
deleted file mode 100644
index daabefd..0000000
--- a/plugins/experimental/tcp_info/Makefile.am
+++ /dev/null
@@ -1,22 +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
-
-pkglib_LTLIBRARIES = tcp_info.la
-tcp_info_la_SOURCES = tcp_info.cc
-tcp_info_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/plugins/experimental/tcp_info/README
----------------------------------------------------------------------
diff --git a/plugins/experimental/tcp_info/README b/plugins/experimental/tcp_info/README
deleted file mode 100644
index 56c911f..0000000
--- a/plugins/experimental/tcp_info/README
+++ /dev/null
@@ -1,76 +0,0 @@
-Apache Traffic Server TCP info plugin
-
-This plugin was written to log client round trip times.  This
-information is retrieved from the getsockopt() function using the
-TCP_INFO option.  Other information can also be gathered from TCP_INFO
-and there is an option to log most of the data structure.
-
-
-Configuration:
-The configuration files default location is in the etc or
-configuration directory under the default install directory.  For
-example if your installation directory is "/usr/local", then the
-plugin will first look in "/usr/local/etc" and then in
-"/usr/local/conf" for the configuration file.  The configuration
-filename is "tcp_info.config".
-
-
---------------------------------------------------------------------------------
-Configuration Options:
-
-"sample" is the number of times per 1000 requests that the data will
-be logged.  A pseudo-random number generator is used to determine if a
-request will be logged.  The default value is 1000 and this option is
-not required to be in the configuration file.  To achieve a log rate
-of 1% you would set this value to 10.
-example:
-sample=1000
-
-"log_file" is the full path to the log file.  There is no default
-value and this option is required to be set in the config file.  If
-the plugin can't open the log file the plugin will assert.
-example:
-log_file=/usr/local/var/log/trafficserver/tcp_info.log
-
-"log_level" determines how much information you want in the log file.
-The default is 1 and this option is not required to be in the config
-file.  Log level of 1 will only log the rtt value from the TCP_INFO
-data structure.  To log most of the TCP_INFO data structure use the
-value of 2.
-example:
-log_level=1
-
-
-*** "hook" DOESN'T WORK RIGHT NOW - ATS NEEDS ANOTHER HOOK BEFORE CLOSING THE SOCKET ***
-"hook" tells the plugin when to log the information.  The default is 1
-and this will log the TCP_INFO data when the client makes a TCP
-connection.  A value of 2 will log the information at the end of the
-TCP connection.  If you are looking for information about retransmit
-or lost, then you most likely would want to set this to 2.  This
-configuration option is not required to be in the config file.
-example:
-hook=1
-
---------------------------------------------------------------------------------
-Log Format:
-
-log_level=1
-[unix seconds] [client ip] [server ip] [rtt]
-example:
-1344483780 192.168.1.12 192.168.1.1 1875
-
-log_level=2
-[unix seconds] [microseconds] [client ip] [server ip] [last_data_sent]
-[last_data_recv] [snd_cwnd] [snd_ssthresh] [rcv_ssthresh] [rtt]
-[rttvar] [unacked] [sacked] [lost] [retrans] [fackets]
-
-
-example:
-1344483817 281068 192.168.1.12 192.168.1.1 2 2 10 2147483647 32768 3875 4500 0 0 0 0 0
-
---------------------------------------------------------------------------------
-Version 1.0.1 (8/9/2012, bcall)
-  * Documentation and code cleanup
-
-Version 1.0.0 (8/8/2012, bcall)
-  * Initial Version

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/plugins/experimental/tcp_info/tcp_info.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/tcp_info/tcp_info.cc b/plugins/experimental/tcp_info/tcp_info.cc
deleted file mode 100644
index e828ded..0000000
--- a/plugins/experimental/tcp_info/tcp_info.cc
+++ /dev/null
@@ -1,424 +0,0 @@
-/** @file
-
-  tcp_info: A plugin to log TCP session information.
-
-  @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 <ts/ts.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <getopt.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <arpa/inet.h>
-
-#include "ink_defs.h"
-
-#if defined(TCP_INFO) && defined(HAVE_STRUCT_TCP_INFO)
-#define TCPI_PLUGIN_SUPPORTED 1
-#endif
-
-#define TCPI_HOOK_SSN_START     0x01u
-#define TCPI_HOOK_TXN_START     0x02u
-#define TCPI_HOOK_SEND_RESPONSE 0x04u
-#define TCPI_HOOK_SSN_CLOSE     0x08u
-#define TCPI_HOOK_TXN_CLOSE     0x10u
-
-// Log format headers. These are emitted once at the start of a log file. Note that we
-// carefully order the fields so the field ordering is compatible. This lets you change
-// the verbosity without breaking a perser that is moderately robust.
-static const char * tcpi_headers[] = {
-  "timestamp event client server rtt",
-  "timestamp event client server rtt rttvar last_sent last_recv "
-    "snd_ssthresh rcv_ssthresh unacked sacked lost retrans fackets",
-};
-
-struct Config {
-  int sample;
-  unsigned log_level;
-  TSTextLogObject log;
-
-  Config() : sample(1000), log_level(1), log(NULL) {
-  }
-
-  ~Config() {
-    if (log) {
-      TSTextLogObjectDestroy(log);
-    }
-  }
-};
-
-union const_sockaddr_ptr {
-  const struct sockaddr * sa;
-  const struct sockaddr_in * in;
-  const struct sockaddr_in6 * in6;
-
-  const void * addr() const {
-    switch (sa->sa_family) {
-    case AF_INET: return &(in->sin_addr);
-    case AF_INET6: return &(in6->sin6_addr);
-    default: return NULL;
-    }
-  }
-
-};
-
-#if TCPI_PLUGIN_SUPPORTED
-
-static void
-log_tcp_info(Config * config, const char * event_name, TSHttpSsn ssnp)
-{
-  char                client_str[INET6_ADDRSTRLEN];
-  char                server_str[INET6_ADDRSTRLEN];
-  const_sockaddr_ptr  client_addr;
-  const_sockaddr_ptr  server_addr;
-
-  struct tcp_info     info;
-  socklen_t           tcp_info_len = sizeof(info);
-  int                 fd;
-
-  TSReleaseAssert(config->log != NULL);
-
-  if (TSHttpSsnClientFdGet(ssnp, &fd) != TS_SUCCESS) {
-    TSDebug("tcp_info", "error getting the client socket fd");
-    return;
-  }
-
-  if (getsockopt(fd, IPPROTO_TCP, TCP_INFO, &info, &tcp_info_len) != 0) {
-    TSDebug("tcp_info", "getsockopt(%d, TCP_INFO) failed: %s", fd, strerror(errno));
-    return;
-  }
-
-  client_addr.sa = TSHttpSsnClientAddrGet(ssnp);
-  server_addr.sa = TSHttpSsnIncomingAddrGet(ssnp);
-
-  if (client_addr.sa == NULL || server_addr.sa == NULL) {
-    return;
-  }
-
-  // convert ip to string
-  inet_ntop(client_addr.sa->sa_family, client_addr.addr(), client_str, sizeof(client_str));
-  inet_ntop(server_addr.sa->sa_family, server_addr.addr(), server_str, sizeof(server_str));
-
-  TSReturnCode ret;
-
-  if (config->log_level == 2) {
-#if !defined(freebsd) || defined(__GLIBC__)
-    ret = TSTextLogObjectWrite(config->log, "%s %s %s %u %u %u %u %u %u %u %u %u %u %u %u",
-                     event_name,
-                     client_str,
-                     server_str,
-                     info.tcpi_rtt,
-                     info.tcpi_rttvar,
-                     info.tcpi_last_data_sent,
-                     info.tcpi_last_data_recv,
-                     info.tcpi_snd_cwnd,
-                     info.tcpi_snd_ssthresh,
-                     info.tcpi_rcv_ssthresh,
-                     info.tcpi_unacked,
-                     info.tcpi_sacked,
-                     info.tcpi_lost,
-                     info.tcpi_retrans,
-                     info.tcpi_fackets);
-#else
-    ret = TSTextLogObjectWrite(config->log, "%s %s %s %u %u %u %u %u %u %u %u %u %u %u %u",
-                     event_name,
-                     client_str,
-                     server_str,
-                     info.tcpi_rtt,
-                     info.tcpi_rttvar,
-                     info.__tcpi_last_data_sent,
-                     info.tcpi_last_data_recv,
-                     info.tcpi_snd_cwnd,
-                     info.tcpi_snd_ssthresh,
-                     info.__tcpi_rcv_ssthresh,
-                     info.__tcpi_unacked,
-                     info.__tcpi_sacked,
-                     info.__tcpi_lost,
-                     info.__tcpi_retrans,
-                     info.__tcpi_fackets);
-#endif
-  } else {
-    ret = TSTextLogObjectWrite(config->log, "%s %s %s %u",
-                     event_name,
-                     client_str,
-                     server_str,
-                     info.tcpi_rtt);
-  }
-
-  // It's really not clear how we should handle logging failures. It a failure transient
-  // or persistent? Should we try to re-open the logs? How frequently should we do that?
-  if (ret != TS_SUCCESS) {
-    TSError("[tcp_info] log write failed, disabling logging");
-    TSTextLogObjectDestroy(config->log);
-    config->log = NULL;
-  }
-}
-
-#else /* TCPI_PLUGIN_SUPPORTED */
-
-static void
-log_tcp_info(Config * /* config */, const char * /* event_name */, TSHttpSsn /* ssnp */)
-{
-  return; // TCP metrics not supported.
-}
-
-#endif /* TCPI_PLUGIN_SUPPORTED */
-
-static int
-tcp_info_hook(TSCont contp, TSEvent event, void *edata)
-{
-  TSHttpSsn ssnp = NULL;
-  TSHttpTxn txnp = NULL;
-  int       random = 0;
-  Config *  config = (Config *)TSContDataGet(contp);
-
-  const char *event_name;
-  switch (event) {
-  case TS_EVENT_HTTP_SSN_START:
-    ssnp = (TSHttpSsn)edata;
-    event_name = "ssn_start";
-    break;
-  case TS_EVENT_HTTP_TXN_START:
-    txnp = (TSHttpTxn)edata;
-    ssnp = TSHttpTxnSsnGet(txnp);
-    event_name = "txn_start";
-    break;
-  case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
-    txnp = (TSHttpTxn)edata;
-    ssnp = TSHttpTxnSsnGet(txnp);
-    event_name = "send_resp_hdr";
-    break;
-  case TS_EVENT_HTTP_SSN_CLOSE:
-    ssnp = (TSHttpSsn)edata;
-    event_name = "ssn_close";
-  default:
-    return 0;
-  }
-
-  TSDebug("tcp_info", "logging hook called for %s (%s) with log object %p",
-      TSHttpEventNameLookup(event), event_name, config->log);
-
-  if (config->log == NULL) {
-    goto done;
-  }
-
-  // no need to run rand if we are always going log (100%)
-  if (config->sample < 1000) {
-    random = rand() % 1000;
-    TSDebug("tcp_info", "random: %d, config->sample: %d", random, config->sample);
-  }
-
-  if (random < config->sample) {
-    TSDebug("tcp_info", "sampling TCP metrics for %s event", event_name);
-    log_tcp_info(config, event_name, ssnp);
-  }
-
-done:
-  if (txnp != NULL) {
-    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
-  } else if (ssnp != NULL) {
-    TSHttpSsnReenable(ssnp, TS_EVENT_HTTP_CONTINUE);
-  }
-
-  return TS_EVENT_NONE;
-}
-
-static bool
-parse_unsigned(const char * str, unsigned long& lval)
-{
-  char * end = NULL;
-
-  if (*str == '\0') {
-    return false;
-  }
-
-  lval = strtoul(str, &end, 0 /* base */);
-  if (end == str) {
-    // No valid characters.
-    return false;
-  }
-
-  if (end && *end != '\0') {
-    // Not all charaters consumed.
-    return false;
-  }
-
-  return true;
-}
-
-// Parse a comma-separated list of hook names into a hook bitmask.
-static unsigned
-parse_hook_list(const char * hook_list)
-{
-  unsigned mask = 0;
-  char * tok;
-  char * str;
-  char * last;
-
-  const struct hookmask { const char * name; unsigned mask; } hooks[] = {
-    { "ssn_start", TCPI_HOOK_SSN_START },
-    { "txn_start", TCPI_HOOK_TXN_START },
-    { "send_resp_hdr", TCPI_HOOK_SEND_RESPONSE },
-    { "ssn_close", TCPI_HOOK_SSN_CLOSE },
-    { "txn_close", TCPI_HOOK_TXN_CLOSE },
-    { NULL, 0u }
-  };
-
-  str = TSstrdup(hook_list);
-
-  for (tok = strtok_r(str, ",", &last); tok; tok = strtok_r(NULL, ",", &last)) {
-    bool match = false;
-
-    for (const struct hookmask * m = hooks; m->name != NULL; ++m) {
-      if (strcmp(m->name, tok) == 0) {
-        mask |= m->mask;
-        match = true;
-        break;
-      }
-    }
-
-    if (!match) {
-      TSError("[tcp_info] invalid hook name '%s'", tok);
-    }
-  }
-
-  TSfree(str);
-  return mask;
-}
-
-void
-TSPluginInit(int argc, const char * argv[])
-{
-  static const char usage[] = "tcp_info.so [--log-file=PATH] [--log-level=LEVEL] [--hooks=LIST] [--sample-rate=COUNT]";
-  static const struct option longopts[] = {
-    { const_cast<char *>("sample-rate"), required_argument, NULL, 'r' },
-    { const_cast<char *>("log-file"), required_argument, NULL, 'f' },
-    { const_cast<char *>("log-level"), required_argument, NULL, 'l' },
-    { const_cast<char *>("hooks"), required_argument, NULL, 'h' },
-    { NULL, 0, NULL, 0 }
-  };
-
-  TSPluginRegistrationInfo info;
-  Config *  config = new Config();
-  const char *  filename = "tcp_info";
-  TSCont    cont;
-  unsigned  hooks = 0;
-
-  info.plugin_name = (char*)"tcp_info";
-  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) {
-    TSError("tcp_info: plugin registration failed");
-  }
-
-  optind = 0;
-  for (;;) {
-    unsigned long lval;
-
-    switch (getopt_long(argc, (char * const *)argv, "r:f:l:h:", longopts, NULL)) {
-    case 'r':
-      if (parse_unsigned(optarg, lval)) {
-        config->sample = atoi(optarg);
-      } else {
-        TSError("[tcp_info] invalid sample rate '%s'", optarg);
-      }
-      break;
-    case 'f':
-      filename = optarg;
-      break;
-    case 'l':
-      if (parse_unsigned(optarg, lval) && (lval <= countof(tcpi_headers))) {
-        config->log_level = lval;
-      } else {
-        TSError("[tcp_info] invalid log level '%s'", optarg);
-      }
-      break;
-    case 'h':
-      hooks = parse_hook_list(optarg);
-      break;
-    case -1:
-        goto init;
-    default:
-        TSError("[tcp_info] usage: %s", usage);
-    }
-  }
-
-init:
-
-#if !TCPI_PLUGIN_SUPPORTED
-  TSError("[tcp_info] TCP metrics are not supported on this platform");
-#endif
-
-  TSDebug("tcp_info", "sample: %d", config->sample);
-  TSDebug("tcp_info", "log filename: %s", filename);
-  TSDebug("tcp_info", "log_level: %u", config->log_level);
-  TSDebug("tcp_info", "hook mask: 0x%x", hooks);
-
-  if (TSTextLogObjectCreate(filename, TS_LOG_MODE_ADD_TIMESTAMP, &config->log) != TS_SUCCESS) {
-    TSError("[tcp_info] failed to create log file '%s'", filename);
-    delete config;
-    return;
-  }
-
-  TSTextLogObjectHeaderSet(config->log, tcpi_headers[config->log_level - 1]);
-
-  // Enable log rolling. Unless we specify an explicit rolling period, the log will
-  // be rolled based on the size specified in proxy.config.log.rolling_size_mb.
-  TSTextLogObjectRollingEnabledSet(config->log, 1 /* rolling_enabled */);
-
-  cont = TSContCreate(tcp_info_hook, NULL);
-  TSContDataSet(cont, config);
-
-  if (hooks & TCPI_HOOK_SSN_START) {
-    TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, cont);
-    TSDebug("tcp_info", "added hook to the start of the TCP connection");
-  }
-
-  if (hooks & TCPI_HOOK_TXN_START) {
-    TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, cont);
-    TSDebug("tcp_info", "added hook to the close of the transaction");
-  }
-
-  if (hooks & TCPI_HOOK_SEND_RESPONSE) {
-    TSHttpHookAdd(TS_HTTP_SEND_RESPONSE_HDR_HOOK, cont);
-    TSDebug("tcp_info", "added hook to the sending of the headers");
-  }
-
-  if (hooks & TCPI_HOOK_SSN_CLOSE) {
-    TSHttpHookAdd(TS_HTTP_SSN_CLOSE_HOOK, cont);
-    TSDebug("tcp_info", "added hook to the close of the TCP connection");
-  }
-
-  if (hooks & TCPI_HOOK_TXN_CLOSE) {
-    TSHttpHookAdd(TS_HTTP_TXN_CLOSE_HOOK, cont);
-    TSDebug("tcp_info", "added hook to the close of the transaction");
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/plugins/experimental/tcp_info/tcp_info.config
----------------------------------------------------------------------
diff --git a/plugins/experimental/tcp_info/tcp_info.config b/plugins/experimental/tcp_info/tcp_info.config
deleted file mode 100644
index 52321de..0000000
--- a/plugins/experimental/tcp_info/tcp_info.config
+++ /dev/null
@@ -1,3 +0,0 @@
-log_file=/usr/local/var/log/trafficserver/tcp_info.log
-sample=1000
-log_level=1

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/plugins/tcpinfo/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/tcpinfo/Makefile.am b/plugins/tcpinfo/Makefile.am
new file mode 100644
index 0000000..ae1078b
--- /dev/null
+++ b/plugins/tcpinfo/Makefile.am
@@ -0,0 +1,22 @@
+#  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 = tcpinfo.la
+tcpinfo_la_SOURCES = tcpinfo.cc
+tcpinfo_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86453b99/plugins/tcpinfo/tcpinfo.cc
----------------------------------------------------------------------
diff --git a/plugins/tcpinfo/tcpinfo.cc b/plugins/tcpinfo/tcpinfo.cc
new file mode 100644
index 0000000..cad921e
--- /dev/null
+++ b/plugins/tcpinfo/tcpinfo.cc
@@ -0,0 +1,424 @@
+/** @file
+
+  tcpinfo: A plugin to log TCP session information.
+
+  @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 <ts/ts.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <arpa/inet.h>
+
+#include "ink_defs.h"
+
+#if defined(TCP_INFO) && defined(HAVE_STRUCT_TCP_INFO)
+#define TCPI_PLUGIN_SUPPORTED 1
+#endif
+
+#define TCPI_HOOK_SSN_START     0x01u
+#define TCPI_HOOK_TXN_START     0x02u
+#define TCPI_HOOK_SEND_RESPONSE 0x04u
+#define TCPI_HOOK_SSN_CLOSE     0x08u
+#define TCPI_HOOK_TXN_CLOSE     0x10u
+
+// Log format headers. These are emitted once at the start of a log file. Note that we
+// carefully order the fields so the field ordering is compatible. This lets you change
+// the verbosity without breaking a perser that is moderately robust.
+static const char * tcpi_headers[] = {
+  "timestamp event client server rtt",
+  "timestamp event client server rtt rttvar last_sent last_recv "
+    "snd_ssthresh rcv_ssthresh unacked sacked lost retrans fackets",
+};
+
+struct Config {
+  int sample;
+  unsigned log_level;
+  TSTextLogObject log;
+
+  Config() : sample(1000), log_level(1), log(NULL) {
+  }
+
+  ~Config() {
+    if (log) {
+      TSTextLogObjectDestroy(log);
+    }
+  }
+};
+
+union const_sockaddr_ptr {
+  const struct sockaddr * sa;
+  const struct sockaddr_in * in;
+  const struct sockaddr_in6 * in6;
+
+  const void * addr() const {
+    switch (sa->sa_family) {
+    case AF_INET: return &(in->sin_addr);
+    case AF_INET6: return &(in6->sin6_addr);
+    default: return NULL;
+    }
+  }
+
+};
+
+#if TCPI_PLUGIN_SUPPORTED
+
+static void
+log_tcp_info(Config * config, const char * event_name, TSHttpSsn ssnp)
+{
+  char                client_str[INET6_ADDRSTRLEN];
+  char                server_str[INET6_ADDRSTRLEN];
+  const_sockaddr_ptr  client_addr;
+  const_sockaddr_ptr  server_addr;
+
+  struct tcp_info     info;
+  socklen_t           tcp_info_len = sizeof(info);
+  int                 fd;
+
+  TSReleaseAssert(config->log != NULL);
+
+  if (TSHttpSsnClientFdGet(ssnp, &fd) != TS_SUCCESS) {
+    TSDebug("tcpinfo", "error getting the client socket fd");
+    return;
+  }
+
+  if (getsockopt(fd, IPPROTO_TCP, TCP_INFO, &info, &tcp_info_len) != 0) {
+    TSDebug("tcpinfo", "getsockopt(%d, TCP_INFO) failed: %s", fd, strerror(errno));
+    return;
+  }
+
+  client_addr.sa = TSHttpSsnClientAddrGet(ssnp);
+  server_addr.sa = TSHttpSsnIncomingAddrGet(ssnp);
+
+  if (client_addr.sa == NULL || server_addr.sa == NULL) {
+    return;
+  }
+
+  // convert ip to string
+  inet_ntop(client_addr.sa->sa_family, client_addr.addr(), client_str, sizeof(client_str));
+  inet_ntop(server_addr.sa->sa_family, server_addr.addr(), server_str, sizeof(server_str));
+
+  TSReturnCode ret;
+
+  if (config->log_level == 2) {
+#if !defined(freebsd) || defined(__GLIBC__)
+    ret = TSTextLogObjectWrite(config->log, "%s %s %s %u %u %u %u %u %u %u %u %u %u %u %u",
+                     event_name,
+                     client_str,
+                     server_str,
+                     info.tcpi_rtt,
+                     info.tcpi_rttvar,
+                     info.tcpi_last_data_sent,
+                     info.tcpi_last_data_recv,
+                     info.tcpi_snd_cwnd,
+                     info.tcpi_snd_ssthresh,
+                     info.tcpi_rcv_ssthresh,
+                     info.tcpi_unacked,
+                     info.tcpi_sacked,
+                     info.tcpi_lost,
+                     info.tcpi_retrans,
+                     info.tcpi_fackets);
+#else
+    ret = TSTextLogObjectWrite(config->log, "%s %s %s %u %u %u %u %u %u %u %u %u %u %u %u",
+                     event_name,
+                     client_str,
+                     server_str,
+                     info.tcpi_rtt,
+                     info.tcpi_rttvar,
+                     info.__tcpi_last_data_sent,
+                     info.tcpi_last_data_recv,
+                     info.tcpi_snd_cwnd,
+                     info.tcpi_snd_ssthresh,
+                     info.__tcpi_rcv_ssthresh,
+                     info.__tcpi_unacked,
+                     info.__tcpi_sacked,
+                     info.__tcpi_lost,
+                     info.__tcpi_retrans,
+                     info.__tcpi_fackets);
+#endif
+  } else {
+    ret = TSTextLogObjectWrite(config->log, "%s %s %s %u",
+                     event_name,
+                     client_str,
+                     server_str,
+                     info.tcpi_rtt);
+  }
+
+  // It's really not clear how we should handle logging failures. It a failure transient
+  // or persistent? Should we try to re-open the logs? How frequently should we do that?
+  if (ret != TS_SUCCESS) {
+    TSError("[tcpinfo] log write failed, disabling logging");
+    TSTextLogObjectDestroy(config->log);
+    config->log = NULL;
+  }
+}
+
+#else /* TCPI_PLUGIN_SUPPORTED */
+
+static void
+log_tcp_info(Config * /* config */, const char * /* event_name */, TSHttpSsn /* ssnp */)
+{
+  return; // TCP metrics not supported.
+}
+
+#endif /* TCPI_PLUGIN_SUPPORTED */
+
+static int
+tcp_info_hook(TSCont contp, TSEvent event, void *edata)
+{
+  TSHttpSsn ssnp = NULL;
+  TSHttpTxn txnp = NULL;
+  int       random = 0;
+  Config *  config = (Config *)TSContDataGet(contp);
+
+  const char *event_name;
+  switch (event) {
+  case TS_EVENT_HTTP_SSN_START:
+    ssnp = (TSHttpSsn)edata;
+    event_name = "ssn_start";
+    break;
+  case TS_EVENT_HTTP_TXN_START:
+    txnp = (TSHttpTxn)edata;
+    ssnp = TSHttpTxnSsnGet(txnp);
+    event_name = "txn_start";
+    break;
+  case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
+    txnp = (TSHttpTxn)edata;
+    ssnp = TSHttpTxnSsnGet(txnp);
+    event_name = "send_resp_hdr";
+    break;
+  case TS_EVENT_HTTP_SSN_CLOSE:
+    ssnp = (TSHttpSsn)edata;
+    event_name = "ssn_close";
+  default:
+    return 0;
+  }
+
+  TSDebug("tcpinfo", "logging hook called for %s (%s) with log object %p",
+      TSHttpEventNameLookup(event), event_name, config->log);
+
+  if (config->log == NULL) {
+    goto done;
+  }
+
+  // no need to run rand if we are always going log (100%)
+  if (config->sample < 1000) {
+    random = rand() % 1000;
+    TSDebug("tcpinfo", "random: %d, config->sample: %d", random, config->sample);
+  }
+
+  if (random < config->sample) {
+    TSDebug("tcpinfo", "sampling TCP metrics for %s event", event_name);
+    log_tcp_info(config, event_name, ssnp);
+  }
+
+done:
+  if (txnp != NULL) {
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+  } else if (ssnp != NULL) {
+    TSHttpSsnReenable(ssnp, TS_EVENT_HTTP_CONTINUE);
+  }
+
+  return TS_EVENT_NONE;
+}
+
+static bool
+parse_unsigned(const char * str, unsigned long& lval)
+{
+  char * end = NULL;
+
+  if (*str == '\0') {
+    return false;
+  }
+
+  lval = strtoul(str, &end, 0 /* base */);
+  if (end == str) {
+    // No valid characters.
+    return false;
+  }
+
+  if (end && *end != '\0') {
+    // Not all charaters consumed.
+    return false;
+  }
+
+  return true;
+}
+
+// Parse a comma-separated list of hook names into a hook bitmask.
+static unsigned
+parse_hook_list(const char * hook_list)
+{
+  unsigned mask = 0;
+  char * tok;
+  char * str;
+  char * last;
+
+  const struct hookmask { const char * name; unsigned mask; } hooks[] = {
+    { "ssn_start", TCPI_HOOK_SSN_START },
+    { "txn_start", TCPI_HOOK_TXN_START },
+    { "send_resp_hdr", TCPI_HOOK_SEND_RESPONSE },
+    { "ssn_close", TCPI_HOOK_SSN_CLOSE },
+    { "txn_close", TCPI_HOOK_TXN_CLOSE },
+    { NULL, 0u }
+  };
+
+  str = TSstrdup(hook_list);
+
+  for (tok = strtok_r(str, ",", &last); tok; tok = strtok_r(NULL, ",", &last)) {
+    bool match = false;
+
+    for (const struct hookmask * m = hooks; m->name != NULL; ++m) {
+      if (strcmp(m->name, tok) == 0) {
+        mask |= m->mask;
+        match = true;
+        break;
+      }
+    }
+
+    if (!match) {
+      TSError("[tcpinfo] invalid hook name '%s'", tok);
+    }
+  }
+
+  TSfree(str);
+  return mask;
+}
+
+void
+TSPluginInit(int argc, const char * argv[])
+{
+  static const char usage[] = "tcpinfo.so [--log-file=PATH] [--log-level=LEVEL] [--hooks=LIST] [--sample-rate=COUNT]";
+  static const struct option longopts[] = {
+    { const_cast<char *>("sample-rate"), required_argument, NULL, 'r' },
+    { const_cast<char *>("log-file"), required_argument, NULL, 'f' },
+    { const_cast<char *>("log-level"), required_argument, NULL, 'l' },
+    { const_cast<char *>("hooks"), required_argument, NULL, 'h' },
+    { NULL, 0, NULL, 0 }
+  };
+
+  TSPluginRegistrationInfo info;
+  Config *  config = new Config();
+  const char *  filename = "tcpinfo";
+  TSCont    cont;
+  unsigned  hooks = 0;
+
+  info.plugin_name = (char*)"tcpinfo";
+  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) {
+    TSError("[tcpinfo] plugin registration failed");
+  }
+
+  optind = 0;
+  for (;;) {
+    unsigned long lval;
+
+    switch (getopt_long(argc, (char * const *)argv, "r:f:l:h:", longopts, NULL)) {
+    case 'r':
+      if (parse_unsigned(optarg, lval)) {
+        config->sample = atoi(optarg);
+      } else {
+        TSError("[tcpinfo] invalid sample rate '%s'", optarg);
+      }
+      break;
+    case 'f':
+      filename = optarg;
+      break;
+    case 'l':
+      if (parse_unsigned(optarg, lval) && (lval <= countof(tcpi_headers))) {
+        config->log_level = lval;
+      } else {
+        TSError("[tcpinfo] invalid log level '%s'", optarg);
+      }
+      break;
+    case 'h':
+      hooks = parse_hook_list(optarg);
+      break;
+    case -1:
+        goto init;
+    default:
+        TSError("[tcpinfo] usage: %s", usage);
+    }
+  }
+
+init:
+
+#if !TCPI_PLUGIN_SUPPORTED
+  TSError("[tcpinfo] TCP metrics are not supported on this platform");
+#endif
+
+  TSDebug("tcpinfo", "sample: %d", config->sample);
+  TSDebug("tcpinfo", "log filename: %s", filename);
+  TSDebug("tcpinfo", "log_level: %u", config->log_level);
+  TSDebug("tcpinfo", "hook mask: 0x%x", hooks);
+
+  if (TSTextLogObjectCreate(filename, TS_LOG_MODE_ADD_TIMESTAMP, &config->log) != TS_SUCCESS) {
+    TSError("[tcpinfo] failed to create log file '%s'", filename);
+    delete config;
+    return;
+  }
+
+  TSTextLogObjectHeaderSet(config->log, tcpi_headers[config->log_level - 1]);
+
+  // Enable log rolling. Unless we specify an explicit rolling period, the log will
+  // be rolled based on the size specified in proxy.config.log.rolling_size_mb.
+  TSTextLogObjectRollingEnabledSet(config->log, 1 /* rolling_enabled */);
+
+  cont = TSContCreate(tcp_info_hook, NULL);
+  TSContDataSet(cont, config);
+
+  if (hooks & TCPI_HOOK_SSN_START) {
+    TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, cont);
+    TSDebug("tcpinfo", "added hook to the start of the TCP connection");
+  }
+
+  if (hooks & TCPI_HOOK_TXN_START) {
+    TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, cont);
+    TSDebug("tcpinfo", "added hook to the close of the transaction");
+  }
+
+  if (hooks & TCPI_HOOK_SEND_RESPONSE) {
+    TSHttpHookAdd(TS_HTTP_SEND_RESPONSE_HDR_HOOK, cont);
+    TSDebug("tcpinfo", "added hook to the sending of the headers");
+  }
+
+  if (hooks & TCPI_HOOK_SSN_CLOSE) {
+    TSHttpHookAdd(TS_HTTP_SSN_CLOSE_HOOK, cont);
+    TSDebug("tcpinfo", "added hook to the close of the TCP connection");
+  }
+
+  if (hooks & TCPI_HOOK_TXN_CLOSE) {
+    TSHttpHookAdd(TS_HTTP_TXN_CLOSE_HOOK, cont);
+    TSDebug("tcpinfo", "added hook to the close of the transaction");
+  }
+
+}


[14/50] git commit: Added a bunch of Jira's to the CHANGES.

Posted by zw...@apache.org.
Added a bunch of Jira's to the CHANGES.


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

Branch: refs/heads/5.0.x
Commit: 6d6b5a8d36b63d09249713b2afc9805bc9286f44
Parents: 136cc1f
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Apr 10 14:41:28 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Apr 10 14:42:08 2014 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6d6b5a8d/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index adc154b..3f113bc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,19 @@ Changes with Apache Traffic Server 5.0.0
 
   *) [TS-2706] Replace the tcp_info plugin config file with options.
 
+  *) [TS-2691] Fix how we count redirect retries in the core and APIs.
+
+  *) [TS-2693] Deprecate the old TSRedirectUrlSet()/TSRedirectUrlGet().
+
+  *) [TS-2692] Add an API to Get the current redirection retry count,
+   TSHttpTxnRedirectRetries().
+
+  *) [TS-2707] Migrate TSRedirectUrlSet/Get to TSHttpTxnRedirectUrlSet/Get.
+
+  *) [TS-2703] Add a text log format to escalate plugin.
+
+  *) [TS-2690] Fixes and improvements for the escalate plugin.
+
   *) [TS-2699] Add TSClientProtoStackCreate API.
 
   *) [TS-2678] Some sites (e.g. craigslist) fails to load due to


[36/50] git commit: TS-2711 Do not use the -C option with make, not available on all platforms

Posted by zw...@apache.org.
TS-2711 Do not use the -C option with make, not available on all platforms


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

Branch: refs/heads/5.0.x
Commit: 4c09fff8a4e4b61d47a3f6eeae8cf37f94d69332
Parents: 76a0777
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 15 16:52:33 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Apr 15 16:52:36 2014 -0600

----------------------------------------------------------------------
 lib/Makefile.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c09fff8/lib/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b52766b..ad5a731 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -42,8 +42,8 @@ all-local:
 	@echo "Making all in luajit"
 	test -d "$(top_srcdir)/luajit/src" || (cd "$(top_srcdir)" && git submodule update --init)
 	test -d "$(top_builddir)/$(subdir)/luajit/src" || cp -rf "$(srcdir)/luajit" "$(top_builddir)/$(subdir)/"
-	make -C luajit PREFIX=$(prefix)
+	cd luajit && make PREFIX=$(prefix)
 
 clean-local:
-	test "$(top_srcdir)" != "$(top_builddir)" || make -C "$(top_builddir)/$(subdir)/luajit" clean
+	test "$(top_srcdir)" != "$(top_builddir)" || (cd "$(top_builddir)/$(subdir)/luajit" && make clean)
 	test "$(top_srcdir)" = "$(top_builddir)" || rm -rf "$(top_builddir)/$(subdir)/luajit"


[27/50] git commit: TS-2715 Fix some ESI compile warnings

Posted by zw...@apache.org.
TS-2715 Fix some ESI compile warnings


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

Branch: refs/heads/5.0.x
Commit: 1e6b4194e80a99e9d9b9ede0a66611209b52c178
Parents: b90a731
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Apr 14 13:51:11 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Apr 14 13:51:11 2014 -0600

----------------------------------------------------------------------
 CHANGES                                 |  3 +++
 plugins/experimental/esi/lib/EsiGzip.cc | 12 ------------
 plugins/experimental/esi/lib/gzip.cc    | 12 ------------
 plugins/experimental/esi/lib/gzip.h     | 14 ++++++++++++++
 4 files changed, 17 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1e6b4194/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 93b67d0..0ffa264 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2715] Fix some ESI compile warnings, change the constants to
+   be part of an include.
+
   *) [TS-898] Remove pointless NULL check on address of array.
 
   *) [TS-898] Avoid passing -1 to close (2) in traffic_cop.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1e6b4194/plugins/experimental/esi/lib/EsiGzip.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/lib/EsiGzip.cc b/plugins/experimental/esi/lib/EsiGzip.cc
index 312ed30..c7d5534 100644
--- a/plugins/experimental/esi/lib/EsiGzip.cc
+++ b/plugins/experimental/esi/lib/EsiGzip.cc
@@ -29,18 +29,6 @@
 using std::string;
 using namespace EsiLib;
 
-static const int COMPRESSION_LEVEL = 6;
-static const int ZLIB_MEM_LEVEL = 8;
-
-static const int GZIP_HEADER_SIZE = 10;
-static const int GZIP_TRAILER_SIZE = 8;
-
-static const char MAGIC_BYTE_1 = 0x1f;
-static const char MAGIC_BYTE_2 = 0x8b;
-static const char OS_TYPE = 3; // Unix
-
-static const int BUF_SIZE = 1 << 15; // 32k buffer
-
 EsiGzip::EsiGzip(const char *debug_tag,
                            ComponentBase::Debug debug_func, ComponentBase::Error error_func)
   : ComponentBase(debug_tag, debug_func, error_func),

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1e6b4194/plugins/experimental/esi/lib/gzip.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/lib/gzip.cc b/plugins/experimental/esi/lib/gzip.cc
index 5be1be4..9a38ce4 100644
--- a/plugins/experimental/esi/lib/gzip.cc
+++ b/plugins/experimental/esi/lib/gzip.cc
@@ -31,18 +31,6 @@
 using namespace EsiLib;
 using std::string;
 
-static const int COMPRESSION_LEVEL = 6;
-static const int ZLIB_MEM_LEVEL = 8;
-
-static const int GZIP_HEADER_SIZE = 10;
-static const int GZIP_TRAILER_SIZE = 8;
-
-static const char MAGIC_BYTE_1 = 0x1f;
-static const char MAGIC_BYTE_2 = 0x8b;
-static const char OS_TYPE = 3; // Unix
-
-static const int BUF_SIZE = 1 << 15; // 32k buffer
-
 template<typename T>
 inline void append(string &out, T data) {
   for (unsigned int i = 0; i < sizeof(data); ++i) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1e6b4194/plugins/experimental/esi/lib/gzip.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/lib/gzip.h b/plugins/experimental/esi/lib/gzip.h
index 92d81ec..13906b8 100644
--- a/plugins/experimental/esi/lib/gzip.h
+++ b/plugins/experimental/esi/lib/gzip.h
@@ -28,6 +28,20 @@
 #include <string>
 #include <list>
 
+// Defines for various GZIP constants
+static const int COMPRESSION_LEVEL = 6;
+static const int ZLIB_MEM_LEVEL = 8;
+
+static const int GZIP_HEADER_SIZE = 10;
+static const int GZIP_TRAILER_SIZE = 8;
+
+static const char MAGIC_BYTE_1 = 0x1f;
+static const char MAGIC_BYTE_2 = 0x8b;
+static const char OS_TYPE = 3; // Unix
+
+static const int BUF_SIZE = 1 << 15; // 32k buffer
+
+
 namespace EsiLib {
 
 struct ByteBlock {


[39/50] git commit: TS-2555 add global plugin support for ts_lua plugin

Posted by zw...@apache.org.
TS-2555 add global plugin support 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/904e1f7c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/904e1f7c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/904e1f7c

Branch: refs/heads/5.0.x
Commit: 904e1f7c2995dbb4a8afea7cd99e32f0fd844f46
Parents: 9f509d4
Author: Kit Chan <ki...@apache.org>
Authored: Tue Apr 15 22:30:01 2014 -0700
Committer: Kit Chan <ki...@apache.org>
Committed: Tue Apr 15 22:30:01 2014 -0700

----------------------------------------------------------------------
 plugins/experimental/ts_lua/ts_lua.c        | 155 ++++++++++++++++++++++-
 plugins/experimental/ts_lua/ts_lua_common.h |   8 ++
 plugins/experimental/ts_lua/ts_lua_util.c   |   9 ++
 3 files changed, 170 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/904e1f7c/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 ca78665..32cb58c 100644
--- a/plugins/experimental/ts_lua/ts_lua.c
+++ b/plugins/experimental/ts_lua/ts_lua.c
@@ -26,9 +26,10 @@
 #define TS_LUA_MAX_STATE_COUNT                  2048
 
 static volatile int32_t ts_lua_http_next_id = 0;
+static volatile int32_t ts_lua_g_http_next_id = 0;
 
 ts_lua_main_ctx         *ts_lua_main_ctx_array;
-
+ts_lua_main_ctx         *ts_lua_g_main_ctx_array;
 
 TSReturnCode
 TSRemapInit(TSRemapInterface *api_info, char * errbuf ATS_UNUSED , int errbuf_size ATS_UNUSED )
@@ -119,7 +120,7 @@ TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
     http_ctx->client_request_bufp = rri->requestBufp;
     http_ctx->client_request_hdrp = rri->requestHdrp;
     http_ctx->client_request_url = rri->requestUrl;
-
+    http_ctx->remap = 1;
     l = http_ctx->lua;
 
     lua_getglobal(l, TS_LUA_FUNCTION_REMAP);
@@ -146,3 +147,153 @@ TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
     return ret;
 }
 
+static int
+globalHookHandler(TSCont contp, TSEvent event, void *edata) {
+  TSHttpTxn txnp = (TSHttpTxn) edata;
+
+  int ret = 0;
+  int64_t req_id;
+
+  lua_State *l;
+  TSCont txn_contp;
+
+  ts_lua_main_ctx     *main_ctx;
+  ts_lua_http_ctx     *http_ctx;
+
+  ts_lua_instance_conf *conf = (ts_lua_instance_conf *)TSContDataGet(contp);
+
+  req_id = (int64_t) ts_lua_atomic_increment((&ts_lua_g_http_next_id), 1);
+  main_ctx = &ts_lua_g_main_ctx_array[req_id%TS_LUA_MAX_STATE_COUNT];
+
+  TSMutexLock(main_ctx->mutexp);
+
+  http_ctx = ts_lua_create_http_ctx(main_ctx, conf);
+  http_ctx->txnp = txnp;
+  http_ctx->remap = 0;
+
+  TSMBuffer bufp;
+  TSMLoc hdr_loc;
+  TSMLoc url_loc;
+
+  if(TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) == TS_SUCCESS) {
+    http_ctx->client_request_bufp = bufp;
+    http_ctx->client_request_hdrp = hdr_loc;
+    if (TSHttpHdrUrlGet(bufp, hdr_loc, &url_loc) == TS_SUCCESS) {
+      http_ctx->client_request_url = url_loc;
+    }
+  }
+
+  if(!http_ctx->client_request_hdrp) {
+    TSMutexUnlock(main_ctx->mutexp);
+    TSHttpTxnReenable(txnp,TS_EVENT_HTTP_CONTINUE);
+    return 0;
+  }
+ 
+  l = http_ctx->lua;
+
+  switch (event) {
+  case TS_EVENT_HTTP_READ_REQUEST_HDR:
+    lua_getglobal(l, TS_LUA_FUNCTION_G_READ_REQUEST);
+    break;
+
+  case TS_EVENT_HTTP_SEND_REQUEST_HDR:
+    lua_getglobal(l, TS_LUA_FUNCTION_G_SEND_REQUEST);
+    break;
+
+  case TS_EVENT_HTTP_READ_RESPONSE_HDR:
+    lua_getglobal(l, TS_LUA_FUNCTION_G_READ_RESPONSE);
+    break;
+
+  case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
+    lua_getglobal(l, TS_LUA_FUNCTION_G_SEND_RESPONSE);
+    break;
+
+  case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
+    lua_getglobal(l, TS_LUA_FUNCTION_G_CACHE_LOOKUP_COMPLETE);
+    break;
+
+  default:
+    TSMutexUnlock(main_ctx->mutexp);
+    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+    return 0;
+    break;
+  }
+
+  if (lua_type(l, -1) != LUA_TFUNCTION) {
+      TSMutexUnlock(main_ctx->mutexp);
+      TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+      return 0;
+  }
+
+  txn_contp = TSContCreate(ts_lua_http_cont_handler, NULL);
+  TSContDataSet(txn_contp, http_ctx);
+  http_ctx->main_contp = txn_contp;
+
+  if (lua_pcall(l, 0, 1, 0) != 0) {
+      fprintf(stderr, "lua_pcall failed: %s\n", lua_tostring(l, -1));
+  }
+
+  ret = lua_tointeger(l, -1);
+  lua_pop(l, 1);
+
+  TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, txn_contp);
+
+  TSMutexUnlock(main_ctx->mutexp);
+
+  TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
+  return ret;
+}
+
+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 global_contp = TSContCreate(globalHookHandler, NULL);
+    if (!global_contp) {
+      TSError("[%s] Could not create global continuation", __FUNCTION__);
+      return;
+    }
+    TSContDataSet(global_contp, conf);
+
+    TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_SEND_REQUEST_HDR_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_SEND_RESPONSE_HDR_HOOK, global_contp);
+    TSHttpHookAdd(TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, global_contp);
+ 
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/904e1f7c/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 66ba35e..4c84e3f 100644
--- a/plugins/experimental/ts_lua/ts_lua_common.h
+++ b/plugins/experimental/ts_lua/ts_lua_common.h
@@ -41,6 +41,12 @@
 #define TS_LUA_FUNCTION_READ_RESPONSE           "do_read_response"
 #define TS_LUA_FUNCTION_SEND_RESPONSE           "do_send_response"
 
+#define TS_LUA_FUNCTION_G_SEND_REQUEST "do_global_send_request"
+#define TS_LUA_FUNCTION_G_READ_REQUEST "do_global_read_request"
+#define TS_LUA_FUNCTION_G_SEND_RESPONSE "do_global_send_response"
+#define TS_LUA_FUNCTION_G_READ_RESPONSE "do_global_read_response"
+#define TS_LUA_FUNCTION_G_CACHE_LOOKUP_COMPLETE "do_global_cache_lookup_complete"
+
 #define TS_LUA_MAX_SCRIPT_FNAME_LENGTH      1024
 #define TS_LUA_MAX_URL_LENGTH               2048
 
@@ -85,6 +91,8 @@ typedef struct {
     int         intercept_type;
     int         ref;
 
+    int         remap;
+
 } ts_lua_http_ctx;
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/904e1f7c/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 ea20fa9..81231ee 100644
--- a/plugins/experimental/ts_lua/ts_lua_util.c
+++ b/plugins/experimental/ts_lua/ts_lua_util.c
@@ -280,6 +280,15 @@ ts_lua_destroy_http_ctx(ts_lua_http_ctx* http_ctx)
 
     main_ctx = http_ctx->mctx;
 
+    if(!http_ctx->remap) {
+      if(http_ctx->client_request_bufp) {
+        if(http_ctx->client_request_url) {
+          TSHandleMLocRelease(http_ctx->client_request_bufp, http_ctx->client_request_hdrp, http_ctx->client_request_url);
+        } 
+        TSHandleMLocRelease(http_ctx->client_request_bufp, TS_NULL_MLOC, http_ctx->client_request_hdrp);
+      }
+    } 
+
     if (http_ctx->server_request_bufp) {
         TSHandleMLocRelease(http_ctx->server_request_bufp, TS_NULL_MLOC, http_ctx->server_request_hdrp);
     }


[38/50] git commit: Remove unused include file

Posted by zw...@apache.org.
Remove unused include file


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

Branch: refs/heads/5.0.x
Commit: 9f509d4018d4d28e35298053f6dd1f599d4c5d60
Parents: e2a40e6
Author: James Peach <jp...@apache.org>
Authored: Tue Apr 15 09:57:21 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Tue Apr 15 17:18:10 2014 -0700

----------------------------------------------------------------------
 example/include_other/macro.h | 75 --------------------------------------
 1 file changed, 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9f509d40/example/include_other/macro.h
----------------------------------------------------------------------
diff --git a/example/include_other/macro.h b/example/include_other/macro.h
deleted file mode 100644
index 6c0a2dd..0000000
--- a/example/include_other/macro.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-#ifndef _MACRO_H_
-#define _MACRO_H_
-
-#define LOG_SET_FUNCTION_NAME(NAME) const char * FUNCTION_NAME = NAME
-
-#define LOG_AUTO_ERROR(API_NAME, COMMENT) \
-{ \
-    TSDebug(PLUGIN_NAME, "%s %s [%s: line %d] (%s)", API_NAME, "AUTO_FAIL", \
-            FUNCTION_NAME, __LINE__, COMMENT); \
-}
-#define LOG_API_ERROR(API_NAME) { \
-    TSDebug(DEBUG_TAG, "%s: %s %s [%s] File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
-	     FUNCTION_NAME, __FILE__, __LINE__); \
-}
-
-#define LOG_API_ERROR_COMMENT(API_NAME, COMMENT) { \
-    TSDebug(DEBUG_TAG, "%s: %s %s [%s] File %s, line number %d (%s)", PLUGIN_NAME, API_NAME, "APIFAIL", \
-	     FUNCTION_NAME, __FILE__, __LINE__, COMMENT); \
-}
-
-#define LOG_ERROR_AND_RETURN(API_NAME) \
-{ \
-    LOG_API_ERROR(API_NAME); \
-    return -1; \
-}
-#define LOG_ERROR_AND_CLEANUP(API_NAME) \
-{ \
-    LOG_API_ERROR(API_NAME); \
-    goto done; \
-}
-#define LOG_ERROR_AND_REENABLE(API_NAME) \
-{ \
-    LOG_API_ERROR(API_NAME); \
-    TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); \
-}
-
-/* added by nkale for internal plugins */
-#define LOG_NEG_ERROR(API_NAME) { \
-    TSDebug(NEG_ERROR_TAG, "%s: %s %s %s File %s, line number %d",PLUGIN_NAME, API_NAME, "NEGAPIFAIL", \
-             FUNCTION_NAME, __FILE__, __LINE__); \
-}
-
-/* Release macros */
-#define VALID_PTR(X) (X != NULL))
-
-#define FREE(X) \
-{ \
-    if (VALID_PTR(X)) { \
-        TSfree((void *)X); \
-        X = NULL; \
-    } \
-} \


[17/50] git commit: TS-898: ensure cache span probe closes file descriptors

Posted by zw...@apache.org.
TS-898: ensure cache span probe closes file descriptors

Add a new helper class xfd (by analogy to xptr). This ensures that
the opened file descriptor is always closed in every error path.

Coverity #1196462


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

Branch: refs/heads/5.0.x
Commit: e503ce048bb5fcab84b251ebcc31efa972d67710
Parents: 17579ee
Author: James Peach <jp...@apache.org>
Authored: Sun Apr 6 11:25:11 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Apr 10 14:43:22 2014 -0700

----------------------------------------------------------------------
 CHANGES                              |  2 ++
 iocore/cache/Store.cc                | 27 +++++++++-----------
 iocore/eventsystem/I_SocketManager.h | 42 +++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e503ce04/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3f113bc..2115ad8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-898] Ensure the cache span probe always closes file descriptors.
+
   *) [TS-2706] Replace the tcp_info plugin config file with options.
 
   *) [TS-2691] Fix how we count redirect retries in the core and APIs.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e503ce04/iocore/cache/Store.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Store.cc b/iocore/cache/Store.cc
index 2e79958..46c346c 100644
--- a/iocore/cache/Store.cc
+++ b/iocore/cache/Store.cc
@@ -496,16 +496,15 @@ Span::init(char *an, int64_t size)
     return "error stat of file";
   }
 
-  int fd = socketManager.open(n, O_RDONLY);
-  if (fd < 0) {
-    Warning("unable to open '%s': %d, %s", n, fd, strerror(errno));
+  xfd fd(socketManager.open(n, O_RDONLY));
+  if (!fd) {
+    Warning("unable to open '%s': %s", n, strerror(errno));
     return "unable to open";
   }
 
   struct statvfs fs;
   if ((ret = fstatvfs(fd, &fs)) < 0) {
     Warning("unable to statvfs '%s': %d %d, %s", n, ret, errno, strerror(errno));
-    socketManager.close(fd);
     return "unable to statvfs";
   }
 
@@ -569,7 +568,6 @@ Span::init(char *an, int64_t size)
   Debug("cache_init", "Span::init - %s hw_sector_size = %d  size = %" PRId64 ", blocks = %" PRId64 ", disk_id = %d, file_pathname = %d", pathname, hw_sector_size, size, blocks, disk_id, file_pathname);
 
 Lfail:
-  socketManager.close(fd);
   return err;
 }
 
@@ -589,9 +587,9 @@ Span::init(char *filename, int64_t size)
   //
   is_mmapable_internal = true;
 
-  int fd = socketManager.open(filename, O_RDONLY);
-  if (fd < 0) {
-    Warning("unable to open '%s': %d, %s", filename, fd, strerror(errno));
+  xfd fd(socketManager.open(filename, O_RDONLY));
+  if (!fd) {
+    Warning("unable to open '%s': %s", filename, strerror(errno));
     return "unable to open";
   }
 
@@ -657,7 +655,6 @@ Span::init(char *filename, int64_t size)
   Debug("cache_init", "Span::init - %s hw_sector_size = %d  size = %" PRId64 ", blocks = %" PRId64 ", disk_id = %d, file_pathname = %d", filename, hw_sector_size, size, blocks, disk_id, file_pathname);
 
 Lfail:
-  socketManager.close(fd);
   return err;
 }
 #endif
@@ -672,9 +669,10 @@ Lfail:
 const char *
 Span::init(char *filename, int64_t size)
 {
-  int devnum = 0, fd, arg = 0;
+  int devnum = 0, arg = 0;
   int ret = 0, is_disk = 0;
   u_int64_t heads, sectors, cylinders, adjusted_sec;
+  xfd fd;
 
   /* Fetch file type */
   struct stat stat_buf;
@@ -705,11 +703,12 @@ Span::init(char *filename, int64_t size)
     break;
   }
 
-  if ((fd = socketManager.open(filename, O_RDONLY)) < 0) {
-    Warning("unable to open '%s': %d, %s", filename, fd, strerror(errno));
+  fd = socketManager.open(filename, O_RDONLY);
+  if (!fd) {
+    Warning("unable to open '%s': %s", filename, strerror(errno));
     return "unable to open";
   }
-  Debug("cache_init", "Span::init - socketManager.open(\"%s\", O_RDONLY) = %d", filename, fd);
+  Debug("cache_init", "Span::init - socketManager.open(\"%s\", O_RDONLY) = %d", filename, (int)fd);
 
   adjusted_sec = 1;
 #ifdef BLKPBSZGET
@@ -822,8 +821,6 @@ Span::init(char *filename, int64_t size)
 
   disk_id = devnum;
 
-  socketManager.close(fd);
-
   return NULL;
 }
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e503ce04/iocore/eventsystem/I_SocketManager.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_SocketManager.h b/iocore/eventsystem/I_SocketManager.h
index d294a5c..6d3dc07 100644
--- a/iocore/eventsystem/I_SocketManager.h
+++ b/iocore/eventsystem/I_SocketManager.h
@@ -134,4 +134,46 @@ private:
 
 extern SocketManager socketManager;
 
+struct xfd {
+
+  xfd() : m_fd(-1) {
+  }
+
+  explicit xfd(int _fd) : m_fd(_fd) {
+  }
+
+  ~xfd() {
+    if (this->m_fd != -1) {
+      socketManager.close(this->m_fd);
+    }
+  }
+
+  /// Auto convert to a raw file descriptor.
+  operator int() const { return m_fd; }
+
+  /// Boolean operator. Returns true if we have a valid file descriptor.
+  operator bool() const { return m_fd != -1; }
+
+  xfd& operator=(int fd) {
+    if (this->m_fd != -1) {
+      socketManager.close(this->m_fd);
+    }
+
+    this->m_fd = fd;
+    return *this;
+  }
+
+  int release() {
+    int tmp = this->m_fd;
+    this->m_fd = -1;
+    return tmp;
+  }
+
+ private:
+  int m_fd;
+
+  xfd(xfd const&);            // disabled
+  xfd& operator=(xfd const&); // disabled
+};
+
 #endif /*_SocketManager_h_*/


[50/50] git commit: doc: IO continuations get passed a TSVIO

Posted by zw...@apache.org.
doc: IO continuations get passed a TSVIO


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

Branch: refs/heads/5.0.x
Commit: 721d5cf5068f93fd0590241828954b46aa1dadb8
Parents: 3fb0519
Author: James Peach <jp...@apache.org>
Authored: Wed Apr 16 14:36:47 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Apr 16 14:37:15 2014 -0700

----------------------------------------------------------------------
 doc/sdk/continuations/writing-handler-functions.en.rst | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/721d5cf5/doc/sdk/continuations/writing-handler-functions.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/continuations/writing-handler-functions.en.rst b/doc/sdk/continuations/writing-handler-functions.en.rst
index 07793a6..8f451e6 100644
--- a/doc/sdk/continuations/writing-handler-functions.en.rst
+++ b/doc/sdk/continuations/writing-handler-functions.en.rst
@@ -100,11 +100,11 @@ Event                                    Event Sender
 ``TS_EVENT_HOST_LOOKUP``                 ``TSHostLookup``                        ``TSHostLookupResult``
 ``TS_EVENT_TIMEOUT``                     ``TSContSchedule``
 ``TS_EVENT_ERROR``
-``TS_EVENT_VCONN_READ_READY``            ``TSVConnRead``                         ``TSVConn``
-``TS_EVENT_VCONN_WRITE_READY``           ``TSVConnWrite``                        ``TSVConn``
-``TS_EVENT_VCONN_READ_COMPLETE``         ``TSVConnRead``                         ``TSVConn``
-``TS_EVENT_VCONN_WRITE_COMPLETE``        ``TSVConnWrite``                        ``TSVConn``
-``TS_EVENT_VCONN_EOS``                   ``TSVConnRead``                         ``TSVConn``
+``TS_EVENT_VCONN_READ_READY``            ``TSVConnRead``                         ``TSVIO``
+``TS_EVENT_VCONN_WRITE_READY``           ``TSVConnWrite``                        ``TSVIO``
+``TS_EVENT_VCONN_READ_COMPLETE``         ``TSVConnRead``                         ``TSVIO``
+``TS_EVENT_VCONN_WRITE_COMPLETE``        ``TSVConnWrite``                        ``TSVIO``
+``TS_EVENT_VCONN_EOS``                   ``TSVConnRead``                         ``TSVIO``
 ``TS_EVENT_NET_CONNECT``                 ``TSNetConnect``                        ``TSVConn``
 ``TS_EVENT_NET_CONNECT_FAILED``          ``TSNetConnect``                        ``TSVConn``
 ``TS_EVENT_HTTP_CONTINUE``


[28/50] git commit: TS-2711 Build with the include LuaJIT

Posted by zw...@apache.org.
TS-2711 Build with the include LuaJIT


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

Branch: refs/heads/5.0.x
Commit: 31f1857cd465834e55fa459ed986c2d64f4c4abb
Parents: 1e6b419
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 15 08:29:30 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Apr 15 08:29:30 2014 -0600

----------------------------------------------------------------------
 Makefile.am                             |  18 ++--
 NOTICE                                  |   6 ++
 build/lua.m4                            | 142 ---------------------------
 configure.ac                            |  51 ----------
 lib/Makefile.am                         |  19 +++-
 plugins/experimental/Makefile.am        |   1 -
 plugins/experimental/ts_lua/Makefile.am |  33 ++++---
 proxy/Makefile.am                       |  75 +++++++++++++-
 8 files changed, 129 insertions(+), 216 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/31f1857c/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 398f300..0be55a6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -53,12 +53,6 @@ distclean-local:
 doxygen:
 	@cd doc && $(MAKE) $(AM_MAKEFLAGS) $@
 
-asf-distdir:
-	@$(am__remove_distdir)
-	test -d .git && git clone . $(distdir)
-	cd $(distdir) && autoreconf -i
-	rm -rf -- $(distdir)/autom4te.cache $(distdir)/.git $(distdir)/.gitignore $(distdir)/ci
-
 asf-dist: asf-distdir
 	tardir=$(distdir) && $(am__tar) --mtime=./configure.ac | bzip2 -9 -c >$(distdir).tar.bz2
 	@$(am__remove_distdir)
@@ -67,6 +61,12 @@ asf-dist-rc: asf-distdir
 	tardir=$(distdir) && $(am__tar) --mtime=./configure.ac | bzip2 -9 -c >$(distdir)-rc$(RC).tar.bz2
 	@$(am__remove_distdir)
 
+asf-distdir:
+	@$(am__remove_distdir)
+	test -d .git && git clone . $(distdir)
+	cd $(distdir) && git submodule update --init && autoreconf -i
+	rm -rf -- $(distdir)/autom4te.cache $(distdir)/.git $(distdir)/.gitignore $(distdir)/ci
+
 asf-dist-sign: asf-dist
 	md5sum -b $(distdir).tar.bz2 >$(distdir).tar.bz2.md5
 	sha1sum -b $(distdir).tar.bz2 >$(distdir).tar.bz2.sha1
@@ -95,8 +95,11 @@ install-data-hook:
 rat:
 	java -jar $(top_srcdir)/ci/apache-rat-0.11-SNAPSHOT.jar -E $(top_srcdir)/ci/rat-regex.txt  -d $(top_srcdir)
 
+submodules:
+	git submodule update --init
+
 help:
-	@echo 'all              default target for building the package' && \
+	@echo 'all             default target for building the package' && \
 	echo 'check            run the test suite, if any' && \
 	echo 'clean            remove whatever make created' && \
 	echo 'distclean        remove whatever configure created' && \
@@ -108,6 +111,7 @@ help:
 	echo 'rel-candidate    recreate a signed relelease candidate source package and a signed git tag' && \
 	echo 'distcheck        verify dist by performing VPATH build and then distclean' && \
 	echo 'rat              produce a RAT licence compliance report of the source' && \
+	echo 'submodules       update the git submodules' && \
 	echo 'doxygen          generate doxygen docs in doc/html dir' && \
 	echo 'help             display this list of make targets' && \
 	echo 'install          install by copying the built files to system-wide dirs' && \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/31f1857c/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index ecf66b0..00196cb 100644
--- a/NOTICE
+++ b/NOTICE
@@ -8,6 +8,7 @@ This product includes software developed at
   - OmniTI
   - Comcast
   - LinkedIn
+  - Mike Pall
 
 ~~~
 
@@ -55,3 +56,8 @@ Copyright (c) 2013 LinkedIn
 
 remap_stats plugin developed by Comcast.
 Copyright (C) 2013 Comcast
+
+~~~
+
+LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
+Copyright (C) 2005-2014 Mike Pall. All rights reserved.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/31f1857c/build/lua.m4
----------------------------------------------------------------------
diff --git a/build/lua.m4 b/build/lua.m4
deleted file mode 100644
index 8d83b13..0000000
--- a/build/lua.m4
+++ /dev/null
@@ -1,142 +0,0 @@
-dnl -------------------------------------------------------- -*- autoconf -*-
-dnl Licensed to the Apache Software Foundation (ASF) under one or more
-dnl contributor license agreements.  See the NOTICE file distributed with
-dnl this work for additional information regarding copyright ownership.
-dnl The ASF licenses this file to You under the Apache License, Version 2.0
-dnl (the "License"); you may not use this file except in compliance with
-dnl the License.  You may obtain a copy of the License at
-dnl
-dnl     http://www.apache.org/licenses/LICENSE-2.0
-dnl
-dnl Unless required by applicable law or agreed to in writing, software
-dnl distributed under the License is distributed on an "AS IS" BASIS,
-dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-dnl See the License for the specific language governing permissions and
-dnl limitations under the License.
-
-dnl Check for Lua 5.1 Libraries
-dnl
-dnl CHECK_LUA(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
-dnl Sets:
-dnl  LUA_CFLAGS
-dnl  LUA_LIBS
-AC_DEFUN([CHECK_LUA],
-[dnl
-
-AC_ARG_WITH(
-    lua,
-    [AC_HELP_STRING([--with-lua=PATH],[Path to the Lua 5.1 prefix])],
-    lua_path="$withval",
-    :)
-
-dnl # Determine lua lib directory
-if test -z "$lua_path"; then
-    test_paths=". /usr/local /usr"
-else
-    test_paths="${lua_path}"
-fi
-
-dnl
-dnl Note that we check for the existence of lua_getfenv (used to be
-dnl luaL_newstate). This is because Lua v5.2 and later deprecates
-dnl lua_getfenv() because of changes in how environements are handled.
-dnl Also see: https://issues.apache.org/jira/browse/TS-1931
-dnl
-AC_CHECK_LIB(m, pow, lib_m="-lm")
-AC_CHECK_LIB(m, sqrt, lib_m="-lm")
-for x in $test_paths ; do
-  if test "x$x" = "x."; then
-    AC_CHECK_HEADER(lua.h,[
-        save_CFLAGS=$CFLAGS
-        save_LDFLAGS=$LDFLAGS
-        CFLAGS="$CFLAGS"
-        LDFLAGS="$LDFLAGS $lib_m"
-        AC_CHECK_LIB(lua5.1, lua_getfenv, [
-            LUA_LIBS="-llua5.1 $lib_m"
-        ],[
-            AC_CHECK_LIB(lua-5.1, lua_getfenv, [
-                LUA_LIBS="-llua-5.1 $lib_m"
-            ],[
-                AC_CHECK_LIB(lua, lua_getfenv, [
-                    LUA_LIBS="-llua $lib_m"
-                ])
-            ])
-        ])
-        LUA_CFLAGS=
-        CFLAGS=$save_CFLAGS
-        LDFLAGS=$save_LDFLAGS
-        break
-    ])
-  else
-    AC_MSG_CHECKING([for lua.h in ${x}/include/lua5.1])
-    if test -f ${x}/include/lua5.1/lua.h; then
-        AC_MSG_RESULT([yes])
-        save_CFLAGS=$CFLAGS
-        save_LDFLAGS=$LDFLAGS
-        CFLAGS="$CFLAGS"
-        LDFLAGS="-L$x/lib $LDFLAGS $lib_m"
-        AC_CHECK_LIB(lua5.1, lua_getfenv, [
-            LUA_LIBS="-L$x/lib -llua5.1 $lib_m"
-            LUA_CFLAGS="-I$x/include/lua5.1"
-            ])
-        CFLAGS=$save_CFLAGS
-        LDFLAGS=$save_LDFLAGS
-        break
-    else
-        AC_MSG_RESULT([no])
-    fi
-    AC_MSG_CHECKING([for lua.h in ${x}/include/lua51])
-    if test -f ${x}/include/lua51/lua.h; then
-        AC_MSG_RESULT([yes])
-        save_CFLAGS=$CFLAGS
-        save_LDFLAGS=$LDFLAGS
-        CFLAGS="$CFLAGS"
-        LDFLAGS="-L$x/lib/lua51 $LDFLAGS $lib_m"
-        AC_CHECK_LIB(lua, lua_getfenv, [
-            LUA_LIBS="-L$x/lib/lua51 -llua $lib_m"
-            LUA_CFLAGS="-I$x/include/lua51"
-            ])
-        CFLAGS=$save_CFLAGS
-        LDFLAGS=$save_LDFLAGS
-        break
-    else
-        AC_MSG_RESULT([no])
-    fi
-    AC_MSG_CHECKING([for lua.h in ${x}/include])
-    if test -f ${x}/include/lua.h; then
-        AC_MSG_RESULT([yes])
-        save_CFLAGS=$CFLAGS
-        save_LDFLAGS=$LDFLAGS
-        CFLAGS="$CFLAGS"
-        LDFLAGS="-L$x/lib $LDFLAGS $lib_m"
-        AC_CHECK_LIB(lua, lua_getfenv, [
-            LUA_LIBS="-L$x/lib -llua $lib_m"
-            LUA_CFLAGS="-I$x/include"
-            ])
-        CFLAGS=$save_CFLAGS
-        LDFLAGS=$save_LDFLAGS
-        break
-    else
-        AC_MSG_RESULT([no])
-    fi
-  fi
-done
-
-AC_SUBST(LUA_LIBS)
-AC_SUBST(LUA_CFLAGS)
-
-if test -z "${LUA_LIBS}"; then
-  AC_MSG_WARN([*** Lua 5.1 library not found.])
-  ifelse([$2], ,
-    enable_lua="no"
-    if test -z "${lua_path}"; then
-        AC_MSG_WARN([Lua 5.1 library is required])
-    else
-        AC_MSG_ERROR([Lua 5.1 library is required])
-    fi,
-    $2)
-else
-  ifelse([$1], , , $1) 
-fi 
-])
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/31f1857c/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 504f357..b0502a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1417,56 +1417,6 @@ TS_CHECK_TCMALLOC
 # Check for libreadline/libedit
 AX_LIB_READLINE
 
-#
-# Check for Lua, at least version 5.1, sets LUA_CFLAGS and LUA_LIBS. We support both standard
-# Lua and LuaJIT, preferring LuaJIT if the user did not indicate a preference.
-AC_MSG_CHECKING([whether to enable Linux LuaJIT support])
-AC_ARG_ENABLE([luajit],
-  [AS_HELP_STRING([--enable-luajit], [enable LuaJIT support @<:@default=check@:>@])],
-  [enable_luajit="${enableval}"],
-  [enable_luajit=check]
-)
-AC_MSG_RESULT([$enable_luajit])
-
-PKG_CHECK_MODULES([luajit], [luajit], [have_luajit=yes], [have_luajit=no])
-CHECK_LUA([have_lua=yes], [have_lua=no])
-
-case $enable_luajit in
-yes)
-  # LuaJIT required. Fail if it's not available.
-  AS_IF([ test "x${have_luajit}" = "xyes" ], [
-    LUA_CFLAGS="${luajit_CFLAGS}"
-    LUA_LIBS="${luajit_LIBS}"
-    enable_lua_support=LuaJIT
-  ], [
-    AC_MSG_ERROR([LuaJIT package not available])
-  ])
-  ;;
-
-no)
-  # LuaJIT disabled, just check for the regular Lua support.
-  enable_lua_support="${have_lua}"
-  ;;
-
-*)
-  # No user preference, prefer LuaJIT over standard Lua.
-  AS_IF([ test "x${have_luajit}" = "xyes" ], [
-    LUA_CFLAGS="${luajit_CFLAGS}"
-    LUA_LIBS="${luajit_LIBS}"
-    enable_lua_support=LuaJIT
-  ], [
-    enable_lua_support="${have_lua}"
-  ])
-  ;;
-esac
-
-AC_SUBST(LUA_CFLAGS)
-AC_SUBST(LUA_LIBS)
-AC_MSG_CHECKING([whether to enable Lua support])
-AM_CONDITIONAL([BUILD_LUA_SUPPORT], [ test "x${enable_lua_support}" != "xno" ])
-AM_CONDITIONAL([BUILD_HAVE_LUAJIT], [ test "x${have_luajit}" = "xyes" ])
-AC_MSG_RESULT([$enable_lua_support])
-
 # On Darwin LuaJIT requires magic link options, otherwise it will crash in luaL_openlibs() at startup. See
 # http://luajit.org/install.html.
 case $host_os in
@@ -1989,7 +1939,6 @@ AC_CONFIG_FILES([
   plugins/experimental/geoip_acl/Makefile
   plugins/experimental/healthchecks/Makefile
   plugins/experimental/hipes/Makefile
-  plugins/experimental/lua/Makefile
   plugins/experimental/metalink/Makefile
   plugins/experimental/remap_stats/Makefile
   plugins/experimental/rfc5861/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/31f1857c/lib/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 9664374..b52766b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -29,4 +29,21 @@ endif
 
 if ENABLE_CPPAPI
 SUBDIRS += atscppapi
-endif
\ No newline at end of file
+endif
+
+# Some special hacks around building the luajit.
+#
+#  - 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 ] ?
+all-local:
+	@echo "Making all in luajit"
+	test -d "$(top_srcdir)/luajit/src" || (cd "$(top_srcdir)" && git submodule update --init)
+	test -d "$(top_builddir)/$(subdir)/luajit/src" || cp -rf "$(srcdir)/luajit" "$(top_builddir)/$(subdir)/"
+	make -C luajit PREFIX=$(prefix)
+
+clean-local:
+	test "$(top_srcdir)" != "$(top_builddir)" || make -C "$(top_builddir)/$(subdir)/luajit" clean
+	test "$(top_srcdir)" = "$(top_builddir)" || rm -rf "$(top_builddir)/$(subdir)/luajit"

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/31f1857c/plugins/experimental/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/Makefile.am b/plugins/experimental/Makefile.am
index a2c5a37..9aac6ad 100644
--- a/plugins/experimental/Makefile.am
+++ b/plugins/experimental/Makefile.am
@@ -28,7 +28,6 @@ SUBDIRS = \
  geoip_acl \
  healthchecks \
  hipes \
- lua \
  metalink \
  remap_stats \
  rfc5861 \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/31f1857c/plugins/experimental/ts_lua/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/Makefile.am b/plugins/experimental/ts_lua/Makefile.am
index a519578..4a696f6 100644
--- a/plugins/experimental/ts_lua/Makefile.am
+++ b/plugins/experimental/ts_lua/Makefile.am
@@ -16,20 +16,29 @@
 
 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.
 tslua_la_CPPFLAGS = \
-  $(LUA_CFLAGS) \
-  $(AM_CPPFLAGS)
+  $(AM_CPPFLAGS) \
+  -I$(top_srcdir)/lib/luajit/src
 
 pkglib_LTLIBRARIES = tslua.la
 
-tslua_la_LIBADD = $(LUA_LIBS)
-tslua_la_SOURCES = ts_lua.c ts_lua_cached_response.c ts_lua_client_request.c ts_lua_client_response.c ts_lua_context.c ts_lua_hook.c ts_lua_http.c ts_lua_http_intercept.c ts_lua_log.c ts_lua_misc.c ts_lua_server_request.c ts_lua_server_response.c ts_lua_transform.c ts_lua_util.c ts_lua_remap.c
-tslua_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)
+#tslua_la_LIBADD = $(top_builddir)/lib/luajit/src/libluajit.a
 
-endif
+tslua_la_SOURCES = \
+  ts_lua.c \
+  ts_lua_cached_response.c \
+  ts_lua_client_request.c \
+  ts_lua_client_response.c \
+  ts_lua_context.c \
+  ts_lua_hook.c \
+  ts_lua_http.c \
+  ts_lua_http_intercept.c \
+  ts_lua_log.c \
+  ts_lua_misc.c \
+  ts_lua_server_request.c \
+  ts_lua_server_response.c \
+  ts_lua_transform.c \
+  ts_lua_util.c \
+  ts_lua_remap.c
+
+tslua_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/31f1857c/proxy/Makefile.am
----------------------------------------------------------------------
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index 6dfc816..5b753b2 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -52,6 +52,75 @@ noinst_HEADERS = \
   ConfigParse.h \
   Show.h
 
+# These are currently built separate, as part of building the lib/ tree, using
+# the normal LuaJIT build system. We are using the .o's directly, instead of the
+# luajit.a to avoid the linker from optimizing symbols away. We could maybe
+# switch to using the luajit.so, but that involves making sure it installs safely
+# and cleanly.
+LUAJIT = \
+  lib_aux.o \
+  lib_base.o \
+  lib_bit.o \
+  lib_debug.o \
+  lib_ffi.o \
+  lib_init.o \
+  lib_io.o \
+  lib_jit.o \
+  lib_math.o \
+  lib_os.o \
+  lib_package.o \
+  lib_string.o \
+  lib_table.o \
+  lj_alloc.o \
+  lj_api.o \
+  lj_asm.o \
+  lj_bc.o \
+  lj_bcread.o \
+  lj_bcwrite.o \
+  lj_carith.o \
+  lj_ccall.o \
+  lj_ccallback.o \
+  lj_cconv.o \
+  lj_cdata.o \
+  lj_char.o \
+  lj_clib.o \
+  lj_cparse.o \
+  lj_crecord.o \
+  lj_ctype.o \
+  lj_debug.o \
+  lj_dispatch.o \
+  lj_err.o \
+  lj_ffrecord.o \
+  lj_func.o \
+  lj_gc.o \
+  lj_gdbjit.o \
+  lj_ir.o \
+  lj_lex.o \
+  lj_lib.o \
+  lj_load.o \
+  lj_mcode.o \
+  lj_meta.o \
+  lj_obj.o \
+  lj_opt_dce.o \
+  lj_opt_fold.o \
+  lj_opt_loop.o \
+  lj_opt_mem.o \
+  lj_opt_narrow.o \
+  lj_opt_sink.o \
+  lj_opt_split.o \
+  lj_parse.o \
+  lj_record.o \
+  lj_snap.o \
+  lj_state.o \
+  lj_str.o \
+  lj_strscan.o \
+  lj_tab.o \
+  lj_trace.o \
+  lj_udata.o \
+  lj_vm.o \
+  lj_vmevent.o \
+  lj_vmmath.o
+
 if STATIC_LIBTS
     which_libts = $(top_builddir)/lib/ts/.libs/libtsutil.a
 else
@@ -146,6 +215,7 @@ traffic_server_LDADD = \
   $(top_builddir)/lib/records/librecprocess.a \
   $(top_builddir)/iocore/eventsystem/libinkevent.a \
   $(which_libts) \
+  $(LUAJIT:%=$(top_builddir)/lib/luajit/src/%) \
   @hwloc_LIBS@ \
   @LIBPCRE@ \
   @OPENSSL_LIBS@ \
@@ -160,9 +230,10 @@ traffic_server_LDADD = \
   @SPDYLAY_LIBS@ \
   -lm
 
-if BUILD_LUA_SUPPORT
+
+# 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@
-endif
 
 traffic_logcat_SOURCES = logcat.cc
 traffic_logcat_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@


[03/50] git commit: TS-2691 Fix how we count redirect retries

Posted by zw...@apache.org.
TS-2691 Fix how we count redirect retries

TS-2691 Also eliminate api_enable_redirection which seems superfluous


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

Branch: refs/heads/5.0.x
Commit: dfc2a8f8dba53cd0ab541753ac192eb06bba2fa4
Parents: 2ab1bb6
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Apr 2 10:21:57 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Apr 10 06:50:20 2014 -0600

----------------------------------------------------------------------
 proxy/InkAPI.cc           | 33 +++++++++++++++------------------
 proxy/http/HttpCacheSM.cc |  4 ++--
 proxy/http/HttpConfig.h   |  2 +-
 proxy/http/HttpSM.cc      | 22 +++++-----------------
 proxy/http/HttpSM.h       |  1 -
 proxy/http/HttpTunnel.cc  |  3 +--
 6 files changed, 24 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfc2a8f8/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 241ab45..68d31d0 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -4938,17 +4938,6 @@ TSHttpTxnSecondUrlTryLock(TSHttpTxn txnp)
 }
 
 TSReturnCode
-TSHttpTxnFollowRedirect(TSHttpTxn txnp, int on)
-{
-  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
-
-  HttpSM *sm = (HttpSM *) txnp;
-
-  sm->api_enable_redirection = (on ? true : false);
-  return TS_SUCCESS;
-}
-
-TSReturnCode
 TSHttpTxnRedirectRequest(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc url_loc)
 {
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
@@ -7116,6 +7105,20 @@ TSCacheHttpInfoSizeSet(TSCacheHttpInfo infop, int64_t size)
   info->object_size_set(size);
 }
 
+// This API tells the core to follow normal (301/302) redirects using the
+// standard Location: URL. This does not need to be called if you set an
+// explicit URL using TSRedirectUrlSet().
+TSReturnCode
+TSHttpTxnFollowRedirect(TSHttpTxn txnp, int on)
+{
+  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+
+  HttpSM *sm = (HttpSM *) txnp;
+
+  sm->enable_redirection = (on ? true : false);
+  return TS_SUCCESS;
+}
+
 // this function should be called at TS_EVENT_HTTP_READ_RESPONSE_HDR
 void
 TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len)
@@ -7134,13 +7137,7 @@ TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len)
   sm->redirect_url = (char*)ats_malloc(url_len + 1);
   ink_strlcpy(sm->redirect_url, (char*)url, url_len + 1);
   sm->redirect_url_len = url_len;
-  // have to turn redirection on for this transaction if user wants to redirect to another URL
-  if (sm->enable_redirection == false) {
-    sm->enable_redirection = true;
-    // max-out "redirection_tries" to avoid the regular redirection being turned on in
-    // this transaction improperly. This variable doesn't affect the custom-redirection
-    sm->redirection_tries = HttpConfig::m_master.number_of_redirections;
-  }
+  sm->enable_redirection = true;
 }
 
 const char*

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfc2a8f8/proxy/http/HttpCacheSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpCacheSM.cc b/proxy/http/HttpCacheSM.cc
index 7f82dd5..a684f00 100644
--- a/proxy/http/HttpCacheSM.cc
+++ b/proxy/http/HttpCacheSM.cc
@@ -292,8 +292,8 @@ HttpCacheSM::open_write(URL * url, HTTPHdr * request, CacheHTTPInfo * old_info,
   //  a new write (could happen on a very busy document
   //  that must be revalidated every time)
   // Changed by YTS Team, yamsat Plugin
-  if (open_write_tries > master_sm->redirection_tries && open_write_tries >
-      master_sm->t_state.http_config_param->max_cache_open_write_retries) {
+  if (open_write_tries > master_sm->redirection_tries &&
+      open_write_tries > master_sm->t_state.http_config_param->max_cache_open_write_retries) {
     master_sm->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *) -ECACHE_DOC_BUSY);
     return ACTION_RESULT_DONE;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfc2a8f8/proxy/http/HttpConfig.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index 064f4c6..343148f 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -929,7 +929,7 @@ HttpConfigParams::HttpConfigParams()
     errors_log_error_pages(1),
     enable_http_info(0),
     cluster_time_delta(0),
-    redirection_enabled(1),
+    redirection_enabled(0),
     number_of_redirections(1),
     post_copy_size(2048),
     ignore_accept_mismatch(0),

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfc2a8f8/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 36135be..fc4f9bc 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -302,8 +302,8 @@ static int next_sm_id = 0;
 HttpSM::HttpSM()
   : Continuation(NULL), proto_stack(1u << TS_PROTO_HTTP), sm_id(-1), magic(HTTP_SM_MAGIC_DEAD),
     //YTS Team, yamsat Plugin
-    enable_redirection(false), api_enable_redirection(true), redirect_url(NULL), redirect_url_len(0), redirection_tries(0), transfered_bytes(0),
-    post_failed(false), debug_on(false),
+    enable_redirection(false), redirect_url(NULL), redirect_url_len(0), redirection_tries(0),
+    transfered_bytes(0), post_failed(false), debug_on(false),
     plugin_tunnel_type(HTTP_NO_PLUGIN_TUNNEL),
     plugin_tunnel(NULL), reentrancy_count(0),
     history_pos(0), tunnel(), ua_entry(NULL),
@@ -373,12 +373,7 @@ HttpSM::init()
   milestones.sm_start = ink_get_hrtime();
 
   magic = HTTP_SM_MAGIC_ALIVE;
-
   sm_id = 0;
-  enable_redirection = false;
-  api_enable_redirection = true;
-  redirect_url = NULL;
-  redirect_url_len = 0;
 
   // Unique state machine identifier.
   //  changed next_sm_id from int64_t to int because
@@ -1837,11 +1832,9 @@ HttpSM::state_read_server_response_header(int event, void *data)
     t_state.transact_return_point = HttpTransact::HandleResponse;
     t_state.api_next_action = HttpTransact::SM_ACTION_API_READ_RESPONSE_HDR;
 
-    // YTS Team, yamsat Plugin
-    // Incrementing redirection_tries according to config parameter
     // if exceeded limit deallocate postdata buffers and disable redirection
-    if (enable_redirection && (redirection_tries <= HttpConfig::m_master.number_of_redirections)) {
-      redirection_tries++;
+    if (enable_redirection && (redirection_tries < HttpConfig::m_master.number_of_redirections)) {
+      ++redirection_tries;
     } else {
       tunnel.deallocate_redirect_postdata_buffers();
       enable_redirection = false;
@@ -7267,12 +7260,7 @@ void
 HttpSM::do_redirect()
 {
   DebugSM("http_redirect", "[HttpSM::do_redirect]");
-  if (enable_redirection == false || redirection_tries > (HttpConfig::m_master.number_of_redirections)) {
-    tunnel.deallocate_redirect_postdata_buffers();
-    return;
-  }
-
-  if (api_enable_redirection == false) {
+  if (!enable_redirection || redirection_tries >= HttpConfig::m_master.number_of_redirections) {
     tunnel.deallocate_redirect_postdata_buffers();
     return;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfc2a8f8/proxy/http/HttpSM.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h
index 0a0a23e..0a7b116 100644
--- a/proxy/http/HttpSM.h
+++ b/proxy/http/HttpSM.h
@@ -270,7 +270,6 @@ public:
 
   //YTS Team, yamsat Plugin
   bool enable_redirection;      //To check if redirection is enabled
-  bool api_enable_redirection;  //To check if redirection is enabled
   char *redirect_url;           //url for force redirect (provide users a functionality to redirect to another url when needed)
   int redirect_url_len;
   int redirection_tries;        //To monitor number of redirections

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dfc2a8f8/proxy/http/HttpTunnel.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc
index 748d397..3e3baf2 100644
--- a/proxy/http/HttpTunnel.cc
+++ b/proxy/http/HttpTunnel.cc
@@ -903,8 +903,7 @@ HttpTunnel::producer_run(HttpTunnelProducer * p)
   //YTS Team, yamsat Plugin
   // Allocate and copy partial POST data to buffers. Check for the various parameters
   // including the maximum configured post data size
-  if (p->alive && sm->t_state.method == HTTP_WKSIDX_POST && sm->enable_redirection
-      && sm->redirection_tries == 0 && (p->vc_type == HT_HTTP_CLIENT)) {
+  if (p->alive && sm->t_state.method == HTTP_WKSIDX_POST && sm->enable_redirection && (p->vc_type == HT_HTTP_CLIENT)) {
     Debug("http_redirect", "[HttpTunnel::producer_run] client post: %" PRId64" max size: %" PRId64"",
           p->buffer_start->read_avail(), HttpConfig::m_master.post_copy_size);
 


[32/50] git commit: Added TS-2717 to CHANGES.

Posted by zw...@apache.org.
Added TS-2717 to CHANGES.


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

Branch: refs/heads/5.0.x
Commit: ec2411903843f4cca6247013929e369b0c6c59d0
Parents: 9b236f1
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 15 10:38:21 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Apr 15 10:38:21 2014 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ec241190/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 0ffa264..ebe5161 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2717] header-rewrite set-redirect not working.
+   Author: Igor Brezac
+
   *) [TS-2715] Fix some ESI compile warnings, change the constants to
    be part of an include.
 


[13/50] git commit: TS-2706: replace the tcp_info plugin config file with options

Posted by zw...@apache.org.
TS-2706: replace the tcp_info plugin config file with options

Managing a configuration file is a lot of pain for a small number
of options. Replace the tcp_info plugin configuration file with
command line options that can be specified in plugin.config. This
also replaces the number is hook mast option with a human-readable
list of hooks where TCP informations whould be logged.


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

Branch: refs/heads/5.0.x
Commit: 136cc1fde704c3d06f6cd5181611066b12a26cc3
Parents: d80ab01
Author: James Peach <jp...@apache.org>
Authored: Tue Apr 8 17:09:46 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Apr 10 13:34:37 2014 -0700

----------------------------------------------------------------------
 CHANGES                                   |   2 +
 plugins/experimental/tcp_info/tcp_info.cc | 211 ++++++++++++++++---------
 2 files changed, 138 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/136cc1fd/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 6076a4f..adc154b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2706] Replace the tcp_info plugin config file with options.
+
   *) [TS-2699] Add TSClientProtoStackCreate API.
 
   *) [TS-2678] Some sites (e.g. craigslist) fails to load due to

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/136cc1fd/plugins/experimental/tcp_info/tcp_info.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/tcp_info/tcp_info.cc b/plugins/experimental/tcp_info/tcp_info.cc
index f9b2b0c..c5277a3 100644
--- a/plugins/experimental/tcp_info/tcp_info.cc
+++ b/plugins/experimental/tcp_info/tcp_info.cc
@@ -1,6 +1,6 @@
 /** @file
 
-  A brief file description
+  tcp_info: A plugin to log TCP session information.
 
   @section license License
 
@@ -21,9 +21,6 @@
   limitations under the License.
  */
 
-/* tcp_info.cc:  logs the tcp_info data struture to a file
- */
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <ts/ts.h>
@@ -33,78 +30,26 @@
 #include <assert.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <getopt.h>
 #include <fcntl.h>
 #include <limits.h>
 #include <string.h>
 #include <sys/time.h>
 #include <arpa/inet.h>
 
+#define TCPI_HOOK_SSN_START     0x01u
+#define TCPI_HOOK_TXN_START     0x02u
+#define TCPI_HOOK_SEND_RESPONSE 0x04u
+#define TCPI_HOOK_SSN_CLOSE     0x08u
+
 struct Config {
   int sample;
   const char* log_file;
   int log_fd;
   int log_level;
-  int hook;
 };
-static Config config;
-
-static void
-load_config() {
-  char config_file[PATH_MAX];
-  config.sample = 1000;
-  config.log_level = 1;
-  config.log_file = NULL;
-  config.hook = 1;
-
-  // get the install directory
-  const char* install_dir = TSInstallDirGet();
-
-  // figure out the config file and open it
-  snprintf(config_file, sizeof(config_file), "%s/%s/%s", install_dir, "etc", "tcp_info.config");
-  FILE *file = fopen(config_file, "r");
-  if (file == NULL) {
-    snprintf(config_file, sizeof(config_file), "%s/%s/%s", install_dir, "conf", "tcp_info.config");
-    file = fopen(config_file, "r");
-  }
-  TSDebug("tcp_info", "config file name: %s", config_file);
-  assert(file != NULL);
-
-  // read and parse the lines
-  char line[256];
-  while (fgets(line, sizeof(line), file) != NULL) {
-    char *pos = strchr(line, '=');
-    *pos = '\0';
-    char *value = pos + 1;
-
-    // remove the new line
-    pos = strchr(value, '\n');
-    if (pos != NULL) {
-      *pos = '\0';
-    }
-
-    if (value != NULL) {
-      TSDebug("tcp_info", "config key: %s", line);
-      TSDebug("tcp_info", "config value: %s", value);
-      if (strcmp(line, "sample") == 0) {
-        config.sample = atoi(value);
-      } else if (strcmp(line, "log_file") == 0) {
-        config.log_file = strdup(value);
-      } else if (strcmp(line, "log_level") == 0) {
-        config.log_level = atoi(value);
-      } else if (strcmp(line, "hook") == 0) {
-        config.hook = atoi(value);
-      }
-    }
-  }
 
-  TSDebug("tcp_info", "sample: %d", config.sample);
-  TSDebug("tcp_info", "log filename: %s", config.log_file);
-  TSDebug("tcp_info", "log_level: %d", config.log_level);
-  TSDebug("tcp_info", "hook: %d", config.hook);
-
-  config.log_fd = open(config.log_file, O_APPEND | O_CREAT | O_RDWR, 0666);
-  assert(config.log_fd > 0);
-}
+static Config config;
 
 static void
 log_tcp_info(const char* event_name, const char* client_ip, const char* server_ip, struct tcp_info &info) {
@@ -259,39 +204,155 @@ done:
   return 0;
 }
 
+static bool
+parse_unsigned(const char * str, unsigned long& lval)
+{
+  char * end = NULL;
+
+  if (*str == '\0') {
+    return false;
+  }
+
+  lval = strtoul(str, &end, 0 /* base */);
+  if (end == str) {
+    // No valid characters.
+    return false;
+  }
+
+  if (end != '\0') {
+    // Not all charaters consumed.
+    return false;
+  }
+
+  return true;
+}
+
+// Parse a comma-separated list of hook names into a hook bitmask.
+static unsigned
+parse_hook_list(const char * hook_list)
+{
+  unsigned mask = 0;
+  char * tok;
+  char * str;
+  char * last;
+
+  const struct hookmask { const char * name; unsigned mask; } hooks[] = {
+    { "ssn_start", TCPI_HOOK_SSN_START },
+    { "txn_start", TCPI_HOOK_TXN_START },
+    { "send_resp_hdr", TCPI_HOOK_SEND_RESPONSE },
+    { "ssn_close", TCPI_HOOK_SSN_CLOSE },
+    { NULL, 0u }
+  };
+
+  str = TSstrdup(hook_list);
+
+  for (tok = strtok_r(str, ",", &last); tok; tok = strtok_r(NULL, ",", &last)) {
+    bool match = false;
+
+    for (const struct hookmask * m = hooks; m->name != NULL; ++m) {
+      if (strcmp(m->name, tok) == 0) {
+        mask |= m->mask;
+        match = true;
+        break;
+      }
+    }
+
+    if (!match) {
+      TSError("[tcp_info] invalid hook name '%s'", tok);
+    }
+  }
+
+  TSfree(str);
+  return mask;
+}
+
 void
-TSPluginInit(int, const char *[]) // int argc, const char *argv[]
+TSPluginInit(int argc, const char * argv[])
 {
+  static const char usage[] = "tcp_info.so [--log-file=PATH] [--log-level=LEVEL] [--hooks=LIST] [--sample-rate=COUNT]";
+  static const struct option longopts[] = {
+    { const_cast<char *>("sample-rate"), required_argument, NULL, 'r' },
+    { const_cast<char *>("log-file"), required_argument, NULL, 'f' },
+    { const_cast<char *>("log-level"), required_argument, NULL, 'l' },
+    { const_cast<char *>("hooks"), required_argument, NULL, 'h' },
+    { NULL, 0, NULL, 0 }
+  };
+
   TSPluginRegistrationInfo info;
+  unsigned hooks = 0;
 
   info.plugin_name = (char*)"tcp_info";
   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)
-    TSError("Plugin registration failed. \n");
+  if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
+    TSError("tcp_info: plugin registration failed");
+  }
+
+  config.sample = 1000;
+  config.log_level = 1;
+  config.log_file = NULL;
 
-  // load the configuration file
-  load_config();
+  optind = 0;
+  for (;;) {
+    unsigned long lval;
 
-  // add a hook to the state machine
-  // TODO: need another hook before the socket is closed, keeping it in for now because it will be easier to change if or when another hook is added to ATS
-  if ((config.hook & 1) != 0) {
+    switch (getopt_long(argc, (char * const *)argv, "r:f:l:h:", longopts, NULL)) {
+    case 'r':
+      if (parse_unsigned(optarg, lval)) {
+        config.sample = atoi(optarg);
+      } else {
+        TSError("[tcp_info] invalid sample rate '%s'", optarg);
+      }
+      break;
+    case 'f':
+      config.log_file = optarg;
+      break;
+    case 'l':
+      if (parse_unsigned(optarg, lval) && (lval == 1 || lval == 2)) {
+        config.log_level = atoi(optarg);
+      } else {
+        TSError("[tcp_info] invalid log level '%s'", optarg);
+      }
+      break;
+    case 'h':
+      hooks = parse_hook_list(optarg);
+      break;
+    case -1:
+        goto init;
+    default:
+        TSError("[tcp_info] usage: %s", usage);
+    }
+  }
+
+init:
+
+  TSDebug("tcp_info", "sample: %d", config.sample);
+  TSDebug("tcp_info", "log filename: %s", config.log_file);
+  TSDebug("tcp_info", "log_level: %d", config.log_level);
+  TSDebug("tcp_info", "hook mask: 0x%x", hooks);
+
+  config.log_fd = open(config.log_file, O_APPEND | O_CREAT | O_RDWR, 0666);
+  assert(config.log_fd > 0);
+
+  if (hooks & TCPI_HOOK_SSN_START) {
     TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, TSContCreate(tcp_info_hook, NULL));
     TSDebug("tcp_info", "added hook to the start of the TCP connection");
   }
-  if ((config.hook & 2) != 0) {
+
+  if (hooks & TCPI_HOOK_TXN_START) {
     TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, TSContCreate(tcp_info_hook, NULL));
     TSDebug("tcp_info", "added hook to the close of the transaction");
   }
-  if ((config.hook & 4) != 0) {
+
+  if (hooks & TCPI_HOOK_SEND_RESPONSE) {
     TSHttpHookAdd(TS_HTTP_SEND_RESPONSE_HDR_HOOK, TSContCreate(tcp_info_hook, NULL));
     TSDebug("tcp_info", "added hook to the sending of the headers");
   }
-  if ((config.hook & 8) != 0) {
+
+  if (hooks & TCPI_HOOK_SSN_CLOSE) {
     TSHttpHookAdd(TS_HTTP_SSN_CLOSE_HOOK, TSContCreate(tcp_info_hook, NULL));
     TSDebug("tcp_info", "added hook to the close of the TCP connection");
   }
 
-  TSDebug("tcp_info", "tcp info module registered");
 }


[08/50] git commit: TS-2690 Fixes for escalation plugin

Posted by zw...@apache.org.
TS-2690 Fixes for escalation plugin

This fixes the following:

1. Change to use the API for following redirects.
2. Make it only replace the "host" portions of a URL
3. Cleanup.


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

Branch: refs/heads/5.0.x
Commit: d3e2d2ce5ddf9f9eb07ece751b79ef810e291bd1
Parents: dfc2a8f
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Apr 2 10:03:31 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Apr 10 06:50:21 2014 -0600

----------------------------------------------------------------------
 plugins/experimental/escalate/escalate.cc | 140 +++++++++++++------------
 1 file changed, 75 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d3e2d2ce/plugins/experimental/escalate/escalate.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/escalate/escalate.cc b/plugins/experimental/escalate/escalate.cc
index 7181111..d013b27 100644
--- a/plugins/experimental/escalate/escalate.cc
+++ b/plugins/experimental/escalate/escalate.cc
@@ -28,64 +28,84 @@
 #include <getopt.h>
 #include <string.h>
 #include <string>
-#include <sstream>
 #include <iterator>
 #include <map>
 
+
+// Constants
+const char PLUGIN_NAME[] = "escalate";
+
+
+static int EscalateResponse(TSCont, TSEvent, void *);
+
 struct EscalationState
 {
-  typedef std::map<unsigned, TSMLoc> urlmap_type;
+  typedef std::map<unsigned, std::string> hostmap_type;
 
-  EscalationState() {
-    this->mbuf = TSMBufferCreate();
+  EscalationState()
+  {
+    handler = TSContCreate(EscalateResponse, NULL);
+    TSContDataSet(handler, this);
   }
 
-  ~EscalationState() {
-    TSMBufferDestroy(this->mbuf);
+  ~EscalationState()
+  {
+    TSContDestroy(handler);
   }
 
-  TSCont      handler;
-  urlmap_type urlmap;
-  TSMBuffer   mbuf;
+  TSCont       handler;
+  hostmap_type hostmap;
 };
 
-static unsigned
-toint(const std::string& str)
-{
-  std::istringstream istr(str);
-  unsigned val;
-
-  istr >> val;
-  return val;
-}
 
 static int
-EscalateResponse(TSCont cont, TSEvent event, void * edata)
+EscalateResponse(TSCont cont, TSEvent event, void* edata)
 {
-  EscalationState * es = (EscalationState *)TSContDataGet(cont);
-  TSHttpTxn         txn = (TSHttpTxn)edata;
-  TSMBuffer         buffer;
-  TSMLoc            hdr;
-  TSHttpStatus      status;
+  EscalationState* es = static_cast<EscalationState*>(TSContDataGet(cont));
+  TSHttpTxn        txn = (TSHttpTxn)edata;
+  TSMBuffer        response;
+  TSMLoc           resp_hdr;
 
-  TSDebug("escalate", "hit escalation hook with event %d", (int)event);
+  TSDebug(PLUGIN_NAME, "Recieved event %d", (int)event);
   TSReleaseAssert(event == TS_EVENT_HTTP_READ_RESPONSE_HDR);
 
   // First, we need the server response ...
-  TSReleaseAssert(
-    TSHttpTxnServerRespGet(txn, &buffer, &hdr) == TS_SUCCESS
-  );
-
-  // Next, the respose status ...
-  status = TSHttpHdrStatusGet(buffer, hdr);
-
-  // If we have an escalation URL for this response code, set the redirection URL and force it
-  // to be followed.
-  EscalationState::urlmap_type::iterator entry = es->urlmap.find((unsigned)status);
-  if (entry != es->urlmap.end()) {
-    TSDebug("escalate", "found an escalation entry for HTTP status %u", (unsigned)status);
-    TSHttpTxnRedirectRequest(txn, es->mbuf, entry->second);
-    TSHttpTxnFollowRedirect(txn, 1 /* on */);
+  if (TS_SUCCESS == TSHttpTxnServerRespGet(txn, &response, &resp_hdr)) {
+    // Next, the respose status ...
+    TSHttpStatus status = TSHttpHdrStatusGet(response, resp_hdr);
+
+    // If we have an escalation URL for this response code, set the redirection URL and force it
+    // to be followed.
+    EscalationState::hostmap_type::iterator entry = es->hostmap.find((unsigned)status);
+
+    if (entry != es->hostmap.end()) {
+      TSMBuffer request;
+      TSMLoc    req_hdr;
+
+      TSDebug(PLUGIN_NAME, "found an escalation entry for HTTP status %u", (unsigned)status);
+      if (TS_SUCCESS == TSHttpTxnClientReqGet(txn, &request, &req_hdr)) {
+        TSMLoc url;
+
+        if (TS_SUCCESS == TSHttpHdrUrlGet(request, req_hdr, &url)) {
+          char* url_str;
+          int url_len;
+
+          // Update the request URL with the new Host to try.
+          TSUrlHostSet(request, url, entry->second.c_str(), entry->second.size());
+          url_str = TSUrlStringGet(request, url, &url_len);
+
+          TSDebug(PLUGIN_NAME, "Setting new URL to %.*s", url_len, url_str);
+          TSRedirectUrlSet(txn, url_str, url_len);
+
+          TSfree(static_cast<void*>(url_str));
+        }
+        // Release the response MLoc
+        TSHandleMLocRelease(request, TS_NULL_MLOC, req_hdr);
+      }
+    }
+
+    // Release the response MLoc
+    TSHandleMLocRelease(response, TS_NULL_MLOC, resp_hdr);
   }
 
   // Set the transaction free ...
@@ -94,52 +114,42 @@ EscalateResponse(TSCont cont, TSEvent event, void * edata)
 }
 
 TSReturnCode
-TSRemapInit(TSRemapInterface * /* api */, char * /* errbuf */, int /* bufsz */)
+TSRemapInit(TSRemapInterface* /* api */, char* /* errbuf */, int /* bufsz */)
 {
   return TS_SUCCESS;
 }
 
 TSReturnCode
-TSRemapNewInstance(int argc, char * argv[], void ** instance, char * errbuf, int errbuf_size)
+TSRemapNewInstance(int argc, char* argv[], void** instance, char* errbuf, int errbuf_size)
 {
-  EscalationState * es((EscalationState *)instance);
-
-  es = new EscalationState();
-  es->handler = TSContCreate(EscalateResponse, NULL);
-  TSContDataSet(es->handler, es);
+  EscalationState* es = new EscalationState();
 
   // The first two arguments are the "from" and "to" URL string. We can just
   // skip those, since we only ever remap on the error path.
   for (int i = 2; i < argc; ++i) {
-    unsigned  status;
-    TSMLoc    url;
-    char *    sep;
+    unsigned status;
+    char*    sep;
 
-    // Each token should be a status code then a URL, separated by '='.
-    sep = strchr(argv[i], '=');
+    // Each token should be a status code then a URL, separated by ':'.
+    sep = strchr(argv[i], ':');
     if (sep == NULL) {
       snprintf(errbuf, errbuf_size, "missing status code: %s", argv[i]);
       goto fail;
     }
 
-    status = toint(std::string(argv[i], std::distance(argv[i], sep)));
+    *sep = '\0';
+    status = strtol(argv[i], NULL, 10);
+
     if (status < 100 || status > 599) {
       snprintf(errbuf, errbuf_size, "invalid status code: %.*s", (int)std::distance(argv[i], sep), argv[i]);
       goto fail;
     }
 
-    TSReleaseAssert(TSUrlCreate(es->mbuf, &url) == TS_SUCCESS);
-
-    ++sep; // Skip over the '='.
-
-    TSDebug("escalate", "escalating HTTP status %u to %s", status, sep);
-    if (TSUrlParse(es->mbuf, url, (const char **)&sep, argv[i] + strlen(argv[i])) != TS_PARSE_DONE) {
-      snprintf(errbuf, errbuf_size, "invalid target URL: %s", sep);
-      goto fail;
-    }
+    ++sep; // Skip over the ':'
 
     // OK, we have a valid status/URL pair.
-    es->urlmap[status] = url;
+    TSDebug(PLUGIN_NAME, "Redirect of HTTP status %u to %s", status, sep);
+    es->hostmap[status] = sep;
   }
 
   *instance = es;
@@ -151,15 +161,15 @@ fail:
 }
 
 void
-TSRemapDeleteInstance(void * instance)
+TSRemapDeleteInstance(void* instance)
 {
   delete (EscalationState *)instance;
 }
 
 TSRemapStatus
-TSRemapDoRemap(void * instance, TSHttpTxn txn, TSRemapRequestInfo * /* rri */)
+TSRemapDoRemap(void* instance, TSHttpTxn txn, TSRemapRequestInfo* /* rri */)
 {
-  EscalationState * es((EscalationState *)instance);
+  EscalationState* es = static_cast<EscalationState *>(instance);
 
   TSHttpTxnHookAdd(txn, TS_HTTP_READ_RESPONSE_HDR_HOOK, es->handler);
   return TSREMAP_NO_REMAP;


[09/50] git commit: TS-2703 Add a text log format to escalate plugin

Posted by zw...@apache.org.
TS-2703 Add a text log format to escalate plugin


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

Branch: refs/heads/5.0.x
Commit: 77c5cf39b0719c7e8d8855070452644379df2ea1
Parents: 4b6c8e0
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Apr 7 14:23:45 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Apr 10 06:54:37 2014 -0600

----------------------------------------------------------------------
 .../background_fetch/background_fetch.cc        | 101 ++++++++++++++++---
 1 file changed, 89 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/77c5cf39/plugins/experimental/background_fetch/background_fetch.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/background_fetch/background_fetch.cc b/plugins/experimental/background_fetch/background_fetch.cc
index 297bd7d..13223bd 100644
--- a/plugins/experimental/background_fetch/background_fetch.cc
+++ b/plugins/experimental/background_fetch/background_fetch.cc
@@ -22,12 +22,11 @@
     limitations under the License.
 
 */
-
-
-
 #include <stdio.h>
 #include <string.h>
 #include <string>
+#include <stdarg.h>
+#include <getopt.h>
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -168,6 +167,12 @@ public:
     // ToDo: Destroy mutex ? TS-1432
   }
 
+  void create_log(const char* log_name)
+  {
+    TSDebug(PLUGIN_NAME, "Creating log name %s\n", log_name);
+    TSAssert(TS_SUCCESS == TSTextLogObjectCreate(log_name, TS_LOG_MODE_ADD_TIMESTAMP, &log));
+  }
+
   bool acquire(const std::string &url)
   {
     bool ret;
@@ -200,12 +205,14 @@ public:
     return ret;
   }
 
+  TSTextLogObject log;
+
 private:
   OutstandingRequests _urls;
   TSMutex _lock;
 };
 
-BGFetchConfig gConfig;
+BGFetchConfig* gConfig;
 
 //////////////////////////////////////////////////////////////////////////////
 // Hold and manage some state for the background fetch continuation
@@ -215,8 +222,8 @@ static int cont_bg_fetch(TSCont contp, TSEvent event, void* edata);
 
 struct BGFetchData
 {
-  BGFetchData(BGFetchConfig* cfg=&gConfig)
-    : hdr_loc(TS_NULL_MLOC), url_loc(TS_NULL_MLOC), _cont(NULL),  _config(cfg)
+  BGFetchData(BGFetchConfig* cfg=gConfig)
+    : hdr_loc(TS_NULL_MLOC), url_loc(TS_NULL_MLOC), vc(NULL), _bytes(0), _cont(NULL),  _config(cfg)
   {
     mbuf = TSMBufferCreate();
   }
@@ -230,6 +237,12 @@ struct BGFetchData
 
     TSMBufferDestroy(mbuf);
 
+    if (vc) {
+      TSError("%s: Destroyed BGFetchDATA while VC was alive", PLUGIN_NAME);
+      TSVConnClose(vc);
+      vc = NULL;
+    }
+
     // If we got schedule, also clean that up
     if (_cont) {
       TSContDestroy(_cont);
@@ -245,9 +258,11 @@ struct BGFetchData
   bool release_url() const { return _config->release(_url); }
 
   const char* get_url() const { return _url.c_str(); }
+  void add_bytes(int64_t b) { _bytes += b; }
 
   bool initialize(TSMBuffer request, TSMLoc req_hdr, TSHttpTxn txnp);
   void schedule();
+  void log(TSEvent event) const;
 
   TSMBuffer mbuf;
   TSMLoc hdr_loc;
@@ -262,6 +277,7 @@ struct BGFetchData
 
 private:
   std::string _url;
+  int64_t _bytes;
   TSCont _cont;
   BGFetchConfig* _config;
 };
@@ -353,6 +369,39 @@ BGFetchData::schedule()
 }
 
 
+// Log format is:
+//    remap-tag bytes status url
+void
+BGFetchData::log(TSEvent event) const
+{
+  BGFetchConfig* conf = _config ? _config : gConfig;
+
+  if (conf->log) {
+    const char* status;
+
+    switch (event) {
+    case TS_EVENT_VCONN_EOS:
+      status = "EOS";
+      break;
+    case TS_EVENT_VCONN_INACTIVITY_TIMEOUT:
+      status = "TIMEOUT";
+      break;
+    case TS_EVENT_ERROR:
+      status = "ERROR";
+    case TS_EVENT_VCONN_READ_COMPLETE:
+      status = "READ_COMP";
+      break;
+    default:
+      status = "UNKNOWN";
+      break;
+    }
+
+    // ToDo: Also deal with per-remap tagging
+    TSTextLogObjectWrite(conf->log, "%s %" PRId64 " %s %s", "-", _bytes, status, _url.c_str());
+  }
+}
+
+
 //////////////////////////////////////////////////////////////////////////////
 // Continuation to perform a background fill of a URL. This is pretty
 // expensive (memory allocations etc.), we could eliminate maybe the
@@ -389,13 +438,15 @@ cont_bg_fetch(TSCont contp, TSEvent event, void* /* edata ATS_UNUSED */)
     }
 
     // Setup the NetVC for background fetch
+    TSAssert(NULL == data->vc);
     if ((data->vc = TSHttpConnect((sockaddr*)&data->client_ip)) != NULL) {
       TSHttpHdrPrint(data->mbuf, data->hdr_loc, data->req_io_buf);
       // We never send a body with the request. ToDo: Do we ever need to support that ?
       TSIOBufferWrite(data->req_io_buf, "\r\n", 2);
 
       data->r_vio = TSVConnRead(data->vc, contp, data->resp_io_buf, INT64_MAX);
-      data->w_vio = TSVConnWrite(data->vc, contp, data->req_io_buf_reader, TSIOBufferReaderAvail(data->req_io_buf_reader));
+      data->w_vio = TSVConnWrite(data->vc, contp, data->req_io_buf_reader,
+                                 TSIOBufferReaderAvail(data->req_io_buf_reader));
     } else {
       delete data;
       TSError("%s: failed to connect to internal process, major malfunction", PLUGIN_NAME);
@@ -407,6 +458,7 @@ cont_bg_fetch(TSCont contp, TSEvent event, void* /* edata ATS_UNUSED */)
 
   case TS_EVENT_VCONN_READ_READY:
     avail = TSIOBufferReaderAvail(data->resp_io_buf_reader);
+    data->add_bytes(avail);
     TSIOBufferReaderConsume(data->resp_io_buf_reader, avail);
     TSVIONDoneSet(data->r_vio, TSVIONDoneGet(data->r_vio) + avail);
     TSVIOReenable(data->r_vio);
@@ -415,6 +467,7 @@ cont_bg_fetch(TSCont contp, TSEvent event, void* /* edata ATS_UNUSED */)
   case TS_EVENT_VCONN_READ_COMPLETE:
   case TS_EVENT_VCONN_EOS:
   case TS_EVENT_VCONN_INACTIVITY_TIMEOUT:
+  case TS_EVENT_ERROR:
     if (event == TS_EVENT_VCONN_INACTIVITY_TIMEOUT) {
       TSDebug(PLUGIN_NAME, "Encountered Inactivity Timeout");
       TSVConnAbort(data->vc, TS_VC_CLOSE_ABORT);
@@ -422,18 +475,20 @@ cont_bg_fetch(TSCont contp, TSEvent event, void* /* edata ATS_UNUSED */)
       TSVConnClose(data->vc);
     }
 
-    // ToDo: Is this really necessary to do here for all 3 cases?
-    TSDebug(PLUGIN_NAME, "Closing down background transaction, event=%d", event);
+    TSDebug(PLUGIN_NAME, "Closing down background transaction, event= %s(%d)", TSHttpEventNameLookup(event), event);
     avail = TSIOBufferReaderAvail(data->resp_io_buf_reader);
+    data->add_bytes(avail);
     TSIOBufferReaderConsume(data->resp_io_buf_reader, avail);
     TSVIONDoneSet(data->r_vio, TSVIONDoneGet(data->r_vio) + avail);
 
-    // Release and Cleanup
+    data->log(event);
+    data->vc = NULL;
+    // Close, release and cleanup
     delete data;
     break;
 
   default:
-    TSDebug(PLUGIN_NAME, "Unhandled event: %d", event); // ToDo: use new API in v5.0.0
+    TSDebug(PLUGIN_NAME, "Unhandled event: %s (%d)", TSHttpEventNameLookup(event), event);
     break;
   }
 
@@ -535,9 +590,13 @@ cont_handle_response(TSCont /* contp ATS_UNUSED */, TSEvent /* event ATS_UNUSED
 ///////////////////////////////////////////////////////////////////////////
 // Setup global hooks
 void
-TSPluginInit(int /* argc ATS_UNUSED */, const char* /* argv ATS_UNUSED */[])
+TSPluginInit(int argc, const char* argv[])
 {
   TSPluginRegistrationInfo info;
+  static const struct option longopt[] = {
+    { "log", required_argument, NULL, 'l' },
+    {NULL, no_argument, NULL, '\0' }
+  };
 
   info.plugin_name = (char*)PLUGIN_NAME;
   info.vendor_name = (char*)"Apache Software Foundation";
@@ -547,6 +606,24 @@ TSPluginInit(int /* argc ATS_UNUSED */, const char* /* argv ATS_UNUSED */[])
     TSError("%s: plugin registration failed.\n", PLUGIN_NAME);
   }
 
+  gConfig = new BGFetchConfig();
+  optind = 1;
+
+  while (true) {
+    int opt = getopt_long(argc, (char * const *)argv, "l", longopt, NULL);
+
+    switch (opt) {
+    case 'l':
+      gConfig->create_log(optarg);
+      break;
+    }
+
+    if (opt == -1) {
+      break;
+    }
+  }
+
+
   TSDebug(PLUGIN_NAME, "Initialized");
   TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(cont_handle_response, NULL));
 }


[49/50] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/trafficserver

Posted by zw...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/trafficserver


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

Branch: refs/heads/5.0.x
Commit: 3fb05190ff96689e06f2a08a4ef57915db31e705
Parents: a486036 9d12a5d
Author: Brian Geffon <br...@apache.org>
Authored: Wed Apr 16 13:13:41 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Wed Apr 16 13:13:41 2014 -0700

----------------------------------------------------------------------
 CHANGES                                         |   7 +
 configure.ac                                    |  12 +-
 doc/reference/plugins/index.en.rst              |   1 +
 doc/reference/plugins/tcpinfo.en.rst            | 126 ++++++
 doc/reference/plugins/ts_lua.en.rst             |  77 ++--
 doc/sdk/actions-guide.en.rst                    |   4 +-
 doc/sdk/actions-guide/hosts-lookup-api.en.rst   |   4 +-
 doc/sdk/http-headers/http-headers.en.rst        |  46 +-
 doc/sdk/http-headers/mime-headers.en.rst        |  84 ++--
 doc/sdk/http-headers/urls.en.rst                |  56 +--
 .../adding-hooks.en.rst                         |  10 +-
 .../http-sessions.en.rst                        |   4 +-
 .../http-transactions.en.rst                    |  34 +-
 .../initiate-http-connection.en.rst             |   2 +-
 .../intercepting-http-transactions.en.rst       |   2 +-
 doc/sdk/io-guide.en.rst                         |  16 +-
 doc/sdk/io-guide/io-buffers.en.rst              |   2 +-
 doc/sdk/io-guide/transformations.en.rst         |   4 +-
 doc/sdk/io-guide/vios.en.rst                    |  22 +-
 doc/sdk/misc-interface-guide.en.rst             |  10 +-
 .../memory-allocation.en.rst                    |  10 +-
 .../thread-functions.en.rst                     |   8 +-
 .../misc-interface-guide/tsfopen-family.en.rst  |  12 +-
 doc/sdk/mutex-guide.en.rst                      |  16 +-
 doc/sdk/plugin-configurations.en.rst            |   8 +-
 .../guide-to-the-logging-api.en.rst             |  16 +-
 ...trafficserver-settings-and-statistics.en.rst |  10 +-
 example/include_other/macro.h                   |  75 ----
 lib/Makefile.am                                 |   4 +-
 plugins/Makefile.am                             |   1 +
 plugins/experimental/Makefile.am                |   1 -
 plugins/experimental/tcp_info/Makefile.am       |  26 --
 plugins/experimental/tcp_info/README            |  76 ----
 plugins/experimental/tcp_info/tcp_info.cc       | 358 ----------------
 plugins/experimental/tcp_info/tcp_info.config   |   3 -
 plugins/experimental/ts_lua/example/hdr.lua     |  37 --
 .../ts_lua/example/test_global_hdr.lua          |  37 ++
 .../experimental/ts_lua/example/test_hdr.lua    |  37 ++
 plugins/experimental/ts_lua/ts_lua.c            | 155 ++++++-
 plugins/experimental/ts_lua/ts_lua_common.h     |   8 +
 plugins/experimental/ts_lua/ts_lua_util.c       |   9 +
 plugins/tcpinfo/Makefile.am                     |  22 +
 plugins/tcpinfo/tcpinfo.cc                      | 424 +++++++++++++++++++
 proxy/PluginVC.h                                |   5 -
 proxy/api/ts/ts.h                               |   4 +-
 45 files changed, 1078 insertions(+), 807 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3fb05190/CHANGES
----------------------------------------------------------------------
diff --cc CHANGES
index 8cb41d9,b952ea0..a2b07b9
--- a/CHANGES
+++ b/CHANGES
@@@ -1,8 -1,12 +1,14 @@@
                                                           -*- coding: utf-8 -*-
  Changes with Apache Traffic Server 5.0.0
 +  
 +  *) [TS-2720] Fix bug with request transformations in C++ api
  
+   *) [TS-2714] Promote the tcp_info plugin to stable as 'tcpinfo'.
+ 
+   *) [TS-2708] Refactor and modernize the tcp_info plugin.
+ 
+   *) [TS-2555] Adding global plugin support to ts_lua plugin.
+ 
    *) [TS-2717] header-rewrite set-redirect not working.
     Author: Igor Brezac
  


[18/50] git commit: tcp_info plugin build fix

Posted by zw...@apache.org.
tcp_info plugin build fix


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

Branch: refs/heads/5.0.x
Commit: b514248a7e25a3080bd4abcf2ea5f34933c574ea
Parents: e503ce0
Author: James Peach <jp...@apache.org>
Authored: Thu Apr 10 15:56:07 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Apr 10 15:56:07 2014 -0700

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b514248a/plugins/experimental/tcp_info/tcp_info.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/tcp_info/tcp_info.cc b/plugins/experimental/tcp_info/tcp_info.cc
index c5277a3..7835039 100644
--- a/plugins/experimental/tcp_info/tcp_info.cc
+++ b/plugins/experimental/tcp_info/tcp_info.cc
@@ -219,7 +219,7 @@ parse_unsigned(const char * str, unsigned long& lval)
     return false;
   }
 
-  if (end != '\0') {
+  if (end && *end != '\0') {
     // Not all charaters consumed.
     return false;
   }


[47/50] git commit: docs: Fix visible hyperlink target on Read the Docs (should only show the link text)

Posted by zw...@apache.org.
docs: Fix visible hyperlink target on Read the Docs (should only show the link text)

This closes #72


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

Branch: refs/heads/5.0.x
Commit: 9d12a5db757e20033a60b92926890abf13453a46
Parents: b25b2c2
Author: Jack Bates <ja...@nottheoilrig.com>
Authored: Tue Apr 15 11:10:59 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Apr 16 12:43:20 2014 -0700

----------------------------------------------------------------------
 doc/sdk/actions-guide.en.rst                    |  4 +-
 doc/sdk/actions-guide/hosts-lookup-api.en.rst   |  4 +-
 doc/sdk/http-headers/http-headers.en.rst        | 46 +++++------
 doc/sdk/http-headers/mime-headers.en.rst        | 84 ++++++++++----------
 doc/sdk/http-headers/urls.en.rst                | 56 ++++++-------
 .../adding-hooks.en.rst                         | 10 +--
 .../http-sessions.en.rst                        |  4 +-
 .../http-transactions.en.rst                    | 34 ++++----
 .../initiate-http-connection.en.rst             |  2 +-
 .../intercepting-http-transactions.en.rst       |  2 +-
 doc/sdk/io-guide.en.rst                         | 16 ++--
 doc/sdk/io-guide/io-buffers.en.rst              |  2 +-
 doc/sdk/io-guide/transformations.en.rst         |  4 +-
 doc/sdk/io-guide/vios.en.rst                    | 22 ++---
 doc/sdk/misc-interface-guide.en.rst             | 10 +--
 .../memory-allocation.en.rst                    | 10 +--
 .../thread-functions.en.rst                     |  8 +-
 .../misc-interface-guide/tsfopen-family.en.rst  | 12 +--
 doc/sdk/mutex-guide.en.rst                      | 16 ++--
 doc/sdk/plugin-configurations.en.rst            |  8 +-
 .../guide-to-the-logging-api.en.rst             | 16 ++--
 ...trafficserver-settings-and-statistics.en.rst | 10 +--
 22 files changed, 190 insertions(+), 190 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/actions-guide.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/actions-guide.en.rst b/doc/sdk/actions-guide.en.rst
index f73d12d..ec9a53d 100644
--- a/doc/sdk/actions-guide.en.rst
+++ b/doc/sdk/actions-guide.en.rst
@@ -175,6 +175,6 @@ cancel the action. The following sample code implements this:
 
 The action functions are:
 
--  ```TSActionCancel`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a5d49a6addcc9dbdc7f339ee6b73ac0b6>`__
--  ```TSActionDone`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#abe189274ad59911f2a57d345d11bfecb>`__
+-  :c:func:`TSActionCancel`
+-  :c:func:`TSActionDone`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/actions-guide/hosts-lookup-api.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/actions-guide/hosts-lookup-api.en.rst b/doc/sdk/actions-guide/hosts-lookup-api.en.rst
index 66fc687..d77ee71 100644
--- a/doc/sdk/actions-guide/hosts-lookup-api.en.rst
+++ b/doc/sdk/actions-guide/hosts-lookup-api.en.rst
@@ -23,6 +23,6 @@ lookup of a host name, much like a DNS lookup.
 
 The hosts lookup functions are as follows:
 
--  ```TSHostLookup`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ab5bf6eea0ed883e5dc69253965935d12>`__
--  ```TSHostLookupResultAddrGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aecac0767192746af1867f528e01d167b>`__
+-  :c:func:`TSHostLookup`
+-  :c:func:`TSHostLookupResultAddrGet`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/http-headers/http-headers.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/http-headers/http-headers.en.rst b/doc/sdk/http-headers/http-headers.en.rst
index 7208840..f74f8a0 100644
--- a/doc/sdk/http-headers/http-headers.en.rst
+++ b/doc/sdk/http-headers/http-headers.en.rst
@@ -159,28 +159,28 @@ known schemes, since this removes the possibility of a spelling error.
 
 The **HTTP Header Functions** are listed below:
 
--  ```TSHttpHdrClone`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#abd410a18e8bc73298302c4ff3ee9b0c6>`__
--  ```TSHttpHdrCopy`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a5ff26f3836a74e885113423dfd4d9ed6>`__
--  ```TSHttpHdrCreate`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a8bbd8c2aaf70fb579af4520053fd5e10>`__
--  ```TSHttpHdrDestroy`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a500ac4aae8f369221cf3ac2e3ce0d2a0>`__
--  ```TSHttpHdrLengthGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a3afc557e4e99565ab81bf6437b65181b>`__
--  ```TSHttpHdrMethodGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a358627e05506baa5c8270891652ac4d2>`__
--  ```TSHttpHdrMethodSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a32bbcacacbef997e89c04cc3898b0ca4>`__
--  ```TSHttpHdrPrint`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a7c88f30d6325a461fb038e6a117b3731>`__
--  ```TSHttpHdrReasonGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a8b1609e9c8a8a52ebe7762b6109d3bef>`__
--  ```TSHttpHdrReasonLookup`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ab49fded8874b8e3e17cf4395c9832378>`__
--  ```TSHttpHdrReasonSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ab86e5f5e7c0af2092c77327d2e0d3b23>`__
--  ```TSHttpHdrStatusGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ac29d5acc357a0c82c83874f42b1e487b>`__
--  ```TSHttpHdrStatusSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#af34459170ed7f3b002ddd597ae38af12>`__
--  ```TSHttpHdrTypeGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#afc1c6f0a3258c4bc6567805df1db1ca3>`__
--  ```TSHttpHdrTypeSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a86058d8590a665dbf43a529714202d3f>`__
--  ```TSHttpHdrUrlGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#af149d7b5c1b8902363afc0ad658c494e>`__
--  ```TSHttpHdrUrlSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ad935635a3918575fa6cca6843c474cfe>`__
--  ```TSHttpHdrVersionGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a90cc8783f5d0bc159f226079aa0104e4>`__
--  ```TSHttpHdrVersionSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aa2a2c03399cdc8dc39b8756f13e7f189>`__
--  ```TSHttpParserClear`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a7cb1b53b4464dc71287351616d6e7509>`__
--  ```TSHttpParserCreate`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a6075fb4e8fc41eb75d640f258722115b>`__
+-  :c:func:`TSHttpHdrClone`
+-  :c:func:`TSHttpHdrCopy`
+-  :c:func:`TSHttpHdrCreate`
+-  :c:func:`TSHttpHdrDestroy`
+-  :c:func:`TSHttpHdrLengthGet`
+-  :c:func:`TSHttpHdrMethodGet`
+-  :c:func:`TSHttpHdrMethodSet`
+-  :c:func:`TSHttpHdrPrint`
+-  :c:func:`TSHttpHdrReasonGet`
+-  :c:func:`TSHttpHdrReasonLookup`
+-  :c:func:`TSHttpHdrReasonSet`
+-  :c:func:`TSHttpHdrStatusGet`
+-  :c:func:`TSHttpHdrStatusSet`
+-  :c:func:`TSHttpHdrTypeGet`
+-  :c:func:`TSHttpHdrTypeSet`
+-  :c:func:`TSHttpHdrUrlGet`
+-  :c:func:`TSHttpHdrUrlSet`
+-  :c:func:`TSHttpHdrVersionGet`
+-  :c:func:`TSHttpHdrVersionSet`
+-  :c:func:`TSHttpParserClear`
+-  :c:func:`TSHttpParserCreate`
 -  `TSHttpParserDestroy <link/to/doxyge>`__
--  ```TSHttpHdrParseReq`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a64193b3c9ddff8bc434c1cc9332004cc>`__
--  ```TSHttpHdrParseResp`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a03c8a14b6ab2b7896ef0e4005222ecff>`__
+-  :c:func:`TSHttpHdrParseReq`
+-  :c:func:`TSHttpHdrParseResp`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/http-headers/mime-headers.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/http-headers/mime-headers.en.rst b/doc/sdk/http-headers/mime-headers.en.rst
index ec9b0e8..7796678 100644
--- a/doc/sdk/http-headers/mime-headers.en.rst
+++ b/doc/sdk/http-headers/mime-headers.en.rst
@@ -74,7 +74,7 @@ a MIME header location. If an HTTP header location is passed to these
 functions, then the system locates the MIME header associated with that
 HTTP header and executes the corresponding MIME header operations
 specified by the functions (see the example in the description of
-```TSMimeHdrCopy`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a6e0a392b2e072db8e7f1d795151203b4>`__).
+:c:func:`TSMimeHdrCopy`).
 
 **Note:** MIME headers may contain more than one MIME field with the
 same name. Previous versions of Traffic Server joined multiple fields
@@ -393,45 +393,45 @@ object in one of the MIME headers associated with the object.
 
 The MIME header functions are listed below:
 
--  ```TSMimeHdrFieldAppend`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ae36c9bab9147a30b259d8e0223d697f2>`__
--  ```TSMimeHdrFieldClone`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ade66cd69ddff40d14b015a9e2cd7b46f>`__
--  ```TSMimeHdrFieldCopy`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a612ebefde403abc216af99f9150dd66f>`__
--  ```TSMimeHdrFieldCopyValues`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a5e4b2f68392a26643620641e50e5045b>`__
--  ```TSMimeHdrFieldCreate`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a7f79c0bea2ce14ced3b017eac08f8916>`__
--  ```TSMimeHdrFieldDestroy`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a6bf2d8e95e6f3ef351f63dbe8bc54020>`__
--  ```TSMimeHdrFieldLengthGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a8a906f22ccf7a4a04fac817dc57a785f>`__
--  ```TSMimeHdrFieldNameGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ad68f51073e4630ad6a0433efbfeef2ea>`__
--  ```TSMimeHdrFieldNameSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a6856f6069fa4ee67d1a788bd642d59f0>`__
--  ```TSMimeHdrFieldNext`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#aaf3a205e8a4e7128f3fa3de70991df80>`__
--  ```TSMimeHdrFieldNextDup`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#af2d776615afe959ed7c3639830a7061f>`__
--  ```TSMimeHdrFieldValueAppend`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ad1d4d1dda95311e3389245fd9fa961b5>`__
--  ```TSMimeHdrFieldValueAppend`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ad1d4d1dda95311e3389245fd9fa961b5>`__
--  ```TSMimeHdrFieldValueDateGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ad74a60f0da93397ee015d82f30021d15>`__
--  ```TSMimeHdrFieldValueDateInsert`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a0520a29de96736b04f14e9d790ec8e9c>`__
--  ```TSMimeHdrFieldValueDateSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#abf85e014cb316977dedca38c341d4369>`__
--  ```TSMimeHdrFieldValueIntGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ace1fac92d2be75ff7cbd8eb7725d3fac>`__
--  ```TSMimeHdrFieldValueIntSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aec96c5629a750cdaec709228c4bd8a76>`__
--  ```TSMimeHdrFieldValueStringGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a4aa55cd4eeb9e6d0a5151c02f0c18c28>`__
--  ```TSMimeHdrFieldValueStringInsert`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a979d1591becf1c59de830af117d54923>`__
--  ```TSMimeHdrFieldValueStringSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ac21e44e84b25c23e52ba7bea7bd09ed6>`__
--  ```TSMimeHdrFieldValueUintGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a116b4c9144ad6eda66213adb0167706a>`__
--  ```TSMimeHdrFieldValueUintInsert`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a88db3a90d3ac7766e55c734c89dfe86f>`__
--  ```TSMimeHdrFieldValueUintSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a63b0a686b4a6ec6b8a4f1b796009c3cd>`__
--  ```TSMimeHdrFieldValuesClear`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a8fd3afaf88f6c76793fdb635bbd22113>`__
--  ```TSMimeHdrFieldValuesCount`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a326283521986acf9b8a9ec00f3d6d164>`__
--  ```TSMimeHdrClone`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aa8ab95bda93c3e16e6d134fe35acd1b6>`__
--  ```TSMimeHdrCopy`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a6e0a392b2e072db8e7f1d795151203b4>`__
--  ```TSMimeHdrCreate`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a3427dfbd6b79c531fcba4e8c8b4e217d>`__
--  ```TSMimeHdrDestroy`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a60ad7f4f4f9e2559dcc2ff28ebe8d96c>`__
--  ```TSMimeHdrFieldFind`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a30e4ce224761b273a119dcd57f5a352b>`__
--  ```TSMimeHdrFieldGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a31c0c307010a5d19d027ffb3a2656745>`__
--  ```TSMimeHdrFieldRemove`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a96d9a50d0687456e6e67eb2e9a9c2d72>`__
--  ```TSMimeHdrFieldsClear`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a65d7539e48c9f5c26075344dee6c6ae2>`__
--  ```TSMimeHdrFieldsCount`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ab02f7d0cba75cf0146c6a9b507c79fcf>`__
--  ```TSMimeHdrLengthGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a001cd786282f5c9d04189ddf7c96e269>`__
--  ```TSMimeHdrParse`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a4a6042bcd5b5b0a21267c03cf102e90d>`__
--  ```TSMimeParserClear`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ac173b595659d1909aae5410ecd1ce028>`__
--  ```TSMimeParserCreate`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a518072dc5a90b753df7726878119506b>`__
--  ```TSMimeParserDestroy`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a5f287f5016d931842c0a5012c3d227b7>`__
--  ```TSMimeHdrPrint`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#adfca8722edc6469df4410b8050406bb0>`__
+-  :c:func:`TSMimeHdrFieldAppend`
+-  :c:func:`TSMimeHdrFieldClone`
+-  :c:func:`TSMimeHdrFieldCopy`
+-  :c:func:`TSMimeHdrFieldCopyValues`
+-  :c:func:`TSMimeHdrFieldCreate`
+-  :c:func:`TSMimeHdrFieldDestroy`
+-  :c:func:`TSMimeHdrFieldLengthGet`
+-  :c:func:`TSMimeHdrFieldNameGet`
+-  :c:func:`TSMimeHdrFieldNameSet`
+-  :c:func:`TSMimeHdrFieldNext`
+-  :c:func:`TSMimeHdrFieldNextDup`
+-  :c:func:`TSMimeHdrFieldValueAppend`
+-  :c:func:`TSMimeHdrFieldValueAppend`
+-  :c:func:`TSMimeHdrFieldValueDateGet`
+-  :c:func:`TSMimeHdrFieldValueDateInsert`
+-  :c:func:`TSMimeHdrFieldValueDateSet`
+-  :c:func:`TSMimeHdrFieldValueIntGet`
+-  :c:func:`TSMimeHdrFieldValueIntSet`
+-  :c:func:`TSMimeHdrFieldValueStringGet`
+-  :c:func:`TSMimeHdrFieldValueStringInsert`
+-  :c:func:`TSMimeHdrFieldValueStringSet`
+-  :c:func:`TSMimeHdrFieldValueUintGet`
+-  :c:func:`TSMimeHdrFieldValueUintInsert`
+-  :c:func:`TSMimeHdrFieldValueUintSet`
+-  :c:func:`TSMimeHdrFieldValuesClear`
+-  :c:func:`TSMimeHdrFieldValuesCount`
+-  :c:func:`TSMimeHdrClone`
+-  :c:func:`TSMimeHdrCopy`
+-  :c:func:`TSMimeHdrCreate`
+-  :c:func:`TSMimeHdrDestroy`
+-  :c:func:`TSMimeHdrFieldFind`
+-  :c:func:`TSMimeHdrFieldGet`
+-  :c:func:`TSMimeHdrFieldRemove`
+-  :c:func:`TSMimeHdrFieldsClear`
+-  :c:func:`TSMimeHdrFieldsCount`
+-  :c:func:`TSMimeHdrLengthGet`
+-  :c:func:`TSMimeHdrParse`
+-  :c:func:`TSMimeParserClear`
+-  :c:func:`TSMimeParserCreate`
+-  :c:func:`TSMimeParserDestroy`
+-  :c:func:`TSMimeHdrPrint`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/http-headers/urls.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/http-headers/urls.en.rst b/doc/sdk/http-headers/urls.en.rst
index 5f32b82..91b74b5 100644
--- a/doc/sdk/http-headers/urls.en.rst
+++ b/doc/sdk/http-headers/urls.en.rst
@@ -104,31 +104,31 @@ schemes, since doing so can prevent the possibility of spelling errors.
 
 Traffic Server **URL functions** are listed below:
 
-```TSUrlClone`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#acb775f48f1da5f6c5bf32c833a236574>`__
-```TSUrlCopy`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aa2b8d5f9289a23ab985210914a6301a7>`__
-```TSUrlCreate`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ad3518ea3bca6a6f2d899b859c6fbbede>`__
-```TSUrlDestroy`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a87559aac42f4f9439399ba2bd32693fa>`__
-```TSUrlPrint`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#adec26f5a4afe62b4308dd86f97ae08fd>`__
-```TSUrlFtpTypeGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a5cd15d2c288a48b832f0fc096ed6fb80>`__
-```TSUrlFtpTypeSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a66df700e23085cabf945e92eb1e22890>`__
-```TSUrlHostGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a48e626d9497d4d81c0b9d2781f86066b>`__
-```TSUrlHostSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a7e550dac573f5780f7ba39509aa881f3>`__
-```TSUrlHttpFragmentGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a316696ad964cb6c6afb7e3028da3ef84>`__
-```TSUrlHttpFragmentSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a45f7b216882c4517b92929145adf5424>`__
-```TSUrlHttpParamsGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a9395d5d794078c8ec0f17f27dc8d8498>`__
-```TSUrlHttpParamsSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a566f2996d36663e3eb8ed4a8fda738c3>`__
-```TSUrlHttpQueryGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a74a6c51ea9f472cf29514facbf897785>`__
-```TSUrlHttpQuerySet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a9846aaf11accd8c817fff48bfaa784e0>`__
-```TSUrlLengthGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a96ded2567985b187c0a8274d76d12c17>`__
-```TSUrlParse`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a17f785697773b62b1f5094c06896cac5>`__
-```TSUrlPasswordGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a14614f77e0c15b206bab8fd6fdfa7bd1>`__
-```TSUrlPasswordSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#abb4d983b9d47ba5a254c2b9dd9ad835e>`__
-```TSUrlPathGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#aa064a2d5256d839819d1ec8f252c01a9>`__
-```TSUrlPathSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ad73274cb5b7e98a64d53f992681110b7>`__
-```TSUrlPortGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ad99bfb408a46f47c4aa9478fc1b95e0c>`__
-```TSUrlPortSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aab07c0482fc3c3aae1b545fb0104e3aa>`__
-```TSUrlSchemeGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a24c660b5b46f17b24d7a1cc9aa9a4930>`__
-```TSUrlSchemeSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a03b1a806ea8d79806dfff39bfe138934>`__
-```TSUrlStringGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a1cda3103d8dd59372609aed6c9c47417>`__
-```TSUrlUserGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a3c4d7ffcbbda447c3b665dc857a3226b>`__
-```TSUrlUserSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a3175e9c89c2bbea5ed50e2a7f52d7f9f>`__
+:c:func:`TSUrlClone`
+:c:func:`TSUrlCopy`
+:c:func:`TSUrlCreate`
+:c:func:`TSUrlDestroy`
+:c:func:`TSUrlPrint`
+:c:func:`TSUrlFtpTypeGet`
+:c:func:`TSUrlFtpTypeSet`
+:c:func:`TSUrlHostGet`
+:c:func:`TSUrlHostSet`
+:c:func:`TSUrlHttpFragmentGet`
+:c:func:`TSUrlHttpFragmentSet`
+:c:func:`TSUrlHttpParamsGet`
+:c:func:`TSUrlHttpParamsSet`
+:c:func:`TSUrlHttpQueryGet`
+:c:func:`TSUrlHttpQuerySet`
+:c:func:`TSUrlLengthGet`
+:c:func:`TSUrlParse`
+:c:func:`TSUrlPasswordGet`
+:c:func:`TSUrlPasswordSet`
+:c:func:`TSUrlPathGet`
+:c:func:`TSUrlPathSet`
+:c:func:`TSUrlPortGet`
+:c:func:`TSUrlPortSet`
+:c:func:`TSUrlSchemeGet`
+:c:func:`TSUrlSchemeSet`
+:c:func:`TSUrlStringGet`
+:c:func:`TSUrlUserGet`
+:c:func:`TSUrlUserSet`

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/http-hooks-and-transactions/adding-hooks.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/http-hooks-and-transactions/adding-hooks.en.rst b/doc/sdk/http-hooks-and-transactions/adding-hooks.en.rst
index 2f862e2..04e3e94 100644
--- a/doc/sdk/http-hooks-and-transactions/adding-hooks.en.rst
+++ b/doc/sdk/http-hooks-and-transactions/adding-hooks.en.rst
@@ -34,7 +34,7 @@ There are several ways to add hooks to your plugin.
 
 -  **Transformation hooks** Transformation hooks are a special case of
    transaction hooks. See
-   ```TSVConnCacheObjectSizeGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#af5ca2c5b00e4859d2fa5dec466dfd058>`__
+   :c:func:`TSVConnCacheObjectSizeGet`
    for more information about transformation hooks. You add a
    transformation hook using ``TSHttpTxnHookAdd``, as described in `HTTP
    Transactions <HTTP_Transactions.html>`__.
@@ -55,9 +55,9 @@ There are several ways to add hooks to your plugin.
    information on the alternate selection mechanism.
 
 All of the hook addition functions
-(```TSHttpHookAdd`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a19a663edd3ec439f66256fbbb26cc1db>`__,
-```TSHttpSsnHookAdd`` <HTTPSessionFunctions.html#TSHttpSsnHookAdd>`__,
-```TSHttpSsnReenable`` <HTTPSessionFunctions.html#TSHttpSsnReenable>`__)
+(:c:func:`TSHttpHookAdd`,
+:c:func:`TSHttpSsnHookAdd`,
+:c:func:`TSHttpSsnReenable`)
 take ``TSHttpHookID`` (identifies the hook to add on to) and ``TSCont``
 (the basic callback mechanism in Traffic Server). A single ``TSCont``
 can be added to any number of hooks at a time.
@@ -150,4 +150,4 @@ values for ``TSHttpHookID`` are:
     was left open for keep alive has new data available.
 
 The function you use to add a global HTTP hook is
-```TSHttpHookAdd`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a19a663edd3ec439f66256fbbb26cc1db>`__.
+:c:func:`TSHttpHookAdd`.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/http-hooks-and-transactions/http-sessions.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/http-hooks-and-transactions/http-sessions.en.rst b/doc/sdk/http-hooks-and-transactions/http-sessions.en.rst
index 8d45478..b4014e5 100644
--- a/doc/sdk/http-hooks-and-transactions/http-sessions.en.rst
+++ b/doc/sdk/http-hooks-and-transactions/http-sessions.en.rst
@@ -47,6 +47,6 @@ processing a session hook.
 
 The session hook functions are listed below:
 
--  ```TSHttpSsnHookAdd`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a268d493d94fa5461c8200883a9b8d20b>`__
--  ```TSHttpSsnReenable`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a3bbe42bf4757625bdb8bb65e7ac6f52d>`__
+-  :c:func:`TSHttpSsnHookAdd`
+-  :c:func:`TSHttpSsnReenable`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/http-hooks-and-transactions/http-transactions.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/http-hooks-and-transactions/http-transactions.en.rst b/doc/sdk/http-hooks-and-transactions/http-transactions.en.rst
index 35550fd..e859fb2 100644
--- a/doc/sdk/http-hooks-and-transactions/http-transactions.en.rst
+++ b/doc/sdk/http-hooks-and-transactions/http-transactions.en.rst
@@ -158,12 +158,12 @@ for an illustration of the steps involved in a typical HTTP transaction.
 
 The HTTP transaction functions are:
 
--  ```TSHttpTxnCacheLookupStatusGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ad26c77fa4ba251fb8ccbbd1505a74687>`__
+-  :c:func:`TSHttpTxnCacheLookupStatusGet`
 
--  ```TSHttpTxnCachedReqGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a889b626142157077f4f3cfe479e8b8e2>`__
+-  :c:func:`TSHttpTxnCachedReqGet`
    - Note that it is an error to modify cached headers.
 
--  ```TSHttpTxnCachedRespGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ae8f24b8dabb5008ad11620a11682ffd6>`__
+-  :c:func:`TSHttpTxnCachedRespGet`
    - Note that it is an error to modify cached headers.
 
 -  `TSHttpTxnClientIncomingPortGet <link/to/doxygen>`__
@@ -172,34 +172,34 @@ The HTTP transaction functions are:
 
 -  `TSHttpTxnClientRemotePortGet <link/to/doxygen>`__
 
--  ```TSHttpTxnClientReqGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#acca66f22d0f87bf8f08478ed926006a5>`__
+-  :c:func:`TSHttpTxnClientReqGet`
    - Plugins that must read client request headers use this call to
    retrieve the HTTP header.
 
--  ```TSHttpTxnClientRespGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a92349c8363f72b1f6dfed3ae80901fff>`__
+-  :c:func:`TSHttpTxnClientRespGet`
 
--  ```TSHttpTxnErrorBodySet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ad7efc431279dc97de4b50a58d4ed33c1>`__
+-  :c:func:`TSHttpTxnErrorBodySet`
 
--  ```TSHttpTxnHookAdd`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a10382b88145bbfba0fa9d8ed6402f4b1>`__
+-  :c:func:`TSHttpTxnHookAdd`
 
--  ```TSHttpTxnNextHopAddrGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aa0118beabfefe35d2642f007ac7afa97>`__
+-  :c:func:`TSHttpTxnNextHopAddrGet`
 
--  ```TSHttpTxnParentProxySet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a2a1260b900b665d38a262544446b886c>`__
+-  :c:func:`TSHttpTxnParentProxySet`
 
--  ```TSHttpTxnReenable`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ac367347e02709ac809994dfb21d3288a>`__
+-  :c:func:`TSHttpTxnReenable`
 
--  ```TSHttpTxnServerAddrGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a63917ec11275c4f1ed559362865cd65f>`__
+-  :c:func:`TSHttpTxnServerAddrGet`
 
--  ```TSHttpTxnServerReqGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aac2343a8b47bf9150f3ff7cd4e692d57>`__
+-  :c:func:`TSHttpTxnServerReqGet`
 
--  ```TSHttpTxnServerRespGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a39e8bfb199eadabb54c067ff25a9a400>`__
+-  :c:func:`TSHttpTxnServerRespGet`
 
--  ```TSHttpTxnSsnGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a8c5190bd2e940ef2d1969a5be65f0edd>`__
+-  :c:func:`TSHttpTxnSsnGet`
 
--  ```TSHttpTxnTransformedRespCache`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a213b584cd04001e8f8ad509d187a4103>`__
+-  :c:func:`TSHttpTxnTransformedRespCache`
 
--  ```TSHttpTxnTransformRespGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a4fc46502733adcff09587a436e300114>`__
+-  :c:func:`TSHttpTxnTransformRespGet`
 
--  ```TSHttpTxnUntransformedRespCache`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a8b9c0e61cbcb251417df0d06ae6c4408>`__
+-  :c:func:`TSHttpTxnUntransformedRespCache`
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/http-hooks-and-transactions/initiate-http-connection.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/http-hooks-and-transactions/initiate-http-connection.en.rst b/doc/sdk/http-hooks-and-transactions/initiate-http-connection.en.rst
index 059747d..e5921ad 100644
--- a/doc/sdk/http-hooks-and-transactions/initiate-http-connection.en.rst
+++ b/doc/sdk/http-hooks-and-transactions/initiate-http-connection.en.rst
@@ -21,5 +21,5 @@ Initiate HTTP Connection
 This function enables plugins to initiate HTTP transactions. The
 initiate HTTP connection function is:
 
--  ```TSHttpConnect`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a2b45aa63ac1353b4c52123110197b61e>`__
+-  :c:func:`TSHttpConnect`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/http-hooks-and-transactions/intercepting-http-transactions.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/http-hooks-and-transactions/intercepting-http-transactions.en.rst b/doc/sdk/http-hooks-and-transactions/intercepting-http-transactions.en.rst
index 9dd7682..9a7d59b 100644
--- a/doc/sdk/http-hooks-and-transactions/intercepting-http-transactions.en.rst
+++ b/doc/sdk/http-hooks-and-transactions/intercepting-http-transactions.en.rst
@@ -26,5 +26,5 @@ for reading ``POST`` bodies in plugins as well as using alternative
 transports to the origin server.The intercepting HTTP transaction
 functions are:
 
--  ```TSHttpTxnIntercept`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a3408017633f95161e2ab4fa175c44fa3>`__
+-  :c:func:`TSHttpTxnIntercept`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/io-guide.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/io-guide.en.rst b/doc/sdk/io-guide.en.rst
index 40bf54d..7e95cf3 100644
--- a/doc/sdk/io-guide.en.rst
+++ b/doc/sdk/io-guide.en.rst
@@ -182,13 +182,13 @@ Plugins <../http-transformation-plugin#WritingContentTransformPlugins>`__.
 
 The vconnection functions are listed below:
 
--  ```TSVConnAbort`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a08444a9b2fee637672e177ede78b6218>`__
--  ```TSVConnClose`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a69344c2c6e57ece0990a5cee73b75215>`__
--  ```TSVConnClosedGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a441d74cd77bf5d5564048682ca83b6ec>`__
--  ```TSVConnRead`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a29674799a8deffdde3d6ae3231aba1dc>`__
--  ```TSVConnReadVIOGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#aa6f8788f062737f211c788ad5fcd2813>`__
--  ```TSVConnShutdown`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a5935b6c762b65fe87057adf94b1b00b4>`__
--  ```TSVConnWrite`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#acea65496d1fcaf01924b0210f3129e6b>`__
--  ```TSVConnWriteVIOGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ae9a38dbd4866c59131a1f3b806a18aab>`__
+-  :c:func:`TSVConnAbort`
+-  :c:func:`TSVConnClose`
+-  :c:func:`TSVConnClosedGet`
+-  :c:func:`TSVConnRead`
+-  :c:func:`TSVConnReadVIOGet`
+-  :c:func:`TSVConnShutdown`
+-  :c:func:`TSVConnWrite`
+-  :c:func:`TSVConnWriteVIOGet`
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/io-guide/io-buffers.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/io-guide/io-buffers.en.rst b/doc/sdk/io-guide/io-buffers.en.rst
index 8c4cc40..a43bab9 100644
--- a/doc/sdk/io-guide/io-buffers.en.rst
+++ b/doc/sdk/io-guide/io-buffers.en.rst
@@ -35,7 +35,7 @@ structure. Since only a single writer is allowed, there is no
 corresponding ``TSIOBufferWriter`` data structure. The writer simply
 modifies the IO buffer directly. To see an example that illustrates how
 to use IOBuffers, refer to the sample code in the description of
-```TSIOBufferBlockReadStart`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a367203e6e2cf4349e019952782deb96c>`__.
+:c:func:`TSIOBufferBlockReadStart`.
 
 Additional information about IO buffer functions:
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/io-guide/transformations.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/io-guide/transformations.en.rst b/doc/sdk/io-guide/transformations.en.rst
index 667e611..e627000 100644
--- a/doc/sdk/io-guide/transformations.en.rst
+++ b/doc/sdk/io-guide/transformations.en.rst
@@ -177,6 +177,6 @@ Here's how to make sure that all incoming data is consumed:
    because it knows it already holds the mutex.
 
 The transformation functions are: \*
-```TSTransformCreate`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a54c4902bb537d3d40763bd947ed753b9>`__
+:c:func:`TSTransformCreate`
 \*
-```TSTransformOutputVConnGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ac6832718a2d9f2658409ad231811e1e3>`__
+:c:func:`TSTransformOutputVConnGet`

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/io-guide/vios.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/io-guide/vios.en.rst b/doc/sdk/io-guide/vios.en.rst
index 48e5d12..61718c2 100644
--- a/doc/sdk/io-guide/vios.en.rst
+++ b/doc/sdk/io-guide/vios.en.rst
@@ -45,15 +45,15 @@ as follows:
 The VIO functions below access and modify various parts of the data
 structure.
 
--  ```TSVIOBufferGet`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#a55df75b6ba6e9152292a01e0b4e21963>`__
--  ```TSVIOVConnGet`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#a32b9eaaadf2145f98ceb4d64b7c06c2f>`__
--  ```TSVIOContGet`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#a071f12b307885c02aceebc41601bbdcf>`__
--  ```TSVIOMutexGet`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#ab4e8c755cf230918a14a4411af8b3e63>`__
--  ```TSVIONBytesGet`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#af6fc57adc7308864b343b6b7fd30c5ff>`__
--  ```TSVIONBytesSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a27594723f14891ac43da3e1368328d0e>`__
--  ```TSVIONDoneGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ad71156f68a119c00502ff1fd598824ab>`__
--  ```TSVIONDoneSet`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#af4590966899039571d874e0c090042ad>`__
--  ```TSVIONTodoGet`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#a1dd145ddd60822a5f892becf7b8e8f84>`__
--  ```TSVIOReaderGet`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#a471ee1fde01fbeabce6c39944dfe9da6>`__
--  ```TSVIOReenable`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a792ef9d6962193badad2877a81d8bcff>`__
+-  :c:func:`TSVIOBufferGet`
+-  :c:func:`TSVIOVConnGet`
+-  :c:func:`TSVIOContGet`
+-  :c:func:`TSVIOMutexGet`
+-  :c:func:`TSVIONBytesGet`
+-  :c:func:`TSVIONBytesSet`
+-  :c:func:`TSVIONDoneGet`
+-  :c:func:`TSVIONDoneSet`
+-  :c:func:`TSVIONTodoGet`
+-  :c:func:`TSVIOReaderGet`
+-  :c:func:`TSVIOReenable`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/misc-interface-guide.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/misc-interface-guide.en.rst b/doc/sdk/misc-interface-guide.en.rst
index 2b4675c..067068b 100644
--- a/doc/sdk/misc-interface-guide.en.rst
+++ b/doc/sdk/misc-interface-guide.en.rst
@@ -39,22 +39,22 @@ all Traffic Server-support platforms).
 Debugging Functions
 -------------------
 
--  ```TSDebug`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#afccd91047cc46eb35478a751ec65c78d>`__
+-  :c:func:`TSDebug`
    prints out a formatted statement if you are running Traffic Server in
    debug mode.
 
--  ```TSIsDebugTagSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a2d3ceac855c1cde83eff5484bc952288>`__
+-  :c:func:`TSIsDebugTagSet`
    checks to see if a debug tag is set. If the debug tag is set, then
    Traffic Server prints out all debug statements associated with the
    tag.
 
--  ```TSError`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a19ff77fecfc3e331b03da6e358907787>`__
+-  :c:func:`TSError`
    prints error messages to Traffic Server's error log
 
--  ```TSAssert`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ad94eb4fb1f08082ea1634f169cc49c68>`__
+-  :c:func:`TSAssert`
    enables the use of assertion in a plugin.
 
--  ```TSReleaseAssert`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a5e751769785de91c52bd503bcbc28b0a>`__
+-  :c:func:`TSReleaseAssert`
    enables the use of assertion in a plugin.
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/misc-interface-guide/memory-allocation.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/misc-interface-guide/memory-allocation.en.rst b/doc/sdk/misc-interface-guide/memory-allocation.en.rst
index f2e2e88..b270feb 100644
--- a/doc/sdk/misc-interface-guide/memory-allocation.en.rst
+++ b/doc/sdk/misc-interface-guide/memory-allocation.en.rst
@@ -33,14 +33,14 @@ leaks.
 
 The memory allocation functions are:
 
--  ```TSfree`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#afe7f18beddf31a80436a03a5ab7e759f>`__
+-  :c:func:`TSfree`
 
--  ```TSmalloc`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#af030092823148cbbc5525c4fcde9bb37>`__
+-  :c:func:`TSmalloc`
 
--  ```TSrealloc`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a3abaf3d50d82377dccd1c16bc7b631ab>`__
+-  :c:func:`TSrealloc`
 
--  ```TSstrdup`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a92c01584655c52e46a58986435e17c86>`__
+-  :c:func:`TSstrdup`
 
--  ```TSstrndup`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a11072c11fa6d8470ace2963615229146>`__
+-  :c:func:`TSstrndup`
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/misc-interface-guide/thread-functions.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/misc-interface-guide/thread-functions.en.rst b/doc/sdk/misc-interface-guide/thread-functions.en.rst
index 65fdf3c..a39f515 100644
--- a/doc/sdk/misc-interface-guide/thread-functions.en.rst
+++ b/doc/sdk/misc-interface-guide/thread-functions.en.rst
@@ -27,8 +27,8 @@ shared resources and data using the ``TSMutex`` type, as described in
 
 The thread functions are listed below:
 
--  ```TSThreadCreate`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#ad087d67be30b68b6d608a5094fceed2a>`__
--  ```TSThreadDestroy`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#a600e8ad830081bdcf6caabc07b54c9e4>`__
--  ```TSThreadInit`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#a11088d9aaba362827841687864e55242>`__
--  ```TSThreadSelf`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#a5cc33c5182755e3d62b4aa55277425d9>`__
+-  :c:func:`TSThreadCreate`
+-  :c:func:`TSThreadDestroy`
+-  :c:func:`TSThreadInit`
+-  :c:func:`TSThreadSelf`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/misc-interface-guide/tsfopen-family.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/misc-interface-guide/tsfopen-family.en.rst b/doc/sdk/misc-interface-guide/tsfopen-family.en.rst
index 0952a4b..b0900b0 100644
--- a/doc/sdk/misc-interface-guide/tsfopen-family.en.rst
+++ b/doc/sdk/misc-interface-guide/tsfopen-family.en.rst
@@ -39,16 +39,16 @@ corresponding usage of the ``fopen`` family of functions is
 inappropriate due to file descriptor and portability limitations. The
 ``TSfopen`` family of functions consists of the following:
 
--  ```TSfclose`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a2efebe7583752668e6136de0b47bee4f>`__
+-  :c:func:`TSfclose`
 
--  ```TSfflush`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a3cb0cb348ed189a98577f84e0629ca9a>`__
+-  :c:func:`TSfflush`
 
--  ```TSfgets`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a6dcc724a432a287836352b31984e0de8>`__
+-  :c:func:`TSfgets`
 
--  ```TSfopen`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a53b0430d5b0c042bdb3d06689cf244f3>`__
+-  :c:func:`TSfopen`
 
--  ```TSfread`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a29f83c50b52e4fcabfe2b829de5742e2>`__
+-  :c:func:`TSfread`
 
--  ```TSfwrite`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a596a5562db5180ea8818f7bb87336a15>`__
+-  :c:func:`TSfwrite`
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/mutex-guide.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/mutex-guide.en.rst b/doc/sdk/mutex-guide.en.rst
index 0aa6239..de2eaad 100644
--- a/doc/sdk/mutex-guide.en.rst
+++ b/doc/sdk/mutex-guide.en.rst
@@ -81,24 +81,24 @@ created in ``TSPluginInit``. The ``blacklist-1.c`` code uses
 information, see the
 ```blacklist-1.c`` <../sample-source-code#Sample_blacklist-1.c>`__ code;
 start by looking at the
-```TSPluginInit`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a9a0b0ac9cbce9d6644f66bbe93098313>`__
+:c:func:`TSPluginInit`
 function.
 
 General guidelines for locking shared data are as follows:
 
 1. Create a mutex for the shared data with
-   ```TSMutexCreate`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aa4300d8888c6962a44c9e827d633e433>`__.
+   :c:func:`TSMutexCreate`.
 
 2. Whenever you need to read or modify this data, first lock it by
    calling
-   ```TSMutexLockTry`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ac9c08451aa529851b9474e3c035f44bb>`__;
+   :c:func:`TSMutexLockTry`;
    then read or modify the data.
 
 3. When you are done with the data, unlock it with
-   ```TSMutexUnlock`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#afbb474c217fd5b927f1f8487c45646dd>`__.
+   :c:func:`TSMutexUnlock`.
    If you are unlocking data accessed during the processing of an HTTP
    transaction, then you must unlock it before calling
-   ```TSHttpTxnReenable`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ac367347e02709ac809994dfb21d3288a>`__.
+   :c:func:`TSHttpTxnReenable`.
 
 Protecting a Continuation's Data
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -405,7 +405,7 @@ continuation created in ``txn_handler``:
 
 The mutex functions are listed below:
 
--  ```TSMutexCreate`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aa4300d8888c6962a44c9e827d633e433>`__
--  ```TSMutexLock`` <http://people.apache.org/~amc/ats/doc/html/InkIOCoreAPI_8cc.html#a306f9923bc9d3c0f417c185919531934>`__
--  ```TSMutexLockTry`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#ac9c08451aa529851b9474e3c035f44bb>`__
+-  :c:func:`TSMutexCreate`
+-  :c:func:`TSMutexLock`
+-  :c:func:`TSMutexLockTry`
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/plugin-configurations.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/plugin-configurations.en.rst b/doc/sdk/plugin-configurations.en.rst
index b9dc89b..994f519 100644
--- a/doc/sdk/plugin-configurations.en.rst
+++ b/doc/sdk/plugin-configurations.en.rst
@@ -105,12 +105,12 @@ Here's how the interface works:
 
 The configuration functions are:
 
--  ```TSConfigDataGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#aed2a6f9d350935ac890f75fdd80605db>`__
+-  :c:func:`TSConfigDataGet`
 
--  ```TSConfigGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a478189d6ad87c6b873d8676cb51508c5>`__
+-  :c:func:`TSConfigGet`
 
--  ```TSConfigRelease`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a06711d4a0e70f1ff27f9b5ca34bb649c>`__
+-  :c:func:`TSConfigRelease`
 
--  ```TSConfigSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a8bba9468fdca478e68035a9776f6e9ca>`__
+-  :c:func:`TSConfigSet`
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/plugin-management/guide-to-the-logging-api.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/plugin-management/guide-to-the-logging-api.en.rst b/doc/sdk/plugin-management/guide-to-the-logging-api.en.rst
index 4c3aec2..ad0b193 100644
--- a/doc/sdk/plugin-management/guide-to-the-logging-api.en.rst
+++ b/doc/sdk/plugin-management/guide-to-the-logging-api.en.rst
@@ -27,28 +27,28 @@ you can set log properties.
 The logging API enables you to:
 
 -  Establish a custom text log for your plugin: see
-   ```TSTextLogObjectCreate`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ae75e85e476efeaa16ded185da7a3081b>`__
+   :c:func:`TSTextLogObjectCreate`
 
 -  Set the log header for your custom text log: see
-   ```TSTextLogObjectHeaderSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a7c10f89fe8bcb6b733f4a83b5a73b71c>`__
+   :c:func:`TSTextLogObjectHeaderSet`
 
 -  Enable or disable rolling your custom text log: see
-   ```TSTextLogObjectRollingEnabledSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#aec1e883f0735ee40c8b56d90cf27acd1>`__
+   :c:func:`TSTextLogObjectRollingEnabledSet`
 
 -  Set the rolling interval (in seconds) for your custom text log: see
-   ```TSTextLogObjectRollingIntervalSecSet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#aac0be2e81694db0363c5321e8a2019ce>`__
+   :c:func:`TSTextLogObjectRollingIntervalSecSet`
 
 -  Set the rolling offset for your custom text log: see
-   ```TSTextLogObjectRollingOffsetHrSet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a9d90885b975947c241f74c33550180b4>`__
+   :c:func:`TSTextLogObjectRollingOffsetHrSet`
 
 -  Write text entries to the custom text log: see
-   ```TSTextLogObjectWrite`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a34de01e5603ea639d7ce6c7bf9613254>`__
+   :c:func:`TSTextLogObjectWrite`
 
 -  Flush the contents of the custom text log's write buffer to disk: see
-   ```TSTextLogObjectFlush`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#ad746b22f992c2adb5f0271e5136a6ca1>`__
+   :c:func:`TSTextLogObjectFlush`
 
 -  Destroy custom text logs when you are done with them: see
-   ```TSTextLogObjectDestroy`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#af6521931ada7bbc38194e79e60081d54>`__
+   :c:func:`TSTextLogObjectDestroy`
 
 The steps below show how the logging API is used in the
 ``blacklist-1.c`` sample plugin. For the complete source code, see the

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9d12a5db/doc/sdk/plugin-management/reading-trafficserver-settings-and-statistics.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/plugin-management/reading-trafficserver-settings-and-statistics.en.rst b/doc/sdk/plugin-management/reading-trafficserver-settings-and-statistics.en.rst
index b3341a6..e203198 100644
--- a/doc/sdk/plugin-management/reading-trafficserver-settings-and-statistics.en.rst
+++ b/doc/sdk/plugin-management/reading-trafficserver-settings-and-statistics.en.rst
@@ -40,16 +40,16 @@ the `Traffic Server Administrator's Guide <../../admin/>`__.
 Depending on the result type, you'll use ``TSMgmtIntGet``,
 ``TSMgmtCounterGet``, ``TSMgmtFloatGet``, or ``TSMgmtStringGet`` to
 obtain the variable value (see the example for
-```TSMgmtIntGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a097aaecda41d04b522796ae25eea9a3d>`__.
+:c:func:`TSMgmtIntGet`.
 
 The ``TSMgmt*Get`` functions are:
 
--  ```TSMgmtCounterGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a583e21e614b70256f68658fc6c455ea6>`__
+-  :c:func:`TSMgmtCounterGet`
 
--  ```TSMgmtFloatGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a2ace94b52c71656304b53824d3fa7080>`__
+-  :c:func:`TSMgmtFloatGet`
 
--  ```TSMgmtIntGet`` <http://people.apache.org/~amc/ats/doc/html/ts_8h.html#a097aaecda41d04b522796ae25eea9a3d>`__
+-  :c:func:`TSMgmtIntGet`
 
--  ```TSMgmtStringGet`` <http://people.apache.org/~amc/ats/doc/html/InkAPI_8cc.html#a14167888ed89d5b30df5bdcdcfdf1c30>`__
+-  :c:func:`TSMgmtStringGet`
 
 


[16/50] git commit: Fixing comments

Posted by zw...@apache.org.
Fixing comments


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

Branch: refs/heads/5.0.x
Commit: 17579ee72fe2ddef6c69cc8e913d482408a7bc2d
Parents: b639e72
Author: Brian Geffon <br...@apache.org>
Authored: Thu Apr 10 14:21:33 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Thu Apr 10 14:22:22 2014 -0700

----------------------------------------------------------------------
 mgmt/api/include/mgmtapi.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/17579ee7/mgmt/api/include/mgmtapi.h
----------------------------------------------------------------------
diff --git a/mgmt/api/include/mgmtapi.h b/mgmt/api/include/mgmtapi.h
index 786db7f..ef6338b 100644
--- a/mgmt/api/include/mgmtapi.h
+++ b/mgmt/api/include/mgmtapi.h
@@ -48,7 +48,7 @@
 #if defined (__SUNPRO_CC) || (defined (__GNUC__) || ! defined(__cplusplus))
 #if !defined (bool)
 #if !defined(darwin) && !defined(freebsd) && !defined(solaris)
-// XXX: What other platforms are there?
+/* XXX: What other platforms are there? */
 #define bool int
 #endif
 #endif
@@ -62,7 +62,7 @@
 #endif
 
 #endif
-#endif  // not linux
+#endif  /* not linux */
 
 #if !defined (NULL)
 #define NULL 0


[20/50] git commit: Add TS-2711 to CHANGES, this closes #70

Posted by zw...@apache.org.
Add TS-2711 to CHANGES, this closes #70


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

Branch: refs/heads/5.0.x
Commit: ba6d0c760b6b0311e3166c3e444ba40321d73e76
Parents: 61d14d5
Author: Leif Hedstrom <zw...@apache.org>
Authored: Fri Apr 11 15:55:37 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Fri Apr 11 15:55:37 2014 -0600

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ba6d0c76/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 2115ad8..a276d93 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2711] Include Lua JIT as a Submodule.
+
   *) [TS-898] Ensure the cache span probe always closes file descriptors.
 
   *) [TS-2706] Replace the tcp_info plugin config file with options.


[12/50] git commit: TS-2699: Add TSClientProtoStackCreate API

Posted by zw...@apache.org.
TS-2699: Add TSClientProtoStackCreate API

Currently, plugin authors are expected to construct TSClientProtoStack
values by bitshifting them into their correct locations. This is
tedious likely to be error-prone. TSClientProtoStackCreate() accepts
a sequence of TSProtoType values, terminated by a TS_PROTO_NULL.
It combines the values and returns a TSClientProtoStack value that
describes the protocol layering of a client request.


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

Branch: refs/heads/5.0.x
Commit: d80ab011a852733fe33a7d7e212153c98e9560ee
Parents: afd37d2
Author: James Peach <jp...@apache.org>
Authored: Fri Apr 4 20:45:18 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Apr 10 13:00:27 2014 -0700

----------------------------------------------------------------------
 CHANGES                             |  2 ++
 iocore/net/P_ProtocolAcceptCont.h   |  4 ++--
 lib/ts/apidefs.h.in                 |  4 ++--
 plugins/experimental/spdy/stream.cc |  2 +-
 proxy/InkAPI.cc                     | 36 ++++++++++++++++++++++++++++++++
 proxy/InkAPITest.cc                 | 30 +++++++++++++++++++++++++-
 proxy/api/ts/ts.h                   |  3 +++
 proxy/logging/Log.cc                |  2 +-
 8 files changed, 76 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d80ab011/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 4efb31c..6076a4f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2699] Add TSClientProtoStackCreate API.
+
   *) [TS-2678] Some sites (e.g. craigslist) fails to load due to
    incorrect truncated response detection.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d80ab011/iocore/net/P_ProtocolAcceptCont.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_ProtocolAcceptCont.h b/iocore/net/P_ProtocolAcceptCont.h
index 7631e5c..8b25cd8 100644
--- a/iocore/net/P_ProtocolAcceptCont.h
+++ b/iocore/net/P_ProtocolAcceptCont.h
@@ -31,7 +31,7 @@ class ProtocolAcceptCont: public AcceptCont
 public:
   ProtocolAcceptCont(): AcceptCont(NULL)
   {
-    memset(endpoint, 0, TS_PROTO_MAX * sizeof(AcceptCont *));
+    memset(endpoint, 0, sizeof(endpoint));
     SET_HANDLER(&ProtocolAcceptCont::mainEvent);
   }
   ~ProtocolAcceptCont() {}
@@ -44,7 +44,7 @@ private:
   ProtocolAcceptCont(const ProtocolAcceptCont &); // disabled
   ProtocolAcceptCont& operator =(const ProtocolAcceptCont&); // disabled
 
-  Continuation *endpoint[TS_PROTO_MAX];
+  Continuation *endpoint[sizeof(TSClientProtoStack) * CHAR_BIT];
 };
 
 #endif /* P_ProtocolAcceptCont_H_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d80ab011/lib/ts/apidefs.h.in
----------------------------------------------------------------------
diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in
index ffd8cbb..e909821 100644
--- a/lib/ts/apidefs.h.in
+++ b/lib/ts/apidefs.h.in
@@ -116,10 +116,10 @@ extern "C"
     TS_PROTO_HTTP = 12,
     TS_PROTO_SPDY = 13,
     TS_PROTO_RTMP = 14,
-    TS_PROTO_WBSK = 15, /* WebSocket */
+    TS_PROTO_WS   = 15, /* WebSocket */
 
     /* MAX value of TSProtoType  */
-    TS_PROTO_MAX
+    TS_PROTO_NULL = 32
   } TSProtoType;
 
   typedef uint32_t TSClientProtoStack;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d80ab011/plugins/experimental/spdy/stream.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/stream.cc b/plugins/experimental/spdy/stream.cc
index b5a7474..1d6fda9 100644
--- a/plugins/experimental/spdy/stream.cc
+++ b/plugins/experimental/spdy/stream.cc
@@ -71,7 +71,7 @@ initiate_client_request(
 {
     TSReleaseAssert(stream->vconn == nullptr);
 
-    stream->vconn = TSHttpConnect(addr);
+    stream->vconn = TSHttpConnectWithProtoStack(addr, TSClientProtoStackCreate(TS_PROTO_TLS, TS_PROTO_SPDY, TS_PROTO_NULL));
     if (stream->vconn) {
         TSVConnRead(stream->vconn, contp, stream->input.buffer, std::numeric_limits<int64_t>::max());
         TSVConnWrite(stream->vconn, contp, stream->output.reader, std::numeric_limits<int64_t>::max());

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d80ab011/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 2aa4cb5..c9eaf89 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -6048,6 +6048,42 @@ TSHttpAltInfoQualitySet(TSHttpAltInfo infop, float quality)
   info->m_qvalue = quality;
 }
 
+TSClientProtoStack
+TSClientProtoStackCreate(TSProtoType ptype, ...)
+{
+  unsigned  pstack = 0;
+  va_list   args;
+  const int pmax = (sizeof(TSClientProtoStack) * CHAR_BIT) - 1;
+
+  if (ptype == TS_PROTO_NULL || ptype > pmax) {
+    return 0;
+  }
+
+  pstack |= (1u << ptype);
+
+  va_start(args, ptype);
+  for (;;) {
+    ptype = (TSProtoType)va_arg(args, int);
+
+    // TS_PROTO_NULL ends the list.
+    if (ptype == TS_PROTO_NULL) {
+      va_end(args);
+      return pstack;
+    }
+
+    // Protocol stack value is out of range.
+    if (ptype > pmax) {
+      va_end(args);
+      return 0;
+    }
+
+    pstack |= (1u << ptype);
+  }
+
+  // We can't get here.
+  ink_release_assert(0);
+}
+
 extern HttpAcceptCont *plugin_http_accept;
 extern HttpAcceptCont *plugin_http_transparent_accept;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d80ab011/proxy/InkAPITest.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index f380eb5..5541323 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -42,10 +42,11 @@
 #include "api/ts/ts.h"
 #include "api/ts/experimental.h"
 #include "I_RecCore.h"
-#include "I_Layout.h"
+#include <sys/types.h>
 
 #include "InkAPITestTool.cc"
 #include "http/HttpSM.h"
+#include "ts/TestBox.h"
 
 #define TC_PASS 1
 #define TC_FAIL 0
@@ -7664,3 +7665,30 @@ REGRESSION_TEST(SDK_API_DEBUG_NAME_LOOKUPS) (RegressionTest * test, int /* atype
   return;
 }
 
+
+////////////////////////////////////////////////
+// SDK_API_PROTO_STACK_CREATE
+//
+// Unit Test for API: TSClientProtoStackCreate
+////////////////////////////////////////////////
+
+REGRESSION_TEST(SDK_API_TSClientProtoStackCreate)(RegressionTest * t, int /* atype ATS_UNUSED */, int * pstatus)
+{
+  TestBox box(t, pstatus);
+
+  box = REGRESSION_TEST_PASSED;
+
+#define CHECK(expr, expected) do {  \
+  TSClientProtoStack ps = (expr); \
+  box.check(ps == expected, "%s: received %u, expected %u", #expr, (unsigned)ps, (unsigned)expected); \
+} while(0)
+
+ CHECK(TSClientProtoStackCreate(TS_PROTO_NULL), 0);
+ CHECK(TSClientProtoStackCreate((TSProtoType)99, TS_PROTO_NULL), 0);
+ CHECK(TSClientProtoStackCreate(TS_PROTO_SPDY, (TSProtoType)99, TS_PROTO_NULL), 0);
+ CHECK(TSClientProtoStackCreate(TS_PROTO_UDP, TS_PROTO_NULL), 1);
+ CHECK(TSClientProtoStackCreate(TS_PROTO_UDP, TS_PROTO_TCP, TS_PROTO_NULL), 3);
+
+}
+
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d80ab011/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 8279155..8c787b1 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -1576,6 +1576,9 @@ extern "C"
 
   /* --------------------------------------------------------------------------
      Initiate Http Connection */
+
+  tsapi TSClientProtoStack TSClientProtoStackCreate(TSProtoType, ...);
+
   /**
       Allows the plugin to initiate an http connection. The TSVConn the
       plugin receives as the result of successful operates identically to

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d80ab011/proxy/logging/Log.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 8a7d0d5..aeac203 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -375,7 +375,7 @@ Log::init_fields()
                        TS_PROTO_HTTP, "HTTP",
                        TS_PROTO_SPDY, "SPDY",
                        TS_PROTO_RTMP, "RTMP",
-                       TS_PROTO_WBSK, "WBSK");
+                       TS_PROTO_WS,   "WS");
 
   field = NEW(new LogField("client_protocol_stack", "cps",
                            LogField::sINT,


[30/50] git commit: TS-2711 Use the right define to detect Darwin

Posted by zw...@apache.org.
TS-2711 Use the right define to detect Darwin


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

Branch: refs/heads/5.0.x
Commit: b76b23c84ff9b848c4648b651532b70aeed21c50
Parents: f290a71
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 15 10:22:15 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Apr 15 10:22:15 2014 -0600

----------------------------------------------------------------------
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b76b23c8/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 0dacfda..ad8c054 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1419,7 +1419,7 @@ AX_LIB_READLINE
 
 # On Darwin LuaJIT requires magic link options, otherwise it will crash in luaL_openlibs() at startup. See
 # http://luajit.org/install.html.
-case $host_os in
+case $host_os_def in
   darwin)
     LUA_LUAJIT_LDFLAGS="-Wl,-pagezero_size,10000 -Wl,-image_base,100000000"
     ;;


[10/50] git commit: TS-2678: stop inspecting keep alive state to detect truncation

Posted by zw...@apache.org.
TS-2678: stop inspecting keep alive state to detect truncation

When the server session breaks, is_http_server_eos_truncation()
tries to determine whether the response was truncated. If it was
truncated, then we need to propagate that to the client, otherwise
we can just continue on.

is_http_server_eos_truncation() was examining the current server
keepalive state to determine truncation, which is really not relevant
at all. In this case, the server sent a HTTP/1.1 response without
a Content-Length header and closes the connection. This should not
be classed as a truncation.


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

Branch: refs/heads/5.0.x
Commit: 1147bb3ad7369f6e0a27f52b016f2f1829745d11
Parents: 77c5cf3
Author: James Peach <jp...@apache.org>
Authored: Thu Apr 3 15:09:42 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Apr 10 12:39:20 2014 -0700

----------------------------------------------------------------------
 CHANGES              | 3 +++
 proxy/http/HttpSM.cc | 5 -----
 2 files changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1147bb3a/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index dd31b00..4efb31c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2678] Some sites (e.g. craigslist) fails to load due to
+   incorrect truncated response detection.
+
   *) [TS-2603] Do not update HostDB for server intercept requests.
    Author: Quehan <qu...@taobao.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1147bb3a/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index f1fafff..92f7b74 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -2708,11 +2708,6 @@ HttpSM::tunnel_handler(int event, void *data)
 bool
 HttpSM::is_http_server_eos_truncation(HttpTunnelProducer * p)
 {
-  // If we are keep alive, an eos event means we
-  //  did not get all the data
-  if (t_state.current.server->keep_alive == HTTP_KEEPALIVE) {
-    return true;
-  }
 
   if ((p->do_dechunking || p->do_chunked_passthru) && p->chunked_handler.truncation) {
     return true;


[45/50] git commit: Revert typos in ts.h

Posted by zw...@apache.org.
Revert typos in ts.h


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

Branch: refs/heads/5.0.x
Commit: 50d69f19b7e73503033c0db4ef8bfda109f29c1b
Parents: 86453b9
Author: James Peach <jp...@apache.org>
Authored: Wed Apr 16 10:42:16 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Apr 16 10:42:21 2014 -0700

----------------------------------------------------------------------
 proxy/api/ts/ts.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/50d69f19/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 8e0edb4..26dabc5 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -1382,7 +1382,7 @@ extern "C"
   /** Change packet TOS for the server side connection
    *
       
-   note The change takes effect immediately, if no OS connection has been
+      @note The change takes effect immediately, if no OS connection has been
       made, then this sets the mark that will be used IF an OS connection
       is established
       
@@ -1402,7 +1402,6 @@ extern "C"
      string would prevent setting a content type header (but that is not adviced).
 
      @param txnp HTTP transaction whose parent proxy to get.
-     TSError("[tcp_info] TCP metrics are not supported on this platform");
      @param buf The body message (must be heap allocated).
      @param buflength Length of the body message.
      @param mimetype The MIME type to set the response to (can be NULL, but must
@@ -2118,7 +2117,7 @@ extern "C"
 
   /**
       Set the rolling offset. rolling_offset_hr specifies the hour (between 0 and 23) when log rolling
-      shuld take place.
+      should take place.
 
    */
   tsapi void TSTextLogObjectRollingOffsetHrSet(TSTextLogObject the_object, int rolling_offset_hr);


[21/50] git commit: TS-898: fix minor regex_remap parsing bug

Posted by zw...@apache.org.
TS-898: fix minor regex_remap parsing bug

If the line contains only whitespace, don't index into the string.

Coverity #1021882


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

Branch: refs/heads/5.0.x
Commit: c945682e7c746b3036b64527b03b886a2b23dc14
Parents: ba6d0c7
Author: James Peach <jp...@apache.org>
Authored: Sat Apr 12 12:23:01 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Sat Apr 12 12:36:27 2014 -0700

----------------------------------------------------------------------
 CHANGES                            |  2 ++
 plugins/regex_remap/regex_remap.cc | 10 ++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c945682e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index a276d93..8c6e195 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-898] Fix minor regex_remap parsing bug.
+
   *) [TS-2711] Include Lua JIT as a Submodule.
 
   *) [TS-898] Ensure the cache span probe always closes file descriptors.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c945682e/plugins/regex_remap/regex_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index 416f90c..efd3d24 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -733,12 +733,14 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
     if (line.empty()) {
       continue;
     }
-    pos1 = line.find_first_not_of(" \t\n");
-    if (line[pos1] == '#') {
-      continue;  // Skip comment lines
-    }
 
+    pos1 = line.find_first_not_of(" \t\n");
     if (pos1 != std::string::npos) {
+
+      if (line[pos1] == '#') {
+        continue;  // Skip comment lines
+      }
+
       pos2 = line.find_first_of(" \t\n", pos1);
       if (pos2 != std::string::npos) {
         regex = line.substr(pos1, pos2-pos1);


[37/50] git commit: Remove unused PluginVC::is_over_ssl()

Posted by zw...@apache.org.
Remove unused PluginVC::is_over_ssl()


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

Branch: refs/heads/5.0.x
Commit: e2a40e6cccf6f568fe98727c4469ab8e7dcd9cdf
Parents: 4c09fff
Author: James Peach <jp...@apache.org>
Authored: Mon Apr 14 14:47:41 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Tue Apr 15 17:18:10 2014 -0700

----------------------------------------------------------------------
 proxy/PluginVC.h | 5 -----
 1 file changed, 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e2a40e6c/proxy/PluginVC.h
----------------------------------------------------------------------
diff --git a/proxy/PluginVC.h b/proxy/PluginVC.h
index 83277de..d770de5 100644
--- a/proxy/PluginVC.h
+++ b/proxy/PluginVC.h
@@ -87,11 +87,6 @@ public:
 
   virtual VIO *do_io_write(Continuation * c = NULL, int64_t nbytes = INT64_MAX, IOBufferReader * buf = 0, bool owner = false);
 
-  virtual bool is_over_ssl()
-  {
-    return (false);
-  }
-
   virtual void do_io_close(int lerrno = -1);
   virtual void do_io_shutdown(ShutdownHowTo_t howto);
 


[43/50] git commit: TS-2708: refactor and modernize the tcp_info plugin

Posted by zw...@apache.org.
TS-2708: refactor and modernize the tcp_info plugin

Always build the tcp_info plugin, even if it doesn't end up doing
anything useful on the build platform. This is convenient for
development.

Only sample and log TCP metrics after it passes the sample threshold
to reduce unnecessary work.

Add IPv6 support. Use TS*Assert instead of assert. Remove the Config
global variable. Add a txn_close hook.

Use the text logging API rather than writing custom logs.


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

Branch: refs/heads/5.0.x
Commit: d461c33e2050905bce86dc1eba59665ee879754b
Parents: bf16745
Author: James Peach <jp...@apache.org>
Authored: Fri Apr 11 13:33:46 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Apr 16 10:29:03 2014 -0700

----------------------------------------------------------------------
 CHANGES                                   |   2 +
 configure.ac                              |  10 +-
 plugins/experimental/tcp_info/Makefile.am |   4 -
 plugins/experimental/tcp_info/tcp_info.cc | 268 +++++++++++++++----------
 proxy/api/ts/ts.h                         |   7 +-
 5 files changed, 180 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d461c33e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index f578673..932f614 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2708] Refactor and modernize the tcp_info plugin.
+
   *) [TS-2555] Adding global plugin support to ts_lua plugin.
 
   *) [TS-2717] header-rewrite set-redirect not working.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d461c33e/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index ad8c054..2a19d01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1801,11 +1801,13 @@ TS_CHECK_GETHOSTBYNAME_R_STYLE
 TS_CHECK_MACRO_IN6_IS_ADDR_UNSPECIFIED
 
 AC_CHECK_TYPE([struct tcp_info],
-  [enable_tcpinfo_plugin=yes],
-  [enable_tcpinfo_plugin=no],
-  [[#include <netinet/tcp.h>]]
+  [AC_DEFINE(HAVE_STRUCT_TCP_INFO, 1, [whether struct tcp_info is available])],
+  [],
+  [[
+   #include <netinet/in.h>
+   #include <netinet/tcp.h>
+  ]]
 )
-AM_CONDITIONAL([BUILD_TCPINFO_PLUGIN], [ test "x${enable_tcpinfo_plugin}" != "xno" ])
 
 # See if we can build the remap_stats plugin
 AS_IF([test "x$enable_experimental_plugins" = xyes],

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d461c33e/plugins/experimental/tcp_info/Makefile.am
----------------------------------------------------------------------
diff --git a/plugins/experimental/tcp_info/Makefile.am b/plugins/experimental/tcp_info/Makefile.am
index 7e6e5f1..daabefd 100644
--- a/plugins/experimental/tcp_info/Makefile.am
+++ b/plugins/experimental/tcp_info/Makefile.am
@@ -16,11 +16,7 @@
 
 include $(top_srcdir)/build/plugins.mk
 
-if BUILD_TCPINFO_PLUGIN
-
 pkglib_LTLIBRARIES = tcp_info.la
 tcp_info_la_SOURCES = tcp_info.cc
 tcp_info_la_LDFLAGS = $(TS_PLUGIN_LDFLAGS)
 
-endif
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d461c33e/plugins/experimental/tcp_info/tcp_info.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/tcp_info/tcp_info.cc b/plugins/experimental/tcp_info/tcp_info.cc
index 7835039..e828ded 100644
--- a/plugins/experimental/tcp_info/tcp_info.cc
+++ b/plugins/experimental/tcp_info/tcp_info.cc
@@ -27,102 +27,176 @@
 #include <unistd.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
-#include <assert.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <getopt.h>
 #include <fcntl.h>
 #include <limits.h>
 #include <string.h>
+#include <errno.h>
 #include <sys/time.h>
 #include <arpa/inet.h>
 
+#include "ink_defs.h"
+
+#if defined(TCP_INFO) && defined(HAVE_STRUCT_TCP_INFO)
+#define TCPI_PLUGIN_SUPPORTED 1
+#endif
+
 #define TCPI_HOOK_SSN_START     0x01u
 #define TCPI_HOOK_TXN_START     0x02u
 #define TCPI_HOOK_SEND_RESPONSE 0x04u
 #define TCPI_HOOK_SSN_CLOSE     0x08u
+#define TCPI_HOOK_TXN_CLOSE     0x10u
+
+// Log format headers. These are emitted once at the start of a log file. Note that we
+// carefully order the fields so the field ordering is compatible. This lets you change
+// the verbosity without breaking a perser that is moderately robust.
+static const char * tcpi_headers[] = {
+  "timestamp event client server rtt",
+  "timestamp event client server rtt rttvar last_sent last_recv "
+    "snd_ssthresh rcv_ssthresh unacked sacked lost retrans fackets",
+};
 
 struct Config {
   int sample;
-  const char* log_file;
-  int log_fd;
-  int log_level;
+  unsigned log_level;
+  TSTextLogObject log;
+
+  Config() : sample(1000), log_level(1), log(NULL) {
+  }
+
+  ~Config() {
+    if (log) {
+      TSTextLogObjectDestroy(log);
+    }
+  }
 };
 
-static Config config;
+union const_sockaddr_ptr {
+  const struct sockaddr * sa;
+  const struct sockaddr_in * in;
+  const struct sockaddr_in6 * in6;
+
+  const void * addr() const {
+    switch (sa->sa_family) {
+    case AF_INET: return &(in->sin_addr);
+    case AF_INET6: return &(in6->sin6_addr);
+    default: return NULL;
+    }
+  }
+
+};
+
+#if TCPI_PLUGIN_SUPPORTED
 
 static void
-log_tcp_info(const char* event_name, const char* client_ip, const char* server_ip, struct tcp_info &info) {
-  char buffer[256];
+log_tcp_info(Config * config, const char * event_name, TSHttpSsn ssnp)
+{
+  char                client_str[INET6_ADDRSTRLEN];
+  char                server_str[INET6_ADDRSTRLEN];
+  const_sockaddr_ptr  client_addr;
+  const_sockaddr_ptr  server_addr;
+
+  struct tcp_info     info;
+  socklen_t           tcp_info_len = sizeof(info);
+  int                 fd;
 
-  // get the current time
-  struct timeval now;
-  gettimeofday(&now, NULL);
+  TSReleaseAssert(config->log != NULL);
 
-  int bytes = 0;
-  if (config.log_level == 2) {
+  if (TSHttpSsnClientFdGet(ssnp, &fd) != TS_SUCCESS) {
+    TSDebug("tcp_info", "error getting the client socket fd");
+    return;
+  }
+
+  if (getsockopt(fd, IPPROTO_TCP, TCP_INFO, &info, &tcp_info_len) != 0) {
+    TSDebug("tcp_info", "getsockopt(%d, TCP_INFO) failed: %s", fd, strerror(errno));
+    return;
+  }
+
+  client_addr.sa = TSHttpSsnClientAddrGet(ssnp);
+  server_addr.sa = TSHttpSsnIncomingAddrGet(ssnp);
+
+  if (client_addr.sa == NULL || server_addr.sa == NULL) {
+    return;
+  }
+
+  // convert ip to string
+  inet_ntop(client_addr.sa->sa_family, client_addr.addr(), client_str, sizeof(client_str));
+  inet_ntop(server_addr.sa->sa_family, server_addr.addr(), server_str, sizeof(server_str));
+
+  TSReturnCode ret;
+
+  if (config->log_level == 2) {
 #if !defined(freebsd) || defined(__GLIBC__)
-    bytes = snprintf(buffer, sizeof(buffer), "%s %u %u %s %s %u %u %u %u %u %u %u %u %u %u %u %u\n",
+    ret = TSTextLogObjectWrite(config->log, "%s %s %s %u %u %u %u %u %u %u %u %u %u %u %u",
                      event_name,
-                     (uint32_t)now.tv_sec,
-                     (uint32_t)now.tv_usec,
-                     client_ip,
-                     server_ip,
+                     client_str,
+                     server_str,
+                     info.tcpi_rtt,
+                     info.tcpi_rttvar,
                      info.tcpi_last_data_sent,
                      info.tcpi_last_data_recv,
                      info.tcpi_snd_cwnd,
                      info.tcpi_snd_ssthresh,
                      info.tcpi_rcv_ssthresh,
-                     info.tcpi_rtt,
-                     info.tcpi_rttvar,
                      info.tcpi_unacked,
                      info.tcpi_sacked,
                      info.tcpi_lost,
                      info.tcpi_retrans,
-                     info.tcpi_fackets
-      );
+                     info.tcpi_fackets);
 #else
-        bytes = snprintf(buffer, sizeof(buffer), "%s %u %u %s %s %u %u %u %u %u %u %u %u %u %u %u %u\n",
+    ret = TSTextLogObjectWrite(config->log, "%s %s %s %u %u %u %u %u %u %u %u %u %u %u %u",
                      event_name,
-                     (uint32_t)now.tv_sec,
-                     (uint32_t)now.tv_usec,
-                     client_ip,
-                     server_ip,
+                     client_str,
+                     server_str,
+                     info.tcpi_rtt,
+                     info.tcpi_rttvar,
                      info.__tcpi_last_data_sent,
                      info.tcpi_last_data_recv,
                      info.tcpi_snd_cwnd,
                      info.tcpi_snd_ssthresh,
                      info.__tcpi_rcv_ssthresh,
-                     info.tcpi_rtt,
-                     info.tcpi_rttvar,
                      info.__tcpi_unacked,
                      info.__tcpi_sacked,
                      info.__tcpi_lost,
                      info.__tcpi_retrans,
-                     info.__tcpi_fackets
-      );
+                     info.__tcpi_fackets);
 #endif
   } else {
-    bytes = snprintf(buffer, sizeof(buffer), "%s %u %s %s %u\n",
+    ret = TSTextLogObjectWrite(config->log, "%s %s %s %u",
                      event_name,
-                     (uint32_t)now.tv_sec,
-                     client_ip,
-                     server_ip,
-                     info.tcpi_rtt
-    );
+                     client_str,
+                     server_str,
+                     info.tcpi_rtt);
+  }
+
+  // It's really not clear how we should handle logging failures. It a failure transient
+  // or persistent? Should we try to re-open the logs? How frequently should we do that?
+  if (ret != TS_SUCCESS) {
+    TSError("[tcp_info] log write failed, disabling logging");
+    TSTextLogObjectDestroy(config->log);
+    config->log = NULL;
   }
+}
 
-  ssize_t wrote = write(config.log_fd, buffer, bytes);
-  assert(wrote == bytes);
-  TSDebug("tcp_info", "wrote: %d bytes to file: %s", bytes, config.log_file);
-  TSDebug("tcp_info", "logging: %s", buffer);
+#else /* TCPI_PLUGIN_SUPPORTED */
+
+static void
+log_tcp_info(Config * /* config */, const char * /* event_name */, TSHttpSsn /* ssnp */)
+{
+  return; // TCP metrics not supported.
 }
 
+#endif /* TCPI_PLUGIN_SUPPORTED */
+
 static int
-tcp_info_hook(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
+tcp_info_hook(TSCont contp, TSEvent event, void *edata)
 {
   TSHttpSsn ssnp = NULL;
   TSHttpTxn txnp = NULL;
+  int       random = 0;
+  Config *  config = (Config *)TSContDataGet(contp);
 
   const char *event_name;
   switch (event) {
@@ -147,52 +221,22 @@ tcp_info_hook(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
     return 0;
   }
 
-  TSDebug("tcp_info", "tcp_info_hook called, event: %s", event_name);
+  TSDebug("tcp_info", "logging hook called for %s (%s) with log object %p",
+      TSHttpEventNameLookup(event), event_name, config->log);
 
-  struct tcp_info tcp_info;
-  int tcp_info_len = sizeof(tcp_info);
-  int fd;
-
-  if (TSHttpSsnClientFdGet(ssnp, &fd) != TS_SUCCESS) {
-    TSDebug("tcp_info", "error getting the client socket fd");
+  if (config->log == NULL) {
     goto done;
   }
 
-  // get the tcp info structure
-  if (getsockopt(fd, IPPROTO_TCP, TCP_INFO, (void *)&tcp_info, (socklen_t *)&tcp_info_len) == 0) {
-    // the structure is the correct size
-    if (tcp_info_len == sizeof(tcp_info)) {
-      // no need to run rand if we are always going log (100%)
-      int random = 0;
-      if (config.sample < 1000) {
-        random = rand() % 1000;
-        TSDebug("tcp_info", "random: %d, config.sample: %d", random, config.sample);
-      }
-
-      if (random < config.sample) {
-        TSDebug("tcp_info", "got the tcp_info struture and now logging");
-
-        // get the client address
-        const struct sockaddr *client_addr = TSHttpSsnClientAddrGet(ssnp);
-        const struct sockaddr *server_addr = TSHttpSsnIncomingAddrGet(ssnp);
-        if (client_addr == NULL || server_addr == NULL)
-          goto done;
-        struct sockaddr_in *client_in_addr = (struct sockaddr_in *)client_addr;
-        struct sockaddr_in *server_in_addr = (struct sockaddr_in *)server_addr;
-        char client_str[INET_ADDRSTRLEN];
-        char server_str[INET_ADDRSTRLEN];
-
-        // convert ip to string
-        inet_ntop(client_addr->sa_family, &(client_in_addr->sin_addr), client_str, INET_ADDRSTRLEN);
-        inet_ntop(server_addr->sa_family, &(server_in_addr->sin_addr), server_str, INET_ADDRSTRLEN);
+  // no need to run rand if we are always going log (100%)
+  if (config->sample < 1000) {
+    random = rand() % 1000;
+    TSDebug("tcp_info", "random: %d, config->sample: %d", random, config->sample);
+  }
 
-        log_tcp_info(event_name, client_str, server_str, tcp_info);
-      }
-    } else {
-      TSDebug("tcp_info", "tcp_info length is the wrong size");
-    }
-  } else {
-    TSDebug("tcp_info", "error calling getsockopt()");
+  if (random < config->sample) {
+    TSDebug("tcp_info", "sampling TCP metrics for %s event", event_name);
+    log_tcp_info(config, event_name, ssnp);
   }
 
 done:
@@ -201,7 +245,8 @@ done:
   } else if (ssnp != NULL) {
     TSHttpSsnReenable(ssnp, TS_EVENT_HTTP_CONTINUE);
   }
-  return 0;
+
+  return TS_EVENT_NONE;
 }
 
 static bool
@@ -241,6 +286,7 @@ parse_hook_list(const char * hook_list)
     { "txn_start", TCPI_HOOK_TXN_START },
     { "send_resp_hdr", TCPI_HOOK_SEND_RESPONSE },
     { "ssn_close", TCPI_HOOK_SSN_CLOSE },
+    { "txn_close", TCPI_HOOK_TXN_CLOSE },
     { NULL, 0u }
   };
 
@@ -279,7 +325,10 @@ TSPluginInit(int argc, const char * argv[])
   };
 
   TSPluginRegistrationInfo info;
-  unsigned hooks = 0;
+  Config *  config = new Config();
+  const char *  filename = "tcp_info";
+  TSCont    cont;
+  unsigned  hooks = 0;
 
   info.plugin_name = (char*)"tcp_info";
   info.vendor_name = (char*)"Apache Software Foundation";
@@ -289,10 +338,6 @@ TSPluginInit(int argc, const char * argv[])
     TSError("tcp_info: plugin registration failed");
   }
 
-  config.sample = 1000;
-  config.log_level = 1;
-  config.log_file = NULL;
-
   optind = 0;
   for (;;) {
     unsigned long lval;
@@ -300,17 +345,17 @@ TSPluginInit(int argc, const char * argv[])
     switch (getopt_long(argc, (char * const *)argv, "r:f:l:h:", longopts, NULL)) {
     case 'r':
       if (parse_unsigned(optarg, lval)) {
-        config.sample = atoi(optarg);
+        config->sample = atoi(optarg);
       } else {
         TSError("[tcp_info] invalid sample rate '%s'", optarg);
       }
       break;
     case 'f':
-      config.log_file = optarg;
+      filename = optarg;
       break;
     case 'l':
-      if (parse_unsigned(optarg, lval) && (lval == 1 || lval == 2)) {
-        config.log_level = atoi(optarg);
+      if (parse_unsigned(optarg, lval) && (lval <= countof(tcpi_headers))) {
+        config->log_level = lval;
       } else {
         TSError("[tcp_info] invalid log level '%s'", optarg);
       }
@@ -327,32 +372,53 @@ TSPluginInit(int argc, const char * argv[])
 
 init:
 
-  TSDebug("tcp_info", "sample: %d", config.sample);
-  TSDebug("tcp_info", "log filename: %s", config.log_file);
-  TSDebug("tcp_info", "log_level: %d", config.log_level);
+#if !TCPI_PLUGIN_SUPPORTED
+  TSError("[tcp_info] TCP metrics are not supported on this platform");
+#endif
+
+  TSDebug("tcp_info", "sample: %d", config->sample);
+  TSDebug("tcp_info", "log filename: %s", filename);
+  TSDebug("tcp_info", "log_level: %u", config->log_level);
   TSDebug("tcp_info", "hook mask: 0x%x", hooks);
 
-  config.log_fd = open(config.log_file, O_APPEND | O_CREAT | O_RDWR, 0666);
-  assert(config.log_fd > 0);
+  if (TSTextLogObjectCreate(filename, TS_LOG_MODE_ADD_TIMESTAMP, &config->log) != TS_SUCCESS) {
+    TSError("[tcp_info] failed to create log file '%s'", filename);
+    delete config;
+    return;
+  }
+
+  TSTextLogObjectHeaderSet(config->log, tcpi_headers[config->log_level - 1]);
+
+  // Enable log rolling. Unless we specify an explicit rolling period, the log will
+  // be rolled based on the size specified in proxy.config.log.rolling_size_mb.
+  TSTextLogObjectRollingEnabledSet(config->log, 1 /* rolling_enabled */);
+
+  cont = TSContCreate(tcp_info_hook, NULL);
+  TSContDataSet(cont, config);
 
   if (hooks & TCPI_HOOK_SSN_START) {
-    TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, TSContCreate(tcp_info_hook, NULL));
+    TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, cont);
     TSDebug("tcp_info", "added hook to the start of the TCP connection");
   }
 
   if (hooks & TCPI_HOOK_TXN_START) {
-    TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, TSContCreate(tcp_info_hook, NULL));
+    TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, cont);
     TSDebug("tcp_info", "added hook to the close of the transaction");
   }
 
   if (hooks & TCPI_HOOK_SEND_RESPONSE) {
-    TSHttpHookAdd(TS_HTTP_SEND_RESPONSE_HDR_HOOK, TSContCreate(tcp_info_hook, NULL));
+    TSHttpHookAdd(TS_HTTP_SEND_RESPONSE_HDR_HOOK, cont);
     TSDebug("tcp_info", "added hook to the sending of the headers");
   }
 
   if (hooks & TCPI_HOOK_SSN_CLOSE) {
-    TSHttpHookAdd(TS_HTTP_SSN_CLOSE_HOOK, TSContCreate(tcp_info_hook, NULL));
+    TSHttpHookAdd(TS_HTTP_SSN_CLOSE_HOOK, cont);
     TSDebug("tcp_info", "added hook to the close of the TCP connection");
   }
 
+  if (hooks & TCPI_HOOK_TXN_CLOSE) {
+    TSHttpHookAdd(TS_HTTP_TXN_CLOSE_HOOK, cont);
+    TSDebug("tcp_info", "added hook to the close of the transaction");
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d461c33e/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 3dce82f..8e0edb4 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -1381,7 +1381,8 @@ extern "C"
   
   /** Change packet TOS for the server side connection
    *
-      @note The change takes effect immediately, if no OS connection has been
+      
+   note The change takes effect immediately, if no OS connection has been
       made, then this sets the mark that will be used IF an OS connection
       is established
       
@@ -1401,6 +1402,7 @@ extern "C"
      string would prevent setting a content type header (but that is not adviced).
 
      @param txnp HTTP transaction whose parent proxy to get.
+     TSError("[tcp_info] TCP metrics are not supported on this platform");
      @param buf The body message (must be heap allocated).
      @param buflength Length of the body message.
      @param mimetype The MIME type to set the response to (can be NULL, but must
@@ -2115,7 +2117,8 @@ extern "C"
   tsapi void TSTextLogObjectRollingIntervalSecSet(TSTextLogObject the_object, int rolling_interval_sec);
 
   /**
-      Set the rolling offset.
+      Set the rolling offset. rolling_offset_hr specifies the hour (between 0 and 23) when log rolling
+      shuld take place.
 
    */
   tsapi void TSTextLogObjectRollingOffsetHrSet(TSTextLogObject the_object, int rolling_offset_hr);


[04/50] git commit: TS-2690 Make the escalate plugin support URL and Host redirects

Posted by zw...@apache.org.
TS-2690 Make the escalate plugin support URL and Host redirects

TS-2690 Support multiple status codes for each rule, e.g. 403,404:


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

Branch: refs/heads/5.0.x
Commit: 4b6c8e022de1b20371c334eec77d2ebd7c733ee2
Parents: a7b7d5f
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed Apr 9 13:29:23 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Apr 10 06:50:21 2014 -0600

----------------------------------------------------------------------
 plugins/experimental/escalate/escalate.cc | 172 +++++++++++++++----------
 proxy/InkAPI.cc                           |   2 +-
 2 files changed, 108 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b6c8e02/plugins/experimental/escalate/escalate.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/escalate/escalate.cc b/plugins/experimental/escalate/escalate.cc
index 2f71041..6768a70 100644
--- a/plugins/experimental/escalate/escalate.cc
+++ b/plugins/experimental/escalate/escalate.cc
@@ -1,6 +1,6 @@
 /** @file
 
-  Escalation plugin.
+  This plugin allows retrying requests against different destinations.
 
   @section license License
 
@@ -20,7 +20,6 @@
   See the License for the specific language governing permissions and
   limitations under the License.
  */
-
 #include <ts/ts.h>
 #include <ts/remap.h>
 #include <ts/experimental.h>
@@ -32,94 +31,123 @@
 #include <map>
 
 
-// Constants
+// Constants and some declarations
 const char PLUGIN_NAME[] = "escalate";
-
-
 static int EscalateResponse(TSCont, TSEvent, void *);
 
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Hold information about the escalation / retry states for a remap rule.
+//
 struct EscalationState
 {
-  typedef std::map<unsigned, std::string> hostmap_type;
+  enum RetryType {
+    RETRY_URL,
+    RETRY_HOST
+  };
+
+  struct RetryInfo
+  {
+    RetryType type;
+    std::string target;
+  };
+
+  typedef std::map<unsigned, RetryInfo*> StatusMapType;
 
   EscalationState()
   {
-    handler = TSContCreate(EscalateResponse, NULL);
-    TSContDataSet(handler, this);
+    cont = TSContCreate(EscalateResponse, NULL);
+    TSContDataSet(cont, this);
   }
 
   ~EscalationState()
   {
-    TSContDestroy(handler);
+    for (StatusMapType::iterator iter = status_map.begin(); iter != status_map.end(); ++iter) {
+      delete(iter->second);
+    }
+    TSContDestroy(cont);
   }
 
-  TSCont       handler;
-  hostmap_type hostmap;
+  TSCont cont;
+  StatusMapType status_map;
 };
 
 
+//////////////////////////////////////////////////////////////////////////////////////////
+// Main continuation for the plugin, examining an origin response for a potential retry.
+//
 static int
 EscalateResponse(TSCont cont, TSEvent event, void* edata)
 {
+  TSHttpTxn txn = (TSHttpTxn)edata;
   EscalationState* es = static_cast<EscalationState*>(TSContDataGet(cont));
-  TSHttpTxn        txn = (TSHttpTxn)edata;
-  TSMBuffer        response;
-  TSMLoc           resp_hdr;
+  EscalationState::StatusMapType::iterator entry;
+  TSMBuffer mbuf;
+  TSMLoc hdrp, url;
+  TSHttpStatus status;
+  char* url_str = NULL;
+  int url_len, tries;
 
-  TSReleaseAssert(event == TS_EVENT_HTTP_READ_RESPONSE_HDR);
+  TSAssert(event == TS_EVENT_HTTP_READ_RESPONSE_HDR);
 
   // First, we need the server response ...
-  if (TS_SUCCESS == TSHttpTxnServerRespGet(txn, &response, &resp_hdr)) {
-    int tries = TSHttpTxnRedirectRetries(txn);
-
-    TSDebug(PLUGIN_NAME, "This is try %d", tries);
-    if (0 == tries) { // ToDo: Future support for more than one retry-URL
-      // Next, the response status ...
-      TSHttpStatus status = TSHttpHdrStatusGet(response, resp_hdr);
-
-      // If we have an escalation URL for this response code, set the redirection URL and force it
-      // to be followed.
-      EscalationState::hostmap_type::iterator entry = es->hostmap.find((unsigned)status);
-
-      if (entry != es->hostmap.end()) {
-        TSMBuffer request;
-        TSMLoc    req_hdr;
-
-        TSDebug(PLUGIN_NAME, "Found an entry for HTTP status %u", (unsigned)status);
-        if (TS_SUCCESS == TSHttpTxnClientReqGet(txn, &request, &req_hdr)) {
-          TSMLoc url;
-
-          if (TS_SUCCESS == TSHttpHdrUrlGet(request, req_hdr, &url)) {
-            char* url_str;
-            int url_len;
-
-            // Update the request URL with the new Host to try.
-            TSUrlHostSet(request, url, entry->second.c_str(), entry->second.size());
-            url_str = TSUrlStringGet(request, url, &url_len);
-
-            TSDebug(PLUGIN_NAME, "Setting new URL to %.*s", url_len, url_str);
-            TSHttpTxnRedirectUrlSet(txn, url_str, url_len); // Transfers ownership
-          }
-          // Release the request MLoc
-        TSHandleMLocRelease(request, TS_NULL_MLOC, req_hdr);
-        }
+  if (TS_SUCCESS != TSHttpTxnServerRespGet(txn, &mbuf, &hdrp)) {
+    goto no_action;
+  }
+
+  tries = TSHttpTxnRedirectRetries(txn);
+  if (0 != tries) { // ToDo: Future support for more than one retry-URL
+    goto no_action;
+  }
+  TSDebug(PLUGIN_NAME, "This is try %d, proceeding", tries);
+
+  // Next, the response status ...
+  status = TSHttpHdrStatusGet(mbuf, hdrp);
+  TSHandleMLocRelease(mbuf, TS_NULL_MLOC, hdrp);  // Don't need this any more
+
+  // See if we have an escalation retry config for this response code
+  entry  = es->status_map.find((unsigned)status);
+  if (entry == es->status_map.end()) {
+    goto no_action;
+  }
+
+  TSDebug(PLUGIN_NAME, "Found an entry for HTTP status %u", (unsigned)status);
+  if (EscalationState::RETRY_URL == entry->second->type) {
+    url_str = TSstrdup(entry->second->target.c_str());
+    url_len = entry->second->target.size();
+    TSDebug(PLUGIN_NAME, "Setting new URL to %.*s", url_len, url_str);
+  } else if (EscalationState::RETRY_HOST == entry->second->type) {
+    if (TS_SUCCESS == TSHttpTxnClientReqGet(txn, &mbuf, &hdrp)) {
+      if (TS_SUCCESS == TSHttpHdrUrlGet(mbuf, hdrp, &url)) {
+        // Update the request URL with the new Host to try.
+        TSUrlHostSet(mbuf, url, entry->second->target.c_str(), entry->second->target.size());
+        url_str = TSUrlStringGet(mbuf, url, &url_len);
+        TSDebug(PLUGIN_NAME, "Setting new Host: to %.*s", url_len, url_str);
       }
+      // Release the request MLoc
+      TSHandleMLocRelease(mbuf, TS_NULL_MLOC, hdrp);
     }
-    // Release the response MLoc
-    TSHandleMLocRelease(response, TS_NULL_MLOC, resp_hdr);
+  }
+
+  // Now update the Redirect URL, if set
+  if (url_str) {
+    TSHttpTxnRedirectUrlSet(txn, url_str, url_len); // Transfers ownership
   }
 
   // Set the transaction free ...
+ no_action:
   TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
   return TS_EVENT_NONE;
 }
 
+
 TSReturnCode
 TSRemapInit(TSRemapInterface* /* api */, char* /* errbuf */, int /* bufsz */)
 {
   return TS_SUCCESS;
 }
 
+
 TSReturnCode
 TSRemapNewInstance(int argc, char* argv[], void** instance, char* errbuf, int errbuf_size)
 {
@@ -128,29 +156,41 @@ TSRemapNewInstance(int argc, char* argv[], void** instance, char* errbuf, int er
   // The first two arguments are the "from" and "to" URL string. We can just
   // skip those, since we only ever remap on the error path.
   for (int i = 2; i < argc; ++i) {
-    unsigned status;
-    char*    sep;
+    char *sep, *token, *save;
 
     // Each token should be a status code then a URL, separated by ':'.
     sep = strchr(argv[i], ':');
     if (sep == NULL) {
-      snprintf(errbuf, errbuf_size, "missing status code: %s", argv[i]);
+      snprintf(errbuf, errbuf_size, "malformed status:target config: %s", argv[i]);
       goto fail;
     }
 
     *sep = '\0';
-    status = strtol(argv[i], NULL, 10);
+    ++sep; // Skip over the ':' (which is now \0)
 
-    if (status < 100 || status > 599) {
-      snprintf(errbuf, errbuf_size, "invalid status code: %.*s", (int)std::distance(argv[i], sep), argv[i]);
-      goto fail;
+    // OK, we have a valid status/URL pair.
+    EscalationState::RetryInfo* info = new EscalationState::RetryInfo();
+
+    info->target = sep;
+    if (std::string::npos != info->target.find('/')) {
+      info->type = EscalationState::RETRY_URL;
+      TSDebug(PLUGIN_NAME, "Creating Redirect rule with URL = %s", sep);
+    } else {
+      info->type = EscalationState::RETRY_HOST;
+      TSDebug(PLUGIN_NAME, "Creating Redirect rule with Host = %s", sep);
     }
 
-    ++sep; // Skip over the ':'
+    for (token = strtok_r(argv[i], ",", &save); token; token = strtok_r(NULL, ",", &save)) {
+      unsigned status = strtol(token, NULL, 10);
 
-    // OK, we have a valid status/URL pair.
-    TSDebug(PLUGIN_NAME, "Redirect of HTTP status %u to %s", status, sep);
-    es->hostmap[status] = sep;
+      if (status < 100 || status > 599) {
+        snprintf(errbuf, errbuf_size, "invalid status code: %.*s", (int)std::distance(argv[i], sep), argv[i]);
+        goto fail;
+      }
+
+      TSDebug(PLUGIN_NAME, "      added status = %d to rule", status);
+      es->status_map[status] = info;
+    }
   }
 
   *instance = es;
@@ -161,17 +201,19 @@ fail:
   return TS_ERROR;
 }
 
+
 void
 TSRemapDeleteInstance(void* instance)
 {
-  delete (EscalationState *)instance;
+  delete static_cast<EscalationState*>(instance);
 }
 
+
 TSRemapStatus
 TSRemapDoRemap(void* instance, TSHttpTxn txn, TSRemapRequestInfo* /* rri */)
 {
-  EscalationState* es = static_cast<EscalationState *>(instance);
+  EscalationState* es = static_cast<EscalationState*>(instance);
 
-  TSHttpTxnHookAdd(txn, TS_HTTP_READ_RESPONSE_HDR_HOOK, es->handler);
+  TSHttpTxnHookAdd(txn, TS_HTTP_READ_RESPONSE_HDR_HOOK, es->cont);
   return TSREMAP_NO_REMAP;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4b6c8e02/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index cc4c4dd..2aa4cb5 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7129,7 +7129,7 @@ TSHttpTxnRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len)
   HttpSM *sm = (HttpSM*) txnp;
 
   if (sm->redirect_url != NULL) {
-    ats_free((void*)sm->redirect_url);
+    ats_free(sm->redirect_url);
     sm->redirect_url = NULL;
     sm->redirect_url_len = 0;
   }


[02/50] git commit: TS-2603: Do not update hostdb if intercept exists

Posted by zw...@apache.org.
TS-2603: Do not update hostdb if intercept exists

We should not update hostdb if a HttpSM was intercepted, as the
HttpSM did not really connect to the origin server.  Otherwise we
may set the hostdb address to zero if timeout occurs.

Signed-off-by: Quehan <qu...@taobao.com>


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

Branch: refs/heads/5.0.x
Commit: 2ab1bb6ac56469e212148f665c9db7b725183a7b
Parents: 8aa3af9
Author: Quehan <qu...@taobao.com>
Authored: Sat Mar 1 20:07:48 2014 +0800
Committer: James Peach <jp...@apache.org>
Committed: Wed Apr 9 16:32:46 2014 -0700

----------------------------------------------------------------------
 CHANGES              | 3 +++
 proxy/http/HttpSM.cc | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ab1bb6a/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 010a6e4..dd31b00 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2603] Do not update HostDB for server intercept requests.
+   Author: Quehan <qu...@taobao.com>
+
   *) [TS-2622] Optimize the ink_cluster_time() function.
    Author: Yu Qing <zh...@taobao.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ab1bb6a/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 80c5d78..36135be 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -3926,7 +3926,7 @@ HttpSM::do_hostdb_update_if_necessary()
 {
   int issue_update = 0;
 
-  if (t_state.current.server == NULL) {
+  if (t_state.current.server == NULL || plugin_tunnel_type != HTTP_NO_PLUGIN_TUNNEL) {
     // No server, so update is not necessary
     return;
   }


[19/50] git commit: Add luajit submodule (luajit 2.0.3)

Posted by zw...@apache.org.
Add luajit submodule (luajit 2.0.3)


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

Branch: refs/heads/5.0.x
Commit: 61d14d5dbc2d68233d8a221f80064d1dbf5e6694
Parents: b514248
Author: Ask Bjørn Hansen <as...@apache.org>
Authored: Fri Apr 11 15:38:10 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Fri Apr 11 15:46:14 2014 -0600

----------------------------------------------------------------------
 .gitmodules | 3 +++
 lib/luajit  | 1 +
 2 files changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/61d14d5d/.gitmodules
----------------------------------------------------------------------
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..2111b7d
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "lib/luajit"]
+	path = lib/luajit
+	url = http://luajit.org/git/luajit-2.0.git

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/61d14d5d/lib/luajit
----------------------------------------------------------------------
diff --git a/lib/luajit b/lib/luajit
new file mode 160000
index 0000000..880ca30
--- /dev/null
+++ b/lib/luajit
@@ -0,0 +1 @@
+Subproject commit 880ca300e8fb7b432b9d25ed377db2102e4cb63d


[31/50] git commit: TS-2717 header-rewrite set-redirect not working

Posted by zw...@apache.org.
TS-2717 header-rewrite set-redirect not working


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

Branch: refs/heads/5.0.x
Commit: 9b236f1247289fc46ecb1cd2511e7a477a921138
Parents: b76b23c
Author: Igor Brezac <ig...@ypass.net>
Authored: Tue Apr 15 10:34:19 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Apr 15 10:34:19 2014 -0600

----------------------------------------------------------------------
 plugins/header_rewrite/operators.cc | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9b236f12/plugins/header_rewrite/operators.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/operators.cc b/plugins/header_rewrite/operators.cc
index 7b3beb5..e22ab51 100644
--- a/plugins/header_rewrite/operators.cc
+++ b/plugins/header_rewrite/operators.cc
@@ -298,6 +298,9 @@ OperatorSetRedirect::exec(const Resources& res) const
       }
 
       TSHttpTxnSetHttpRetStatus(res.txnp,(TSHttpStatus)_status.get_int_value());
+      const_cast<Resources&>(res).changed_url = true;
+      res._rri->redirect = 1;
+
       //TSHttpHdrStatusSet(res.bufp, res.hdr_loc, (TSHttpStatus)_status.get_int_value());
       const char *start = value.c_str();
       const char *end = value.size() + start;


[40/50] git commit: TS-2555 Add to CHANGES

Posted by zw...@apache.org.
TS-2555 Add to CHANGES


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

Branch: refs/heads/5.0.x
Commit: e350291161f291ddcd70442edcbf2f916cb232d3
Parents: 904e1f7
Author: Kit Chan <ki...@apache.org>
Authored: Tue Apr 15 23:02:46 2014 -0700
Committer: Kit Chan <ki...@apache.org>
Committed: Tue Apr 15 23:02:46 2014 -0700

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


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e3502911/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index ebe5161..9f8cf54 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-2555] adding global plugin support to ts_lua plugin
+
   *) [TS-2717] header-rewrite set-redirect not working.
    Author: Igor Brezac
 


[26/50] git commit: TS-898: remove pointless NULL check on array

Posted by zw...@apache.org.
TS-898: remove pointless NULL check on array

cl.origin_list is an array do the NULL check is pointless. Also
simplify the code around origiin set initialization so that the
origin set is always allocated. Coverity #1200013.


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

Branch: refs/heads/5.0.x
Commit: b90a731d4e2d31fbb1e958bde76250a3994fb690
Parents: d3b6c11
Author: James Peach <jp...@apache.org>
Authored: Sun Apr 13 17:00:18 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Sun Apr 13 17:04:34 2014 -0700

----------------------------------------------------------------------
 CHANGES           |  2 ++
 proxy/logstats.cc | 22 ++++++++--------------
 2 files changed, 10 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b90a731d/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 4970f8e..93b67d0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-898] Remove pointless NULL check on address of array.
+
   *) [TS-898] Avoid passing -1 to close (2) in traffic_cop.
 
   *) [TS-898] Fix minor regex_remap parsing bug.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b90a731d/proxy/logstats.cc
----------------------------------------------------------------------
diff --git a/proxy/logstats.cc b/proxy/logstats.cc
index f3249ef..15aeaa2 100644
--- a/proxy/logstats.cc
+++ b/proxy/logstats.cc
@@ -1372,7 +1372,7 @@ parse_log_buff(LogBufferHeader * buf_header, bool summary = false)
 
             // TODO: If we save state (struct) for a run, we probably need to always
             // update the origin data, no matter what the origin_set is.
-            if (origin_set ? (origin_set->find(tok) != origin_set->end()) : 1) {
+            if (origin_set->empty() || (origin_set->find(tok) != origin_set->end())) {
               o_iter = origins.find(tok);
               if (origins.end() == o_iter) {
                 o_stats = (OriginStats *)ats_malloc(sizeof(OriginStats));
@@ -2189,7 +2189,7 @@ my_exit(const ExitStatus& status)
   }
 
   // Next the totals for all Origins, unless we specified a list of origins to filter.
-  if (!origin_set) {
+  if (origin_set->empty()) {
     first = false;
     if (cl.json) {
       std::cout << "{ \"total\": {" << std::endl;
@@ -2284,7 +2284,7 @@ main(int /* argc ATS_UNUSED */, char *argv[])
   memset(&totals, 0, sizeof(totals));
   init_elapsed(&totals);
 
-  origin_set = NULL;
+  origin_set = NEW(new OriginSet);
   parse_errors = 0;
 
   // Command line parsing
@@ -2309,13 +2309,9 @@ main(int /* argc ATS_UNUSED */, char *argv[])
     char *tok;
     char *sep_ptr;
 
-    if (NULL == origin_set)
-        origin_set = NEW(new OriginSet);
-    if (cl.origin_list) {
-      for (tok = strtok_r(cl.origin_list, ",", &sep_ptr); tok != NULL;) {
-        origin_set->insert(tok);
-        tok = strtok_r(NULL, ",", &sep_ptr);
-      }
+    for (tok = strtok_r(cl.origin_list, ",", &sep_ptr); tok != NULL;) {
+      origin_set->insert(tok);
+      tok = strtok_r(NULL, ",", &sep_ptr);
     }
   }
   // Load origins from an "external" file (\n separated)
@@ -2329,9 +2325,6 @@ main(int /* argc ATS_UNUSED */, char *argv[])
       _exit(0);
     }
 
-    if (NULL == origin_set)
-      origin_set = NEW(new OriginSet);
-
     while (!fs.eof()) {
       std::string line;
       std::string::size_type start, end;
@@ -2347,8 +2340,9 @@ main(int /* argc ATS_UNUSED */, char *argv[])
           char *buf;
 
           buf = ats_strdup(line.substr(start, end).c_str());
-          if (buf)
+          if (buf) {
             origin_set->insert(buf);
+          }
         }
       }
     }


[33/50] git commit: TS-2703 Fix logging when there is no log file configured

Posted by zw...@apache.org.
TS-2703 Fix logging when there is no log file configured


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

Branch: refs/heads/5.0.x
Commit: f2f57b681745a315a1fc53f47c54195f30cc12e9
Parents: ec24119
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 15 11:25:07 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Apr 15 11:25:07 2014 -0600

----------------------------------------------------------------------
 plugins/experimental/background_fetch/background_fetch.cc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2f57b68/plugins/experimental/background_fetch/background_fetch.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/background_fetch/background_fetch.cc b/plugins/experimental/background_fetch/background_fetch.cc
index 13223bd..334caa5 100644
--- a/plugins/experimental/background_fetch/background_fetch.cc
+++ b/plugins/experimental/background_fetch/background_fetch.cc
@@ -158,6 +158,7 @@ dump_headers(TSMBuffer bufp, TSMLoc hdr_loc)
 class BGFetchConfig {
 public:
   BGFetchConfig()
+    : log(NULL)
   {
     _lock = TSMutexCreate();
   }


[22/50] git commit: TS-898: avoid passing -1 to close (2) in traffic_cop

Posted by zw...@apache.org.
TS-898: avoid passing -1 to close (2) in traffic_cop

This is harmless, but also trivial to fix. Coverity #1021900.


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

Branch: refs/heads/5.0.x
Commit: f4aa7b22055f9eea4b524fcb5462915e792d627c
Parents: c945682
Author: James Peach <jp...@apache.org>
Authored: Sat Apr 12 12:30:25 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Sat Apr 12 12:36:27 2014 -0700

----------------------------------------------------------------------
 CHANGES                        | 2 ++
 cmd/traffic_cop/traffic_cop.cc | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f4aa7b22/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 8c6e195..4970f8e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.0.0
 
+  *) [TS-898] Avoid passing -1 to close (2) in traffic_cop.
+
   *) [TS-898] Fix minor regex_remap parsing bug.
 
   *) [TS-2711] Include Lua JIT as a Submodule.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f4aa7b22/cmd/traffic_cop/traffic_cop.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_cop/traffic_cop.cc b/cmd/traffic_cop/traffic_cop.cc
index ee80716..50615f2 100644
--- a/cmd/traffic_cop/traffic_cop.cc
+++ b/cmd/traffic_cop/traffic_cop.cc
@@ -737,7 +737,9 @@ spawn_manager()
   } else if (err == -1) {
     cop_log(COP_FATAL, "unable to fork [%d '%s']\n", errno, strerror(errno));
     exit(1);
-  } else {
+  }
+
+  if (log_fd >= 0) {
     close(log_fd);
   }
 


[24/50] git commit: ICP fixed, remove the broken note in records.config

Posted by zw...@apache.org.
ICP fixed, remove the broken note in records.config


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

Branch: refs/heads/5.0.x
Commit: 559ca5debfdfdd2f005a8241340a7e8166d3a570
Parents: bff513d
Author: Zhao Yongming <mi...@gmail.com>
Authored: Sun Apr 13 22:28:23 2014 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Sun Apr 13 22:30:07 2014 +0800

----------------------------------------------------------------------
 proxy/config/records.config.default.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/559ca5de/proxy/config/records.config.default.in
----------------------------------------------------------------------
diff --git a/proxy/config/records.config.default.in b/proxy/config/records.config.default.in
index 98f29a8..8086e09 100644
--- a/proxy/config/records.config.default.in
+++ b/proxy/config/records.config.default.in
@@ -540,7 +540,7 @@ CONFIG proxy.config.ssl.client.CA.cert.filename STRING NULL
 CONFIG proxy.config.ssl.client.CA.cert.path STRING @rel_sysconfdir@
 ##############################################################################
 #
-# ICP Configuration. NOTE! ICP is currently broken NOTE!
+# ICP Configuration.
 #
 ##############################################################################
    # icp modes


[15/50] git commit: Update the deprecation comments

Posted by zw...@apache.org.
Update the deprecation comments


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

Branch: refs/heads/5.0.x
Commit: b639e7250972214587d14b52cf59da0e15a88ba2
Parents: 6d6b5a8
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Apr 10 15:19:44 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Apr 10 15:19:44 2014 -0600

----------------------------------------------------------------------
 proxy/api/ts/ts.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b639e725/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 8c787b1..3dce82f 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -309,7 +309,7 @@ extern "C"
 
    */
   /** @deprecated There is no reason to destroy the URL, just release
-      the marshal buffers. */
+      the marshal buffers. Should be removed for v5.0.0 */
   tsapi TS_DEPRECATED TSReturnCode TSUrlDestroy(TSMBuffer bufp, TSMLoc offset);
 
   /**
@@ -2256,6 +2256,7 @@ extern "C"
      @param url_len the length of the URL
   */
   tsapi void TSHttpTxnRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len);
+  //  This is deprecated as of v5.0.0.
   tsapi TS_DEPRECATED void TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len);
 
   /**
@@ -2268,6 +2269,7 @@ extern "C"
      @return the url string
   */
   tsapi const char* TSHttpTxnRedirectUrlGet(TSHttpTxn txnp, int* url_len_ptr);
+  //  This is deprecated as of v5.0.0.
   tsapi TS_DEPRECATED const char* TSRedirectUrlGet(TSHttpTxn txnp, int* url_len_ptr);
 
   /**


[05/50] git commit: TS-2707 Migrate TSRedirectUrlSet/Get to TSHttpTxnRedirectUrlSet/Get

Posted by zw...@apache.org.
TS-2707 Migrate TSRedirectUrlSet/Get to TSHttpTxnRedirectUrlSet/Get

1. We leave TSRedirectUrlSet() / Get() as is (as far as functionality
goes). This makes this proposal both API and binary compatible with v4.2.x.

2. We mark them as Deprecated, removing the old API in 6.0.0.

3. We add TSHttpTxnRedirectSet() / Get() , with the new string ownership as
described above. This naming convention is much better aligned with the rest
of our APIs.

I left the URL string lengths as int type for now, we’ll discuss at the Summit
about TS-2514, changing our usage of “int” to more appropriate size_t etc.


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

Branch: refs/heads/5.0.x
Commit: a7b7d5f98cfc94ba95ea572cadc5d14f8ecdf153
Parents: 98c5819
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Apr 8 21:11:48 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Apr 10 06:50:21 2014 -0600

----------------------------------------------------------------------
 .../custom_redirect/custom_redirect.cc          |  2 +-
 plugins/experimental/escalate/escalate.cc       |  4 +-
 proxy/InkAPI.cc                                 | 40 ++++++++++++++++++--
 proxy/api/ts/ts.h                               | 11 ++++--
 4 files changed, 48 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a7b7d5f9/plugins/experimental/custom_redirect/custom_redirect.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/custom_redirect/custom_redirect.cc b/plugins/experimental/custom_redirect/custom_redirect.cc
index 075f712..5af9a83 100644
--- a/plugins/experimental/custom_redirect/custom_redirect.cc
+++ b/plugins/experimental/custom_redirect/custom_redirect.cc
@@ -74,7 +74,7 @@ handle_response (TSHttpTxn txnp, TSCont /* contp ATS_UNUSED */)
                               char* url = (char*)TSmalloc(redirect_url_length+1);
 
                               TSstrlcpy(url, redirect_url_str, redirect_url_length + 1);
-                              TSRedirectUrlSet(txnp, url, redirect_url_length);
+                              TSHttpTxnRedirectUrlSet(txnp, url, redirect_url_length);
                             }
                         }
                         TSHandleMLocRelease (resp_bufp, resp_loc, redirect_url_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a7b7d5f9/plugins/experimental/escalate/escalate.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/escalate/escalate.cc b/plugins/experimental/escalate/escalate.cc
index 05a8234..2f71041 100644
--- a/plugins/experimental/escalate/escalate.cc
+++ b/plugins/experimental/escalate/escalate.cc
@@ -70,7 +70,7 @@ EscalateResponse(TSCont cont, TSEvent event, void* edata)
 
   // First, we need the server response ...
   if (TS_SUCCESS == TSHttpTxnServerRespGet(txn, &response, &resp_hdr)) {
-    int tries = TSRedirectRetriesGet(txn);
+    int tries = TSHttpTxnRedirectRetries(txn);
 
     TSDebug(PLUGIN_NAME, "This is try %d", tries);
     if (0 == tries) { // ToDo: Future support for more than one retry-URL
@@ -98,7 +98,7 @@ EscalateResponse(TSCont cont, TSEvent event, void* edata)
             url_str = TSUrlStringGet(request, url, &url_len);
 
             TSDebug(PLUGIN_NAME, "Setting new URL to %.*s", url_len, url_str);
-            TSRedirectUrlSet(txn, url_str, url_len); // Transfers ownership
+            TSHttpTxnRedirectUrlSet(txn, url_str, url_len); // Transfers ownership
           }
           // Release the request MLoc
         TSHandleMLocRelease(request, TS_NULL_MLOC, req_hdr);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a7b7d5f9/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 92c37fc..cc4c4dd 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7121,7 +7121,7 @@ TSHttpTxnFollowRedirect(TSHttpTxn txnp, int on)
 
 // this function should be called at TS_EVENT_HTTP_READ_RESPONSE_HDR
 void
-TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len)
+TSHttpTxnRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len)
 {
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
   sdk_assert(sdk_sanity_check_null_ptr((void*)url) == TS_SUCCESS);
@@ -7139,8 +7139,35 @@ TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len)
   sm->enable_redirection = true;
 }
 
+// Deprecated, remove for v6.0.0
+void
+TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len)
+{
+  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+  sdk_assert(sdk_sanity_check_null_ptr((void*)url) == TS_SUCCESS);
+
+  HttpSM *sm = (HttpSM*) txnp;
+
+  if (sm->redirect_url != NULL) {
+    ats_free(sm->redirect_url);
+    sm->redirect_url = NULL;
+    sm->redirect_url_len = 0;
+  }
+
+  sm->redirect_url = (char*)ats_malloc(url_len + 1);
+  ink_strlcpy(sm->redirect_url, url, url_len + 1);
+  sm->redirect_url_len = url_len;
+  // have to turn redirection on for this transaction if user wants to redirect to another URL
+  if (sm->enable_redirection == false) {
+    sm->enable_redirection = true;
+    // max-out "redirection_tries" to avoid the regular redirection being turned on in
+    // this transaction improperly. This variable doesn't affect the custom-redirection
+    sm->redirection_tries = HttpConfig::m_master.number_of_redirections;
+  }
+}
+
 const char*
-TSRedirectUrlGet(TSHttpTxn txnp, int *url_len_ptr)
+TSHttpTxnRedirectUrlGet(TSHttpTxn txnp, int *url_len_ptr)
 {
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
 
@@ -7150,8 +7177,15 @@ TSRedirectUrlGet(TSHttpTxn txnp, int *url_len_ptr)
   return sm->redirect_url;
 }
 
+// Deprecated, remove for v6.0.0
+const char*
+TSRedirectUrlGet(TSHttpTxn txnp, int *url_len_ptr)
+{
+  return TSHttpTxnRedirectUrlGet(txnp, url_len_ptr);
+}
+
 int
-TSRedirectRetriesGet(TSHttpTxn txnp)
+TSHttpTxnRedirectRetries(TSHttpTxn txnp)
 {
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a7b7d5f9/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index eaafda1..8279155 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -2237,6 +2237,7 @@ extern "C"
      @return @c TS_SUCCESS if it succeeded
   */
   tsapi TSReturnCode TSHttpTxnFollowRedirect(TSHttpTxn txnp, int on);
+
   /**
      This is a generalization of the TSHttpTxnFollowRedirect(), but gives finer
      control over the behavior. Instead of using the Location: header for the new
@@ -2251,7 +2252,9 @@ extern "C"
      @param url  a heap allocated string with the URL
      @param url_len the length of the URL
   */
-  tsapi void TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len);
+  tsapi void TSHttpTxnRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len);
+  tsapi TS_DEPRECATED void TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len);
+
   /**
      Return the current (if set) redirection URL string. This is still owned by the
      core, and must not be free'd.
@@ -2261,7 +2264,9 @@ extern "C"
 
      @return the url string
   */
-  tsapi const char* TSRedirectUrlGet(TSHttpTxn txnp, int* url_len_ptr);
+  tsapi const char* TSHttpTxnRedirectUrlGet(TSHttpTxn txnp, int* url_len_ptr);
+  tsapi TS_DEPRECATED const char* TSRedirectUrlGet(TSHttpTxn txnp, int* url_len_ptr);
+
   /**
      Return the number of redirection retries we have done. This starts off
      at zero, and can be used to select different URLs based on which attempt this
@@ -2272,7 +2277,7 @@ extern "C"
 
      @return the redirect try count
   */
-  tsapi int TSRedirectRetriesGet(TSHttpTxn txnp);
+  tsapi int TSHttpTxnRedirectRetries(TSHttpTxn txnp);
 
   /* Get current HTTP connection stats */
   tsapi int TSHttpCurrentClientConnectionsGet(void);


[41/50] git commit: TS-2555 adding example and documentation

Posted by zw...@apache.org.
TS-2555 adding example and documentation


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

Branch: refs/heads/5.0.x
Commit: 01be17ecd6ec47b493366feb755db9998bb9146e
Parents: e350291
Author: Kit Chan <ki...@apache.org>
Authored: Wed Apr 16 00:38:25 2014 -0700
Committer: Kit Chan <ki...@apache.org>
Committed: Wed Apr 16 00:38:25 2014 -0700

----------------------------------------------------------------------
 doc/reference/plugins/ts_lua.en.rst             | 77 +++++++++++++-------
 plugins/experimental/ts_lua/example/hdr.lua     | 37 ----------
 .../ts_lua/example/test_global_hdr.lua          | 37 ++++++++++
 .../experimental/ts_lua/example/test_hdr.lua    | 37 ++++++++++
 4 files changed, 125 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/01be17ec/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 fbf7674..ebcb88c 100644
--- a/doc/reference/plugins/ts_lua.en.rst
+++ b/doc/reference/plugins/ts_lua.en.rst
@@ -23,16 +23,6 @@ ts-lua Plugin
 
 Embed the Power of Lua into TrafficServer.
 
-Status
-======
-
-This module is being tested under our production environment.
-
-Version
-=======
-
-ts-lua has not been released yet.
-
 Synopsis
 ========
 
@@ -242,18 +232,52 @@ Synopsis
         return 0
     end
 
+**test_global_hdr.lua**
+
+::
+
+
+    function send_response()
+        ts.client_response.header['Rhost'] = ts.ctx['rhost']
+        return 0
+    end
+
+    function do_global_read_request()
+        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
+
 
 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:::
+This module embeds Lua, into Apache Traffic Server. This module acts as remap plugin of Traffic Server. In this case we
+should provide **'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/tslua.so
+@pparam=/etc/trafficserver/script/test_hdr.lua
 
-     map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/usr/lib64/trafficserver/plugins/tslua.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:::
 
-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/tslua.so
+@pparam=/etc/trafficserver/script/sethost.lua @pparam=img03.tbcdn.cn
 
-     map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/usr/lib64/trafficserver/plugins/tslua.so @pparam=/etc/trafficserver/script/sethost.lua @pparam=img03.tbcdn.cn
+This module can also act as a global plugin of Traffic Server. In this case we should provide one of these functions
+(**'do_global_read_request'**, **'do_global_send_request'**, **'do_global_read_response'**,
+**'do_global_send_response'**, **'do_global_cache_lookup_complete'**) in each lua script. We can write this in
+plugin.config:::
 
+     tslua.so /etc/trafficserver/script/test_global_hdr.lua
 
 
 TS API for Lua
@@ -262,7 +286,8 @@ 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.
+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.
 
 
 
@@ -306,7 +331,7 @@ ts.hook
 -------
 **syntax**: *ts.hook(HOOK_POINT, FUNCTION)*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/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.
@@ -323,7 +348,7 @@ Here is an example:::
 
 Hook point constants
 --------------------
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
     TS_LUA_HOOK_CACHE_LOOKUP_COMPLETE
     TS_LUA_HOOK_SEND_REQUEST_HDR
@@ -339,7 +364,7 @@ ts.ctx
 ------
 **syntax**: *ts.ctx[KEY]*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
 **description**: This table can be used to store per-request Lua context data and has a life time identical to the current request.
 
@@ -418,7 +443,7 @@ ts.http.resp_cache_transformed
 ------------------------------
 **syntax**: *ts.http.resp_cache_transformed(BOOL)*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
 **description**: This function can be used to tell trafficserver whether to cache the transformed data.
 
@@ -446,7 +471,7 @@ ts.http.resp_cache_untransformed
 --------------------------------
 **syntax**: *ts.http.resp_cache_untransformed(BOOL)*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
 **description**: This function can be used to tell trafficserver whether to cache the untransformed data.
 
@@ -474,7 +499,7 @@ ts.client_request.client_addr.get_addr
 --------------------------------------
 **syntax**: *ts.client_request.client_addr.get_addr()*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
 **description**: This function can be used to get socket address of the client.
 
@@ -492,7 +517,7 @@ ts.client_request.get_method
 ----------------------------
 **syntax**: *ts.client_request.get_method()*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
 **description**: This function can be used to retrieve the current request's request method name. String like "GET" or 
 "POST" is returned.
@@ -511,7 +536,7 @@ ts.client_request.get_url
 -------------------------
 **syntax**: *ts.client_request.get_url()*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
 **description**: This function can be used to retrieve the whole request's url.
 
@@ -520,7 +545,7 @@ ts.client_request.get_uri
 -------------------------
 **syntax**: *ts.client_request.get_uri()*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
 **description**: This function can be used to retrieve the request's path.
 
@@ -538,7 +563,7 @@ ts.client_request.get_uri_args
 ------------------------------
 **syntax**: *ts.client_request.get_uri_args()*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
 **description**: This function can be used to retrieve the request's query string.
 
@@ -560,7 +585,7 @@ ts.client_request.header.HEADER
 
 **syntax**: *VALUE = ts.client_request.header.HEADER*
 
-**context**: do_remap or later
+**context**: do_remap/do_global_*/later
 
 **description**: Set, add to, clear or get the current request's HEADER.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/01be17ec/plugins/experimental/ts_lua/example/hdr.lua
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/example/hdr.lua b/plugins/experimental/ts_lua/example/hdr.lua
deleted file mode 100644
index b79a63b..0000000
--- a/plugins/experimental/ts_lua/example/hdr.lua
+++ /dev/null
@@ -1,37 +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.
-
-
-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
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/01be17ec/plugins/experimental/ts_lua/example/test_global_hdr.lua
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/example/test_global_hdr.lua b/plugins/experimental/ts_lua/example/test_global_hdr.lua
new file mode 100644
index 0000000..012dbcf
--- /dev/null
+++ b/plugins/experimental/ts_lua/example/test_global_hdr.lua
@@ -0,0 +1,37 @@
+--  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.
+
+
+function send_response()
+    ts.client_response.header['Rhost'] = ts.ctx['rhost']
+    return 0
+end
+
+
+function do_global_read_request()
+    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
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/01be17ec/plugins/experimental/ts_lua/example/test_hdr.lua
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/example/test_hdr.lua b/plugins/experimental/ts_lua/example/test_hdr.lua
new file mode 100644
index 0000000..b79a63b
--- /dev/null
+++ b/plugins/experimental/ts_lua/example/test_hdr.lua
@@ -0,0 +1,37 @@
+--  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.
+
+
+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
+


[46/50] git commit: tcpinfo: fix docutils option formatting issues

Posted by zw...@apache.org.
tcpinfo: fix docutils option formatting issues


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

Branch: refs/heads/5.0.x
Commit: b25b2c28c04d3a4bfdf58045d210ba122669e06b
Parents: 50d69f1
Author: James Peach <jp...@apache.org>
Authored: Wed Apr 16 12:38:41 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Wed Apr 16 12:38:41 2014 -0700

----------------------------------------------------------------------
 doc/reference/plugins/tcpinfo.en.rst | 44 +++++++++++++++++--------------
 1 file changed, 24 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b25b2c28/doc/reference/plugins/tcpinfo.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/tcpinfo.en.rst b/doc/reference/plugins/tcpinfo.en.rst
index 688fe45..e2eef53 100644
--- a/doc/reference/plugins/tcpinfo.en.rst
+++ b/doc/reference/plugins/tcpinfo.en.rst
@@ -5,20 +5,20 @@ TCPInfo Plugin
 
 .. 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
+   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.
+   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.
 
 This global plugin logs TCP metrics at various points in the HTTP
 processing pipeline. The TCP information is retrieved by the
@@ -34,7 +34,11 @@ Plugin Options
 
 The following options may be specified in :file:`plugin.config`:
 
---hooks=LIST
+.. NOTE: if the option name is not long enough, docutils will not
+   add the colspan attribute and the options table formatting will
+   be all messed up. Just a trap for young players.
+
+--hooks=NAMELIST
   This option specifies when TCP information should be logged. The
   argument is a comma-separated list of the event names listed
   below. TCP information will be sampled and logged each time the
@@ -43,11 +47,11 @@ The following options may be specified in :file:`plugin.config`:
   ==============  ===============================================
    Event Name     Triggered when
   ==============  ===============================================
-   send_resp_hdr  The server begins sending an HTTP response.
-   ssn_close      The TCP connection closes.
-   ssn_start      A new TCP connection is accepted.
-   txn_close      A HTTP transaction is completed.
-   txn_start      A HTTP transaction is initiated.
+  send_resp_hdr   The server begins sending an HTTP response.
+  ssn_close       The TCP connection closes.
+  ssn_start       A new TCP connection is accepted.
+  txn_close       A HTTP transaction is completed.
+  txn_start       A HTTP transaction is initiated.
   ==============  ===============================================
 
 --log-file=NAME
@@ -105,13 +109,13 @@ The following options may be specified in :file:`plugin.config`:
 Examples:
 ---------
 
-This example logs the simple TCP information to ``jpeach.log``
+This example logs the simple TCP information to ``tcp-metrics.log``
 at the start of a TCP connection and once for each HTTP
 transaction thereafter::
 
-  tcp_info.so --log-file=jpeach --log-level=1 --hooks=ssn_start,txn_start
+  tcp_info.so --log-file=tcp-metrics --log-level=1 --hooks=ssn_start,txn_start
 
-The file ``jpeach.log`` will contain the following log format::
+The file ``tcp-metrics.log`` will contain the following log format::
 
   timestamp event client server rtt
   20140414.17h40m14s ssn_start 127.0.0.1 127.0.0.1 4000


[07/50] git commit: TS-2693 Modify string ownership for TSRedirectUrlSet()

Posted by zw...@apache.org.
TS-2693 Modify string ownership for TSRedirectUrlSet()


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

Branch: refs/heads/5.0.x
Commit: 6cec1a2092a40ed5794a7b8a65c1e1d63fc228c2
Parents: d3e2d2c
Author: Leif Hedstrom <zw...@apache.org>
Authored: Fri Apr 4 11:20:34 2014 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Apr 10 06:50:21 2014 -0600

----------------------------------------------------------------------
 plugins/experimental/custom_redirect/custom_redirect.cc | 6 ++++--
 plugins/experimental/escalate/escalate.cc               | 4 +---
 proxy/InkAPI.cc                                         | 7 +++----
 proxy/api/ts/ts.h                                       | 5 +----
 proxy/http/HttpSM.cc                                    | 4 ++--
 proxy/http/HttpSM.h                                     | 6 +++---
 proxy/http/HttpTransact.cc                              | 1 +
 7 files changed, 15 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cec1a20/plugins/experimental/custom_redirect/custom_redirect.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/custom_redirect/custom_redirect.cc b/plugins/experimental/custom_redirect/custom_redirect.cc
index 5ccf8ef..075f712 100644
--- a/plugins/experimental/custom_redirect/custom_redirect.cc
+++ b/plugins/experimental/custom_redirect/custom_redirect.cc
@@ -71,9 +71,11 @@ handle_response (TSHttpTxn txnp, TSCont /* contp ATS_UNUSED */)
                         redirect_url_str = TSMimeHdrFieldValueStringGet (resp_bufp, resp_loc, redirect_url_loc, -1, &redirect_url_length);
                         if (redirect_url_str) {
                             if (redirect_url_length > 0) {
-                              TSRedirectUrlSet(txnp, redirect_url_str, redirect_url_length);
+                              char* url = (char*)TSmalloc(redirect_url_length+1);
+
+                              TSstrlcpy(url, redirect_url_str, redirect_url_length + 1);
+                              TSRedirectUrlSet(txnp, url, redirect_url_length);
                             }
-                            //TSHandleStringRelease(resp_bufp, redirect_url_loc, redirect_url_str);
                         }
                         TSHandleMLocRelease (resp_bufp, resp_loc, redirect_url_loc);
                     }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cec1a20/plugins/experimental/escalate/escalate.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/escalate/escalate.cc b/plugins/experimental/escalate/escalate.cc
index d013b27..d57003a 100644
--- a/plugins/experimental/escalate/escalate.cc
+++ b/plugins/experimental/escalate/escalate.cc
@@ -95,9 +95,7 @@ EscalateResponse(TSCont cont, TSEvent event, void* edata)
           url_str = TSUrlStringGet(request, url, &url_len);
 
           TSDebug(PLUGIN_NAME, "Setting new URL to %.*s", url_len, url_str);
-          TSRedirectUrlSet(txn, url_str, url_len);
-
-          TSfree(static_cast<void*>(url_str));
+          TSRedirectUrlSet(txn, url_str, url_len); // Transfers ownership
         }
         // Release the response MLoc
         TSHandleMLocRelease(request, TS_NULL_MLOC, req_hdr);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cec1a20/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 68d31d0..e4a0b9c 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7129,13 +7129,12 @@ TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len)
   HttpSM *sm = (HttpSM*) txnp;
 
   if (sm->redirect_url != NULL) {
-    ats_free(sm->redirect_url);
+    ats_free((void*)sm->redirect_url);
     sm->redirect_url = NULL;
     sm->redirect_url_len = 0;
   }
 
-  sm->redirect_url = (char*)ats_malloc(url_len + 1);
-  ink_strlcpy(sm->redirect_url, (char*)url, url_len + 1);
+  sm->redirect_url = url;
   sm->redirect_url_len = url_len;
   sm->enable_redirection = true;
 }
@@ -7148,7 +7147,7 @@ TSRedirectUrlGet(TSHttpTxn txnp, int *url_len_ptr)
   HttpSM *sm = (HttpSM*)txnp;
 
   *url_len_ptr = sm->redirect_url_len;
-  return (const char*)sm->redirect_url;
+  return sm->redirect_url;
 }
 
 char*

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cec1a20/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 367317b..99098da 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -1456,7 +1456,6 @@ extern "C"
    */
   tsapi void TSHttpTxnReenable(TSHttpTxn txnp, TSEvent event);
   tsapi TSReturnCode TSHttpCacheReenable(TSCacheTxn txnp, const TSEvent event, const void* data, const uint64_t size);
-  tsapi TSReturnCode TSHttpTxnFollowRedirect(TSHttpTxn txnp, int on);
 
   tsapi void TSHttpTxnArgSet(TSHttpTxn txnp, int arg_idx, void* arg);
   tsapi void* TSHttpTxnArgGet(TSHttpTxn txnp, int arg_idx);
@@ -2228,9 +2227,7 @@ extern "C"
 
   tsapi TSReturnCode TSHttpTxnConfigFind(const char* name, int length, TSOverridableConfigKey* conf, TSRecordDataType* type);
 
-  /*
-    It's unclear if these actually function properly still.
-  */
+  tsapi TSReturnCode TSHttpTxnFollowRedirect(TSHttpTxn txnp, int on);
   tsapi void TSRedirectUrlSet(TSHttpTxn txnp, const char* url, const int url_len);
   tsapi const char* TSRedirectUrlGet(TSHttpTxn txnp, int* url_len_ptr);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cec1a20/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index fc4f9bc..f1fafff 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -6457,7 +6457,7 @@ HttpSM::kill_this()
     HTTP_SM_SET_DEFAULT_HANDLER(NULL);
 
     if (redirect_url != NULL) {
-      ats_free(redirect_url);
+      ats_free((void*)redirect_url);
       redirect_url = NULL;
       redirect_url_len = 0;
     }
@@ -7295,7 +7295,7 @@ HttpSM::do_redirect()
 
       if (redirect_url != NULL) {
         redirect_request(redirect_url, redirect_url_len);
-        ats_free(redirect_url);
+        ats_free((void*)redirect_url);
         redirect_url = NULL;
         redirect_url_len = 0;
         HTTP_INCREMENT_DYN_STAT(http_total_x_redirect_stat);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cec1a20/proxy/http/HttpSM.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h
index 0a7b116..a04742d 100644
--- a/proxy/http/HttpSM.h
+++ b/proxy/http/HttpSM.h
@@ -270,12 +270,12 @@ public:
 
   //YTS Team, yamsat Plugin
   bool enable_redirection;      //To check if redirection is enabled
-  char *redirect_url;           //url for force redirect (provide users a functionality to redirect to another url when needed)
+  const char *redirect_url;     //url for force redirect (provide users a functionality to redirect to another url when needed)
   int redirect_url_len;
   int redirection_tries;        //To monitor number of redirections
-  int64_t transfered_bytes;         //Added to calculate POST data
+  int64_t transfered_bytes;     //Added to calculate POST data
   bool post_failed;             //Added to identify post failure
-  bool debug_on;              //Transaction specific debug flag
+  bool debug_on;               //Transaction specific debug flag
 
   // Tunneling request to plugin
   HttpPluginTunnel_t plugin_tunnel_type;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cec1a20/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index c5ee223..aa671fa 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -900,6 +900,7 @@ HttpTransact::EndRemapRequest(State* s)
 
       char *redirect_url = s->http_config_param->reverse_proxy_no_host_redirect;
       int redirect_url_len = s->http_config_param->reverse_proxy_no_host_redirect_len;
+
       SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_NO_FORWARD);
       if (redirect_url) {       /* there is a redirect url */
         build_error_response(s, HTTP_STATUS_MOVED_TEMPORARILY, "Redirect For Explanation", "request#no_host",


[23/50] git commit: value filter is always a good idea in RecordsConfig

Posted by zw...@apache.org.
value filter is always a good idea in RecordsConfig


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

Branch: refs/heads/5.0.x
Commit: bff513d930f8b1b5354627455efde4e6fb94af9d
Parents: f4aa7b2
Author: Zhao Yongming <mi...@gmail.com>
Authored: Fri Apr 4 14:47:06 2014 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Sun Apr 13 22:28:48 2014 +0800

----------------------------------------------------------------------
 mgmt/RecordsConfig.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bff513d9/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 3621399..9e45111 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -985,7 +985,7 @@ RecordElement RecordsConfig[] = {
   //# HostDB
   //#
   //##############################################################################
-  {RECT_CONFIG, "proxy.config.hostdb", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  {RECT_CONFIG, "proxy.config.hostdb", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_NULL, "[0-1]", RECA_NULL}
   ,
   //       # up to 511 characters, may not be changed while running
   {RECT_CONFIG, "proxy.config.hostdb.filename", RECD_STRING, "host.db", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
@@ -999,7 +999,7 @@ RecordElement RecordsConfig[] = {
   ,
   //       # in minutes (all three)
   //       #  0 = obey, 1 = ignore, 2 = min(X,ttl), 3 = max(X,ttl)
-  {RECT_CONFIG, "proxy.config.hostdb.ttl_mode", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  {RECT_CONFIG, "proxy.config.hostdb.ttl_mode", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, "[0-3]", RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.hostdb.lookup_timeout", RECD_INT, "120", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,