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 <[email protected]>
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;

Reply via email to