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 2019/06/15 16:22:30 UTC

[trafficserver] branch master updated (d34c192 -> e5e9074)

This is an automated email from the ASF dual-hosted git repository.

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


    from d34c192  Removes the explicit Vary configurations and code
     new ba978b6  Step 1: Removes proxy.config.admin.number_config_bak and code
     new bc04279  Step 2: Rempve findVersions(), findVersions_ml() and versionCmp()
     new d367d36  Step 3: Remove revertToVersion() and revertToVersion_ml()
     new a880a3d  Step 4: Remove forceUpdate() and forceUpdate_ml()
     new 1e938dd  Step 5: Remove removeVersion() and removeVersion_ml()
     new 6d03c33  Step 6: Simplifies checkForUserUpdate(), moving critical code here
     new 1c2a39e  Step 7: Removes updateVersion() and updateVersion_ml()
     new 589dc20  Step 8: Removes internalUpdate(), functionality was moved in 6
     new ea3859d  Step 9: Removes getVersion() and getVersion_ml()
     new d1189c2  Step 10: Removes versionTimeStamp() and versionTimeStamp_ml()
     new 33cc9e2  Step 11: Removes statVersion()
     new a28aee0  Step 12: Removes extractVersionInfo()
     new af5c885  Step 13: Removes openFile() and closeFile()
     new 1692000  Step 14: Removes numberOfVersions() and getCurrentVersion()
     new cfa1dd9  Step 15: Removes getBaseName() and various unused members
     new 3a3f286  Step 16: Removes createPathStr() and cleans up statFile()
     new 36f5925  Step 17: Removes versionInfo, as well as currentVersion and highestSeen
     new e336562  Step 18: Removes setLastModifiedTime, and simplifies code
     new e41c667  Step 19: Removes the now unused Rollback member variables
     new de76e1e  Step 20: Removes incVersion/inc_version from Filemanager etc.
     new 3ea91a0  Step 21: Removes the UNVERSIONED option flag completely
     new 8458750  Step 22: Renames Rollback.cc/.h -> ConfigManager.cc/.h
     new e5e9074  Step 23: Renames Rollback object -> FileManager consistently

The 23 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/admin-guide/files/records.config.en.rst        |   4 -
 doc/admin-guide/monitoring/error-messages.en.rst   |   5 +-
 doc/developer-guide/api/types/TSMgmtTypes.en.rst   |   2 -
 .../admin-guide/monitoring/error-messages.en.po    |   4 +-
 iocore/net/P_SSLConfig.h                           |   2 +-
 iocore/net/SSLUtils.cc                             |   8 +-
 lib/perl/lib/Apache/TS/AdminClient.pm              |   1 -
 lib/records/I_RecCore.h                            |  17 +-
 lib/records/I_RecEvents.h                          |   1 -
 lib/records/P_RecCore.cc                           |  35 +-
 lib/records/P_RecCore.h                            |   4 +-
 lib/records/RecConfigParse.cc                      |   4 +-
 lib/records/RecCore.cc                             |   2 +-
 lib/records/RecLocal.cc                            |   2 +-
 mgmt/BaseManager.h                                 |   2 +-
 mgmt/ConfigManager.cc                              | 127 +++
 mgmt/ConfigManager.h                               | 117 +++
 mgmt/FileManager.cc                                |  75 +-
 mgmt/FileManager.h                                 |  26 +-
 mgmt/LocalManager.cc                               |  26 +-
 mgmt/LocalManager.h                                |   2 +-
 mgmt/Makefile.am                                   |   4 +-
 mgmt/ProcessManager.cc                             |  11 +-
 mgmt/ProcessManager.h                              |   2 +-
 mgmt/ProxyConfig.h                                 |   4 -
 mgmt/RecordsConfig.cc                              |   2 -
 mgmt/Rollback.cc                                   | 945 ---------------------
 mgmt/Rollback.h                                    | 255 ------
 mgmt/api/CoreAPI.cc                                |   2 +-
 src/traffic_manager/AddConfigFilesHere.cc          |   2 +-
 src/traffic_manager/traffic_manager.cc             |   4 +-
 src/traffic_server/EventName.cc                    |   2 -
 src/traffic_server/HostStatus.cc                   |   2 +-
 src/traffic_server/traffic_server.cc               |  10 +-
 34 files changed, 360 insertions(+), 1351 deletions(-)
 create mode 100644 mgmt/ConfigManager.cc
 create mode 100644 mgmt/ConfigManager.h
 delete mode 100644 mgmt/Rollback.cc
 delete mode 100644 mgmt/Rollback.h


[trafficserver] 11/23: Step 11: Removes statVersion()

Posted by zw...@apache.org.
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

commit 33cc9e243047615b76b279c5ee4690c369c4d962
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:49:43 2019 -0600

    Step 11: Removes statVersion()
---
 mgmt/Rollback.cc | 12 ------------
 mgmt/Rollback.h  |  1 -
 2 files changed, 13 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index e56fa32..a669f55 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -257,18 +257,6 @@ Rollback::extractVersionInfo(ExpandingArray *listNames, const char *testFileName
   return version;
 }
 
