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:36 UTC

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

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);