You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2015/01/28 17:44:46 UTC

trafficserver git commit: TS-3337: remove internal plugin SDK enumeration

Repository: trafficserver
Updated Branches:
  refs/heads/master 7b59c016b -> 7f0f3a47b


TS-3337: remove internal plugin SDK enumeration

There's no point having an internal and external plugin version
number, so remove the internal one. Fail plugin registration if the
version number fails to match.  Stop loading plugins that fail to
register.

Coverity CID #1021901


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

Branch: refs/heads/master
Commit: 7f0f3a47b253d361a16c33413b4501a5ff5d69fe
Parents: 7b59c01
Author: James Peach <jp...@apache.org>
Authored: Mon Jan 12 17:09:18 2015 -0800
Committer: James Peach <jp...@apache.org>
Committed: Wed Jan 28 08:40:03 2015 -0800

----------------------------------------------------------------------
 CHANGES         |  2 ++
 proxy/InkAPI.cc | 20 ++++++++++----------
 proxy/Plugin.cc | 32 +++++++++++++++++++++++++-------
 proxy/Plugin.h  | 11 -----------
 4 files changed, 37 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f0f3a47/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 545c72e..66766b3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.3.0
 
+  *) [TS-3337] Remove internal plugin SDK versioning.
+
   *) [TS-3336] Remove unimplemented HTTP metrics.
 
   *) [TS-3333] Enable TOS settings on IPv6 connections.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f0f3a47/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 7825eb7..2f929dd 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -1769,22 +1769,22 @@ TSPluginDirGet(void)
 TSReturnCode
 TSPluginRegister(TSSDKVersion sdk_version, TSPluginRegistrationInfo *plugin_info)
 {
-  PluginSDKVersion version = (PluginSDKVersion)sdk_version;
+  sdk_assert(sdk_sanity_check_null_ptr((void*) plugin_info) == TS_SUCCESS);
 
-  if (!plugin_reg_current)
+  if (!plugin_reg_current) {
     return TS_ERROR;
+  }
 
-  sdk_assert(sdk_sanity_check_null_ptr((void*) plugin_info) == TS_SUCCESS);
+  switch (sdk_version) {
+    case TS_SDK_VERSION_2_0:
+    case TS_SDK_VERSION_3_0:
+      break;
+    default:
+      return TS_ERROR;
+  }
 
   plugin_reg_current->plugin_registered = true;
 
-  // We're compatible only within the 3.x release
-  if (version >= PLUGIN_SDK_VERSION_3_0 && version < PLUGIN_SDK_VERSION_4_0) {
-    plugin_reg_current->sdk_version = version;
-  } else {
-    plugin_reg_current->sdk_version = PLUGIN_SDK_VERSION_UNKNOWN;
-  }
-
   if (plugin_info->plugin_name) {
     plugin_reg_current->plugin_name = ats_strdup(plugin_info->plugin_name);
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f0f3a47/proxy/Plugin.cc
----------------------------------------------------------------------
diff --git a/proxy/Plugin.cc b/proxy/Plugin.cc
index dd675cc..44f3bd9 100644
--- a/proxy/Plugin.cc
+++ b/proxy/Plugin.cc
@@ -51,9 +51,23 @@ DLL<PluginRegInfo> plugin_reg_list;
 PluginRegInfo *plugin_reg_current = NULL;
 
 PluginRegInfo::PluginRegInfo()
-  : plugin_registered(false), plugin_path(NULL), sdk_version(PLUGIN_SDK_VERSION_UNKNOWN),
+  : plugin_registered(false), plugin_path(NULL),
     plugin_name(NULL), vendor_name(NULL), support_email(NULL)
-{ }
+{
+}
+
+PluginRegInfo::~PluginRegInfo()
+{
+  // We don't support unloading plugins once they are successfully loaded, so assert
+  // that we don't accidentally attempt this.
+  ink_release_assert(this->plugin_registered == false);
+  ink_release_assert(this->link.prev == NULL);
+
+  ats_free(this->plugin_path);
+  ats_free(this->plugin_name);
+  ats_free(this->vendor_name);
+  ats_free(this->support_email);
+}
 
 static void
 plugin_load(int argc, char *argv[])
@@ -61,7 +75,6 @@ plugin_load(int argc, char *argv[])
   char path[PATH_NAME_MAX + 1];
   void *handle;
   init_func_t init;
-  PluginRegInfo *plugin_reg_temp;
 
   if (argc < 1) {
     return;
@@ -70,14 +83,14 @@ plugin_load(int argc, char *argv[])
 
   Note("loading plugin '%s'", path);
 
-  plugin_reg_temp = plugin_reg_list.head;
-  while (plugin_reg_temp) {
+  for (PluginRegInfo * plugin_reg_temp = plugin_reg_list.head; plugin_reg_temp != NULL;
+      plugin_reg_temp = (plugin_reg_temp->link).next) {
     if (strcmp(plugin_reg_temp->plugin_path, path) == 0) {
       Warning("multiple loading of plugin %s", path);
       break;
     }
-    plugin_reg_temp = (plugin_reg_temp->link).next;
   }
+
   // elevate the access to read files as root if compiled with capabilities, if not
   // change the effective user to root
   {
@@ -108,7 +121,12 @@ plugin_load(int argc, char *argv[])
     init(argc, argv);
   } // done elevating access
 
-  plugin_reg_list.push(plugin_reg_current);
+  if (plugin_reg_current->plugin_registered) {
+    plugin_reg_list.push(plugin_reg_current);
+  } else {
+    delete plugin_reg_current;
+  }
+
   plugin_reg_current = NULL;
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f0f3a47/proxy/Plugin.h
----------------------------------------------------------------------
diff --git a/proxy/Plugin.h b/proxy/Plugin.h
index 4a23557..91d9904 100644
--- a/proxy/Plugin.h
+++ b/proxy/Plugin.h
@@ -26,16 +26,6 @@
 
 #include "List.h"
 
-// need to keep syncronized with TSSDKVersion
-//   in ts/ts.h.in
-typedef enum
-{
-  PLUGIN_SDK_VERSION_UNKNOWN = -1,
-  PLUGIN_SDK_VERSION_2_0,
-  PLUGIN_SDK_VERSION_3_0,
-  PLUGIN_SDK_VERSION_4_0
-} PluginSDKVersion;
-
 struct PluginRegInfo
 {
   PluginRegInfo();
@@ -44,7 +34,6 @@ struct PluginRegInfo
   bool plugin_registered;
   char *plugin_path;
 
-  PluginSDKVersion sdk_version;
   char *plugin_name;
   char *vendor_name;
   char *support_email;