trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject [trafficserver] branch master updated: Revert "allow regex_revalidate per remap rule, remove direct ink includes"
Date Mon, 17 Dec 2018 19:41:29 GMT
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new eef8d13  Revert "allow regex_revalidate per remap rule, remove direct ink includes"
eef8d13 is described below

commit eef8d136db97fc499c4a8dbd1b5a5652b5a8e30e
Author: Brian Olsen <brian_olsen2@comcast.com>
AuthorDate: Thu Dec 13 19:27:38 2018 +0000

    Revert "allow regex_revalidate per remap rule, remove direct ink includes"
    
    This reverts commit a89fb08794d0ffa00cf07e0825e55dcb9616bb22.
---
 doc/admin-guide/plugins/regex_revalidate.en.rst |   5 +-
 plugins/regex_revalidate/regex_revalidate.c     | 167 ++++++------------------
 2 files changed, 43 insertions(+), 129 deletions(-)

diff --git a/doc/admin-guide/plugins/regex_revalidate.en.rst b/doc/admin-guide/plugins/regex_revalidate.en.rst
index 5074882..a24fbee 100644
--- a/doc/admin-guide/plugins/regex_revalidate.en.rst
+++ b/doc/admin-guide/plugins/regex_revalidate.en.rst
@@ -24,8 +24,7 @@ Regex Revalidate Plugin
 
 This plugin allows for the creation of rules which match regular expressions
 against mapped URLs to determine if and when a cache object revalidation should
-be forced.  This plugin can be used both globally and for individual remap
-rules.
+be forced.
 
 Purpose
 =======
@@ -61,7 +60,7 @@ The rule configuration file format is described below in `Revalidation Rules`_.
 
 By default The plugin regularly (every 60 seconds) checks its rules configuration
 file for changes and it will also check for changes when ``traffic_ctl config reload``
-is run. If the file has been modified since its last scan, the contents 
+is run. If the file has been modified since its last scan, the contents
 are read and the in-memory rules list is updated. Thus, new rules may be added and
 existing ones modified without requiring a service restart.
 
diff --git a/plugins/regex_revalidate/regex_revalidate.c b/plugins/regex_revalidate/regex_revalidate.c
index 56713ea..4b009df 100644
--- a/plugins/regex_revalidate/regex_revalidate.c
+++ b/plugins/regex_revalidate/regex_revalidate.c
@@ -19,8 +19,8 @@
   limitations under the License.
  */
 
-#include "ts/ts.h"
-#include "ts/remap.h"
+#include "tscore/ink_defs.h"
+#include "tscore/ink_platform.h"
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -59,13 +59,6 @@ ts_free(void *s)
   return TSfree(s);
 }
 
-static void
-setup_memory_allocation()
-{
-  pcre_malloc = &ts_malloc;
-  pcre_free   = &ts_free;
-}
-
 typedef struct invalidate_t {
   const char *regex_text;
   pcre *regex;
@@ -338,7 +331,7 @@ list_config(plugin_state_t *pstate, invalidate_t *i)
 }
 
 static int
