Skip to content
Browse files

TS-2292: the version of records.config increases unexpectly

  • Loading branch information...
1 parent 26e1417 commit 6cb58be3e7a5defab6d3419229d8d5e4b548e933 Yu Qing committed with mingzym Oct 29, 2013
View
3 CHANGES
@@ -2,6 +2,9 @@
Changes with Apache Traffic Server 4.1.0
+ *) [TS-2292] the version of records.config increases unexpectly.
+ Author: Yu Qing
+
*) [TS-2277] cluster alarm messages broadcast infinitely.
Author: Yu Qing
View
4 cop/TrafficCop.cc
@@ -487,7 +487,7 @@ transient_error(int error, int wait_ms)
}
static void
-config_register_variable(RecT rec_type, RecDataT data_type, const char * name, const char * value)
+config_register_variable(RecT rec_type, RecDataT data_type, const char * name, const char * value, bool /* inc_version */)
{
configTable.insert(std::make_pair(std::string(name), ConfigValue(rec_type, data_type, value)));
}
@@ -566,7 +566,7 @@ config_reload_records()
configTable.clear();
- if (RecConfigFileParse(config_file, config_register_variable) != REC_ERR_OKAY) {
+ if (RecConfigFileParse(config_file, config_register_variable, false) != REC_ERR_OKAY) {
cop_log(COP_FATAL, "could not parse \"%s\"\n", config_file);
exit(1);
}
View
14 lib/records/I_RecCore.h
@@ -40,10 +40,10 @@ int RecSetDiags(Diags * diags);
//-------------------------------------------------------------------------
// Config File Parsing
//-------------------------------------------------------------------------
-typedef void (*RecConfigEntryCallback)(RecT rec_type, RecDataT data_type, const char * name, const char * value);
+typedef void (*RecConfigEntryCallback)(RecT rec_type, RecDataT data_type, const char * name, const char * value, bool inc_version);
void RecConfigFileInit(void);
-int RecConfigFileParse(const char * path, RecConfigEntryCallback handler);
+int RecConfigFileParse(const char * path, RecConfigEntryCallback handler, bool inc_version);
// Test whether the named configuration value is overridden by an environment variable. Return either
// the overridden value, or the original value. Caller MUST NOT free the result.
@@ -105,11 +105,11 @@ int RecRegisterRawStatUpdateFunc(const char *name, RecRawStatBlock * rsb, int id
// already been taken out for the callback.
// RecSetRecordConvert -> WebMgmtUtils.cc::varSetFromStr()
-int RecSetRecordConvert(const char *name, const RecString rec_string, bool lock = true);
-int RecSetRecordInt(const char *name, RecInt rec_int, bool lock = true);
-int RecSetRecordFloat(const char *name, RecFloat rec_float, bool lock = true);
-int RecSetRecordString(const char *name, const RecString rec_string, bool lock = true);
-int RecSetRecordCounter(const char *name, RecCounter rec_counter, bool lock = true);
+int RecSetRecordConvert(const char *name, const RecString rec_string, bool lock = true, bool inc_version = true);
+int RecSetRecordInt(const char *name, RecInt rec_int, bool lock = true, bool inc_version = true);
+int RecSetRecordFloat(const char *name, RecFloat rec_float, bool lock = true, bool inc_version = true);
+int RecSetRecordString(const char *name, const RecString rec_string, bool lock = true, bool inc_version = true);
+int RecSetRecordCounter(const char *name, RecCounter rec_counter, bool lock = true, bool inc_version = true);
int RecGetRecordInt(const char *name, RecInt * rec_int, bool lock = true);
int RecGetRecordFloat(const char *name, RecFloat * rec_float, bool lock = true);
View
52 lib/records/P_RecCore.cc
@@ -378,7 +378,7 @@ RecRegisterConfigCounter(RecT rec_type, const char *name,
// RecSetRecordXXX
//-------------------------------------------------------------------------
int
-RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data, RecRawStat *data_raw, bool lock)
+RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data, RecRawStat *data_raw, bool lock, bool inc_version)
{
int err = REC_ERR_OKAY;
RecRecord *r1;
@@ -423,6 +423,9 @@ RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data,
if (RecDataSet(data_type, &(r1->data), data)) {
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;
}
@@ -479,43 +482,43 @@ RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data,
}
int
-RecSetRecordConvert(const char *name, const RecString rec_string, bool lock)
+RecSetRecordConvert(const char *name, const RecString rec_string, bool lock, bool inc_version)
{
RecData data;
data.rec_string = rec_string;
- return RecSetRecord(RECT_NULL, name, RECD_NULL, &data, NULL, lock);
+ return RecSetRecord(RECT_NULL, name, RECD_NULL, &data, NULL, lock, inc_version);
}
int
-RecSetRecordInt(const char *name, RecInt rec_int, bool lock)
+RecSetRecordInt(const char *name, RecInt rec_int, bool lock, bool inc_version)
{
RecData data;
data.rec_int = rec_int;
- return RecSetRecord(RECT_NULL, name, RECD_INT, &data, NULL, lock);
+ return RecSetRecord(RECT_NULL, name, RECD_INT, &data, NULL, lock, inc_version);
}
int
-RecSetRecordFloat(const char *name, RecFloat rec_float, bool lock)
+RecSetRecordFloat(const char *name, RecFloat rec_float, bool lock, bool inc_version)
{
RecData data;
data.rec_float = rec_float;
- return RecSetRecord(RECT_NULL, name, RECD_FLOAT, &data, NULL, lock);
+ return RecSetRecord(RECT_NULL, name, RECD_FLOAT, &data, NULL, lock, inc_version);
}
int
-RecSetRecordString(const char *name, const RecString rec_string, bool lock)
+RecSetRecordString(const char *name, const RecString rec_string, bool lock, bool inc_version)
{
RecData data;
data.rec_string = rec_string;
- return RecSetRecord(RECT_NULL, name, RECD_STRING, &data, NULL, lock);
+ return RecSetRecord(RECT_NULL, name, RECD_STRING, &data, NULL, lock, inc_version);
}
int
-RecSetRecordCounter(const char *name, RecCounter rec_counter, bool lock)
+RecSetRecordCounter(const char *name, RecCounter rec_counter, bool lock, bool inc_version)
{
RecData data;
data.rec_counter = rec_counter;
- return RecSetRecord(RECT_NULL, name, RECD_COUNTER, &data, NULL, lock);
+ return RecSetRecord(RECT_NULL, name, RECD_COUNTER, &data, NULL, lock, inc_version);
}
@@ -591,33 +594,31 @@ RecSyncStatsFile()
return REC_ERR_OKAY;
}
-
-//-------------------------------------------------------------------------
-// RecReadConfigFile
-//-------------------------------------------------------------------------
-
// 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)
+RecConsumeConfigEntry(RecT rec_type, RecDataT data_type, const char * name, const char * value, bool inc_version)
{
RecData data;
memset(&data, 0, sizeof(RecData));
RecDataSetFromString(data_type, &data, value);
- RecSetRecord(rec_type, name, data_type, &data, NULL, false);
+ RecSetRecord(rec_type, name, data_type, &data, NULL, false, inc_version);
RecDataClear(data_type, &data);
}
+//-------------------------------------------------------------------------
+// RecReadConfigFile
+//-------------------------------------------------------------------------
int
-RecReadConfigFile()
+RecReadConfigFile(bool inc_version)
{
RecDebug(DL_Note, "Reading '%s'", g_rec_config_fpath);
// lock our hash table
ink_rwlock_wrlock(&g_records_rwlock);
// Parse the actual fileand hash the values.
- RecConfigFileParse(g_rec_config_fpath, RecConsumeConfigEntry);
+ RecConfigFileParse(g_rec_config_fpath, RecConsumeConfigEntry, inc_version);
// release our hash table
ink_rwlock_unlock(&g_records_rwlock);
@@ -630,10 +631,13 @@ RecReadConfigFile()
// RecSyncConfigFile
//-------------------------------------------------------------------------
int
-RecSyncConfigToTB(textBuffer * tb)
+RecSyncConfigToTB(textBuffer * tb, bool *inc_version)
{
int err = REC_ERR_FAIL;
+ if (inc_version != NULL) {
+ *inc_version = false;
+ }
/*
* g_mode_type should be initialized by
* RecLocalInit() or RecProcessInit() earlier.
@@ -664,6 +668,12 @@ RecSyncConfigToTB(textBuffer * tb)
}
r->sync_required = r->sync_required & ~REC_DISK_SYNC_REQUIRED;
sync_to_disk = true;
+ if (r->sync_required & REC_INC_CONFIG_VERSION) {
+ r->sync_required = r->sync_required & ~REC_INC_CONFIG_VERSION;
+ if (inc_version != NULL) {
+ *inc_version = true;
+ }
+ }
}
}
rec_mutex_release(&(r->lock));
View
6 lib/records/P_RecCore.h
@@ -78,7 +78,7 @@ RecRecord *RecForceInsert(RecRecord * record);
//-------------------------------------------------------------------------
int RecSetRecord(RecT rec_type, const char *name, RecDataT data_type,
- RecData *data, RecRawStat *raw_stat, bool lock = true);
+ RecData *data, RecRawStat *raw_stat, bool lock = true, bool inc_version = true);
int RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData * data, bool lock = true);
@@ -88,8 +88,8 @@ int RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData * data, b
int RecReadStatsFile();
int RecSyncStatsFile();
-int RecReadConfigFile();
-int RecSyncConfigToTB(textBuffer * tb);
+int RecReadConfigFile(bool inc_version);
+int RecSyncConfigToTB(textBuffer * tb, bool *inc_version = NULL);
//-------------------------------------------------------------------------
// Misc
View
1 lib/records/P_RecDefs.h
@@ -54,6 +54,7 @@
#define REC_DISK_SYNC_REQUIRED 1
#define REC_PEER_SYNC_REQUIRED (REC_DISK_SYNC_REQUIRED << 1)
+#define REC_INC_CONFIG_VERSION (REC_PEER_SYNC_REQUIRED << 1)
#define REC_SYNC_REQUIRED (REC_DISK_SYNC_REQUIRED | REC_PEER_SYNC_REQUIRED)
enum RecEntryT
View
4 lib/records/RecConfigParse.cc
@@ -107,7 +107,7 @@ RecConfigOverrideFromEnvironment(const char * name, const char * value)
// RecParseConfigFile
//-------------------------------------------------------------------------
int
-RecConfigFileParse(const char * path, RecConfigEntryCallback handler)
+RecConfigFileParse(const char * path, RecConfigEntryCallback handler, bool inc_version)
{
char *fbuf;
int fsize;
@@ -227,7 +227,7 @@ RecConfigFileParse(const char * path, RecConfigEntryCallback handler)
}
// OK, we parsed the record, send it to the handler ...
- handler(rec_type, data_type, name_str, RecConfigOverrideFromEnvironment(name_str, data_str));
+ handler(rec_type, data_type, name_str, RecConfigOverrideFromEnvironment(name_str, data_str), inc_version);
// update our g_rec_config_contents_xxx
cfe = (RecConfigFileEntry *)ats_malloc(sizeof(RecConfigFileEntry));
View
2 lib/records/RecCore.cc
@@ -203,7 +203,7 @@ RecCoreInit(RecModeT mode_type, Diags *_diags)
}
}
if (file_exists) {
- RecReadConfigFile();
+ RecReadConfigFile(true);
}
}
View
25 lib/records/RecLocal.cc
@@ -102,23 +102,36 @@ sync_thr(void *data)
{
textBuffer *tb = NEW(new textBuffer(65536));
Rollback *rb;
+ bool inc_version;
+ bool written;
while (1) {
send_push_message();
RecSyncStatsFile();
- if (RecSyncConfigToTB(tb) == REC_ERR_OKAY) {
+ if (RecSyncConfigToTB(tb, &inc_version) == REC_ERR_OKAY) {
+ written = false;
if (configFiles->getRollbackObj(REC_CONFIG_FILE, &rb)) {
- RecDebug(DL_Note, "Rollback: '%s'", REC_CONFIG_FILE);
- version_t ver = rb->getCurrentVersion();
- if ((rb->updateVersion(tb, ver, -1, false)) != OK_ROLLBACK) {
- RecDebug(DL_Note, "Rollback failed: '%s'", REC_CONFIG_FILE);
+ if (inc_version) {
+ RecDebug(DL_Note, "Rollback: '%s'", REC_CONFIG_FILE);
+ version_t ver = rb->getCurrentVersion();
+ if ((rb->updateVersion(tb, ver, -1, false)) != OK_ROLLBACK) {
+ RecDebug(DL_Note, "Rollback failed: '%s'", REC_CONFIG_FILE);
+ }
+ written = true;
}
- } else {
+ }
+ else {
+ rb = NULL;
+ }
+ if (!written) {
int nbytes;
RecDebug(DL_Note, "Writing '%s'", g_rec_config_fpath);
RecHandle h_file = RecFileOpenW(g_rec_config_fpath);
RecFileWrite(h_file, tb->bufPtr(), tb->spaceUsed(), &nbytes);
RecFileClose(h_file);
+ if (rb != NULL) {
+ rb->setLastModifiedTime();
+ }
}
}
usleep(REC_REMOTE_SYNC_INTERVAL_MS * 1000);
View
2 mgmt/AddConfigFilesHere.cc
@@ -35,7 +35,7 @@
****************************************************************************/
void
-testcall(char *foo)
+testcall(char *foo, bool /* incVersion */)
{
Debug("lm", "Received Callback that %s has changed\n", foo);
}
View
1 mgmt/BaseManager.h
@@ -63,6 +63,7 @@
#define MGMT_EVENT_HTTP_CLUSTER_DELTA 10007
#define MGMT_EVENT_ROLL_LOG_FILES 10008
#define MGMT_EVENT_LIBRECORDS 10009
+#define MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION 10010
/***********************************************************************
*
View
6 mgmt/FileManager.cc
@@ -223,7 +223,7 @@ FileManager::getRollbackObj(const char *baseFileName, Rollback ** rbPtr)
//
//
void
-FileManager::fileChanged(const char *baseFileName)
+FileManager::fileChanged(const char *baseFileName, bool incVersion)
{
callbackListable *cb;
@@ -236,7 +236,7 @@ FileManager::fileChanged(const char *baseFileName)
// Dup the string for each callback to be
// defensive incase it modified when it is not supposed to be
filenameCopy = ats_strdup(baseFileName);
- (*cb->func) (filenameCopy);
+ (*cb->func) (filenameCopy, incVersion);
ats_free(filenameCopy);
}
ink_mutex_release(&cbListLock);
@@ -767,7 +767,7 @@ FileManager::rereadConfig()
int enabled = (int) REC_readInteger("proxy.config.body_factory.enable_customizations",
&found);
if (found && enabled) {
- fileChanged("proxy.config.body_factory.template_sets_dir");
+ fileChanged("proxy.config.body_factory.template_sets_dir", true);
}
}
View
4 mgmt/FileManager.h
@@ -41,7 +41,7 @@
class Rollback;
-typedef void (*FileCallbackFunc) (char *);
+typedef void (*FileCallbackFunc) (char *, bool);
struct callbackListable
{
@@ -115,7 +115,7 @@ class FileManager:public MultiFile
void addFile(const char *baseFileName, bool root_access_needed);
bool getRollbackObj(const char *baseFileName, Rollback ** rbPtr);
void registerCallback(FileCallbackFunc func);
- void fileChanged(const char *baseFileName);
+ void fileChanged(const char *baseFileName, bool incVersion);
textBuffer *filesManaged();
void rereadConfig();
//SnapResult takeSnap(const char* snapName);
View
15 mgmt/LocalManager.cc
@@ -753,6 +753,7 @@ 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;
Rollback *rb;
@@ -840,9 +841,14 @@ LocalManager::sendMgmtMsgToProcesses(MgmtMessageHdr * mh)
void
-LocalManager::signalFileChange(const char *var_name)
+LocalManager::signalFileChange(const char *var_name, bool incVersion)
{
- signalEvent(MGMT_EVENT_CONFIG_FILE_UPDATE, var_name);
+ if (incVersion) {
+ signalEvent(MGMT_EVENT_CONFIG_FILE_UPDATE, var_name);
+ }
+ else {
+ signalEvent(MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION, var_name);
+ }
return;
}
@@ -888,10 +894,11 @@ LocalManager::processEventQueue()
char *data_raw = (char *) mh + sizeof(MgmtMessageHdr);
// check if we have a local file update
- if (mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE) {
+ if (mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE || mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION) {
// records.config
if (!(strcmp(data_raw, "records.config"))) {
- if (RecReadConfigFile() != REC_ERR_OKAY) {
+ bool incVersion = mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE;
+ if (RecReadConfigFile(incVersion) != REC_ERR_OKAY) {
mgmt_elog(stderr, "[fileUpdated] Config update failed for records.config\n");
}
handled_by_mgmt = true;
View
2 mgmt/LocalManager.h
@@ -75,7 +75,7 @@ class LocalManager: public BaseManager
void sendMgmtMsgToProcesses(int msg_id, const char *data_raw, int data_len);
void sendMgmtMsgToProcesses(MgmtMessageHdr * mh);
- void signalFileChange(const char *var_name);
+ void signalFileChange(const char *var_name, bool incVersion = true);
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 = NULL, const char *ip = NULL);
View
4 mgmt/Main.cc
@@ -991,7 +991,7 @@ printUsage()
} /* End printUsage */
void
-fileUpdated(char *fname)
+fileUpdated(char *fname, bool incVersion)
{
if (strcmp(fname, "cluster.config") == 0) {
lmgmt->signalFileChange("proxy.config.cluster.cluster_configuration");
@@ -1003,7 +1003,7 @@ fileUpdated(char *fname)
lmgmt->signalFileChange("proxy.config.socks.socks_config_file");
} else if (strcmp(fname, "records.config") == 0) {
- lmgmt->signalFileChange("records.config");
+ lmgmt->signalFileChange("records.config", incVersion);
} else if (strcmp(fname, "cache.config") == 0) {
lmgmt->signalFileChange("proxy.config.cache.control.filename");
View
2 mgmt/Main.h
@@ -35,7 +35,7 @@
#define DEFAULT_LOG_DIRECTORY "var/log/trafficserver"
void MgmtShutdown(int status);
-void fileUpdated(char *fname);
+void fileUpdated(char *fname, bool incVersion);
void runAsUser(char *userName);
void extractConfigInfo(char *mgmt_path, const char *recs_conf, char *userName, int *fds_throttle);
void printUsage(void);
View
1 mgmt/ProcessManager.cc
@@ -312,6 +312,7 @@ ProcessManager::handleMgmtMsgFromLM(MgmtMessageHdr * mh)
signalMgmtEntity(MGMT_EVENT_HTTP_CLUSTER_DELTA, data_raw);
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.
View
60 mgmt/Rollback.cc
@@ -164,17 +164,7 @@ Rollback::Rollback(const char *baseFileName, bool root_access_needed_)
}
currentVersion = highestSeen + 1;
-
- // Try again stating the file. It really ought to be there since
- // we just went through a load trouble to put it there
- // But if we can not get it, just give up, assume the error
- // is transient and use the current time
- if (statFile(ACTIVE_VERSION, &fileInfo) < 0) {
- fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
- } else {
- fileLastModified = (time(NULL) - ink_timezone()) * 1000000000;
- }
-
+ setLastModifiedTime();
} else {
// If is there but we can not stat it, it is unusable to manager
// probably due to permissions problems. Bail!
@@ -389,27 +379,27 @@ Rollback::closeFile(int fd)
RollBackCodes
-Rollback::updateVersion(textBuffer * buf, version_t basedOn, version_t newVersion, bool notifyChange)
+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);
+ 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)
+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);
+ returnCode = internalUpdate(buf, newVersion, notifyChange, incVersion);
}
return returnCode;
@@ -440,15 +430,14 @@ Rollback::forceUpdate_ml(textBuffer * buf, version_t newVersion)
// Creates a version from buf. Callee must be holding the lock
//
RollBackCodes
-Rollback::internalUpdate(textBuffer * buf, version_t newVersion, bool notifyChange)
+Rollback::internalUpdate(textBuffer * buf, version_t newVersion, bool notifyChange, bool incVersion)
{
RollBackCodes returnCode;
char *activeVersion;
char *currentVersion_local;
char *nextVersion;
int writeBytes;
int diskFD;
- struct stat fileInfo;
versionInfo *toRemove;
versionInfo *newBak;
bool failedLink = false;
@@ -460,6 +449,9 @@ Rollback::internalUpdate(textBuffer * buf, version_t newVersion, bool notifyChan
// is telling us to use the next version in squence
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
@@ -522,16 +514,7 @@ Rollback::internalUpdate(textBuffer * buf, version_t newVersion, bool notifyChan
goto UPDATE_CLEANUP;
}
- // Now we need to get the modification time off of the new active file
- if (statFile(ACTIVE_VERSION, &fileInfo) >= 0) {
- fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
- } else {
- // We really shoudn't fail to stat the file since we just
- // created it. If we do, just punt and just use the current
- // time.
- fileLastModified = (time(NULL) - ink_timezone()) * 1000000000;
- }
-
+ setLastModifiedTime();
// Check to see if we need to delete an excess backup versions
//
// We subtract one from numVersions to exclude the active
@@ -563,8 +546,9 @@ Rollback::internalUpdate(textBuffer * buf, version_t newVersion, bool notifyChan
returnCode = OK_ROLLBACK;
// Post the change to the config file manager
- if (notifyChange)
- configFiles->fileChanged(fileName);
+ if (notifyChange) {
+ configFiles->fileChanged(fileName, incVersion);
+ }
UPDATE_CLEANUP:
@@ -962,6 +946,24 @@ Rollback::statVersion(version_t version, struct stat *buf)
return r;
}
+bool
+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) {
+ fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
+ return true;
+ } else {
+ // We really shoudn't fail to stat the file since we just
+ // created it. If we do, just punt and just use the current
+ // time.
+ fileLastModified = (time(NULL) - ink_timezone()) * 1000000000;
+ return false;
+ }
+}
+
// bool Rollback::checkForUserUpdate()
//
// Called to check if the file has been changed
View
7 mgmt/Rollback.h
@@ -164,7 +164,7 @@ class Rollback
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);
+ 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);
@@ -176,11 +176,12 @@ class Rollback
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);
+ 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();
// Lock not necessary since these are only valid for a
// snap shot in time
@@ -205,7 +206,7 @@ class Rollback
int closeFile(int fd);
int statFile(version_t version, struct stat *buf);
char *createPathStr(version_t version);
- RollBackCodes internalUpdate(textBuffer * buf, version_t newVersion, bool notifyChange = true);
+ RollBackCodes internalUpdate(textBuffer * buf, version_t newVersion, bool notifyChange = true, bool incVersion = true);
char *configDir;
ink_mutex fileAccessLock;
char *fileName;
View
7 mgmt/cluster/ClusterCom.cc
@@ -295,8 +295,7 @@ drainIncomingChannel(void *arg)
stat = false;
mgmt_log(stderr, "[drainIncomingChannel] Failed file req: %s v: %d\n", fname, ver);
} else {
- mgmt_log(stderr,
- "[drainIncomingChannel] file req: %s v: %d bytes: %d\n", fname, ver, strlen(buff->bufPtr()));
+ Debug("ccom", "[drainIncomingChannel] file req: %s v: %d bytes: %d\n", fname, ver, (int)strlen(buff->bufPtr()));
}
} else {
mgmt_elog("[drainIncomingChannel] Error file req: %s ver: %d\n", fname, ver);
@@ -1224,7 +1223,7 @@ ClusterCom::handleMultiCastFilePacket(char *last, char *ip)
}
}
- if (!file_update_failure && (rb->updateVersion(reply, our_ver, ver) != OK_ROLLBACK)) {
+ if (!file_update_failure && (rb->updateVersion(reply, our_ver, ver, true, false) != OK_ROLLBACK)) {
file_update_failure = true;
}
@@ -2361,7 +2360,7 @@ checkBackDoor(int req_fd, char *message)
return false;
}
// TODO: I think this is correct, it used to do lmgmt->record_data-> ...
- if (RecSetRecordConvert(variable, value) == REC_ERR_OKAY) {
+ if (RecSetRecordConvert(variable, value, true, false) == REC_ERR_OKAY) {
ink_strlcpy(reply, "\nRecord Updated\n\n", sizeof(reply));
mgmt_writeline(req_fd, reply, strlen(reply));
} else {
View
1 proxy/EventName.cc
@@ -101,6 +101,7 @@ event_int_to_string(int event, int blen, char *buffer)
case MGMT_EVENT_RESTART: return "MGMT_EVENT_RESTART";
case MGMT_EVENT_BOUNCE: 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";
default:

0 comments on commit 6cb58be

Please sign in to comment.
Something went wrong with that request. Please try again.