-int
-Rollback::statVersion(version_t version, struct stat *buf)
-{
-  int r;
-
-  ink_mutex_acquire(&fileAccessLock);
-  r = this->statFile(version, buf);
-  ink_mutex_release(&fileAccessLock);
-
-  return r;
-}
-
 bool
 Rollback::setLastModifiedTime()
 {
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 27b1bbc..9f9a7e8 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -117,7 +117,6 @@ public:
 
   // Automatically take out lock
   bool checkForUserUpdate();
-  int statVersion(version_t, struct stat *buf);
   bool setLastModifiedTime();
 
   // Lock not necessary since these are only valid for a


[trafficserver] 15/23: Step 15: Removes getBaseName() and various unused members

Posted by zw...@apache.org.
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

commit cfa1dd95d88313ec64edc304d854d75aca3939e1
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:58:21 2019 -0600

    Step 15: Removes getBaseName() and various unused members
---
 mgmt/Rollback.cc |  3 +--
 mgmt/Rollback.h  | 11 +----------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index b89f17a..478d4de 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -58,8 +58,7 @@ Rollback::Rollback(const char *fileName_, const char *configName_, bool root_acc
     root_access_needed(root_access_needed_),
     parentRollback(parentRollback_),
     currentVersion(0),
-    fileLastModified(0),
-    numVersions(0)
+    fileLastModified(0)
 {
   version_t highestSeen;             // the highest backup version
   ExpandingArray existVer(25, true); // Existing versions
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index e112047..3200824 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -31,14 +31,6 @@ class TextBuffer;
 
 typedef int version_t;
 
-enum RollBackCodes {
-  OK_ROLLBACK,
-  FILE_NOT_FOUND_ROLLBACK,
-  VERSION_NOT_CURRENT_ROLLBACK,
-  SYS_CALL_ERROR_ROLLBACK,
-  INVALID_VERSION_ROLLBACK
-};
-
 class ExpandingArray;
 
 // Stores info about a backup version
@@ -88,6 +80,7 @@ public:
   {
     ink_mutex_acquire(&fileAccessLock);
   };
+
   void
   releaseLock()
   {
@@ -153,6 +146,4 @@ private:
   Rollback *parentRollback;
   version_t currentVersion;
   time_t fileLastModified;
-  int numVersions;
-  Queue<versionInfo> versionQ; // stores the backup version info
 };


[trafficserver] 23/23: Step 23: Renames Rollback object -> FileManager consistently

Posted by zw...@apache.org.
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

commit e5e90741657f99611b76d8d81c0115b3683c2200
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Thu Jun 13 10:20:32 2019 -0600

    Step 23: Renames Rollback object -> FileManager consistently
    
    I think as a future project, eliminating ConfigManager completely would be
    worthwhile, incorporating all functionality into FileManager.
---
 doc/admin-guide/monitoring/error-messages.en.rst   |  5 +--
 .../admin-guide/monitoring/error-messages.en.po    |  4 +-
 mgmt/ConfigManager.cc                              | 27 +++++------
 mgmt/ConfigManager.h                               | 26 +++++------
 mgmt/FileManager.cc                                | 52 +++++++++++-----------
 mgmt/FileManager.h                                 | 18 ++++----
 mgmt/LocalManager.cc                               |  4 +-
 7 files changed, 66 insertions(+), 70 deletions(-)

diff --git a/doc/admin-guide/monitoring/error-messages.en.rst b/doc/admin-guide/monitoring/error-messages.en.rst
index e7e4ba9..71cc2ba 100644
--- a/doc/admin-guide/monitoring/error-messages.en.rst
+++ b/doc/admin-guide/monitoring/error-messages.en.rst
@@ -78,11 +78,11 @@ Process Warnings
 Alarm Messages
 ==============
 
-``[Rollback::Rollback] Config file is read-only: <filename>``
+``[ConfigManager::ConfigManager] Config file is read-only: <filename>``
    Go to the Traffic Server ``config`` directory and check the
    indicated file permissions; change if necessary.
 
-``[Rollback::Rollback] Unable to read or write config file <filename>``
+``[ConfigManager::ConfigManager] Unable to read or write config file <filename>``
    Go to the Traffic Server ``config`` directory and make sure the
    indicated file exists. Check permissions and modify if necessary.
 
@@ -311,4 +311,3 @@ with corresponding HTTP response codes and customizable files.
    Cannot perform your request for the document ``URL`` because the
    protocol scheme is unknown.
    ``request#scheme_unsupported``
-
diff --git a/doc/locale/ja/LC_MESSAGES/admin-guide/monitoring/error-messages.en.po b/doc/locale/ja/LC_MESSAGES/admin-guide/monitoring/error-messages.en.po
index c0fa265..0000fb2 100644
--- a/doc/locale/ja/LC_MESSAGES/admin-guide/monitoring/error-messages.en.po
+++ b/doc/locale/ja/LC_MESSAGES/admin-guide/monitoring/error-messages.en.po
@@ -185,7 +185,7 @@ msgid "Alarm Messages"
 msgstr ""
 
 #: ../../../admin-guide/monitoring/error-messages.en.rst:92
-msgid "``[Rollback::Rollback] Config file is read-only: <filename>``"
+msgid "``[ConfigManager::ConfigManager] Config file is read-only: <filename>``"
 msgstr ""
 
 #: ../../../admin-guide/monitoring/error-messages.en.rst:91
@@ -199,7 +199,7 @@ msgstr ""
 
 #: ../../../admin-guide/monitoring/error-messages.en.rst:96
 msgid ""
-"``[Rollback::Rollback] Unable to read or write config file <filename>``"
+"``[ConfigManager::ConfigManager] Unable to read or write config file <filename>``"
 msgstr ""
 
 #: ../../../admin-guide/monitoring/error-messages.en.rst:95
diff --git a/mgmt/ConfigManager.cc b/mgmt/ConfigManager.cc
index 4b53cb4..e5ffa73 100644
--- a/mgmt/ConfigManager.cc
+++ b/mgmt/ConfigManager.cc
@@ -1,6 +1,6 @@
 /** @file
 
-  This file contains code for class to allow rollback of configuration files
+  This file contains code for class to allow management of configuration files
 
   @section license License
 
@@ -42,20 +42,16 @@
 #define TS_ARCHIVE_STAT_MTIME(t) ((t).st_mtime * 1000000000)
 #endif
 
-// Error Strings
-const char *RollbackStrings[] = {"Rollback Ok", "File was not found", "Version was out of date", "System Call Error",
-                                 "Invalid Version - Version Numbers Must Increase"};
-
-Rollback::Rollback(const char *fileName_, const char *configName_, bool root_access_needed_, Rollback *parentRollback_)
-  : root_access_needed(root_access_needed_), parentRollback(parentRollback_)
+ConfigManager::ConfigManager(const char *fileName_, const char *configName_, bool root_access_needed_, ConfigManager *parentConfig_)
+  : root_access_needed(root_access_needed_), parentConfig(parentConfig_)
 {
   ExpandingArray existVer(25, true); // Existing versions
   struct stat fileInfo;
   ink_assert(fileName_ != nullptr);
 
   // parent must not also have a parent
-  if (parentRollback) {
-    ink_assert(parentRollback->parentRollback == nullptr);
+  if (parentConfig) {
+    ink_assert(parentConfig->parentConfig == nullptr);
   }
 
   // Copy the file name.
@@ -68,26 +64,27 @@ Rollback::Rollback(const char *fileName_, const char *configName_, bool root_acc
   //
   if (statFile(&fileInfo) < 0) {
     // If we can't find an active version because there is none we have a hard failure.
-    mgmt_fatal(0, "[RollBack::Rollback] Unable to find configuration file %s.\n\tStat failed : %s\n", fileName, strerror(errno));
+    mgmt_fatal(0, "[ConfigManager::ConfigManager] Unable to find configuration file %s.\n\tStat failed : %s\n", fileName,
+               strerror(errno));
 
   } else {
     fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
   }
 }
 
-Rollback::~Rollback()
+ConfigManager::~ConfigManager()
 {
   ats_free(fileName);
 }
 
 //
 //
-// int Rollback::statFile()
+// int ConfigManager::statFile()
 //
 //  A wrapper for stat()
 //
 int
-Rollback::statFile(struct stat *buf)
+ConfigManager::statFile(struct stat *buf)
 {
   int statResult;
   std::string sysconfdir(RecConfigReadConfigDir());
@@ -98,12 +95,12 @@ Rollback::statFile(struct stat *buf)
   return statResult;
 }
 
-// bool Rollback::checkForUserUpdate()
+// bool ConfigManager::checkForUserUpdate()
 //
 //  Called to check if the file has been changed  by the user.
 //  Timestamps are compared to see if a change occurred
 bool
-Rollback::checkForUserUpdate()
+ConfigManager::checkForUserUpdate()
 {
   struct stat fileInfo;
   bool result;
diff --git a/mgmt/ConfigManager.h b/mgmt/ConfigManager.h
index f118e89..d27aed1 100644
--- a/mgmt/ConfigManager.h
+++ b/mgmt/ConfigManager.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Interface for class to allow rollback of configuration files
+  Interface for class to allow management of configuration files
 
   @section license License
 
@@ -32,7 +32,7 @@ class TextBuffer;
 class ExpandingArray;
 
 //
-//  class Rollback
+//  class ConfigManager
 //
 //  public functions
 //
@@ -45,12 +45,12 @@ class ExpandingArray;
 //
 //  statFile(struct stat*) - a wrapper for stat(), using layout engine
 //
-class Rollback
+class ConfigManager
 {
 public:
   // fileName_ should be rooted or a base file name.
-  Rollback(const char *fileName_, const char *configName_, bool root_access_needed, Rollback *parentRollback);
-  ~Rollback();
+  ConfigManager(const char *fileName_, const char *configName_, bool root_access_needed, ConfigManager *parentConfig_);
+  ~ConfigManager();
 
   // Manual take out of lock required
   void
@@ -82,15 +82,15 @@ public:
   }
 
   bool
-  isChildRollback() const
+  isChildManaged() const
   {
-    return parentRollback != nullptr;
+    return parentConfig != nullptr;
   }
 
-  Rollback *
-  getParentRollback() const
+  ConfigManager *
+  getParentConfig() const
   {
-    return parentRollback;
+    return parentConfig;
   }
 
   bool
@@ -102,8 +102,8 @@ public:
   FileManager *configFiles = nullptr; // Manager to notify on an update.
 
   // noncopyable
-  Rollback(const Rollback &) = delete;
-  Rollback &operator=(const Rollback &) = delete;
+  ConfigManager(const ConfigManager &) = delete;
+  ConfigManager &operator=(const ConfigManager &) = delete;
 
 private:
   int statFile(struct stat *buf);
@@ -112,6 +112,6 @@ private:
   char *fileName;
   char *configName;
   bool root_access_needed;
-  Rollback *parentRollback;
+  ConfigManager *parentConfig;
   time_t fileLastModified = 0;
 };
diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index fc1d068..d409045 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -82,9 +82,9 @@ FileManager::registerCallback(FileCallbackFunc func)
 }
 
 // void FileManager::addFile(char* fileName, const configFileInfo* file_info,
-//  Rollback* parentRollback)
+//  ConfigManager* parentConfig)
 //
-//  for the baseFile, creates a Rollback object for it
+//  for the baseFile, creates a ConfigManager object for it
 //
 //  if file_info is not null, a WebFileEdit object is also created for
 //    the file
@@ -92,34 +92,34 @@ FileManager::registerCallback(FileCallbackFunc func)
 //  Pointers to the new objects are stored in the bindings hashtable
 //
 void
-FileManager::addFile(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback)
+FileManager::addFile(const char *fileName, const char *configName, bool root_access_needed, ConfigManager *parentConfig)
 {
   ink_mutex_acquire(&accessLock);
-  addFileHelper(fileName, configName, root_access_needed, parentRollback);
+  addFileHelper(fileName, configName, root_access_needed, parentConfig);
   ink_mutex_release(&accessLock);
 }
 
 // caller must hold the lock
 void
-FileManager::addFileHelper(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback)
+FileManager::addFileHelper(const char *fileName, const char *configName, bool root_access_needed, ConfigManager *parentConfig)
 {
   ink_assert(fileName != nullptr);
 
-  Rollback *rb    = new Rollback(fileName, configName, root_access_needed, parentRollback);
-  rb->configFiles = this;
+  ConfigManager *rb = new ConfigManager(fileName, configName, root_access_needed, parentConfig);
+  rb->configFiles   = this;
 
   bindings.emplace(rb->getFileName(), rb);
 }
 
-// bool FileManager::getRollbackObj(char* fileName, Rollback** rbPtr)
+// bool FileManager::getConfigManagerObj(char* fileName, ConfigManager** rbPtr)
 //
-//  Sets rbPtr to the rollback object associated
+//  Sets rbPtr to the ConfigManager object associated
 //    with the passed in fileName.
 //
 //  If there is no binding, false is returned
 //
 bool
-FileManager::getRollbackObj(const char *fileName, Rollback **rbPtr)
+FileManager::getConfigObj(const char *fileName, ConfigManager **rbPtr)
 {
   ink_mutex_acquire(&accessLock);
   auto it    = bindings.find(fileName);
@@ -132,7 +132,7 @@ FileManager::getRollbackObj(const char *fileName, Rollback **rbPtr)
 
 // bool FileManager::fileChanged(const char* fileName)
 //
-//  Called by the Rollback class whenever a config has changed
+//  Called by the ConfigManager class whenever a config has changed
 //     Initiates callbacks
 //
 //
@@ -159,7 +159,7 @@ FileManager::fileChanged(const char *fileName, const char *configName)
 // void FileManger::rereadConfig()
 //
 //   Iterates through the list of managed files and
-//     calls Rollback::checkForUserUpdate on them
+//     calls ConfigManager::checkForUserUpdate on them
 //
 //   although it is tempting, DO NOT CALL FROM SIGNAL HANDLERS
 //      This function is not Async-Signal Safe.  It
@@ -167,10 +167,10 @@ FileManager::fileChanged(const char *fileName, const char *configName)
 void
 FileManager::rereadConfig()
 {
-  Rollback *rb;
+  ConfigManager *rb;
 
-  std::vector<Rollback *> changedFiles;
-  std::vector<Rollback *> parentFileNeedChange;
+  std::vector<ConfigManager *> changedFiles;
+  std::vector<ConfigManager *> parentFileNeedChange;
   size_t n;
   ink_mutex_acquire(&accessLock);
   for (auto &&it : bindings) {
@@ -179,25 +179,25 @@ FileManager::rereadConfig()
     // happen at all...
     if (rb->checkForUserUpdate()) {
       changedFiles.push_back(rb);
-      if (rb->isChildRollback()) {
-        if (std::find(parentFileNeedChange.begin(), parentFileNeedChange.end(), rb->getParentRollback()) ==
+      if (rb->isChildManaged()) {
+        if (std::find(parentFileNeedChange.begin(), parentFileNeedChange.end(), rb->getParentConfig()) ==
             parentFileNeedChange.end()) {
-          parentFileNeedChange.push_back(rb->getParentRollback());
+          parentFileNeedChange.push_back(rb->getParentConfig());
         }
       }
     }
   }
 
-  std::vector<Rollback *> childFileNeedDelete;
+  std::vector<ConfigManager *> childFileNeedDelete;
   n = changedFiles.size();
   for (size_t i = 0; i < n; i++) {
-    if (changedFiles[i]->isChildRollback()) {
+    if (changedFiles[i]->isChildManaged()) {
       continue;
     }
     // for each parent file, if it is changed, then delete all its children
     for (auto &&it : bindings) {
       rb = it.second;
-      if (rb->getParentRollback() == changedFiles[i]) {
+      if (rb->getParentConfig() == changedFiles[i]) {
         if (std::find(childFileNeedDelete.begin(), childFileNeedDelete.end(), rb) == childFileNeedDelete.end()) {
           childFileNeedDelete.push_back(rb);
         }
@@ -231,7 +231,7 @@ FileManager::rereadConfig()
 bool
 FileManager::isConfigStale()
 {
-  Rollback *rb;
+  ConfigManager *rb;
   bool stale = false;
 
   ink_mutex_acquire(&accessLock);
@@ -249,15 +249,15 @@ FileManager::isConfigStale()
 
 // void configFileChild(const char *parent, const char *child)
 //
-// Add child to the bindings with parentRollback
+// Add child to the bindings with parentConfig
 void
 FileManager::configFileChild(const char *parent, const char *child)
 {
-  Rollback *parentRollback = nullptr;
+  ConfigManager *parentConfig = nullptr;
   ink_mutex_acquire(&accessLock);
   if (auto it = bindings.find(parent); it != bindings.end()) {
-    parentRollback = it->second;
-    addFileHelper(child, "", parentRollback->rootAccessNeeded(), parentRollback);
+    parentConfig = it->second;
+    addFileHelper(child, "", parentConfig->rootAccessNeeded(), parentConfig);
   }
   ink_mutex_release(&accessLock);
 }
diff --git a/mgmt/FileManager.h b/mgmt/FileManager.h
index ea45500..dfc59cf 100644
--- a/mgmt/FileManager.h
+++ b/mgmt/FileManager.h
@@ -29,7 +29,7 @@
 #include <unordered_map>
 
 class ExpandingArray;
-class Rollback;
+class ConfigManager;
 
 typedef void (*FileCallbackFunc)(char *, char *);
 
@@ -49,11 +49,11 @@ enum lockAction_t {
 //  public functions:
 //
 //  addFile(char*, char *, configFileInfo*) - adds a new config file to be
-//       managed.  A rollback object is created for the file.
+//       managed.  A ConfigManager object is created for the file.
 //       if the file_info ptr is not NULL, a WebFileEdit object
 //       is also created
 //
-//  getRollbckObj(char* , RollbackPtr**) - sets *rbPtr to Rollback
+//  getRollbckObj(char* , ConfigManagerPtr**) - sets *rbPtr to ConfigManager
 //       object bound to fileName.  Returns true if there is
 //       a binding and false otherwise
 //
@@ -64,9 +64,9 @@ enum lockAction_t {
 //  registerCallback(FileCallbackFunc) - registers a callback function
 //       which will get called every time a managed file changes.  The
 //       callback function should NOT use the calling thread to
-//       access any Rollback objects or block for a long time
+//       access any ConfigManager objects or block for a long time
 //
-//  fileChanged(const char* fileName, const char *configName) - called by Rollback objects
+//  fileChanged(const char* fileName, const char *configName) - called by ConfigManager objects
 //       when their contents change.  Triggers callbacks to FileCallbackFuncs
 //
 //  isConfigStale() - returns whether the in-memory files might be stale
@@ -80,8 +80,8 @@ class FileManager
 public:
   FileManager();
   ~FileManager();
-  void addFile(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback = nullptr);
-  bool getRollbackObj(const char *fileName, Rollback **rbPtr);
+  void addFile(const char *fileName, const char *configName, bool root_access_needed, ConfigManager *parentConfig = nullptr);
+  bool getConfigObj(const char *fileName, ConfigManager **rbPtr);
   void registerCallback(FileCallbackFunc func);
   void fileChanged(const char *fileName, const char *configName);
   void rereadConfig();
@@ -92,8 +92,8 @@ private:
   ink_mutex accessLock; // Protects bindings hashtable
   ink_mutex cbListLock; // Protects the CallBack List
   DLL<callbackListable> cblist;
-  std::unordered_map<std::string_view, Rollback *> bindings;
-  void addFileHelper(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback);
+  std::unordered_map<std::string_view, ConfigManager *> bindings;
+  void addFileHelper(const char *fileName, const char *configName, bool root_access_needed, ConfigManager *parentConfig);
 };
 
 void initializeRegistry(); // implemented in AddConfigFilesHere.cc
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 058b782..2a0d3d7 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -606,7 +606,7 @@ LocalManager::sendMgmtMsgToProcesses(MgmtMessageHdr *mh)
   case MGMT_EVENT_CONFIG_FILE_UPDATE:
     bool found;
     char *fname = nullptr;
-    Rollback *rb;
+    ConfigManager *rb;
     char *data_raw;
 
     data_raw = (char *)mh + sizeof(MgmtMessageHdr);
@@ -619,7 +619,7 @@ LocalManager::sendMgmtMsgToProcesses(MgmtMessageHdr *mh)
       mgmt_log("[LocalManager:sendMgmtMsgToProcesses] Unknown file change: '%s'\n", data_raw);
     }
     ink_assert(found);
-    if (!(fname && configFiles && configFiles->getRollbackObj(fname, &rb)) &&
+    if (!(fname && configFiles && configFiles->getConfigObj(fname, &rb)) &&
         (strcmp(data_raw, "proxy.config.body_factory.template_sets_dir") != 0) &&
         (strcmp(data_raw, "proxy.config.ssl.server.ticket_key.filename") != 0)) {
       mgmt_fatal(0, "[LocalManager::sendMgmtMsgToProcesses] "


[trafficserver] 09/23: Step 9: Removes getVersion() and getVersion_ml()

Posted by zw...@apache.org.
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

commit ea3859d9d3a9d0ecf9ad42c72eca72de1db5658d
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:47:30 2019 -0600

    Step 9: Removes getVersion() and getVersion_ml()
---
 mgmt/Rollback.cc | 74 --------------------------------------------------------
 mgmt/Rollback.h  |  2 --
 2 files changed, 76 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index fab496b..06a0e8c 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -203,80 +203,6 @@ Rollback::closeFile(int fd, bool callSync)
   return result;
 }
 
-RollBackCodes
-Rollback::getVersion(version_t version, TextBuffer **buffer)
-{
-  RollBackCodes r;
-
-  this->acquireLock();
-  r = getVersion_ml(version, buffer);
-  this->releaseLock();
-
-  return r;
-}
-
-// CALLEE DELETES STORAGE
-RollBackCodes
-Rollback::getVersion_ml(version_t version, TextBuffer **buffer)
-{
-  int diskFD;               // file descriptor for version of the file we are fetching
-  RollBackCodes returnCode; // our eventual return value
-  struct stat fileInfo;     // Info from fstat
-  int readResult;           // return val of (indirect) read calls
-  TextBuffer *newBuffer;    // return buffer
-
-  *buffer = nullptr;
-
-  if (version == currentVersion) {
-    version = ACTIVE_VERSION;
-  }
-  diskFD = openFile(version, O_RDONLY);
-
-  if (diskFD < 0) {
-    returnCode = FILE_NOT_FOUND_ROLLBACK;
-    goto GET_CLEANUP;
-  }
-  // fstat the file so that we know what size is supposed to be
-  if (fstat(diskFD, &fileInfo) < 0) {
-    mgmt_log("[Rollback::getVersion] fstat on %s version %d failed: %s\n", fileName, version, strerror(errno));
-    returnCode = FILE_NOT_FOUND_ROLLBACK;
-    goto GET_CLEANUP;
-  }
-  // Create a textbuffer of the
-  newBuffer = new TextBuffer(fileInfo.st_size + 1);
-
-  do {
-    readResult = newBuffer->readFromFD(diskFD);
-
-    if (readResult < 0) {
-      mgmt_log("[Rollback::getVersion] read failed on %s version %d: %s\n", fileName, version, strerror(errno));
-      returnCode = SYS_CALL_ERROR_ROLLBACK;
-      delete newBuffer;
-      goto GET_CLEANUP;
-    }
-  } while (readResult > 0);
-
-  if ((off_t)newBuffer->spaceUsed() != fileInfo.st_size) {
-    mgmt_log("[Rollback::getVersion] Incorrect amount of data retrieved from %s version %d.  Expected: %d   Got: %d\n", fileName,
-             version, fileInfo.st_size, newBuffer->spaceUsed());
-    returnCode = SYS_CALL_ERROR_ROLLBACK;
-    delete newBuffer;
-    goto GET_CLEANUP;
-  }
-
-  *buffer = newBuffer;
-
-  returnCode = OK_ROLLBACK;
-
-GET_CLEANUP:
-
-  if (diskFD >= 0) {
-    closeFile(diskFD, false);
-  }
-
-  return returnCode;
-}
-
 // version_t Rollback::extractVersionInfo(ExpandingArray* listNames,
 //                                        const char* testFileName)
 //
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 90aeee7..335a02c 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -117,13 +117,11 @@ public:
   {
     ink_mutex_release(&fileAccessLock);
   };
-  RollBackCodes getVersion_ml(version_t version, TextBuffer **buffer);
   time_t versionTimeStamp_ml(version_t version);
   version_t extractVersionInfo(ExpandingArray *listNames, const char *testFileName);
 
   // Automatically take out lock
   bool checkForUserUpdate();
-  RollBackCodes getVersion(version_t version, TextBuffer **buffer);
   time_t versionTimeStamp(version_t version);
   int statVersion(version_t, struct stat *buf);
   bool setLastModifiedTime();


[trafficserver] 07/23: Step 7: Removes updateVersion() and updateVersion_ml()

Posted by zw...@apache.org.
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

commit 1c2a39e5218a5835675e3c5c4d433376a746d521
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:42:30 2019 -0600

    Step 7: Removes updateVersion() and updateVersion_ml()
---
 mgmt/Rollback.cc | 26 --------------------------
 mgmt/Rollback.h  | 10 ----------
 2 files changed, 36 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index c1c36cf..f60bcdf 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -203,32 +203,6 @@ Rollback::closeFile(int fd, bool callSync)
   return result;
 }
 
-RollBackCodes
-Rollback::updateVersion(TextBuffer *buf, version_t basedOn, version_t newVersion, bool notifyChange, bool incVersion)
-{
-  RollBackCodes returnCode;
-
-  this->acquireLock();
-  returnCode = this->updateVersion_ml(buf, basedOn, newVersion, notifyChange, incVersion);
-  this->releaseLock();
-
-  return returnCode;
-}
-
-RollBackCodes
-Rollback::updateVersion_ml(TextBuffer *buf, version_t basedOn, version_t newVersion, bool notifyChange, bool incVersion)
-{
-  RollBackCodes returnCode;
-
-  if (basedOn != currentVersion) {
-    returnCode = VERSION_NOT_CURRENT_ROLLBACK;
-  } else {
-    returnCode = internalUpdate(buf, newVersion, notifyChange, incVersion);
-  }
-
-  return returnCode;
-}
-
 // Rollback::internalUpdate()
 //
 //  Creates a version from buf.  Callee must be holding the lock
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index d29a4bf..a3608d0 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -63,12 +63,6 @@ struct versionInfo {
 //    creates a new TextBuffer that contains the contents of the specified
 //    version.  CALLEE MUST DELETE the buffer
 //
-//  updateVersion(TextBuffer* buf, version_t basedOn) - checks to
-//    if basedOn is the current version.  If it is not, the update
-//    rejected.  If it is current, the active file is versioned and
-//    the contents of buf become the new active file. newVersion tells us what
-//    the new version number should be.  -1 means the next in sequence
-//
 //  getCurrentVersion() - returns the current version number.  Unless the
 //    callee was acquired the fileAccessLock, the return value only represents
 //    a snap shot in time
@@ -128,16 +122,12 @@ public:
     ink_mutex_release(&fileAccessLock);
   };
   RollBackCodes getVersion_ml(version_t version, TextBuffer **buffer);
-  RollBackCodes updateVersion_ml(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
-                                 bool incVersion = true);
   time_t versionTimeStamp_ml(version_t version);
   version_t extractVersionInfo(ExpandingArray *listNames, const char *testFileName);
 
   // Automatically take out lock
   bool checkForUserUpdate();
   RollBackCodes getVersion(version_t version, TextBuffer **buffer);
-  RollBackCodes updateVersion(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
-                              bool incVersion = true);
   time_t versionTimeStamp(version_t version);
   int statVersion(version_t, struct stat *buf);
   bool setLastModifiedTime();


[trafficserver] 04/23: Step 4: Remove forceUpdate() and forceUpdate_ml()

Posted by zw...@apache.org.
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

commit a880a3d29c01dcaa3ea0aaf86f55d831ef80b9a9
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 14:47:19 2019 -0600

    Step 4: Remove forceUpdate() and forceUpdate_ml()
---
 mgmt/Rollback.cc | 18 ------------------
 mgmt/Rollback.h  |  6 ------
 2 files changed, 24 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 1da6817..e4aa1e7 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -229,24 +229,6 @@ Rollback::updateVersion_ml(TextBuffer *buf, version_t basedOn, version_t newVers
   return returnCode;
 }
 
-RollBackCodes
-Rollback::forceUpdate(TextBuffer *buf, version_t newVersion)
-{
-  RollBackCodes r;
-
-  ink_mutex_acquire(&fileAccessLock);
-  r = this->forceUpdate_ml(buf, newVersion);
-  ink_mutex_release(&fileAccessLock);
-
-  return r;
-}
-
-RollBackCodes
-Rollback::forceUpdate_ml(TextBuffer *buf, version_t newVersion)
-{
-  return this->internalUpdate(buf, newVersion);
-}
-
 // Rollback::internalUpdate()
 //
 //  Creates a version from buf.  Callee must be holding the lock
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 64b24a8..5ce3548 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -77,10 +77,6 @@ struct versionInfo {
 //    the contents of buf become the new active file. newVersion tells us what
 //    the new version number should be.  -1 means the next in sequence
 //
-//  forceUpdate(TextBuffer* buf, version_t) - Does not check is the new version
-//    is based on the current version, which can lead to data loss.  versions
-//    the active file and places the contents of buf into the active file
-//
 //  getCurrentVersion() - returns the current version number.  Unless the
 //    callee was acquired the fileAccessLock, the return value only represents
 //    a snap shot in time
@@ -143,7 +139,6 @@ public:
   RollBackCodes getVersion_ml(version_t version, TextBuffer **buffer);
   RollBackCodes updateVersion_ml(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
                                  bool incVersion = true);
-  RollBackCodes forceUpdate_ml(TextBuffer *buf, version_t newVersion = -1);
   time_t versionTimeStamp_ml(version_t version);
   version_t extractVersionInfo(ExpandingArray *listNames, const char *testFileName);
 
@@ -153,7 +148,6 @@ public:
   RollBackCodes getVersion(version_t version, TextBuffer **buffer);
   RollBackCodes updateVersion(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
                               bool incVersion = true);
-  RollBackCodes forceUpdate(TextBuffer *buf, version_t newVersion = -1);
   time_t versionTimeStamp(version_t version);
   int statVersion(version_t, struct stat *buf);
   bool setLastModifiedTime();


[trafficserver] 06/23: Step 6: Simplifies checkForUserUpdate(), moving critical code here

Posted by zw...@apache.org.
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

commit 6d03c33ed841ee62055cfe9d3780f8a7651030fe
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:29:21 2019 -0600

    Step 6: Simplifies checkForUserUpdate(), moving critical code here
---
 mgmt/FileManager.cc |  4 ++--
 mgmt/Rollback.cc    | 38 ++++++--------------------------------
 mgmt/Rollback.h     |  7 +------
 3 files changed, 9 insertions(+), 40 deletions(-)

diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index 74ac4c2..2dd3fb7 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -179,7 +179,7 @@ FileManager::rereadConfig()
     rb = it.second;
     // ToDo: rb->isVersions() was always true before, because numberBackups was always >= 1. So ROLLBACK_CHECK_ONLY could not
     // happen at all...
-    if (rb->checkForUserUpdate(ROLLBACK_CHECK_AND_UPDATE)) {
+    if (rb->checkForUserUpdate()) {
       changedFiles.push_back(rb);
       if (rb->isChildRollback()) {
         if (std::find(parentFileNeedChange.begin(), parentFileNeedChange.end(), rb->getParentRollback()) ==
@@ -238,7 +238,7 @@ FileManager::isConfigStale()
   ink_mutex_acquire(&accessLock);
   for (auto &&it : bindings) {
     rb = it.second;
-    if (rb->checkForUserUpdate(ROLLBACK_CHECK_ONLY)) {
+    if (rb->checkForUserUpdate()) {
       stale = true;
       break;
     }
diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 8bcac70..c1c36cf 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -545,29 +545,14 @@ Rollback::setLastModifiedTime()
 
 // bool Rollback::checkForUserUpdate()
 //
-//  Called to check if the file has been changed
-//    by the user.  Timestamps are compared to see if a
-//    change occurred
-//
-//  If the file has been changed, a new version is rolled.
-//    The new current version and its predecessor will
-//    be the same in this case.  While this is pointless,
-//    for Rolling backward, we need to the version number
-//    to up'ed so that WebFileEdit knows that the file has
-//    changed.  Rolling a new version also has the effect
-//    of creating a new timestamp
-//
+//  Called to check if the file has been changed  by the user.
+//  Timestamps are compared to see if a change occurred
 bool
-Rollback::checkForUserUpdate(RollBackCheckType how)
+Rollback::checkForUserUpdate()
 {
   struct stat fileInfo;
   bool result;
 
-  // Variables to roll the current version
-  version_t currentVersion_local;
-  TextBuffer *buf;
-  RollBackCodes r;
-
   ink_mutex_acquire(&fileAccessLock);
 
   if (this->statFile(ACTIVE_VERSION, &fileInfo) < 0) {
@@ -576,20 +561,9 @@ Rollback::checkForUserUpdate(RollBackCheckType how)
   }
 
   if (fileLastModified < TS_ARCHIVE_STAT_MTIME(fileInfo)) {
-    if (how == ROLLBACK_CHECK_AND_UPDATE) {
-      // We've been modified, Roll a new version
-      currentVersion_local = this->getCurrentVersion();
-      r                    = this->getVersion_ml(currentVersion_local, &buf);
-      if (r == OK_ROLLBACK) {
-        r = this->updateVersion_ml(buf, currentVersion_local);
-        delete buf;
-      }
-      if (r != OK_ROLLBACK) {
-        mgmt_log("[Rollback::checkForUserUpdate] Failed to roll changed user file %s: %s", fileName, RollbackStrings[r]);
-      }
-
-      mgmt_log("User has changed config file %s\n", fileName);
-    }
+    setLastModifiedTime();
+    configFiles->fileChanged(fileName, configName, true);
+    mgmt_log("User has changed config file %s\n", fileName);
 
     result = true;
   } else {
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 692dc25..d29a4bf 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -39,11 +39,6 @@ enum RollBackCodes {
   INVALID_VERSION_ROLLBACK
 };
 
-enum RollBackCheckType {
-  ROLLBACK_CHECK_AND_UPDATE,
-  ROLLBACK_CHECK_ONLY,
-};
-
 class ExpandingArray;
 
 // Stores info about a backup version
@@ -139,7 +134,7 @@ public:
   version_t extractVersionInfo(ExpandingArray *listNames, const char *testFileName);
 
   // Automatically take out lock
-  bool checkForUserUpdate(RollBackCheckType);
+  bool checkForUserUpdate();
   RollBackCodes getVersion(version_t version, TextBuffer **buffer);
   RollBackCodes updateVersion(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
                               bool incVersion = true);


[trafficserver] 17/23: Step 17: Removes versionInfo, as well as currentVersion and highestSeen

Posted by zw...@apache.org.
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

commit 36f59255e50f9348a3726e13fe1f0c8c3697dad7
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Mon May 27 14:24:00 2019 -0600

    Step 17: Removes versionInfo, as well as currentVersion and highestSeen
---
 mgmt/Rollback.cc | 14 +-------------
 mgmt/Rollback.h  |  8 --------
 2 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 5c8ec3e..c33d0d8 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -48,13 +48,8 @@ const char *RollbackStrings[] = {"Rollback Ok", "File was not found", "Version w
 
 Rollback::Rollback(const char *fileName_, const char *configName_, bool root_access_needed_, Rollback *parentRollback_,
                    unsigned flags)
-  : configFiles(nullptr),
-    root_access_needed(root_access_needed_),
-    parentRollback(parentRollback_),
-    currentVersion(0),
-    fileLastModified(0)
+  : configFiles(nullptr), root_access_needed(root_access_needed_), parentRollback(parentRollback_), fileLastModified(0)
 {
-  version_t highestSeen;             // the highest backup version
   ExpandingArray existVer(25, true); // Existing versions
   struct stat fileInfo;
   ink_assert(fileName_ != nullptr);
@@ -81,14 +76,10 @@ Rollback::Rollback(const char *fileName_, const char *configName_, bool root_acc
 
   // ToDo: This was really broken before, it  used to check if numberBackups <=0, but that could never happen.
   if (flags & CONFIG_FLAG_UNVERSIONED) {
-    currentVersion = 0;
     setLastModifiedTime();
     return;
   }
 
-  currentVersion = 0; // Prevent UMR with stat file
-  highestSeen    = 0;
-
   // Check to make sure that our configuration file exists
   //
   if (statFile(&fileInfo) < 0) {
@@ -97,9 +88,6 @@ Rollback::Rollback(const char *fileName_, const char *configName_, bool root_acc
 
   } else {
     fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
-    currentVersion   = highestSeen + 1;
-
-    Debug("rollback", "[Rollback::Rollback] Current Version of %s is %d", fileName, currentVersion);
   }
 }
 
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 2d4cba4..e58db4a 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -53,13 +53,6 @@ struct versionInfo {
 //
 // private functions
 //
-//  CURRENT_VERSION means the active version.  The active version does not
-//    have _version appended to its name.  All prior versions are stored
-//    as fileName_version.  Calling file operations with CURRENT_VERSION
-//    and this->currentVersion have different meanings.  this->currentVersion
-//    refers to a file with an _version which does not exist for the active
-//    version.
-//
 //  statFile(struct stat*) - a wrapper for stat(), using layout engine
 //
 class Rollback
@@ -139,6 +132,5 @@ private:
   size_t fileNameLen;
   bool root_access_needed;
   Rollback *parentRollback;
-  version_t currentVersion;
   time_t fileLastModified;
 };


[trafficserver] 01/23: Step 1: Removes proxy.config.admin.number_config_bak and code

Posted by zw...@apache.org.
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

commit ba978b66afe6bd3c807fc553c1ead9b7c880806d
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Mon May 20 12:17:50 2019 -0600

    Step 1: Removes proxy.config.admin.number_config_bak and code
---
 doc/admin-guide/files/records.config.en.rst |   4 -
 lib/perl/lib/Apache/TS/AdminClient.pm       |   1 -
 mgmt/FileManager.cc                         |   4 +-
 mgmt/RecordsConfig.cc                       |   2 -
 mgmt/Rollback.cc                            | 146 ++--------------------------
 mgmt/Rollback.h                             |  11 +--
 6 files changed, 18 insertions(+), 150 deletions(-)

diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst
index 0c3f0a0..11107d1 100644
--- a/doc/admin-guide/files/records.config.en.rst
+++ b/doc/admin-guide/files/records.config.en.rst
@@ -496,10 +496,6 @@ Network
 Local Manager
 =============
 
-.. ts:cv:: CONFIG proxy.config.admin.number_config_bak INT 3
-
-   The maximum number of copies of rolled configuration files to keep.
-
 .. ts:cv:: CONFIG proxy.config.admin.user_id STRING nobody
 
    Designates the non-privileged account to run the :program:`traffic_server`
diff --git a/lib/perl/lib/Apache/TS/AdminClient.pm b/lib/perl/lib/Apache/TS/AdminClient.pm
index 5bc456b..5529d49 100644
--- a/lib/perl/lib/Apache/TS/AdminClient.pm
+++ b/lib/perl/lib/Apache/TS/AdminClient.pm
@@ -319,7 +319,6 @@ The Apache Traffic Server Administration Manual will explain what these strings
  proxy.config.task_threads
  proxy.config.admin.synthetic_port
  proxy.config.admin.cli_path
- proxy.config.admin.number_config_bak
  proxy.config.admin.user_id
  proxy.config.alarm.abs_path
  proxy.config.alarm.bin
diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index 9288d92..74ac4c2 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -177,7 +177,9 @@ FileManager::rereadConfig()
   ink_mutex_acquire(&accessLock);
   for (auto &&it : bindings) {
     rb = it.second;
-    if (rb->checkForUserUpdate(rb->isVersioned() ? ROLLBACK_CHECK_AND_UPDATE : ROLLBACK_CHECK_ONLY)) {
+    // ToDo: rb->isVersions() was always true before, because numberBackups was always >= 1. So ROLLBACK_CHECK_ONLY could not
+    // happen at all...
+    if (rb->checkForUserUpdate(ROLLBACK_CHECK_AND_UPDATE)) {
       changedFiles.push_back(rb);
       if (rb->isChildRollback()) {
         if (std::find(parentFileNeedChange.begin(), parentFileNeedChange.end(), rb->getParentRollback()) ==
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index eac90b9..9d4a2ad 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -244,8 +244,6 @@ static const RecordElement RecordsConfig[] =
   ,
   {RECT_CONFIG, "proxy.config.admin.autoconf.localhost_only", RECD_INT, "1", RECU_RESTART_TM, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.admin.number_config_bak", RECD_INT, "3", RECU_NULL, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
-  ,
   {RECT_CONFIG, "proxy.config.admin.user_id", RECD_STRING, TS_PKGSYSUSER, RECU_NULL, RR_REQUIRED, RECC_NULL, nullptr, RECA_READ_ONLY}
   ,
   {RECT_CONFIG, "proxy.config.admin.cli_path", RECD_STRING, "cli", RECU_NULL, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 0f4af40..b6f4ddc 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -59,19 +59,11 @@ Rollback::Rollback(const char *fileName_, const char *configName_, bool root_acc
     parentRollback(parentRollback_),
     currentVersion(0),
     fileLastModified(0),
-    numVersions(0),
-    numberBackups(0)
+    numVersions(0)
 {
   version_t highestSeen;             // the highest backup version
   ExpandingArray existVer(25, true); // Existing versions
   struct stat fileInfo;
-  MgmtInt numBak;
-  char *alarmMsg;
-
-  // To Test, Read/Write access to the file
-  int testFD;    // For open test
-  int testErrno; // For open test
-
   ink_assert(fileName_ != nullptr);
 
   // parent must not also have a parent
@@ -94,135 +86,28 @@ Rollback::Rollback(const char *fileName_, const char *configName_, bool root_acc
 
   ink_mutex_init(&fileAccessLock);
 
-  if (varIntFromName("proxy.config.admin.number_config_bak", &numBak) == true) {
-    if (numBak > 1) {
-      numberBackups = (int)numBak;
-    } else {
-      numberBackups = 1;
-    }
-  } else {
-    numberBackups = DEFAULT_BACKUPS;
-  }
-
-  // If we are not doing backups, bail early.
-  if ((numberBackups <= 0) || (flags & CONFIG_FLAG_UNVERSIONED)) {
+  // ToDo: This was really broken before, it  used to check if numberBackups <=0, but that could never happen.
+  if (flags & CONFIG_FLAG_UNVERSIONED) {
     currentVersion = 0;
     setLastModifiedTime();
-    numberBackups = 0;
     return;
   }
 
   currentVersion = 0; // Prevent UMR with stat file
-  highestSeen    = findVersions_ml(versionQ);
+  highestSeen    = 0;
 
-  // Check to make sure that our configuratio file exists
-  //
-  //  If we can't find our file, do our best to rollback
-  //    or create an empty one.  If that fails, just
-  //    give up
+  // Check to make sure that our configuration file exists
   //
   if (statFile(ACTIVE_VERSION, &fileInfo) < 0) {
-    // If we can't find an active version because there is not
-    //   one, attempt to rollback to a previous version if one exists
-    //
-    // If it does not, create a zero length file to prevent total havoc
-    //
-    if (errno == ENOENT) {
-      bool needZeroLength;
-      mgmt_log("[RollBack::Rollback] Missing Configuration File: %s\n", fileName);
-
-      if (highestSeen > 0) {
-        char *highestSeenStr = createPathStr(highestSeen);
-        char *activeVerStr   = createPathStr(ACTIVE_VERSION);
-
-        if (rename(highestSeenStr, activeVerStr) < 0) {
-          mgmt_log("[RollBack::Rollback] Automatic Rollback to prior version failed for %s : %s\n", fileName, strerror(errno));
-          needZeroLength = true;
-        } else {
-          mgmt_log("[RollBack::Rollback] Automatic Rollback to version succeeded for %s\n", fileName, strerror(errno));
-          needZeroLength = false;
-          highestSeen--;
-          // Since we've made the highestVersion active
-          //  remove it from the backup version q
-          versionQ.remove(versionQ.tail);
-        }
-        ats_free(highestSeenStr);
-        ats_free(activeVerStr);
-      } else {
-        needZeroLength = true;
-      }
-
-      if (needZeroLength == true) {
-        int fd = openFile(ACTIVE_VERSION, O_RDWR | O_CREAT);
-        if (fd >= 0) {
-          alarmMsg = (char *)ats_malloc(2048);
-          snprintf(alarmMsg, 2048, "Created zero length place holder for config file %s", fileName);
-          mgmt_log("[RollBack::Rollback] %s\n", alarmMsg);
-          lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_CONFIG_UPDATE_FAILED, alarmMsg);
-          ats_free(alarmMsg);
-          closeFile(fd, true);
-        } else {
-          mgmt_fatal(0, "[RollBack::Rollback] Unable to find configuration file %s.\n\tCreation of a placeholder failed : %s\n",
-                     fileName, strerror(errno));
-        }
-      }
+    // If we can't find an active version because there is none we have a hard failure.
+    mgmt_fatal(0, "[RollBack::Rollback] Unable to find configuration file %s.\n\tStat failed : %s\n", fileName, strerror(errno));
 
-      currentVersion = highestSeen + 1;
-      setLastModifiedTime();
-    } else {
-      // If is there but we can not stat it, it is unusable to manager
-      //   probably due to permissions problems.  Bail!
-      mgmt_fatal(0, "[RollBack::Rollback] Unable to find configuration file %s.\n\tStat failed : %s\n", fileName, strerror(errno));
-    }
   } else {
     fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
     currentVersion   = highestSeen + 1;
 
-    // Make sure that we have a backup of the file
-    if (highestSeen == 0) {
-      TextBuffer *version0 = nullptr;
-      char failStr[]       = "[Rollback::Rollback] Automatic Roll of Version 1 failed: %s";
-      if (getVersion_ml(ACTIVE_VERSION, &version0) != OK_ROLLBACK) {
-        mgmt_log(failStr, fileName);
-      } else {
-        if (forceUpdate_ml(version0) != OK_ROLLBACK) {
-          mgmt_log(failStr, fileName);
-        }
-      }
-      if (version0 != nullptr) {
-        delete version0;
-      }
-    }
-
     Debug("rollback", "[Rollback::Rollback] Current Version of %s is %d", fileName, currentVersion);
   }
-
-  // Now that we'll got every thing set up, try opening
-  //   the file to make sure that we will actually be able to
-  //   read and write it
-  testFD = openFile(ACTIVE_VERSION, O_RDWR, &testErrno);
-  if (testFD < 0) {
-    // We failed to open read-write
-    alarmMsg = (char *)ats_malloc(2048);
-    testFD   = openFile(ACTIVE_VERSION, O_RDONLY, &testErrno);
-
-    if (testFD < 0) {
-      // We are unable to either read or write the file
-      snprintf(alarmMsg, 2048, "Unable to read or write config file");
-      mgmt_log("[Rollback::Rollback] %s %s: %s\n", alarmMsg, fileName, strerror(errno));
-      lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_CONFIG_UPDATE_FAILED, alarmMsg);
-
-    } else {
-      // Read is OK and write fails
-      snprintf(alarmMsg, 2048, "Config file is read-only");
-      mgmt_log("[Rollback::Rollback] %s : %s\n", alarmMsg, fileName);
-      lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_CONFIG_UPDATE_FAILED, alarmMsg);
-      closeFile(testFD, false);
-    }
-    ats_free(alarmMsg);
-  } else {
-    closeFile(testFD, true);
-  }
 }
 
 Rollback::~Rollback()
@@ -376,7 +261,6 @@ Rollback::internalUpdate(TextBuffer *buf, version_t newVersion, bool notifyChang
   ssize_t writeBytes;
   int diskFD;
   int ret;
-  versionInfo *toRemove;
   versionInfo *newBak;
   bool failedLink = false;
   char *alarmMsg  = nullptr;
@@ -448,19 +332,9 @@ Rollback::internalUpdate(TextBuffer *buf, version_t newVersion, bool notifyChang
   }
 
   setLastModifiedTime();
-  // Check to see if we need to delete an excess backup versions
-  //
-  //  We subtract one from numVersions to exclude the active
-  //   copy we just created.  If we subtracted two, but left
-  //   the toRemove calculation the same, version one would
-  //   never get deleted
-  //
-  if (numVersions >= this->numberBackups && failedLink == false) {
-    toRemove = versionQ.head;
-    ink_release_assert(toRemove != nullptr);
-    ink_assert((toRemove->version) < this->currentVersion);
-    removeVersion_ml(toRemove->version);
-  }
+
+  // ToDo: We used to call removeVersion_ml() here.
+
   // If we created a backup version add it to the
   //  List of backup Versions
   if (failedLink == false) {
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index bdcaebd..3186faf 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -193,31 +193,31 @@ public:
   {
     return fileBaseName;
   }
+
   const char *
   getFileName() const
   {
     return fileName;
   }
+
   const char *
   getConfigName() const
   {
     return configName;
   }
+
   bool
   isChildRollback() const
   {
     return parentRollback != nullptr;
   }
+
   Rollback *
   getParentRollback() const
   {
     return parentRollback;
   }
-  bool
-  isVersioned() const
-  {
-    return numberBackups > 0;
-  }
+
   bool
   rootAccessNeeded() const
   {
@@ -246,7 +246,6 @@ private:
   version_t currentVersion;
   time_t fileLastModified;
   int numVersions;
-  int numberBackups;
   Queue<versionInfo> versionQ; // stores the backup version info
 };
 


[trafficserver] 10/23: Step 10: Removes versionTimeStamp() and versionTimeStamp_ml()

Posted by zw...@apache.org.
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

commit d1189c2e473dc83628745fbd0f4354557674d154
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:48:35 2019 -0600

    Step 10: Removes versionTimeStamp() and versionTimeStamp_ml()
---
 mgmt/Rollback.cc | 24 ------------------------
 mgmt/Rollback.h  |  6 ------
 2 files changed, 30 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 06a0e8c..e56fa32 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -257,30 +257,6 @@ Rollback::extractVersionInfo(ExpandingArray *listNames, const char *testFileName
   return version;
 }
 
-time_t
-Rollback::versionTimeStamp(version_t version)
-{
-  time_t t;
-
-  ink_mutex_acquire(&fileAccessLock);
-  t = versionTimeStamp_ml(version);
-  ink_mutex_release(&fileAccessLock);
-
-  return t;
-}
-
-time_t
-Rollback::versionTimeStamp_ml(version_t version)
-{
-  struct stat buf;
-
-  if (this->statFile(version, &buf) < 0) {
-    return -1;
-  } else {
-    return buf.st_mtime;
-  }
-}
-
 int
 Rollback::statVersion(version_t version, struct stat *buf)
 {
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 335a02c..27b1bbc 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -76,10 +76,6 @@ struct versionInfo {
 //    time.  Returns true if the file has been changed manually or false
 //    if it hasn't
 //
-//  versionTimeStamp(version_t) - returns the modification time (mtime)
-//    of the version passed in.  If the version is not foundl, -1 is
-//    returned
-//
 // private functions
 //
 //  CURRENT_VERSION means the active version.  The active version does not
@@ -117,12 +113,10 @@ public:
   {
     ink_mutex_release(&fileAccessLock);
   };
-  time_t versionTimeStamp_ml(version_t version);
   version_t extractVersionInfo(ExpandingArray *listNames, const char *testFileName);
 
   // Automatically take out lock
   bool checkForUserUpdate();
-  time_t versionTimeStamp(version_t version);
   int statVersion(version_t, struct stat *buf);
   bool setLastModifiedTime();
 


[trafficserver] 16/23: Step 16: Removes createPathStr() and cleans up statFile()

Posted by zw...@apache.org.
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

commit 3a3f286c79c6a6c8afda9f4acd36a6b8b0a93f97
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 17:11:25 2019 -0600

    Step 16: Removes createPathStr() and cleans up statFile()
---
 mgmt/Rollback.cc | 47 ++++++++---------------------------------------
 mgmt/Rollback.h  |  9 ++-------
 2 files changed, 10 insertions(+), 46 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 478d4de..5c8ec3e 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -34,12 +34,6 @@
 #include "FileManager.h"
 #include "ProxyConfig.h"
 
-#define MAX_VERSION_DIGITS 11
-#define DEFAULT_BACKUPS 2
-
-constexpr int ACTIVE_VERSION  = 0;
-constexpr int INVALID_VERSION = -1;
-
 #if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
 #define TS_ARCHIVE_STAT_MTIME(t) ((t).st_mtime * 1000000000 + (t).st_mtimespec.tv_nsec)
 #elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
@@ -97,7 +91,7 @@ Rollback::Rollback(const char *fileName_, const char *configName_, bool root_acc
 
   // Check to make sure that our configuration file exists
   //
-  if (statFile(ACTIVE_VERSION, &fileInfo) < 0) {
+  if (statFile(&fileInfo) < 0) {
     // If we can't find an active version because there is none we have a hard failure.
     mgmt_fatal(0, "[RollBack::Rollback] Unable to find configuration file %s.\n\tStat failed : %s\n", fileName, strerror(errno));
 
@@ -114,45 +108,20 @@ Rollback::~Rollback()
   ats_free(fileName);
 }
 
-// Rollback::createPathStr(version_t version)
-//
-//   CALLEE DELETES STORAGE
-//
-char *
-Rollback::createPathStr(version_t version)
-{
-  int bufSize  = 0;
-  char *buffer = nullptr;
-  std::string sysconfdir(RecConfigReadConfigDir());
-  bufSize = sysconfdir.size() + fileNameLen + MAX_VERSION_DIGITS + 1;
-  buffer  = (char *)ats_malloc(bufSize);
-  Layout::get()->relative_to(buffer, bufSize, sysconfdir, fileName);
-  if (version != ACTIVE_VERSION) {
-    size_t pos = strlen(buffer);
-    snprintf(buffer + pos, bufSize - pos, "_%d", version);
-  }
-
-  return buffer;
-}
-
 //
 //
-// int Rollback::statFile(version_t)
+// int Rollback::statFile()
 //
 //  A wrapper for stat()
 //
 int
-Rollback::statFile(version_t version, struct stat *buf)
+Rollback::statFile(struct stat *buf)
 {
   int statResult;
+  std::string sysconfdir(RecConfigReadConfigDir());
+  std::string filePath = Layout::get()->relative_to(sysconfdir, fileName);
 
-  if (version == this->currentVersion) {
-    version = ACTIVE_VERSION;
-  }
-
-  ats_scoped_str filePath(createPathStr(version));
-
-  statResult = root_access_needed ? elevating_stat(filePath, buf) : stat(filePath, buf);
+  statResult = root_access_needed ? elevating_stat(filePath.c_str(), buf) : stat(filePath.c_str(), buf);
 
   return statResult;
 }
@@ -163,7 +132,7 @@ Rollback::setLastModifiedTime()
   struct stat fileInfo;
 
   // Now we need to get the modification time off of the new active file
-  if (statFile(ACTIVE_VERSION, &fileInfo) >= 0) {
+  if (statFile(&fileInfo) >= 0) {
     fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
     return true;
   } else {
@@ -187,7 +156,7 @@ Rollback::checkForUserUpdate()
 
   ink_mutex_acquire(&fileAccessLock);
 
-  if (this->statFile(ACTIVE_VERSION, &fileInfo) < 0) {
+  if (this->statFile(&fileInfo) < 0) {
     ink_mutex_release(&fileAccessLock);
     return false;
   }
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 3200824..2d4cba4 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -60,11 +60,7 @@ struct versionInfo {
 //    refers to a file with an _version which does not exist for the active
 //    version.
 //
-//  statFile(version_t, struct stat*) - a wrapper for stat that
-//    that stats the specified version
-//
-//  createPathStr(version_t) - creates a string to the specified
-//    version of the file.  CALLEE DELETES storage
+//  statFile(struct stat*) - a wrapper for stat(), using layout engine
 //
 class Rollback
 {
@@ -135,8 +131,7 @@ public:
   Rollback &operator=(const Rollback &) = delete;
 
 private:
-  int statFile(version_t version, struct stat *buf);
-  char *createPathStr(version_t version);
+  int statFile(struct stat *buf);
   ink_mutex fileAccessLock;
   char *fileName;
   char *fileBaseName;


[trafficserver] 12/23: Step 12: Removes extractVersionInfo()

Posted by zw...@apache.org.
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

commit a28aee0bcb29d32facf2c0b045dee72a83e338b7
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:50:43 2019 -0600

    Step 12: Removes extractVersionInfo()
---
 mgmt/Rollback.cc | 54 ------------------------------------------------------
 mgmt/Rollback.h  |  1 -
 2 files changed, 55 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index a669f55..6fa04f2 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -203,60 +203,6 @@ Rollback::closeFile(int fd, bool callSync)
   return result;
 }
 
-// version_t Rollback::extractVersionInfo(ExpandingArray* listNames,
-//                                        const char* testFileName)
-//
-//   Extracts the version number out of testFileName if it matches
-//     with the fileName_version format; adds the fileInfo to
-//     listNames if there is a match; returns INVALID_VERSION
-//     if there is no match.
-//
-version_t
-Rollback::extractVersionInfo(ExpandingArray *listNames, const char *testFileName)
-{
-  const char *str;
-  version_t version = INVALID_VERSION;
-
-  // Check to see if the current entry is a rollback file
-  //   fileFormat: fileName_version
-  //
-  // Check to see if the prefix of the current entry
-  //  is the same as our fileName
-  if (strlen(testFileName) > fileNameLen) {
-    if (strncmp(testFileName, fileName, fileNameLen) == 0) {
-      // Check for the underscore
-      if (*(testFileName + fileNameLen) == '_') {
-        // Check for the integer version number
-        const char *currentVersionStr = str = testFileName + fileNameLen + 1;
-
-        for (; isdigit(*str) && *str != '\0'; str++) {
-          ;
-        }
-
-        // Do not tolerate anything but numbers on the end
-        //   of the file
-        if (*str == '\0') {
-          version = atoi(currentVersionStr);
-
-          // Add info about version number and modTime
-          if (listNames != nullptr) {
-            struct stat fileInfo;
-
-            if (statFile(version, &fileInfo) >= 0) {
-              versionInfo *verInfo = (versionInfo *)ats_malloc(sizeof(versionInfo));
-              verInfo->version     = version;
-              verInfo->modTime     = fileInfo.st_mtime;
-              listNames->addEntry((void *)verInfo);
-            }
-          }
-        }
-      }
-    }
-  }
-
-  return version;
-}
-
 bool
 Rollback::setLastModifiedTime()
 {
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 9f9a7e8..ae6d990 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -113,7 +113,6 @@ public:
   {
     ink_mutex_release(&fileAccessLock);
   };
-  version_t extractVersionInfo(ExpandingArray *listNames, const char *testFileName);
 
   // Automatically take out lock
   bool checkForUserUpdate();


[trafficserver] 02/23: Step 2: Rempve findVersions(), findVersions_ml() and versionCmp()

Posted by zw...@apache.org.
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

commit bc04279383746d184a2fc891a30ab247cbab10d3
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 14:40:13 2019 -0600

    Step 2: Rempve findVersions(), findVersions_ml() and versionCmp()
---
 mgmt/Rollback.cc | 105 -------------------------------------------------------
 mgmt/Rollback.h  |  15 --------
 2 files changed, 120 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index b6f4ddc..0350f87 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -494,58 +494,6 @@ Rollback::revertToVersion_ml(version_t version)
   return OK_ROLLBACK;
 }
 
-version_t
-Rollback::findVersions(ExpandingArray *listNames)
-{
-  version_t result;
-
-  ink_mutex_acquire(&fileAccessLock);
-  result = this->findVersions_ml(listNames);
-  ink_mutex_release(&fileAccessLock);
-
-  return result;
-}
-
-// Rollback::findVersions_ml()
-//
-// scans the configuration directory and returns the high
-//   version number encountered.  If no versions of the
-//   file were found, zero is returned
-//
-version_t
-Rollback::findVersions_ml(ExpandingArray *listNames)
-{
-  int count             = 0;
-  version_t highestSeen = 0, version = 0;
-  ats_scoped_str sysconfdir(RecConfigReadConfigDir());
-
-  DIR *dir;
-  struct dirent *entryPtr;
-
-  dir = opendir(sysconfdir);
-
-  if (dir == nullptr) {
-    mgmt_log("[Rollback::findVersions] Unable to open configuration directory: %s: %s\n", (const char *)sysconfdir,
-             strerror(errno));
-    return INVALID_VERSION;
-  }
-
-  while ((entryPtr = readdir(dir))) {
-    if ((version = extractVersionInfo(listNames, entryPtr->d_name)) != INVALID_VERSION) {
-      count++;
-
-      if (version > highestSeen) {
-        highestSeen = version;
-      }
-    }
-  }
-
-  closedir(dir);
-
-  numVersions = count;
-  return highestSeen;
-}
-
 // version_t Rollback::extractVersionInfo(ExpandingArray* listNames,
 //                                        const char* testFileName)
 //
@@ -600,40 +548,6 @@ Rollback::extractVersionInfo(ExpandingArray *listNames, const char *testFileName
   return version;
 }
 
-// version_t Rollback::findVersions_ml(Queue<versionInfo>& q)
-//
-//   Add wrapper to
-//     version_t Rollback::findVersions_ml(ExpandingArray* listNames)
-//
-//   Puts the data in a queue rather than an ExpandingArray
-//
-version_t
-Rollback::findVersions_ml(Queue<versionInfo> &q)
-{
-  ExpandingArray versions(25, true);
-  int num;
-  versionInfo *foundVer;
-  version_t highest;
-
-  // Get the version info and sort it
-  highest = this->findVersions_ml(&versions);
-  num     = versions.getNumEntries();
-  versions.sortWithFunction(versionCmp);
-
-  // Add the entries on to our passed in q
-  for (int i = 0; i < num; i++) {
-    foundVer = (versionInfo *)versions[i];
-    //  We need to create our own copy so that
-    //   constructor gets run
-    versionInfo *addInfo = new versionInfo;
-    addInfo->version     = foundVer->version;
-    addInfo->modTime     = foundVer->modTime;
-    q.enqueue(addInfo);
-  }
-
-  return highest;
-}
-
 RollBackCodes
 Rollback::removeVersion(version_t version)
 {
@@ -798,22 +712,3 @@ Rollback::checkForUserUpdate(RollBackCheckType how)
   ink_mutex_release(&fileAccessLock);
   return result;
 }
-
-// int versionCmp(const void* i1, const void* i2) {
-//   A function that can be passed to qsort to sort arrays
-//     of versionInfo ptrs
-//
-int
-versionCmp(const void *i1, const void *i2)
-{
-  versionInfo *v1 = (versionInfo *)*(void **)i1;
-  versionInfo *v2 = (versionInfo *)*(void **)i2;
-
-  if ((v1->version) < v2->version) {
-    return -1;
-  } else if (v1->version == v2->version) {
-    return 0;
-  } else {
-    return 1;
-  }
-}
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 3186faf..4327e00 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -101,11 +101,6 @@ struct versionInfo {
 //    of the version passed in.  If the version is not foundl, -1 is
 //    returned
 //
-//  findVersions(ExpandingArray* listNames) - scans the config directory for
-//    all versions of the file.  If listNames is not NULL, pointers to versionInfo
-//    structures are inserted into it.  If is the callee's responsibility
-//    to ats_free the versionInfo structures.  They are allocated by ats_malloc
-//
 // private functions
 //
 //  CURRENT_VERSION means the active version.  The active version does not
@@ -115,9 +110,6 @@ struct versionInfo {
 //    refers to a file with an _version which does not exist for the active
 //    version.
 //
-//  findVersions() - scans the configuration directory and returns
-//    the highest version number encountered
-//
 //  openFile(version_t version, int oflags) - a wrapper for open
 //    opens a file based on version number
 //
@@ -156,8 +148,6 @@ public:
   RollBackCodes updateVersion_ml(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
                                  bool incVersion = true);
   RollBackCodes forceUpdate_ml(TextBuffer *buf, version_t newVersion = -1);
-  version_t findVersions_ml(ExpandingArray *listNames);
-  version_t findVersions_ml(Queue<versionInfo> &q);
   time_t versionTimeStamp_ml(version_t version);
   version_t extractVersionInfo(ExpandingArray *listNames, const char *testFileName);
 
@@ -169,7 +159,6 @@ public:
   RollBackCodes updateVersion(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
                               bool incVersion = true);
   RollBackCodes forceUpdate(TextBuffer *buf, version_t newVersion = -1);
-  version_t findVersions(ExpandingArray *);
   time_t versionTimeStamp(version_t version);
   int statVersion(version_t, struct stat *buf);
   bool setLastModifiedTime();
@@ -248,7 +237,3 @@ private:
   int numVersions;
   Queue<versionInfo> versionQ; // stores the backup version info
 };
-
-// qSort compatible function to sort versionInfo*
-//   based on version number
-int versionCmp(const void *i1, const void *i2);


[trafficserver] 21/23: Step 21: Removes the UNVERSIONED option flag completely

Posted by zw...@apache.org.
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

commit 3ea91a0bcdf7d52c071d8034e21874dc9febb018
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Tue Jun 4 11:04:01 2019 -0600

    Step 21: Removes the UNVERSIONED option flag completely
---
 iocore/net/P_SSLConfig.h             |  2 +-
 iocore/net/SSLUtils.cc               |  8 ++++----
 mgmt/FileManager.cc                  | 12 +++++-------
 mgmt/FileManager.h                   |  8 +++-----
 mgmt/LocalManager.cc                 |  7 +++----
 mgmt/ProcessManager.cc               | 10 ++++------
 mgmt/ProcessManager.h                |  2 +-
 mgmt/ProxyConfig.h                   |  4 ----
 src/traffic_server/traffic_server.cc |  8 ++++----
 9 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/iocore/net/P_SSLConfig.h b/iocore/net/P_SSLConfig.h
index a79b965..54a43dd 100644
--- a/iocore/net/P_SSLConfig.h
+++ b/iocore/net/P_SSLConfig.h
@@ -52,7 +52,7 @@ struct ssl_ticket_key_block;
 /////////////////////////////////////////////////////////////
 
 typedef void (*init_ssl_ctx_func)(void *, bool);
-typedef void (*load_ssl_file_func)(const char *, unsigned int);
+typedef void (*load_ssl_file_func)(const char *);
 
 struct SSLConfigParams : public ConfigInfo {
   enum SSL_SESSION_CACHE_MODE {
diff --git a/iocore/net/SSLUtils.cc b/iocore/net/SSLUtils.cc
index 1958ed7..c375047 100644
--- a/iocore/net/SSLUtils.cc
+++ b/iocore/net/SSLUtils.cc
@@ -953,7 +953,7 @@ SSLPrivateKeyHandler(SSL_CTX *ctx, const SSLConfigParams *params, const std::str
       return false;
     }
     if (SSLConfigParams::load_ssl_file_cb) {
-      SSLConfigParams::load_ssl_file_cb(completeServerKeyPath, CONFIG_FLAG_UNVERSIONED);
+      SSLConfigParams::load_ssl_file_cb(completeServerKeyPath);
     }
   } else {
     SSLError("empty SSL private key path in records.config");
@@ -1843,7 +1843,7 @@ SSLMultiCertConfigLoader::load_certs(SSL_CTX *ctx, std::vector<X509 *> &cert_lis
 
     cert_list.push_back(cert);
     if (SSLConfigParams::load_ssl_file_cb) {
-      SSLConfigParams::load_ssl_file_cb(completeServerCertPath.c_str(), CONFIG_FLAG_UNVERSIONED);
+      SSLConfigParams::load_ssl_file_cb(completeServerCertPath.c_str());
     }
 
     // Must load all the intermediate certificates before starting the next chain
@@ -1858,7 +1858,7 @@ SSLMultiCertConfigLoader::load_certs(SSL_CTX *ctx, std::vector<X509 *> &cert_lis
         return false;
       }
       if (SSLConfigParams::load_ssl_file_cb) {
-        SSLConfigParams::load_ssl_file_cb(completeServerCertChainPath, CONFIG_FLAG_UNVERSIONED);
+        SSLConfigParams::load_ssl_file_cb(completeServerCertChainPath);
       }
     }
 
@@ -1872,7 +1872,7 @@ SSLMultiCertConfigLoader::load_certs(SSL_CTX *ctx, std::vector<X509 *> &cert_lis
           return false;
         }
         if (SSLConfigParams::load_ssl_file_cb) {
-          SSLConfigParams::load_ssl_file_cb(completeServerCertChainPath, CONFIG_FLAG_UNVERSIONED);
+          SSLConfigParams::load_ssl_file_cb(completeServerCertChainPath);
         }
       }
     }
diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index af7eba5..3cf4b1d 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -92,18 +92,16 @@ FileManager::registerCallback(FileCallbackFunc func)
 //  Pointers to the new objects are stored in the bindings hashtable
 //
 void
-FileManager::addFile(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback,
-                     unsigned flags)
+FileManager::addFile(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback)
 {
   ink_mutex_acquire(&accessLock);
-  addFileHelper(fileName, configName, root_access_needed, parentRollback, flags);
+  addFileHelper(fileName, configName, root_access_needed, parentRollback);
   ink_mutex_release(&accessLock);
 }
 
 // caller must hold the lock
 void
-FileManager::addFileHelper(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback,
-                           unsigned flags)
+FileManager::addFileHelper(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback)
 {
   ink_assert(fileName != nullptr);
 
@@ -253,13 +251,13 @@ FileManager::isConfigStale()
 //
 // Add child to the bindings with parentRollback
 void
-FileManager::configFileChild(const char *parent, const char *child, unsigned flags)
+FileManager::configFileChild(const char *parent, const char *child)
 {
   Rollback *parentRollback = nullptr;
   ink_mutex_acquire(&accessLock);
   if (auto it = bindings.find(parent); it != bindings.end()) {
     parentRollback = it->second;
-    addFileHelper(child, "", parentRollback->rootAccessNeeded(), parentRollback, flags);
+    addFileHelper(child, "", parentRollback->rootAccessNeeded(), parentRollback);
   }
   ink_mutex_release(&accessLock);
 }
diff --git a/mgmt/FileManager.h b/mgmt/FileManager.h
index f1f3b53..ea45500 100644
--- a/mgmt/FileManager.h
+++ b/mgmt/FileManager.h
@@ -80,22 +80,20 @@ class FileManager
 public:
   FileManager();
   ~FileManager();
-  void addFile(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback = nullptr,
-               unsigned flags = 0);
+  void addFile(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback = nullptr);
   bool getRollbackObj(const char *fileName, Rollback **rbPtr);
   void registerCallback(FileCallbackFunc func);
   void fileChanged(const char *fileName, const char *configName);
   void rereadConfig();
   bool isConfigStale();
-  void configFileChild(const char *parent, const char *child, unsigned int options);
+  void configFileChild(const char *parent, const char *child);
 
 private:
   ink_mutex accessLock; // Protects bindings hashtable
   ink_mutex cbListLock; // Protects the CallBack List
   DLL<callbackListable> cblist;
   std::unordered_map<std::string_view, Rollback *> bindings;
-  void addFileHelper(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback,
-                     unsigned flags = 0);
+  void addFileHelper(const char *fileName, const char *configName, bool root_access_needed, Rollback *parentRollback);
 };
 
 void initializeRegistry(); // implemented in AddConfigFilesHere.cc
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 8673cf4..058b782 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -545,12 +545,11 @@ LocalManager::handleMgmtMsgFromProcesses(MgmtMessageHdr *mh)
     }
     break;
   case MGMT_SIGNAL_CONFIG_FILE_CHILD: {
-    static const MgmtMarshallType fields[] = {MGMT_MARSHALL_STRING, MGMT_MARSHALL_STRING, MGMT_MARSHALL_INT};
+    static const MgmtMarshallType fields[] = {MGMT_MARSHALL_STRING, MGMT_MARSHALL_STRING};
     char *parent                           = nullptr;
     char *child                            = nullptr;
-    MgmtMarshallInt options                = 0;
-    if (mgmt_message_parse(data_raw, mh->data_len, fields, countof(fields), &parent, &child, &options) != -1) {
-      configFiles->configFileChild(parent, child, (unsigned int)options);
+    if (mgmt_message_parse(data_raw, mh->data_len, fields, countof(fields), &parent, &child) != -1) {
+      configFiles->configFileChild(parent, child);
     } else {
       mgmt_log("[LocalManager::handleMgmtMsgFromProcesses] "
                "MGMT_SIGNAL_CONFIG_FILE_CHILD mgmt_message_parse error\n");
diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc
index f7e0888..0431d03 100644
--- a/mgmt/ProcessManager.cc
+++ b/mgmt/ProcessManager.cc
@@ -216,16 +216,14 @@ ProcessManager::reconfigure()
 }
 
 void
-ProcessManager::signalConfigFileChild(const char *parent, const char *child, unsigned int options)
+ProcessManager::signalConfigFileChild(const char *parent, const char *child)
 {
-  static const MgmtMarshallType fields[] = {MGMT_MARSHALL_STRING, MGMT_MARSHALL_STRING, MGMT_MARSHALL_INT};
+  static const MgmtMarshallType fields[] = {MGMT_MARSHALL_STRING, MGMT_MARSHALL_STRING};
 
-  MgmtMarshallInt mgmtopt = options;
-
-  size_t len   = mgmt_message_length(fields, countof(fields), &parent, &child, &mgmtopt);
+  size_t len   = mgmt_message_length(fields, countof(fields), &parent, &child);
   void *buffer = ats_malloc(len);
 
-  mgmt_message_marshall(buffer, len, fields, countof(fields), &parent, &child, &mgmtopt);
+  mgmt_message_marshall(buffer, len, fields, countof(fields), &parent, &child);
   signalManager(MGMT_SIGNAL_CONFIG_FILE_CHILD, (const char *)buffer, len);
 
   ats_free(buffer);
diff --git a/mgmt/ProcessManager.h b/mgmt/ProcessManager.h
index cc79fbc..fdf555d 100644
--- a/mgmt/ProcessManager.h
+++ b/mgmt/ProcessManager.h
@@ -54,7 +54,7 @@ public:
   // Stop the process manager, dropping any unprocessed messages.
   void stop();
 
-  inkcoreapi void signalConfigFileChild(const char *parent, const char *child, unsigned int options);
+  inkcoreapi void signalConfigFileChild(const char *parent, const char *child);
   inkcoreapi void signalManager(int msg_id, const char *data_str);
   inkcoreapi void signalManager(int msg_id, const char *data_raw, int data_len);
 
diff --git a/mgmt/ProxyConfig.h b/mgmt/ProxyConfig.h
index 8c126cd..abd7c78 100644
--- a/mgmt/ProxyConfig.h
+++ b/mgmt/ProxyConfig.h
@@ -36,10 +36,6 @@ void *config_float_cb(void *data, void *value);
 void *config_string511_cb(void *data, void *value);
 void *config_string_alloc_cb(void *data, void *value);
 
-// Configuration file flags shared by proxy configuration and mgmt.
-static constexpr unsigned int CONFIG_FLAG_NONE        = 0;
-static constexpr unsigned int CONFIG_FLAG_UNVERSIONED = 1; // Don't version this config file
-
 //
 // Macros that spin waiting for the data to be bound
 //
diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc
index fe17392..66bd411 100644
--- a/src/traffic_server/traffic_server.cc
+++ b/src/traffic_server/traffic_server.cc
@@ -120,7 +120,7 @@ static void mgmt_drain_callback(ts::MemSpan<void>);
 static void mgmt_storage_device_cmd_callback(int cmd, std::string_view const &arg);
 static void mgmt_lifecycle_msg_callback(ts::MemSpan<void>);
 static void init_ssl_ctx_callback(void *ctx, bool server);
-static void load_ssl_file_callback(const char *ssl_file, unsigned int options);
+static void load_ssl_file_callback(const char *ssl_file);
 static void load_remap_file_callback(const char *remap_file);
 static void task_threads_started_callback();
 
@@ -2087,15 +2087,15 @@ init_ssl_ctx_callback(void *ctx, bool server)
 }
 
 static void
-load_ssl_file_callback(const char *ssl_file, unsigned int options)
+load_ssl_file_callback(const char *ssl_file)
 {
-  pmgmt->signalConfigFileChild("ssl_multicert.config", ssl_file, options);
+  pmgmt->signalConfigFileChild("ssl_multicert.config", ssl_file);
 }
 
 static void
 load_remap_file_callback(const char *remap_file)
 {
-  pmgmt->signalConfigFileChild("remap.config", remap_file, CONFIG_FLAG_UNVERSIONED);
+  pmgmt->signalConfigFileChild("remap.config", remap_file);
 }
 
 static void


[trafficserver] 20/23: Step 20: Removes incVersion/inc_version from Filemanager etc.

Posted by zw...@apache.org.
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

commit de76e1ed2b4390e597e2895e86e6c731564bb6eb
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 31 15:10:52 2019 -0600

    Step 20: Removes incVersion/inc_version from Filemanager etc.
---
 doc/developer-guide/api/types/TSMgmtTypes.en.rst |  2 --
 lib/records/I_RecCore.h                          | 17 +++++-------
 lib/records/I_RecEvents.h                        |  1 -
 lib/records/P_RecCore.cc                         | 35 ++++++++++--------------
 lib/records/P_RecCore.h                          |  4 +--
 lib/records/RecConfigParse.cc                    |  4 +--
 lib/records/RecCore.cc                           |  2 +-
 mgmt/BaseManager.h                               |  2 +-
 mgmt/FileManager.cc                              | 11 ++++----
 mgmt/FileManager.h                               |  4 +--
 mgmt/LocalManager.cc                             | 15 ++++------
 mgmt/LocalManager.h                              |  2 +-
 mgmt/ProcessManager.cc                           |  1 -
 mgmt/Rollback.cc                                 |  2 +-
 src/traffic_manager/AddConfigFilesHere.cc        |  2 +-
 src/traffic_manager/traffic_manager.cc           |  4 +--
 src/traffic_server/EventName.cc                  |  2 --
 src/traffic_server/HostStatus.cc                 |  2 +-
 src/traffic_server/traffic_server.cc             |  2 +-
 19 files changed, 48 insertions(+), 66 deletions(-)

diff --git a/doc/developer-guide/api/types/TSMgmtTypes.en.rst b/doc/developer-guide/api/types/TSMgmtTypes.en.rst
index 854163b..6e18fd9 100644
--- a/doc/developer-guide/api/types/TSMgmtTypes.en.rst
+++ b/doc/developer-guide/api/types/TSMgmtTypes.en.rst
@@ -76,8 +76,6 @@ Management Events
 
 .. c:macro:: MGMT_EVENT_LIBRECORDS
 
-.. c:macro:: MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION
-
 .. c:macro:: MGMT_EVENT_STORAGE_DEVICE_CMD_OFFLINE
 
 .. c:macro:: MGMT_EVENT_LIFECYCLE_MESSAGE
diff --git a/lib/records/I_RecCore.h b/lib/records/I_RecCore.h
index 7609e32..0fd60ef 100644
--- a/lib/records/I_RecCore.h
+++ b/lib/records/I_RecCore.h
@@ -43,11 +43,10 @@ int RecSetDiags(Diags *diags);
 //-------------------------------------------------------------------------
 // Config File Parsing
 //-------------------------------------------------------------------------
-typedef void (*RecConfigEntryCallback)(RecT rec_type, RecDataT data_type, const char *name, const char *value, RecSourceT source,
-                                       bool inc_version);
+typedef void (*RecConfigEntryCallback)(RecT rec_type, RecDataT data_type, const char *name, const char *value, RecSourceT source);
 
 void RecConfigFileInit();
-int RecConfigFileParse(const char *path, RecConfigEntryCallback handler, bool inc_version);
+int RecConfigFileParse(const char *path, RecConfigEntryCallback handler);
 
 // Return a copy of the system's configuration directory.
 std::string RecConfigReadConfigDir();
@@ -140,13 +139,11 @@ RecErrT RecRegisterRawStatUpdateFunc(const char *name, RecRawStatBlock *rsb, int
 // already been taken out for the callback.
 
 // RecSetRecordConvert -> WebMgmtUtils.cc::varSetFromStr()
-RecErrT RecSetRecordConvert(const char *name, const RecString rec_string, RecSourceT source, bool lock = true,
-                            bool inc_version = true);
-RecErrT RecSetRecordInt(const char *name, RecInt rec_int, RecSourceT source, bool lock = true, bool inc_version = true);
-RecErrT RecSetRecordFloat(const char *name, RecFloat rec_float, RecSourceT source, bool lock = true, bool inc_version = true);
-RecErrT RecSetRecordString(const char *name, const RecString rec_string, RecSourceT source, bool lock = true,
-                           bool inc_version = true);
-RecErrT RecSetRecordCounter(const char *name, RecCounter rec_counter, RecSourceT source, bool lock = true, bool inc_version = true);
+RecErrT RecSetRecordConvert(const char *name, const RecString rec_string, RecSourceT source, bool lock = true);
+RecErrT RecSetRecordInt(const char *name, RecInt rec_int, RecSourceT source, bool lock = true);
+RecErrT RecSetRecordFloat(const char *name, RecFloat rec_float, RecSourceT source, bool lock = true);
+RecErrT RecSetRecordString(const char *name, const RecString rec_string, RecSourceT source, bool lock = true);
+RecErrT RecSetRecordCounter(const char *name, RecCounter rec_counter, RecSourceT source, bool lock = true);
 
 RecErrT RecGetRecordInt(const char *name, RecInt *rec_int, bool lock = true);
 RecErrT RecGetRecordFloat(const char *name, RecFloat *rec_float, bool lock = true);
diff --git a/lib/records/I_RecEvents.h b/lib/records/I_RecEvents.h
index d73200a..3e3c476 100644
--- a/lib/records/I_RecEvents.h
+++ b/lib/records/I_RecEvents.h
@@ -33,6 +33,5 @@
 #define REC_EVENT_PLUGIN_CONFIG_UPDATE 10006
 #define REC_EVENT_ROLL_LOG_FILES 10008
 #define REC_EVENT_LIBRECORDS 10009
-#define REC_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION 10010
 
 #define REC_EVENT_CACHE_DISK_CONTROL 10011
diff --git a/lib/records/P_RecCore.cc b/lib/records/P_RecCore.cc
index 5b43866..b2f1550 100644
--- a/lib/records/P_RecCore.cc
+++ b/lib/records/P_RecCore.cc
@@ -359,8 +359,7 @@ RecRegisterConfigCounter(RecT rec_type, const char *name, RecCounter data_defaul
 // RecSetRecordXXX
 //-------------------------------------------------------------------------
 RecErrT
-RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data, RecRawStat *data_raw, RecSourceT source, bool lock,
-             bool inc_version)
+RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data, RecRawStat *data_raw, RecSourceT source, bool lock)
 {
   RecErrT err = REC_ERR_OKAY;
   RecRecord *r1;
@@ -389,10 +388,6 @@ RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data,
 
         if (rec_updated_p) {
           r1->sync_required = REC_SYNC_REQUIRED;
-          if (inc_version) {
-            r1->sync_required |= REC_INC_CONFIG_VERSION;
-          }
-
           if (REC_TYPE_IS_CONFIG(r1->rec_type)) {
             r1->config_meta.update_required = REC_UPDATE_REQUIRED;
           }
@@ -457,43 +452,43 @@ Ldone:
 }
 
 RecErrT
-RecSetRecordConvert(const char *name, const RecString rec_string, RecSourceT source, bool lock, bool inc_version)
+RecSetRecordConvert(const char *name, const RecString rec_string, RecSourceT source, bool lock)
 {
   RecData data;
   data.rec_string = rec_string;
-  return RecSetRecord(RECT_NULL, name, RECD_NULL, &data, nullptr, source, lock, inc_version);
+  return RecSetRecord(RECT_NULL, name, RECD_NULL, &data, nullptr, source, lock);
 }
 
 RecErrT
-RecSetRecordInt(const char *name, RecInt rec_int, RecSourceT source, bool lock, bool inc_version)
+RecSetRecordInt(const char *name, RecInt rec_int, RecSourceT source, bool lock)
 {
   RecData data;
   data.rec_int = rec_int;
-  return RecSetRecord(RECT_NULL, name, RECD_INT, &data, nullptr, source, lock, inc_version);
+  return RecSetRecord(RECT_NULL, name, RECD_INT, &data, nullptr, source, lock);
 }
 
 RecErrT
-RecSetRecordFloat(const char *name, RecFloat rec_float, RecSourceT source, bool lock, bool inc_version)
+RecSetRecordFloat(const char *name, RecFloat rec_float, RecSourceT source, bool lock)
 {
   RecData data;
   data.rec_float = rec_float;
-  return RecSetRecord(RECT_NULL, name, RECD_FLOAT, &data, nullptr, source, lock, inc_version);
+  return RecSetRecord(RECT_NULL, name, RECD_FLOAT, &data, nullptr, source, lock);
 }
 
 RecErrT
-RecSetRecordString(const char *name, const RecString rec_string, RecSourceT source, bool lock, bool inc_version)
+RecSetRecordString(const char *name, const RecString rec_string, RecSourceT source, bool lock)
 {
   RecData data;
   data.rec_string = rec_string;
-  return RecSetRecord(RECT_NULL, name, RECD_STRING, &data, nullptr, source, lock, inc_version);
+  return RecSetRecord(RECT_NULL, name, RECD_STRING, &data, nullptr, source, lock);
 }
 
 RecErrT
-RecSetRecordCounter(const char *name, RecCounter rec_counter, RecSourceT source, bool lock, bool inc_version)
+RecSetRecordCounter(const char *name, RecCounter rec_counter, RecSourceT source, bool lock)
 {
   RecData data;
   data.rec_counter = rec_counter;
-  return RecSetRecord(RECT_NULL, name, RECD_COUNTER, &data, nullptr, source, lock, inc_version);
+  return RecSetRecord(RECT_NULL, name, RECD_COUNTER, &data, nullptr, source, lock);
 }
 
 // check the version of the snap file to remove records.snap or not
@@ -620,13 +615,13 @@ RecSyncStatsFile()
 
 // Consume a parsed record, pushing it into the records hash table.
 static void
-RecConsumeConfigEntry(RecT rec_type, RecDataT data_type, const char *name, const char *value, RecSourceT source, bool inc_version)
+RecConsumeConfigEntry(RecT rec_type, RecDataT data_type, const char *name, const char *value, RecSourceT source)
 {
   RecData data;
 
   memset(&data, 0, sizeof(RecData));
   RecDataSetFromString(data_type, &data, value);
-  RecSetRecord(rec_type, name, data_type, &data, nullptr, source, false, inc_version);
+  RecSetRecord(rec_type, name, data_type, &data, nullptr, source, false);
   RecDataZero(data_type, &data);
 }
 
@@ -634,7 +629,7 @@ RecConsumeConfigEntry(RecT rec_type, RecDataT data_type, const char *name, const
 // RecReadConfigFile
 //-------------------------------------------------------------------------
 RecErrT
-RecReadConfigFile(bool inc_version)
+RecReadConfigFile()
 {
   RecDebug(DL_Note, "Reading '%s'", g_rec_config_fpath);
 
@@ -642,7 +637,7 @@ RecReadConfigFile(bool inc_version)
   ink_rwlock_wrlock(&g_records_rwlock);
 
   // Parse the actual file and hash the values.
-  RecConfigFileParse(g_rec_config_fpath, RecConsumeConfigEntry, inc_version);
+  RecConfigFileParse(g_rec_config_fpath, RecConsumeConfigEntry);
 
   // release our hash table
   ink_rwlock_unlock(&g_records_rwlock);
diff --git a/lib/records/P_RecCore.h b/lib/records/P_RecCore.h
index 7825ae0..9a0424a 100644
--- a/lib/records/P_RecCore.h
+++ b/lib/records/P_RecCore.h
@@ -70,7 +70,7 @@ RecRecord *RecForceInsert(RecRecord *record);
 //-------------------------------------------------------------------------
 
 RecErrT RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data, RecRawStat *raw_stat, RecSourceT source,
-                     bool lock = true, bool inc_version = true);
+                     bool lock = true);
 
 RecErrT RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData *data, bool lock = true);
 
@@ -79,7 +79,7 @@ RecErrT RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData *data
 //-------------------------------------------------------------------------
 RecErrT RecReadStatsFile();
 RecErrT RecSyncStatsFile();
-RecErrT RecReadConfigFile(bool inc_version);
+RecErrT RecReadConfigFile();
 
 //-------------------------------------------------------------------------
 // Misc
diff --git a/lib/records/RecConfigParse.cc b/lib/records/RecConfigParse.cc
index 1fa8e0f..1d84416 100644
--- a/lib/records/RecConfigParse.cc
+++ b/lib/records/RecConfigParse.cc
@@ -133,7 +133,7 @@ RecConfigOverrideFromEnvironment(const char *name, const char *value)
 // RecParseConfigFile
 //-------------------------------------------------------------------------
 int
-RecConfigFileParse(const char *path, RecConfigEntryCallback handler, bool inc_version)
+RecConfigFileParse(const char *path, RecConfigEntryCallback handler)
 {
   char *fbuf;
   int fsize;
@@ -254,7 +254,7 @@ RecConfigFileParse(const char *path, RecConfigEntryCallback handler, bool inc_ve
 
     // OK, we parsed the record, send it to the handler ...
     value_str = RecConfigOverrideFromEnvironment(name_str, data_str);
-    handler(rec_type, data_type, name_str, value_str, value_str == data_str ? REC_SOURCE_EXPLICIT : REC_SOURCE_ENV, inc_version);
+    handler(rec_type, data_type, name_str, value_str, value_str == data_str ? REC_SOURCE_EXPLICIT : REC_SOURCE_ENV);
 
     // update our g_rec_config_contents_xxx
     cfe             = (RecConfigFileEntry *)ats_malloc(sizeof(RecConfigFileEntry));
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 68dd6fa..7c1f8ab 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -224,7 +224,7 @@ RecCoreInit(RecModeT mode_type, Diags *_diags)
     }
 
     if (file_exists) {
-      RecReadConfigFile(true);
+      RecReadConfigFile();
     }
   }
 
diff --git a/mgmt/BaseManager.h b/mgmt/BaseManager.h
index 853acee..322b654 100644
--- a/mgmt/BaseManager.h
+++ b/mgmt/BaseManager.h
@@ -49,7 +49,7 @@
 #define MGMT_EVENT_PLUGIN_CONFIG_UPDATE 10006
 #define MGMT_EVENT_ROLL_LOG_FILES 10008
 #define MGMT_EVENT_LIBRECORDS 10009
-#define MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION 10010
+// 10010 is unused
 // cache storage operations - each is a distinct event.
 // this is done because the code paths share nothing but boilerplate logic
 // so it's easier to do this than to try to encode an opcode and yet another
diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index 6aa30bb..af7eba5 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -139,7 +139,7 @@ FileManager::getRollbackObj(const char *fileName, Rollback **rbPtr)
 //
 //
 void
-FileManager::fileChanged(const char *fileName, const char *configName, bool incVersion)
+FileManager::fileChanged(const char *fileName, const char *configName)
 {
   callbackListable *cb;
   char *filenameCopy, *confignameCopy;
@@ -151,7 +151,7 @@ FileManager::fileChanged(const char *fileName, const char *configName, bool incV
     //  defensive in case it's modified when it's not supposed to be
     confignameCopy = ats_strdup(configName);
     filenameCopy   = ats_strdup(fileName);
-    (*cb->func)(filenameCopy, confignameCopy, incVersion);
+    (*cb->func)(filenameCopy, confignameCopy);
     ats_free(filenameCopy);
     ats_free(confignameCopy);
   }
@@ -216,17 +216,18 @@ FileManager::rereadConfig()
   n = parentFileNeedChange.size();
   for (size_t i = 0; i < n; i++) {
     if (std::find(changedFiles.begin(), changedFiles.end(), parentFileNeedChange[i]) == changedFiles.end()) {
-      fileChanged(parentFileNeedChange[i]->getFileName(), parentFileNeedChange[i]->getConfigName(), true);
+      fileChanged(parentFileNeedChange[i]->getFileName(), parentFileNeedChange[i]->getConfigName());
     }
   }
   // INKqa11910
   // need to first check that enable_customizations is enabled
   bool found;
   int enabled = (int)REC_readInteger("proxy.config.body_factory.enable_customizations", &found);
+
   if (found && enabled) {
-    fileChanged("proxy.config.body_factory.template_sets_dir", "proxy.config.body_factory.template_sets_dir", true);
+    fileChanged("proxy.config.body_factory.template_sets_dir", "proxy.config.body_factory.template_sets_dir");
   }
-  fileChanged("proxy.config.ssl.server.ticket_key.filename", "proxy.config.ssl.server.ticket_key.filename", true);
+  fileChanged("proxy.config.ssl.server.ticket_key.filename", "proxy.config.ssl.server.ticket_key.filename");
 }
 
 bool
diff --git a/mgmt/FileManager.h b/mgmt/FileManager.h
index a667504..f1f3b53 100644
--- a/mgmt/FileManager.h
+++ b/mgmt/FileManager.h
@@ -31,7 +31,7 @@
 class ExpandingArray;
 class Rollback;
 
-typedef void (*FileCallbackFunc)(char *, char *, bool);
+typedef void (*FileCallbackFunc)(char *, char *);
 
 struct callbackListable {
 public:
@@ -84,7 +84,7 @@ public:
                unsigned flags = 0);
   bool getRollbackObj(const char *fileName, Rollback **rbPtr);
   void registerCallback(FileCallbackFunc func);
-  void fileChanged(const char *fileName, const char *configName, bool incVersion);
+  void fileChanged(const char *fileName, const char *configName);
   void rereadConfig();
   bool isConfigStale();
   void configFileChild(const char *parent, const char *child, unsigned int options);
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index a834e68..8673cf4 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -605,7 +605,6 @@ LocalManager::sendMgmtMsgToProcesses(MgmtMessageHdr *mh)
     mgmt_log("[LocalManager::SendMgmtMsgsToProcesses]Event is being constructed .\n");
     break;
   case MGMT_EVENT_CONFIG_FILE_UPDATE:
-  case MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION:
     bool found;
     char *fname = nullptr;
     Rollback *rb;
@@ -691,13 +690,10 @@ LocalManager::sendMgmtMsgToProcesses(MgmtMessageHdr *mh)
 }
 
 void
-LocalManager::signalFileChange(const char *var_name, bool incVersion)
+LocalManager::signalFileChange(const char *var_name)
 {
-  if (incVersion) {
-    signalEvent(MGMT_EVENT_CONFIG_FILE_UPDATE, var_name);
-  } else {
-    signalEvent(MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION, var_name);
-  }
+  signalEvent(MGMT_EVENT_CONFIG_FILE_UPDATE, var_name);
+
   return;
 }
 
@@ -753,11 +749,10 @@ LocalManager::processEventQueue()
     auto payload       = mh->payload().rebind<char>();
 
     // check if we have a local file update
-    if (mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE || mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION) {
+    if (mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE) {
       // records.config
       if (!(strcmp(payload.begin(), REC_CONFIG_FILE))) {
-        bool incVersion = mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE;
-        if (RecReadConfigFile(incVersion) != REC_ERR_OKAY) {
+        if (RecReadConfigFile() != REC_ERR_OKAY) {
           mgmt_elog(errno, "[fileUpdated] Config update failed for records.config\n");
         } else {
           RecConfigWarnIfUnregistered();
diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h
index 0f4faff..4c9cb37 100644
--- a/mgmt/LocalManager.h
+++ b/mgmt/LocalManager.h
@@ -68,7 +68,7 @@ public:
   void sendMgmtMsgToProcesses(int msg_id, const char *data_raw, int data_len);
   void sendMgmtMsgToProcesses(MgmtMessageHdr *mh);
 
-  void signalFileChange(const char *var_name, bool incVersion = true);
+  void signalFileChange(const char *var_name);
   void signalEvent(int msg_id, const char *data_str);
   void signalEvent(int msg_id, const char *data_raw, int data_len);
   void signalAlarm(int alarm_id, const char *desc = nullptr, const char *ip = nullptr);
diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc
index 4636429..f7e0888 100644
--- a/mgmt/ProcessManager.cc
+++ b/mgmt/ProcessManager.cc
@@ -471,7 +471,6 @@ ProcessManager::handleMgmtMsgFromLM(MgmtMessageHdr *mh)
     }
   } break;
   case MGMT_EVENT_CONFIG_FILE_UPDATE:
-  case MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION:
     /*
       librecords -- we don't do anything in here because we are traffic_server
       and we are not the owner of proxy.config.* variables.
diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 70fe2b0..d0e3308 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -117,7 +117,7 @@ Rollback::checkForUserUpdate()
 
   if (fileLastModified < TS_ARCHIVE_STAT_MTIME(fileInfo)) {
     fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
-    configFiles->fileChanged(fileName, configName, true);
+    configFiles->fileChanged(fileName, configName);
     mgmt_log("User has changed config file %s\n", fileName);
 
     result = true;
diff --git a/src/traffic_manager/AddConfigFilesHere.cc b/src/traffic_manager/AddConfigFilesHere.cc
index 6ac388b..30be5a6 100644
--- a/src/traffic_manager/AddConfigFilesHere.cc
+++ b/src/traffic_manager/AddConfigFilesHere.cc
@@ -36,7 +36,7 @@ extern FileManager *configFiles;
  ****************************************************************************/
 
 void
-testcall(char *foo, char * /*configName */, bool /* incVersion */)
+testcall(char *foo, char * /*configName */)
 {
   Debug("lm", "Received Callback that %s has changed", foo);
 }
diff --git a/src/traffic_manager/traffic_manager.cc b/src/traffic_manager/traffic_manager.cc
index 4768a51..99b7466 100644
--- a/src/traffic_manager/traffic_manager.cc
+++ b/src/traffic_manager/traffic_manager.cc
@@ -71,7 +71,7 @@ using namespace std::literals;
 LocalManager *lmgmt = nullptr;
 FileManager *configFiles;
 
-static void fileUpdated(char *fname, char *configName, bool incVersion);
+static void fileUpdated(char *fname, char *configName);
 static void runAsUser(const char *userName);
 
 #if defined(freebsd)
@@ -948,7 +948,7 @@ SigChldHandler(int /* sig ATS_UNUSED */)
 }
 
 void
-fileUpdated(char *fname, char *configName, bool incVersion)
+fileUpdated(char *fname, char *configName)
 {
   // If there is no config name recorded, assume this file is not reloadable
   // Just log a message
diff --git a/src/traffic_server/EventName.cc b/src/traffic_server/EventName.cc
index 1eb9b58..ae0c5993 100644
--- a/src/traffic_server/EventName.cc
+++ b/src/traffic_server/EventName.cc
@@ -125,8 +125,6 @@ event_int_to_string(int event, int blen, char *buffer)
     return "MGMT_EVENT_BOUNCE";
   case MGMT_EVENT_CONFIG_FILE_UPDATE:
     return "MGMT_EVENT_CONFIG_FILE_UPDATE";
-  case MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION:
-    return "MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION";
   case MGMT_EVENT_CLEAR_STATS:
     return "MGMT_EVENT_CLEAR_STATS";
   case MGMT_EVENT_HOST_STATUS_UP:
diff --git a/src/traffic_server/HostStatus.cc b/src/traffic_server/HostStatus.cc
index c931be4..9c23103 100644
--- a/src/traffic_server/HostStatus.cc
+++ b/src/traffic_server/HostStatus.cc
@@ -341,7 +341,7 @@ HostStatus::setHostStatus(const char *name, HostStatus_t status, const unsigned
   if (result == REC_ERR_OKAY) {
     std::stringstream status_rec;
     status_rec << *host_stat;
-    RecSetRecordString(stat_name.c_str(), const_cast<char *>(status_rec.str().c_str()), REC_SOURCE_EXPLICIT, true, false);
+    RecSetRecordString(stat_name.c_str(), const_cast<char *>(status_rec.str().c_str()), REC_SOURCE_EXPLICIT, true);
     if (status == HostStatus_t::HOST_STATUS_UP) {
       Debug("host_statuses", "set status up for name: %s, status: %d, stat_name: %s", name, status, stat_name.c_str());
     } else {
diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc
index 74b91ba..fe17392 100644
--- a/src/traffic_server/traffic_server.cc
+++ b/src/traffic_server/traffic_server.cc
@@ -867,7 +867,7 @@ cmd_verify(char * /* cmd ATS_UNUSED */)
     fprintf(stderr, "INFO: Successfully loaded remap.config\n\n");
   }
 
-  if (RecReadConfigFile(false) != REC_ERR_OKAY) {
+  if (RecReadConfigFile() != REC_ERR_OKAY) {
     exitStatus |= (1 << 1);
     fprintf(stderr, "ERROR: Failed to load records.config, exitStatus %d\n\n", exitStatus);
   } else {


[trafficserver] 14/23: Step 14: Removes numberOfVersions() and getCurrentVersion()

Posted by zw...@apache.org.
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

commit 169200088a7faacb8b9562a1b2c0384c4ea40272
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:53:18 2019 -0600

    Step 14: Removes numberOfVersions() and getCurrentVersion()
---
 mgmt/Rollback.h | 30 ------------------------------
 1 file changed, 30 deletions(-)

diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 8b8d5a5..e112047 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -54,23 +54,6 @@ struct versionInfo {
 //
 //  public functions
 //
-//  _ml functions assume the callee is handling locking issues
-//    via acquireLock() and releaseLock().  The non _ml
-//    simply grab the lock, call the corresponding _ml function,
-//    and then release the lock
-//
-//  getVersion(version_t version, TextBuffer** buffer, version_t) -
-//    creates a new TextBuffer that contains the contents of the specified
-//    version.  CALLEE MUST DELETE the buffer
-//
-//  getCurrentVersion() - returns the current version number.  Unless the
-//    callee was acquired the fileAccessLock, the return value only represents
-//    a snap shot in time
-//
-//  numberOfVersions() - returns the number of versions in the config dir.
-//    Unless the callee was acquired the fileAccessLock, the return value
-//    only represents a snap shot in time
-//
 //  checkForUserUpdate() - compares the last known modification time
 //    of the active version of the file with that files current modification
 //    time.  Returns true if the file has been changed manually or false
@@ -115,19 +98,6 @@ public:
   bool checkForUserUpdate();
   bool setLastModifiedTime();
 
-  // Lock not necessary since these are only valid for a
-  //  snap shot in time
-  version_t
-  getCurrentVersion() const
-  {
-    return currentVersion;
-  };
-  int
-  numberOfVersions() const
-  {
-    return numVersions;
-  }
-
   // Not file based so no lock necessary
   const char *
   getBaseName() const


[trafficserver] 03/23: Step 3: Remove revertToVersion() and revertToVersion_ml()

Posted by zw...@apache.org.
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

commit d367d3674e81c7ab4798243a96a846c7fa0e59da
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 14:42:10 2019 -0600

    Step 3: Remove revertToVersion() and revertToVersion_ml()
---
 mgmt/Rollback.cc | 41 -----------------------------------------
 mgmt/Rollback.h  |  5 -----
 2 files changed, 46 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 0350f87..1da6817 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -453,47 +453,6 @@ GET_CLEANUP:
   return returnCode;
 }
 
-RollBackCodes
-Rollback::revertToVersion(version_t version)
-{
-  RollBackCodes r;
-
-  ink_mutex_acquire(&fileAccessLock);
-  r = this->revertToVersion_ml(version);
-  ink_mutex_release(&fileAccessLock);
-
-  return r;
-}
-
-// Rollback::revertToVersion_ml(version_t version)
-//
-//  assumes callee is holding this->fileAccessLock
-//
-//  moves the current version to fileName_currentVersion
-//  copies fileName_revertToVersion fileName
-//  increases this->currentVersion, this->numVersion
-//
-RollBackCodes
-Rollback::revertToVersion_ml(version_t version)
-{
-  RollBackCodes returnCode;
-  TextBuffer *revertTo;
-
-  returnCode = this->getVersion_ml(version, &revertTo);
-  if (returnCode != OK_ROLLBACK) {
-    mgmt_log("[Rollback::revertToVersion] Unable to open version %d of %s\n", version, fileName);
-    return returnCode;
-  }
-
-  returnCode = forceUpdate_ml(revertTo);
-  if (returnCode != OK_ROLLBACK) {
-    mgmt_log("[Rollback::revertToVersion] Unable to revert to version %d of %s\n", version, fileName);
-  }
-
-  delete revertTo;
-  return OK_ROLLBACK;
-}
-
 // version_t Rollback::extractVersionInfo(ExpandingArray* listNames,
 //                                        const char* testFileName)
 //
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 4327e00..64b24a8 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -67,9 +67,6 @@ struct versionInfo {
 //  removeVersion(version_t ) - removes the specified version from the
 //    configuration directory
 //
-//  revertToVersion(version_t) - rolls the active version to a new file
-//    The specified version of the file is copied to the active version
-//
 //  getVersion(version_t version, TextBuffer** buffer, version_t) -
 //    creates a new TextBuffer that contains the contents of the specified
 //    version.  CALLEE MUST DELETE the buffer
@@ -143,7 +140,6 @@ public:
     ink_mutex_release(&fileAccessLock);
   };
   RollBackCodes removeVersion_ml(version_t version);
-  RollBackCodes revertToVersion_ml(version_t version);
   RollBackCodes getVersion_ml(version_t version, TextBuffer **buffer);
   RollBackCodes updateVersion_ml(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
                                  bool incVersion = true);
@@ -154,7 +150,6 @@ public:
   // Automatically take out lock
   bool checkForUserUpdate(RollBackCheckType);
   RollBackCodes removeVersion(version_t version);
-  RollBackCodes revertToVersion(version_t version);
   RollBackCodes getVersion(version_t version, TextBuffer **buffer);
   RollBackCodes updateVersion(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
                               bool incVersion = true);


[trafficserver] 13/23: Step 13: Removes openFile() and closeFile()

Posted by zw...@apache.org.
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

commit af5c885368fe5175902ba196f74a522cbe7dbd47
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:52:10 2019 -0600

    Step 13: Removes openFile() and closeFile()
---
 mgmt/Rollback.cc | 45 ---------------------------------------------
 mgmt/Rollback.h  |  5 -----
 2 files changed, 50 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 6fa04f2..b89f17a 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -158,51 +158,6 @@ Rollback::statFile(version_t version, struct stat *buf)
   return statResult;
 }
 
-//
-// int Rollback::openFile(version_t)
-//
-//  a wrapper for open()
-//
-int
-Rollback::openFile(version_t version, int oflags, int *errnoPtr)
-{
-  int fd;
-
-  ats_scoped_str filePath(createPathStr(version));
-  // TODO: Use the original permissions
-  //       Anyhow the _1 files should not be created inside Syconfdir.
-  //
-  fd = mgmt_open_mode_elevate(filePath, oflags, 0644, root_access_needed);
-
-  if (fd < 0) {
-    if (errnoPtr != nullptr) {
-      *errnoPtr = errno;
-    }
-    mgmt_log("[Rollback::openFile] Open of %s failed: %s\n", fileName, strerror(errno));
-  } else {
-    fcntl(fd, F_SETFD, FD_CLOEXEC);
-  }
-
-  return fd;
-}
-
-int
-Rollback::closeFile(int fd, bool callSync)
-{
-  int result = 0;
-  if (callSync && fsync(fd) < 0) {
-    result = -1;
-    mgmt_log("[Rollback::closeFile] fsync failed for file '%s' (%d: %s)\n", fileName, errno, strerror(errno));
-  }
-
-  if (result == 0) {
-    result = close(fd);
-  } else {
-    close(fd);
-  }
-  return result;
-}
-
 bool
 Rollback::setLastModifiedTime()
 {
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index ae6d990..8b8d5a5 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -85,9 +85,6 @@ struct versionInfo {
 //    refers to a file with an _version which does not exist for the active
 //    version.
 //
-//  openFile(version_t version, int oflags) - a wrapper for open
-//    opens a file based on version number
-//
 //  statFile(version_t, struct stat*) - a wrapper for stat that
 //    that stats the specified version
 //
@@ -175,8 +172,6 @@ public:
   Rollback &operator=(const Rollback &) = delete;
 
 private:
-  int openFile(version_t version, int oflags, int *errnoPtr = nullptr);
-  int closeFile(int fd, bool callSync);
   int statFile(version_t version, struct stat *buf);
   char *createPathStr(version_t version);
   ink_mutex fileAccessLock;


[trafficserver] 05/23: Step 5: Remove removeVersion() and removeVersion_ml()

Posted by zw...@apache.org.
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

commit 1e938dd22287ea0e807d65089d1567a92cb49e33
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 15:09:33 2019 -0600

    Step 5: Remove removeVersion() and removeVersion_ml()
---
 mgmt/Rollback.cc | 54 ------------------------------------------------------
 mgmt/Rollback.h  |  5 -----
 2 files changed, 59 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index e4aa1e7..8bcac70 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -489,60 +489,6 @@ Rollback::extractVersionInfo(ExpandingArray *listNames, const char *testFileName
   return version;
 }
 
-RollBackCodes
-Rollback::removeVersion(version_t version)
-{
-  RollBackCodes r;
-
-  ink_mutex_acquire(&fileAccessLock);
-  r = this->removeVersion_ml(version);
-  ink_mutex_release(&fileAccessLock);
-
-  return r;
-}
-
-RollBackCodes
-Rollback::removeVersion_ml(version_t version)
-{
-  struct stat statInfo;
-  char *versionPath;
-  versionInfo *removeInfo = nullptr;
-  bool infoFound          = false;
-
-  if (this->statFile(version, &statInfo) < 0) {
-    mgmt_log("[Rollback::removeVersion] Stat failed on %s version %d\n", fileName, version);
-    return FILE_NOT_FOUND_ROLLBACK;
-  }
-
-  versionPath = createPathStr(version);
-  if (unlink(versionPath) < 0) {
-    ats_free(versionPath);
-    mgmt_log("[Rollback::removeVersion] Unlink failed on %s version %d: %s\n", fileName, version, strerror(errno));
-    return SYS_CALL_ERROR_ROLLBACK;
-  }
-  // Take the version we just removed off of the backup queue
-  //   We are doing a linear search but since we almost always
-  //    are deleting the oldest version, the head of the queue
-  //    should be what we are looking for
-  for (removeInfo = versionQ.head; removeInfo != nullptr; removeInfo = removeInfo->link.next) {
-    if (removeInfo->version == version) {
-      infoFound = true;
-      break;
-    }
-  }
-  if (infoFound == true) {
-    versionQ.remove(removeInfo);
-    delete removeInfo;
-  } else {
-    mgmt_log("[Rollback::removeVersion] Unable to find info about %s version %d\n", fileName, version);
-  }
-
-  numVersions--;
-
-  ats_free(versionPath);
-  return OK_ROLLBACK;
-}
-
 time_t
 Rollback::versionTimeStamp(version_t version)
 {
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 5ce3548..692dc25 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -64,9 +64,6 @@ struct versionInfo {
 //    simply grab the lock, call the corresponding _ml function,
 //    and then release the lock
 //
-//  removeVersion(version_t ) - removes the specified version from the
-//    configuration directory
-//
 //  getVersion(version_t version, TextBuffer** buffer, version_t) -
 //    creates a new TextBuffer that contains the contents of the specified
 //    version.  CALLEE MUST DELETE the buffer
@@ -135,7 +132,6 @@ public:
   {
     ink_mutex_release(&fileAccessLock);
   };
-  RollBackCodes removeVersion_ml(version_t version);
   RollBackCodes getVersion_ml(version_t version, TextBuffer **buffer);
   RollBackCodes updateVersion_ml(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
                                  bool incVersion = true);
@@ -144,7 +140,6 @@ public:
 
   // Automatically take out lock
   bool checkForUserUpdate(RollBackCheckType);
-  RollBackCodes removeVersion(version_t version);
   RollBackCodes getVersion(version_t version, TextBuffer **buffer);
   RollBackCodes updateVersion(TextBuffer *buf, version_t basedOn, version_t newVersion = -1, bool notifyChange = true,
                               bool incVersion = true);


[trafficserver] 19/23: Step 19: Removes the now unused Rollback member variables

Posted by zw...@apache.org.
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

commit e41c66724a15c4cfb252eb50f18a2b6e51a3f236
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Mon May 27 14:43:49 2019 -0600

    Step 19: Removes the now unused Rollback member variables
---
 mgmt/FileManager.cc |  2 +-
 mgmt/Rollback.cc    | 18 ++++--------------
 mgmt/Rollback.h     | 20 ++++++--------------
 3 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index 2dd3fb7..6aa30bb 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -107,7 +107,7 @@ FileManager::addFileHelper(const char *fileName, const char *configName, bool ro
 {
   ink_assert(fileName != nullptr);
 
-  Rollback *rb    = new Rollback(fileName, configName, root_access_needed, parentRollback, flags);
+  Rollback *rb    = new Rollback(fileName, configName, root_access_needed, parentRollback);
   rb->configFiles = this;
 
   bindings.emplace(rb->getFileName(), rb);
diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index fc1372d..70fe2b0 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -46,9 +46,8 @@
 const char *RollbackStrings[] = {"Rollback Ok", "File was not found", "Version was out of date", "System Call Error",
                                  "Invalid Version - Version Numbers Must Increase"};
 
-Rollback::Rollback(const char *fileName_, const char *configName_, bool root_access_needed_, Rollback *parentRollback_,
-                   unsigned flags)
-  : configFiles(nullptr), root_access_needed(root_access_needed_), parentRollback(parentRollback_), fileLastModified(0)
+Rollback::Rollback(const char *fileName_, const char *configName_, bool root_access_needed_, Rollback *parentRollback_)
+  : root_access_needed(root_access_needed_), parentRollback(parentRollback_)
 {
   ExpandingArray existVer(25, true); // Existing versions
   struct stat fileInfo;
@@ -60,17 +59,8 @@ Rollback::Rollback(const char *fileName_, const char *configName_, bool root_acc
   }
 
   // Copy the file name.
-  fileNameLen = strlen(fileName_);
-  fileName    = ats_strdup(fileName_);
-  configName  = ats_strdup(configName_);
-
-  // Extract the file base name.
-  fileBaseName = strrchr(fileName, '/');
-  if (fileBaseName) {
-    fileBaseName++;
-  } else {
-    fileBaseName = fileName;
-  }
+  fileName   = ats_strdup(fileName_);
+  configName = ats_strdup(configName_);
 
   ink_mutex_init(&fileAccessLock);
 
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index e8ec017..f118e89 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -49,8 +49,7 @@ class Rollback
 {
 public:
   // fileName_ should be rooted or a base file name.
-  Rollback(const char *fileName_, const char *configName_, bool root_access_needed, Rollback *parentRollback = nullptr,
-           unsigned flags = 0);
+  Rollback(const char *fileName_, const char *configName_, bool root_access_needed, Rollback *parentRollback);
   ~Rollback();
 
   // Manual take out of lock required
@@ -66,16 +65,10 @@ public:
     ink_mutex_release(&fileAccessLock);
   };
 
-  // Automatically take out lock
+  // Check if a file has changed, automatically holds the lock. Used by FileManager.
   bool checkForUserUpdate();
 
-  // Not file based so no lock necessary
-  const char *
-  getBaseName() const
-  {
-    return fileBaseName;
-  }
-
+  // These are getters, for FileManager to get info about a particular configuration.
   const char *
   getFileName() const
   {
@@ -106,7 +99,7 @@ public:
     return root_access_needed;
   }
 
-  FileManager *configFiles; // Manager to notify on an update.
+  FileManager *configFiles = nullptr; // Manager to notify on an update.
 
   // noncopyable
   Rollback(const Rollback &) = delete;
@@ -114,12 +107,11 @@ public:
 
 private:
   int statFile(struct stat *buf);
+
   ink_mutex fileAccessLock;
   char *fileName;
-  char *fileBaseName;
   char *configName;
-  size_t fileNameLen;
   bool root_access_needed;
   Rollback *parentRollback;
-  time_t fileLastModified;
+  time_t fileLastModified = 0;
 };


[trafficserver] 22/23: Step 22: Renames Rollback.cc/.h -> ConfigManager.cc/.h

Posted by zw...@apache.org.
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

commit 8458750a79445a5f5c03833163b809a512ac85a4
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Thu Jun 13 10:05:24 2019 -0600

    Step 22: Renames Rollback.cc/.h -> ConfigManager.cc/.h
---
 lib/records/RecLocal.cc                | 2 +-
 mgmt/{Rollback.cc => ConfigManager.cc} | 2 +-
 mgmt/{Rollback.h => ConfigManager.h}   | 0
 mgmt/FileManager.cc                    | 2 +-
 mgmt/Makefile.am                       | 4 ++--
 mgmt/api/CoreAPI.cc                    | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/records/RecLocal.cc b/lib/records/RecLocal.cc
index 8190feb..2a30917 100644
--- a/lib/records/RecLocal.cc
+++ b/lib/records/RecLocal.cc
@@ -22,7 +22,7 @@
  */
 
 #include "tscore/ink_platform.h"
-#include "Rollback.h"
+#include "ConfigManager.h"
 #include "tscore/ParseRules.h"
 #include "P_RecCore.h"
 #include "P_RecLocal.h"
diff --git a/mgmt/Rollback.cc b/mgmt/ConfigManager.cc
similarity index 99%
rename from mgmt/Rollback.cc
rename to mgmt/ConfigManager.cc
index d0e3308..4b53cb4 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/ConfigManager.cc
@@ -26,7 +26,7 @@
 #include "tscore/ink_time.h"
 #include "Alarms.h"
 #include "LocalManager.h"
-#include "Rollback.h"
+#include "ConfigManager.h"
 #include "WebMgmtUtils.h"
 #include "ExpandingArray.h"
 #include "MgmtSocket.h"
diff --git a/mgmt/Rollback.h b/mgmt/ConfigManager.h
similarity index 100%
rename from mgmt/Rollback.h
rename to mgmt/ConfigManager.h
diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index 3cf4b1d..fc1d068 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -24,7 +24,7 @@
 #include "FileManager.h"
 #include "tscore/ink_platform.h"
 #include "tscore/ink_file.h"
-#include "Rollback.h"
+#include "ConfigManager.h"
 #include "WebMgmtUtils.h"
 
 #include <vector>
diff --git a/mgmt/Makefile.am b/mgmt/Makefile.am
index 34c8b03..a52678d 100644
--- a/mgmt/Makefile.am
+++ b/mgmt/Makefile.am
@@ -63,8 +63,8 @@ libmgmt_lm_la_SOURCES = \
 	FileManager.h \
 	LocalManager.cc \
 	LocalManager.h \
-	Rollback.cc \
-	Rollback.h \
+	ConfigManager.cc \
+	ConfigManager.h \
 	DerivativeMetrics.cc \
 	DerivativeMetrics.h \
 	WebMgmtUtils.cc \
diff --git a/mgmt/api/CoreAPI.cc b/mgmt/api/CoreAPI.cc
index 4959513..1a0ff56 100644
--- a/mgmt/api/CoreAPI.cc
+++ b/mgmt/api/CoreAPI.cc
@@ -36,7 +36,7 @@
 #include "MgmtUtils.h"
 #include "LocalManager.h"
 #include "FileManager.h"
-#include "Rollback.h"
+#include "ConfigManager.h"
 #include "WebMgmtUtils.h"
 #include "tscore/Diags.h"
 #include "ExpandingArray.h"


[trafficserver] 08/23: Step 8: Removes internalUpdate(), functionality was moved in 6

Posted by zw...@apache.org.
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

commit 589dc2060e48fc66b52cff7f383a411e1627c370
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:45:32 2019 -0600

    Step 8: Removes internalUpdate(), functionality was moved in 6
---
 mgmt/Rollback.cc | 132 -------------------------------------------------------
 mgmt/Rollback.h  |   5 ---
 2 files changed, 137 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index f60bcdf..fab496b 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -203,138 +203,6 @@ Rollback::closeFile(int fd, bool callSync)
   return result;
 }
 
-// Rollback::internalUpdate()
-//
-//  Creates a version from buf.  Callee must be holding the lock
-//
-RollBackCodes
-Rollback::internalUpdate(TextBuffer *buf, version_t newVersion, bool notifyChange, bool incVersion)
-{
-  RollBackCodes returnCode;
-  char *activeVersion;
-  char *currentVersion_local;
-  char *nextVersion;
-  ssize_t writeBytes;
-  int diskFD;
-  int ret;
-  versionInfo *newBak;
-  bool failedLink = false;
-  char *alarmMsg  = nullptr;
-
-  // Check to see if the callee has specified a newVersion number
-  //   If the newVersion argument is less than zero, the callee
-  //   is telling us to use the next version in sequence
-  if (newVersion < 0) {
-    newVersion = this->currentVersion + 1;
-    if (incVersion) {
-      incVersion = false; // because the version already increment
-    }
-  } else {
-    // We need to make sure that the specified version is valid
-    //  We can NOT go back in time to a smaller version number
-    //  than the one we have now
-    if (newVersion <= this->currentVersion) {
-      return INVALID_VERSION_ROLLBACK;
-    }
-  }
-
-  Debug("rollback", "[Rollback::internalUpdate] Moving %s from version %d to version %d", this->fileName, this->currentVersion,
-        newVersion);
-
-  currentVersion_local = createPathStr(this->currentVersion);
-  activeVersion        = createPathStr(ACTIVE_VERSION);
-  nextVersion          = createPathStr(newVersion);
-  // Create the new configuration file
-  // TODO: Make sure they are not created in Sysconfigdir!
-  diskFD = openFile(newVersion, O_WRONLY | O_CREAT | O_TRUNC);
-
-  if (diskFD < 0) {
-    // Could not create the new file.  The operation is aborted
-    mgmt_log("[Rollback::internalUpdate] Unable to create new version of %s : %s\n", fileName, strerror(errno));
-    returnCode = SYS_CALL_ERROR_ROLLBACK;
-    goto UPDATE_CLEANUP;
-  }
-  // Write the buffer into the new configuration file
-  writeBytes = write(diskFD, buf->bufPtr(), buf->spaceUsed());
-  ret        = closeFile(diskFD, true);
-  if ((ret < 0) || ((size_t)writeBytes != buf->spaceUsed())) {
-    mgmt_log("[Rollback::internalUpdate] Unable to write new version of %s : %s\n", fileName, strerror(errno));
-    returnCode = SYS_CALL_ERROR_ROLLBACK;
-    goto UPDATE_CLEANUP;
-  }
-
-  // Now that we got a the new version on the disk lets do some renaming
-  if (link(activeVersion, currentVersion_local) < 0) {
-    mgmt_log("[Rollback::internalUpdate] Link failed : %s\n", strerror(errno));
-
-    // If the file was lost, it is lost and log the error and
-    //    install a new file so that we do not go around in
-    //    an endless loop
-    if (errno == ENOENT) {
-      mgmt_log("[Rollback::internalUpdate] The active version of %s was lost.\n\tThe updated copy was installed.\n", fileName);
-      failedLink = true;
-    } else {
-      returnCode = SYS_CALL_ERROR_ROLLBACK;
-      goto UPDATE_CLEANUP;
-    }
-  }
-
-  if (rename(nextVersion, activeVersion) < 0) {
-    mgmt_log("[Rollback::internalUpdate] Rename failed : %s\n", strerror(errno));
-    mgmt_log("[Rollback::internalUpdate] Unable to create new version of %s.  Using prior version\n", fileName);
-
-    returnCode = SYS_CALL_ERROR_ROLLBACK;
-    goto UPDATE_CLEANUP;
-  }
-
-  setLastModifiedTime();
-
-  // ToDo: We used to call removeVersion_ml() here.
-
-  // If we created a backup version add it to the
-  //  List of backup Versions
-  if (failedLink == false) {
-    newBak          = new versionInfo;
-    newBak->version = this->currentVersion;
-    newBak->modTime = 0;
-    versionQ.enqueue(newBak);
-  }
-  // Update instance variables
-  this->numVersions++;
-  this->currentVersion = newVersion;
-
-  returnCode = OK_ROLLBACK;
-
-  // Post the change to the config file manager
-  if (notifyChange && configFiles) {
-    configFiles->fileChanged(fileName, configName, incVersion);
-  }
-
-UPDATE_CLEANUP:
-
-  // Signal an alarm if we failed since if we are unable
-  //   to manipulate the disk, the error might not get
-  //   written to disk
-  if (returnCode != OK_ROLLBACK) {
-    alarmMsg = (char *)ats_malloc(1024);
-    snprintf(alarmMsg, 1024, "[TrafficManager] Configuration File Update Failed: %s", strerror(errno));
-    lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_CONFIG_UPDATE_FAILED, alarmMsg);
-    ats_free(alarmMsg);
-
-    // Remove both the link from currentVersion_local
-    // to the active version and the new version
-    //  that they will not screw up our version id on restart
-    unlink(currentVersion_local);
-    unlink(nextVersion);
-  }
-
-  ats_free(currentVersion_local);
-  ats_free(activeVersion);
-  ats_free(nextVersion);
-
-  return returnCode;
-}
-
 RollBackCodes
 Rollback::getVersion(version_t version, TextBuffer **buffer)
 {
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index a3608d0..90aeee7 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -98,10 +98,6 @@ struct versionInfo {
 //  createPathStr(version_t) - creates a string to the specified
 //    version of the file.  CALLEE DELETES storage
 //
-//  internalUpdate(TextBuffer*, version_t) - does the really work of the
-//    public update functions.  newVersion tells us what the new
-//    version number should be.  -1 means the next in sequence
-
 class Rollback
 {
 public:
@@ -193,7 +189,6 @@ private:
   int closeFile(int fd, bool callSync);
   int statFile(version_t version, struct stat *buf);
   char *createPathStr(version_t version);
-  RollBackCodes internalUpdate(TextBuffer *buf, version_t newVersion, bool notifyChange = true, bool incVersion = true);
   ink_mutex fileAccessLock;
   char *fileName;
   char *fileBaseName;


[trafficserver] 18/23: Step 18: Removes setLastModifiedTime, and simplifies code

Posted by zw...@apache.org.
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

commit e336562b2a2215144aae25e3fc26579a1daac380
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Mon May 27 14:37:29 2019 -0600

    Step 18: Removes setLastModifiedTime, and simplifies code
---
 mgmt/Rollback.cc | 26 +-------------------------
 mgmt/Rollback.h  | 11 -----------
 2 files changed, 1 insertion(+), 36 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index c33d0d8..fc1372d 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -74,12 +74,6 @@ Rollback::Rollback(const char *fileName_, const char *configName_, bool root_acc
 
   ink_mutex_init(&fileAccessLock);
 
-  // ToDo: This was really broken before, it  used to check if numberBackups <=0, but that could never happen.
-  if (flags & CONFIG_FLAG_UNVERSIONED) {
-    setLastModifiedTime();
-    return;
-  }
-
   // Check to make sure that our configuration file exists
   //
   if (statFile(&fileInfo) < 0) {
@@ -114,24 +108,6 @@ Rollback::statFile(struct stat *buf)
   return statResult;
 }
 
-bool
-Rollback::setLastModifiedTime()
-{
-  struct stat fileInfo;
-
-  // Now we need to get the modification time off of the new active file
-  if (statFile(&fileInfo) >= 0) {
-    fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
-    return true;
-  } else {
-    // We really shouldn't fail to stat the file since we just
-    //  created it.  If we do, just punt and just use the current
-    //  time.
-    fileLastModified = (time(nullptr) - ink_timezone()) * 1000000000;
-    return false;
-  }
-}
-
 // bool Rollback::checkForUserUpdate()
 //
 //  Called to check if the file has been changed  by the user.
@@ -150,7 +126,7 @@ Rollback::checkForUserUpdate()
   }
 
   if (fileLastModified < TS_ARCHIVE_STAT_MTIME(fileInfo)) {
-    setLastModifiedTime();
+    fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
     configFiles->fileChanged(fileName, configName, true);
     mgmt_log("User has changed config file %s\n", fileName);
 
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index e58db4a..e8ec017 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -29,18 +29,8 @@
 class FileManager;
 class TextBuffer;
 
-typedef int version_t;
-
 class ExpandingArray;
 
-// Stores info about a backup version
-//   Can be put in to List.h lists
-struct versionInfo {
-  version_t version;
-  time_t modTime;
-  LINK(versionInfo, link);
-};
-
 //
 //  class Rollback
 //
@@ -78,7 +68,6 @@ public:
 
   // Automatically take out lock
   bool checkForUserUpdate();
-  bool setLastModifiedTime();
 
   // Not file based so no lock necessary
   const char *