-free_handler(TSCont cont, TSEvent event, void *edata)
+free_handler(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
 {
   invalidate_t *iptr;
 
@@ -350,7 +343,7 @@ free_handler(TSCont cont, TSEvent event, void *edata)
 }
 
 static int
-config_handler(TSCont cont, TSEvent event, void *edata)
+config_handler(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
 {
   plugin_state_t *pstate;
   invalidate_t *i, *iptr;
@@ -460,23 +453,44 @@ main_handler(TSCont cont, TSEvent event, void *edata)
   return 0;
 }
 
-TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
+static bool
+check_ts_version()
 {
-  TSCont main_cont = NULL;
+  const char *ts_version = TSTrafficServerVersionGet();
 
-  main_cont = TSContCreate(main_handler, NULL);
-  TSContDataSet(main_cont, ih);
-  TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_REQUEST_HDR_HOOK, main_cont);
+  if (ts_version) {
+    int major_ts_version = 0;
+    int minor_ts_version = 0;
+    int micro_ts_version = 0;
 
-  return TSREMAP_NO_REMAP;
+    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;
 }
 
-static bool
-configure_plugin_state(plugin_state_t *pstate, int argc, const char **argv, bool *const disable_timed_reload)
+void
+TSPluginInit(int argc, const char *argv[])
 {
+  TSPluginRegistrationInfo info;
+  TSCont main_cont, config_cont;
+  plugin_state_t *pstate;
+  invalidate_t *iptr        = NULL;
+  bool disable_timed_reload = false;
+
+  TSDebug(LOG_PREFIX, "Starting plugin init");
+
+  pstate = (plugin_state_t *)TSmalloc(sizeof(plugin_state_t));
+  init_plugin_state_t(pstate);
+
   int c;
-  invalidate_t *iptr                    = NULL;
   static const struct option longopts[] = {{"config", required_argument, NULL, 'c'},
                                            {"log", required_argument, NULL, 'l'},
                                            {"disable-timed-reload", no_argument, NULL, 'd'},
@@ -486,19 +500,16 @@ configure_plugin_state(plugin_state_t *pstate, int argc, const char
**argv, bool
     switch (c) {
     case 'c':
       pstate->config_file = TSstrdup(optarg);
-      TSDebug(LOG_PREFIX, "Config File: %s", pstate->config_file);
       break;
     case 'l':
       if (TS_SUCCESS == TSTextLogObjectCreate(optarg, TS_LOG_MODE_ADD_TIMESTAMP, &pstate->log))
{
         TSTextLogObjectRollingEnabledSet(pstate->log, 1);
         TSTextLogObjectRollingIntervalSecSet(pstate->log, LOG_ROLL_INTERVAL);
         TSTextLogObjectRollingOffsetHrSet(pstate->log, LOG_ROLL_OFFSET);
-        TSDebug(LOG_PREFIX, "Logging Mode enabled");
       }
       break;
     case 'd':
-      *disable_timed_reload = true;
-      TSDebug(LOG_PREFIX, "Timed reload disabled (disable-timed-reload)");
+      disable_timed_reload = true;
       break;
     default:
       break;
@@ -507,7 +518,8 @@ configure_plugin_state(plugin_state_t *pstate, int argc, const char **argv,
bool
 
   if (!pstate->config_file) {
     TSError("[regex_revalidate] Plugin requires a --config option along with a config file
name");
-    return false;
+    free_plugin_state_t(pstate);
+    return;
   }
 
   if (!load_config(pstate, &iptr)) {
@@ -517,104 +529,6 @@ configure_plugin_state(plugin_state_t *pstate, int argc, const char
**argv, bool
     list_config(pstate, iptr);
   }
 
-  return true;
-}
-
-TSReturnCode
-TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_size)
-{
-  TSCont config_cont        = NULL;
-  plugin_state_t *pstate    = NULL;
-  bool disable_timed_reload = false;
-
-  TSDebug(LOG_PREFIX, "Starting remap init");
-  pstate = (plugin_state_t *)TSmalloc(sizeof(plugin_state_t));
-  init_plugin_state_t(pstate);
-
-  if (!configure_plugin_state(pstate, argc - 1, (const char **)(argv + 1), &disable_timed_reload))
{
-    free_plugin_state_t(pstate);
-    TSError("[regex_revalidate] Remap plugin registration failed");
-    return TS_ERROR;
-  }
-
-  *ih = (void *)pstate;
-
-  config_cont = TSContCreate(config_handler, TSMutexCreate());
-  TSContDataSet(config_cont, (void *)pstate);
-
-  TSMgmtUpdateRegister(config_cont, LOG_PREFIX);
-
-  if (!disable_timed_reload) {
-    TSContSchedule(config_cont, CONFIG_TMOUT, TS_THREAD_POOL_TASK);
-  }
-
-  TSDebug(LOG_PREFIX, "Remap plugin registration succeeded");
-
-  return TS_SUCCESS;
-}
-
-void
-TSRemapDeleteInstance(void *ih)
-{
-  if (NULL != ih) {
-    plugin_state_t *const pstate = (plugin_state_t *)ih;
-    free_plugin_state_t(pstate);
-  }
-}
-
-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)) {
-      return true;
-    }
-  }
-
-  return false;
-}
-
-TSReturnCode
-TSRemapInit(TSRemapInterface *api_info, char *errbug, int errbuf_size)
-{
-  setup_memory_allocation();
-
-  if (!check_ts_version()) {
-    TSError("[regex_revalidate] Plugin requires Traffic Server %d", TS_VERSION_MAJOR);
-    return TS_ERROR;
-  }
-
-  return TS_SUCCESS;
-}
-
-void
-TSPluginInit(int argc, const char *argv[])
-{
-  TSPluginRegistrationInfo info;
-  TSCont main_cont, config_cont;
-  plugin_state_t *pstate    = NULL;
-  bool disable_timed_reload = false;
-
-  TSDebug(LOG_PREFIX, "Starting plugin init");
-
-  pstate = (plugin_state_t *)TSmalloc(sizeof(plugin_state_t));
-  init_plugin_state_t(pstate);
-
-  if (!configure_plugin_state(pstate, argc, argv, &disable_timed_reload)) {
-    free_plugin_state_t(pstate);
-    return;
-  }
-
   info.plugin_name   = LOG_PREFIX;
   info.vendor_name   = "Apache Software Foundation";
   info.support_email = "dev@trafficserver.apache.org";
@@ -629,12 +543,13 @@ TSPluginInit(int argc, const char *argv[])
   }
 
   if (!check_ts_version()) {
-    TSError("[regex_revalidate] Plugin requires Traffic Server %d", TS_VERSION_MAJOR);
+    TSError("[regex_revalidate] Plugin requires Traffic Server %d.%d.%d", TS_VERSION_MAJOR,
TS_VERSION_MINOR, TS_VERSION_MICRO);
     free_plugin_state_t(pstate);
     return;
   }
 
-  setup_memory_allocation();
+  pcre_malloc = &ts_malloc;
+  pcre_free   = &ts_free;
 
   main_cont = TSContCreate(main_handler, NULL);
   TSContDataSet(main_cont, (void *)pstate);


Mime
View raw message