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