You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2012/10/19 22:03:55 UTC

[2/2] git commit: TS-1542: Fix so that rfc5861 plugin will compile against older versions of TS.

TS-1542: Fix so that rfc5861 plugin will compile against older versions of TS.


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

Branch: refs/heads/master
Commit: 71b9502f310d08f242efcfcf464e5b3f5812c85e
Parents: d334458
Author: Phil Sorber <so...@apache.org>
Authored: Fri Oct 19 16:00:32 2012 -0400
Committer: Phil Sorber <so...@apache.org>
Committed: Fri Oct 19 16:03:39 2012 -0400

----------------------------------------------------------------------
 plugins/experimental/rfc5861/rfc5861.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/71b9502f/plugins/experimental/rfc5861/rfc5861.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/rfc5861/rfc5861.c b/plugins/experimental/rfc5861/rfc5861.c
index 9720365..73d39c2 100644
--- a/plugins/experimental/rfc5861/rfc5861.c
+++ b/plugins/experimental/rfc5861/rfc5861.c
@@ -585,7 +585,9 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
                         TSDebug(LOG_PREFIX, "Looks like we can return fresh info and validate in the background");
                         // lookup async
 
+#if (TS_VERSION_NUMBER >= 3003000)
                         TSHttpTxnConfigIntSet(txn, TS_CONFIG_HTTP_INSERT_AGE_IN_RESPONSE, 1);
+#endif
                         // Set warning header
                         TSHttpTxnHookAdd(txn, TS_HTTP_SEND_RESPONSE_HDR_HOOK, cont);
 
@@ -606,7 +608,9 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
                     else if ((now - chi->date) < (chi->max_age + chi->stale_on_error))
                     {
                         TSDebug(LOG_PREFIX, "Looks like we can return fresh data on 500 error");
+#if (TS_VERSION_NUMBER >= 3003000)
                         TSHttpTxnConfigIntSet(txn, TS_CONFIG_HTTP_INSERT_AGE_IN_RESPONSE, 1);
+#endif
                         //lookup sync
                         state->async_req = false;
                         state->txn = txn;
@@ -658,8 +662,11 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
             if ((http_status == 500) || ((http_status >= 502) && (http_status <= 504))) // 500, 502, 503, or 504
             {
                 TSDebug(LOG_PREFIX, "Set non-cachable");
-                //TSHttpTxnRespCacheableSet(txn, 0);
+#if (TS_VERSION_NUMBER >= 3003000)
                 TSHttpTxnServerRespNoStoreSet(txn,1);
+#else
+                TSHttpTxnServerRespNoStore(txn);
+#endif
             }
             TSHandleMLocRelease(buf, TS_NULL_MLOC, loc);
             TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
@@ -696,15 +703,14 @@ check_ts_version()
     {
         int major_ts_version = 0;
         int minor_ts_version = 0;
-        int patch_ts_version = 0;
+        int micro_ts_version = 0;
 
-        if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version) != 3)
+        if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &micro_ts_version) != 3)
         {
             return false;
         }
 
-        /* We need Traffic Server 3.0.x */
-        if ((major_ts_version >= 3) && (minor_ts_version == 0))
+        if ((TS_VERSION_MAJOR == major_ts_version) && (TS_VERSION_MINOR == minor_ts_version) && (TS_VERSION_MICRO == micro_ts_version))
         {
             return true;
         }
@@ -735,7 +741,7 @@ TSPluginInit (int argc, const char *argv[])
 
     if (!check_ts_version())
     {
-        TSError("Plugin requires Traffic Server 3.0\n");
+        TSError("Plugin requires Traffic Server %d.%d.%d\n", TS_VERSION_MAJOR, TS_VERSION_MINOR, TS_VERSION_MICRO);
         return;
     }