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

[1/3] git commit: TS-1953: remove version check from stable plugins

Updated Branches:
  refs/heads/master 7e26b6845 -> be8fd6cd8


TS-1953: remove version check from stable plugins

we're closing the night with a cleanup in the stable plugins.
Thanks, You've been a great crowd.


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

Branch: refs/heads/master
Commit: be8fd6cd87e6a9b4a00c7f13bd5573165ad09103
Parents: a8febbf
Author: Igor Galić <i....@brainsware.org>
Authored: Fri Aug 2 00:26:56 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Fri Aug 2 00:29:31 2013 +0200

----------------------------------------------------------------------
 plugins/cacheurl/cacheurl.c               | 31 --------------------------
 plugins/gzip/gzip.cc                      |  3 ---
 plugins/gzip/misc.cc                      | 15 -------------
 plugins/stats_over_http/stats_over_http.c | 29 ------------------------
 4 files changed, 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/be8fd6cd/plugins/cacheurl/cacheurl.c
----------------------------------------------------------------------
diff --git a/plugins/cacheurl/cacheurl.c b/plugins/cacheurl/cacheurl.c
index 2f34729..7b28d7d 100644
--- a/plugins/cacheurl/cacheurl.c
+++ b/plugins/cacheurl/cacheurl.c
@@ -361,32 +361,6 @@ static int handle_hook(TSCont contp, TSEvent event, void *edata) {
     return ok;
 }
 
-/* Function to ensure we're running a recent enough version of Traffic Server.
- * (Taken from the example plugin)
- */
-static int check_ts_version() {
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version,
-                &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* we are now v3.x */
-    if (major_ts_version >= 3) {
-      result = 1;
-    }
-
-  }
-  return result;
-}
-
 /* Generic error message function for errors in plugin initialization */
 static void initialization_error(char *msg) {
     TSError("[%s] %s\n", PLUGIN_NAME, msg);
@@ -479,11 +453,6 @@ void TSPluginInit(int argc, const char *argv[]) {
         return;
     }
 
-    if (!check_ts_version()) {
-        initialization_error("Plugin requires Traffic Server 3.0 or later");
-        return;
-    }
-
     if (!log) {
         error = TSTextLogObjectCreate("cacheurl", TS_LOG_MODE_ADD_TIMESTAMP,
                 &log);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/be8fd6cd/plugins/gzip/gzip.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/gzip.cc b/plugins/gzip/gzip.cc
index 9260faf..9c84dc8 100644
--- a/plugins/gzip/gzip.cc
+++ b/plugins/gzip/gzip.cc
@@ -773,9 +773,6 @@ TSPluginInit(int argc, const char *argv[])
   if (!register_plugin()) {
     fatal("The gzip plugin failed to register");
   }
-  if (!check_ts_version()) {
-    fatal("The gzip plugin requires at least traffic server v3");
-  }
 
   //if (argc == 2) {
   //  dictionary = load_dictionary(argv[1]);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/be8fd6cd/plugins/gzip/misc.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/misc.cc b/plugins/gzip/misc.cc
index 5fb98a5..13f9d39 100644
--- a/plugins/gzip/misc.cc
+++ b/plugins/gzip/misc.cc
@@ -140,21 +140,6 @@ init_hidden_header_name()
 }
 
 int
-check_ts_version()
-{
-  const char *ts_version = TSTrafficServerVersionGet();
-  TSReleaseAssert(ts_version);
-
-  int scan_result;
-  int major_version;
-
-  scan_result = sscanf(ts_version, "%d", &major_version);
-  TSReleaseAssert(scan_result == 1);
-
-  return major_version >= 3;
-}
-
-int
 register_plugin()
 {
   TSPluginRegistrationInfo info;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/be8fd6cd/plugins/stats_over_http/stats_over_http.c
----------------------------------------------------------------------
diff --git a/plugins/stats_over_http/stats_over_http.c b/plugins/stats_over_http/stats_over_http.c
index c91de51..89a13af 100644
--- a/plugins/stats_over_http/stats_over_http.c
+++ b/plugins/stats_over_http/stats_over_http.c
@@ -249,30 +249,6 @@ stats_origin(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -285,11 +261,6 @@ TSPluginInit(int argc, const char *argv[])
   if (TSPluginRegister(TS_SDK_VERSION_2_0, &info) != TS_SUCCESS)
     TSError("Plugin registration failed. \n");
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 2.0 or later\n");
-    return;
-  }
-
   if (argc > 1) {
     url_path = TSstrdup(argv[1] + ('/' == argv[1][0] ? 1 : 0)); /* Skip leading / */
   }


[3/3] git commit: TS-1953: remove check_ts_version() from examples

Posted by ig...@apache.org.
TS-1953: remove check_ts_version() from examples

remove the boilerplate check_ts_version() function call from all
examples. This function is nice in a specific example, but it does not
make sense to have it in every single example plugin.

Since the code is compiled, in most cases that's too late to catch
issues with API versions, so it doesn't make sense to begin with.
In order to enable Plugin Developers to do such checks, and #ifdef
around API issues, we'd have to expose the TS_VERSION_* contants.

n.b.: We might want add one example which shows off how to use the
TSTrafficServerGetVersion() API, but we have that in the man page now
anyway.


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

Branch: refs/heads/master
Commit: 5b8b96850137ed29905fd1c244b4c6da3a3b02e2
Parents: 7e26b68
Author: Igor Galić <i....@brainsware.org>
Authored: Fri Aug 2 00:05:02 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Fri Aug 2 00:29:31 2013 +0200

----------------------------------------------------------------------
 example/add-header/add-header.c               | 30 ----------------
 example/append-transform/append-transform.c   | 31 ----------------
 example/basic-auth/basic-auth.c               | 31 ----------------
 example/blacklist-0/blacklist-0.c             | 32 -----------------
 example/blacklist-1/blacklist-1.c             | 31 ----------------
 example/bnull-transform/bnull-transform.c     | 31 ----------------
 example/file-1/file-1.c                       | 30 ----------------
 example/hello/hello.c                         | 30 ----------------
 example/null-transform/null-transform.c       | 31 ----------------
 example/output-header/output-header.c         | 31 ----------------
 example/protocol/Protocol.c                   | 31 ----------------
 example/redirect-1/redirect-1.c               | 31 ----------------
 example/replace-header/replace-header.c       | 31 ----------------
 example/response-header-1/response-header-1.c | 31 ----------------
 example/server-transform/server-transform.c   | 31 ----------------
 example/session-1/session-1.c                 | 31 ----------------
 example/thread-1/thread-1.c                   | 30 ----------------
 example/thread-pool/psi.c                     | 41 ----------------------
 18 files changed, 565 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/add-header/add-header.c
----------------------------------------------------------------------
diff --git a/example/add-header/add-header.c b/example/add-header/add-header.c
index a329162..7bd1e15 100644
--- a/example/add-header/add-header.c
+++ b/example/add-header/add-header.c
@@ -120,31 +120,6 @@ add_header_plugin(TSCont contp, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -162,11 +137,6 @@ TSPluginInit(int argc, const char *argv[])
     goto error;
   }
 
-  if (!check_ts_version()) {
-    TSError("[PluginInit] Plugin requires Traffic Server 3.0 or later\n");
-    goto error;
-  }
-
   if (argc < 2) {
     TSError("[PluginInit] Usage: %s \"name1: value1\" \"name2: value2\" ...>\n", argv[0]);
     goto error;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/append-transform/append-transform.c
----------------------------------------------------------------------
diff --git a/example/append-transform/append-transform.c b/example/append-transform/append-transform.c
index 00f0c22..31d78e6 100644
--- a/example/append-transform/append-transform.c
+++ b/example/append-transform/append-transform.c
@@ -347,32 +347,6 @@ load(const char *filename)
   return 1;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -387,11 +361,6 @@ TSPluginInit(int argc, const char *argv[])
     goto Lerror;
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    goto Lerror;
-  }
-
   if (argc != 2) {
     TSError("usage: %s <filename>\n", argv[0]);
     goto Lerror;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/basic-auth/basic-auth.c
----------------------------------------------------------------------
diff --git a/example/basic-auth/basic-auth.c b/example/basic-auth/basic-auth.c
index 7f6f4af..5b3cda0 100644
--- a/example/basic-auth/basic-auth.c
+++ b/example/basic-auth/basic-auth.c
@@ -209,32 +209,6 @@ auth_plugin(TSCont contp, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 {
@@ -249,11 +223,6 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     TSError("Plugin registration failed.\n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   /* Build translation table */
   for (i = 0, cc = 0; i < 256; i++) {
     base64_codes[i] = 0;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/blacklist-0/blacklist-0.c
----------------------------------------------------------------------
diff --git a/example/blacklist-0/blacklist-0.c b/example/blacklist-0/blacklist-0.c
index a493277..9038b8f 100644
--- a/example/blacklist-0/blacklist-0.c
+++ b/example/blacklist-0/blacklist-0.c
@@ -146,32 +146,6 @@ blacklist_plugin(TSCont contp, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -187,12 +161,6 @@ TSPluginInit(int argc, const char *argv[])
 
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
-
   nsites = argc - 1;
   if (nsites > 0) {
     sites = (char **) TSmalloc(sizeof(char *) * nsites);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/blacklist-1/blacklist-1.c
----------------------------------------------------------------------
diff --git a/example/blacklist-1/blacklist-1.c b/example/blacklist-1/blacklist-1.c
index f1a55a2..3b137d6 100644
--- a/example/blacklist-1/blacklist-1.c
+++ b/example/blacklist-1/blacklist-1.c
@@ -306,32 +306,6 @@ handle_txn_start(TSCont contp ATS_UNUSED, TSHttpTxn txnp)
 }
 
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 {
@@ -347,11 +321,6 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     TSError("Plugin registration failed.\n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   /* create an TSTextLogObject to log blacklisted requests to */
   error = TSTextLogObjectCreate("blacklist", TS_LOG_MODE_ADD_TIMESTAMP, &log);
   if (!log || error == TS_ERROR) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/bnull-transform/bnull-transform.c
----------------------------------------------------------------------
diff --git a/example/bnull-transform/bnull-transform.c b/example/bnull-transform/bnull-transform.c
index 26cceca..03acb26 100644
--- a/example/bnull-transform/bnull-transform.c
+++ b/example/bnull-transform/bnull-transform.c
@@ -306,32 +306,6 @@ transform_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 {
@@ -347,11 +321,6 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     goto Lerror;
   }
 
-  if (!check_ts_version()) {
-    TSError("[bnull-transform] Plugin requires Traffic Server 3.0" " or later\n");
-    goto Lerror;
-  }
-
   /* This is call we could use if we need to protect global data */
   /* TSReleaseAssert ((mutex = TSMutexCreate()) != TS_NULL_MUTEX); */
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/file-1/file-1.c
----------------------------------------------------------------------
diff --git a/example/file-1/file-1.c b/example/file-1/file-1.c
index f7c9791..23d67d7 100644
--- a/example/file-1/file-1.c
+++ b/example/file-1/file-1.c
@@ -36,31 +36,6 @@
 #include <stdio.h>
 #include <ts/ts.h>
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -77,11 +52,6 @@ TSPluginInit(int argc, const char *argv[])
     TSError("Plugin registration failed.\n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   for (i = 1; i < argc; i++) {
     filep = TSfopen(argv[i], "r");
     if (!filep) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/hello/hello.c
----------------------------------------------------------------------
diff --git a/example/hello/hello.c b/example/hello/hello.c
index 5516274..e8906d3 100644
--- a/example/hello/hello.c
+++ b/example/hello/hello.c
@@ -26,31 +26,6 @@
 #include "ts/ts.h"
 #include "ink_defs.h"
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 {
@@ -64,10 +39,5 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     TSError("Plugin registration failed. \n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   TSDebug("debug-hello", "Hello World!\n");
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/null-transform/null-transform.c
----------------------------------------------------------------------
diff --git a/example/null-transform/null-transform.c b/example/null-transform/null-transform.c
index 154613f..2c23dea 100644
--- a/example/null-transform/null-transform.c
+++ b/example/null-transform/null-transform.c
@@ -306,32 +306,6 @@ transform_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 {
@@ -346,11 +320,6 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     goto Lerror;
   }
 
-  if (!check_ts_version()) {
-    TSError("[null-transform] Plugin requires Traffic Server 3.0 " "or later\n");
-    goto Lerror;
-  }
-
   TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(transform_plugin, NULL));
   return;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/output-header/output-header.c
----------------------------------------------------------------------
diff --git a/example/output-header/output-header.c b/example/output-header/output-header.c
index 8307c4e..34a7b81 100644
--- a/example/output-header/output-header.c
+++ b/example/output-header/output-header.c
@@ -148,31 +148,6 @@ hdr_plugin(TSCont contp, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 {
@@ -187,12 +162,6 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     goto error;
   }
 
-  if (!check_ts_version()) {
-    TSError("[PluginInit] Plugin requires Traffic Server 3.0 or later\n");
-    goto error;
-  }
-
-
   TSHttpHookAdd(TS_HTTP_OS_DNS_HOOK, TSContCreate(hdr_plugin, NULL));
 
 error:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/protocol/Protocol.c
----------------------------------------------------------------------
diff --git a/example/protocol/Protocol.c b/example/protocol/Protocol.c
index 5bb786f..5d71430 100644
--- a/example/protocol/Protocol.c
+++ b/example/protocol/Protocol.c
@@ -100,32 +100,6 @@ protocol_init(int accept_port, int server_port ATS_UNUSED)
   pending_action = TSNetAccept(contp, accept_port, -1, 1);
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -140,11 +114,6 @@ TSPluginInit(int argc, const char *argv[])
     goto error;
   }
 
-  if (!check_ts_version()) {
-    TSError("[PluginInit] Plugin requires Traffic Server 3.0 or later\n");
-    goto error;
-  }
-
 
   /* default value */
   accept_port = 4666;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/redirect-1/redirect-1.c
----------------------------------------------------------------------
diff --git a/example/redirect-1/redirect-1.c b/example/redirect-1/redirect-1.c
index 6498b70..613235a 100644
--- a/example/redirect-1/redirect-1.c
+++ b/example/redirect-1/redirect-1.c
@@ -342,32 +342,6 @@ update_redirected_method_stats(TSMBuffer bufp, TSMLoc hdr_loc)
   }
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -383,11 +357,6 @@ TSPluginInit(int argc, const char *argv[])
     TSError("Plugin registration failed.\n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   if (argc == 3) {
     block_ip = TSstrdup(argv[1]);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/replace-header/replace-header.c
----------------------------------------------------------------------
diff --git a/example/replace-header/replace-header.c b/example/replace-header/replace-header.c
index 0b7c7df..d4bc31b 100644
--- a/example/replace-header/replace-header.c
+++ b/example/replace-header/replace-header.c
@@ -93,32 +93,6 @@ replace_header_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 {
@@ -132,10 +106,5 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     TSError("Plugin registration failed. \n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, TSContCreate(replace_header_plugin, NULL));
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/response-header-1/response-header-1.c
----------------------------------------------------------------------
diff --git a/example/response-header-1/response-header-1.c b/example/response-header-1/response-header-1.c
index 73aff35..68c1d11 100644
--- a/example/response-header-1/response-header-1.c
+++ b/example/response-header-1/response-header-1.c
@@ -232,32 +232,6 @@ modify_response_header_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edat
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -273,11 +247,6 @@ TSPluginInit(int argc, const char *argv[])
     TSError("Plugin registration failed.\n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   init_buffer_status = 0;
   if (argc > 1) {
     TSError("usage: %s \n", argv[0]);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/server-transform/server-transform.c
----------------------------------------------------------------------
diff --git a/example/server-transform/server-transform.c b/example/server-transform/server-transform.c
index 930d3b8..4a2df81 100644
--- a/example/server-transform/server-transform.c
+++ b/example/server-transform/server-transform.c
@@ -635,32 +635,6 @@ transform_plugin(TSCont contp, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Since this is an TS-SDK 2.0 plugin, we need at
-       least Traffic Server 2.0 to run */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
 {
@@ -675,11 +649,6 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     TSError("Plugin registration failed.\n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   /* connect to the echo port on localhost */
   server_ip = (127 << 24) | (0 << 16) | (0 << 8) | (1);
   server_ip = htonl(server_ip);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/session-1/session-1.c
----------------------------------------------------------------------
diff --git a/example/session-1/session-1.c b/example/session-1/session-1.c
index 7fbd6e0..8547649 100644
--- a/example/session-1/session-1.c
+++ b/example/session-1/session-1.c
@@ -87,32 +87,6 @@ ssn_handler(TSCont contp, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -128,11 +102,6 @@ TSPluginInit(int argc, const char *argv[])
     goto error;
   }
 
-  if (!check_ts_version()) {
-    TSError("[PluginInit] Plugin requires Traffic Server 3.0 or later\n");
-    goto error;
-  }
-
   transaction_count = INKStatCreate("transaction.count", INKSTAT_TYPE_INT64);
   session_count = INKStatCreate("session.count", INKSTAT_TYPE_INT64);
   av_transaction = INKStatCreate("avg.transactions", INKSTAT_TYPE_FLOAT);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/thread-1/thread-1.c
----------------------------------------------------------------------
diff --git a/example/thread-1/thread-1.c b/example/thread-1/thread-1.c
index d5ec2cb..5af7531 100644
--- a/example/thread-1/thread-1.c
+++ b/example/thread-1/thread-1.c
@@ -64,31 +64,6 @@ thread_plugin(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-
-  }
-
-  return result;
-}
 
 void
 TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
@@ -103,10 +78,5 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     TSError("Plugin registration failed.\n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   TSHttpHookAdd(TS_HTTP_OS_DNS_HOOK, TSContCreate(thread_plugin, NULL));
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5b8b9685/example/thread-pool/psi.c
----------------------------------------------------------------------
diff --git a/example/thread-pool/psi.c b/example/thread-pool/psi.c
index 5a121db..fb84a4a 100644
--- a/example/thread-pool/psi.c
+++ b/example/thread-pool/psi.c
@@ -986,42 +986,6 @@ read_response_handler(TSCont contp ATS_UNUSED, TSEvent event, void *edata)
 
 
 /*-------------------------------------------------------------------------
-  check_ts_version
-  Make sure TS version is at least 2.0
-
-  Input:
-  Output :
-  Return Value:
-    0  if error
-    1  if success
-  -------------------------------------------------------------------------*/
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 2) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
-
-/*-------------------------------------------------------------------------
   TSPluginInit
   Function called at plugin init time
 
@@ -1046,11 +1010,6 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
     TSError("Plugin registration failed.\n");
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   /* Initialize the psi directory = <plugin_path>/include */
   sprintf(psi_directory, "%s/%s", TSPluginDirGet(), PSI_PATH);
 


[2/3] git commit: TS-1953: Remove check_ts_version() from experimental plugins

Posted by ig...@apache.org.
TS-1953: Remove check_ts_version() from experimental plugins

more axing: This time around, plugins/experimental.
i'm noticing that we do expose TS_VERSION, so ignore most of my last
commit message ;)


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

Branch: refs/heads/master
Commit: a8febbf50fecd6707e450d65febac27734b0864f
Parents: 5b8b968
Author: Igor Galić <i....@brainsware.org>
Authored: Fri Aug 2 00:18:12 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Fri Aug 2 00:29:31 2013 +0200

----------------------------------------------------------------------
 .../experimental/channel_stats/channel_stats.cc | 29 ------------------
 .../experimental/healthchecks/healthchecks.c    | 27 -----------------
 plugins/experimental/rfc5861/rfc5861.c          | 31 --------------------
 plugins/experimental/tcp_info/tcp_info.cc       | 30 -------------------
 4 files changed, 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a8febbf5/plugins/experimental/channel_stats/channel_stats.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/channel_stats/channel_stats.cc b/plugins/experimental/channel_stats/channel_stats.cc
index de5f757..5766bd0 100644
--- a/plugins/experimental/channel_stats/channel_stats.cc
+++ b/plugins/experimental/channel_stats/channel_stats.cc
@@ -794,31 +794,6 @@ api_handle_event(TSCont contp, TSEvent event, void *edata)
 
 // initial part
 
-static int
-check_ts_version()
-{
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version,
-                &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    // Need at least TS 3.0.0
-    if (major_ts_version >= 3) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int argc, const char *argv[])
 {
@@ -839,10 +814,6 @@ TSPluginInit(int argc, const char *argv[])
     fatal("plugin registration failed.");
   }
 
-  if (!check_ts_version()) {
-    fatal("plugin requires Traffic Server 3.0.0 or later");
-  }
-
   info("%s(%s) plugin starting...", PLUGIN_NAME, PLUGIN_VERSION);
 
   stats_map_mutex = TSMutexCreate();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a8febbf5/plugins/experimental/healthchecks/healthchecks.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/healthchecks/healthchecks.c b/plugins/experimental/healthchecks/healthchecks.c
index daf21b0..3c550b7 100644
--- a/plugins/experimental/healthchecks/healthchecks.c
+++ b/plugins/experimental/healthchecks/healthchecks.c
@@ -522,28 +522,6 @@ health_check_origin(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *eda
   return 0;
 }
 
-/* Check the TS server version, make sure we're supporting it */
-inline int
-check_ts_version()
-{
-  const char *ts_version = TSTrafficServerVersionGet();
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3)
-      return 0;
-
-    /* Need at least TS 3.0 */
-    if (major_ts_version >= 3)
-      return 1;
-  }
-
-  return 0;
-}
-
 /* Initialize the plugin / global continuation hook */
 void
 TSPluginInit(int argc, const char *argv[])
@@ -564,11 +542,6 @@ TSPluginInit(int argc, const char *argv[])
     return;
   }
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   /* This will update the global configuration file, and is not reloaded at run time */
   /* ToDo: Support reloading with traffic_line -x  ? */
   if (NULL == (g_config = parse_configs(argv[1]))) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a8febbf5/plugins/experimental/rfc5861/rfc5861.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/rfc5861/rfc5861.c b/plugins/experimental/rfc5861/rfc5861.c
index 21c43e2..384aa91 100644
--- a/plugins/experimental/rfc5861/rfc5861.c
+++ b/plugins/experimental/rfc5861/rfc5861.c
@@ -709,31 +709,6 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
     return 0;
 }
 
-static bool
-check_ts_version()
-{
-    const char *ts_version = TSTrafficServerVersionGet();
-
-    if (ts_version)
-    {
-        int major_ts_version = 0;
-        int minor_ts_version = 0;
-        int micro_ts_version = 0;
-
-        if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &micro_ts_version) != 3)
-        {
-            return false;
-        }
-
-        if ((TS_VERSION_MAJOR == major_ts_version) && (TS_VERSION_MINOR == minor_ts_version) && (TS_VERSION_MICRO == micro_ts_version))
-        {
-            return true;
-        }
-    }
-
-    return false;
-}
-
 void
 TSPluginInit (int argc, const char *argv[])
 {
@@ -754,12 +729,6 @@ TSPluginInit (int argc, const char *argv[])
         TSDebug(LOG_PREFIX, "Plugin registration succeeded.\n");
     }
 
-    if (!check_ts_version())
-    {
-        TSError("Plugin requires Traffic Server %d.%d.%d\n", TS_VERSION_MAJOR, TS_VERSION_MINOR, TS_VERSION_MICRO);
-        return;
-    }
-
     if (argc > 1)
     {
         int c;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a8febbf5/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 193d671..8a9d98b 100644
--- a/plugins/experimental/tcp_info/tcp_info.cc
+++ b/plugins/experimental/tcp_info/tcp_info.cc
@@ -261,31 +261,6 @@ done:
   return 0;
 }
 
-int
-check_ts_version()
-{
-
-  const char *ts_version = TSTrafficServerVersionGet();
-  int result = 0;
-
-  if (ts_version) {
-    int major_ts_version = 0;
-    int minor_ts_version = 0;
-    int patch_ts_version = 0;
-
-    if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3) {
-      return 0;
-    }
-
-    /* Need at least TS 2.0 */
-    if (major_ts_version >= 3) {
-      result = 1;
-    }
-  }
-
-  return result;
-}
-
 void
 TSPluginInit(int, const char *[]) // int argc, const char *argv[]
 {
@@ -298,11 +273,6 @@ TSPluginInit(int, const char *[]) // int argc, const char *argv[]
   if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS)
     TSError("Plugin registration failed. \n");
 
-  if (!check_ts_version()) {
-    TSError("Plugin requires Traffic Server 3.0 or later\n");
-    return;
-  }
-
   // load the configuration file
   load_config();