Updated Branches:
  refs/heads/master 26e1417a9 -> 6cb58be3e

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


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/6cb58be3
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/6cb58be3
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/6cb58be3

Branch: refs/heads/master
Commit: 6cb58be3e7a5defab6d3419229d8d5e4b548e933
Parents: 26e1417
Author: Yu Qing <[email protected]>
Authored: Tue Oct 29 14:11:02 2013 +0800
Committer: Zhao Yongming <[email protected]>
Committed: Thu Oct 31 18:51:41 2013 +0800

----------------------------------------------------------------------
 CHANGES                       |  3 ++
 cop/TrafficCop.cc             |  4 +--
 lib/records/I_RecCore.h       | 14 ++++-----
 lib/records/P_RecCore.cc      | 52 ++++++++++++++++++++-------------
 lib/records/P_RecCore.h       |  6 ++--
 lib/records/P_RecDefs.h       |  1 +
 lib/records/RecConfigParse.cc |  4 +--
 lib/records/RecCore.cc        |  2 +-
 lib/records/RecLocal.cc       | 25 ++++++++++++----
 mgmt/AddConfigFilesHere.cc    |  2 +-
 mgmt/BaseManager.h            |  1 +
 mgmt/FileManager.cc           |  6 ++--
 mgmt/FileManager.h            |  4 +--
 mgmt/LocalManager.cc          | 15 +++++++---
 mgmt/LocalManager.h           |  2 +-
 mgmt/Main.cc                  |  4 +--
 mgmt/Main.h                   |  2 +-
 mgmt/ProcessManager.cc        |  1 +
 mgmt/Rollback.cc              | 60 ++++++++++++++++++++------------------
 mgmt/Rollback.h               |  7 +++--
 mgmt/cluster/ClusterCom.cc    |  7 ++---
 proxy/EventName.cc            |  1 +
 22 files changed, 131 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index f6aed0e..3aa3b75 100644
--- a/CHANGES
+++ b/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
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/cop/TrafficCop.cc
----------------------------------------------------------------------
diff --git a/cop/TrafficCop.cc b/cop/TrafficCop.cc
index a681704..7a258b8 100644
--- a/cop/TrafficCop.cc
+++ b/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);
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/lib/records/I_RecCore.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecCore.h b/lib/records/I_RecCore.h
index 75fc359..dda8f44 100644
--- a/lib/records/I_RecCore.h
+++ b/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);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/lib/records/P_RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/P_RecCore.cc b/lib/records/P_RecCore.cc
index c33637e..a2127e6 100644
--- a/lib/records/P_RecCore.cc
+++ b/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 @@ Ldone:
 }
 
 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,25 +594,23 @@ 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);
 
@@ -617,7 +618,7 @@ RecReadConfigFile()
   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));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/lib/records/P_RecCore.h
----------------------------------------------------------------------
diff --git a/lib/records/P_RecCore.h b/lib/records/P_RecCore.h
index 6d3633d..2d92f81 100644
--- a/lib/records/P_RecCore.h
+++ b/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

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/lib/records/P_RecDefs.h
----------------------------------------------------------------------
diff --git a/lib/records/P_RecDefs.h b/lib/records/P_RecDefs.h
index 29c8d85..17cfbb2 100644
--- a/lib/records/P_RecDefs.h
+++ b/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

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/lib/records/RecConfigParse.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecConfigParse.cc b/lib/records/RecConfigParse.cc
index e4fff37..0ab0726 100644
--- a/lib/records/RecConfigParse.cc
+++ b/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));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/lib/records/RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 4571eef..0aee4bd 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -203,7 +203,7 @@ RecCoreInit(RecModeT mode_type, Diags *_diags)
       }
     }
     if (file_exists) {
-      RecReadConfigFile();
+      RecReadConfigFile(true);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/lib/records/RecLocal.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecLocal.cc b/lib/records/RecLocal.cc
index 12d90c9..9502bb9 100644
--- a/lib/records/RecLocal.cc
+++ b/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);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/AddConfigFilesHere.cc
----------------------------------------------------------------------
diff --git a/mgmt/AddConfigFilesHere.cc b/mgmt/AddConfigFilesHere.cc
index 6893c5f..cc6d169 100644
--- a/mgmt/AddConfigFilesHere.cc
+++ b/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);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/BaseManager.h
----------------------------------------------------------------------
diff --git a/mgmt/BaseManager.h b/mgmt/BaseManager.h
index e11c7ef..5063a93 100644
--- a/mgmt/BaseManager.h
+++ b/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
 
 /***********************************************************************
  *

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/FileManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index 38af46e..7ae2265 100644
--- a/mgmt/FileManager.cc
+++ b/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);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/FileManager.h
----------------------------------------------------------------------
diff --git a/mgmt/FileManager.h b/mgmt/FileManager.h
index b516cb7..0d618b0 100644
--- a/mgmt/FileManager.h
+++ b/mgmt/FileManager.h
@@ -41,7 +41,7 @@
 
 class Rollback;
 
-typedef void (*FileCallbackFunc) (char *);
+typedef void (*FileCallbackFunc) (char *, bool);
 
 struct callbackListable
 {
@@ -115,7 +115,7 @@ public:
   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);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/LocalManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index b7feeca..56f3f9e 100644
--- a/mgmt/LocalManager.cc
+++ b/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;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/LocalManager.h
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h
index 9ea4158..8c60978 100644
--- a/mgmt/LocalManager.h
+++ b/mgmt/LocalManager.h
@@ -75,7 +75,7 @@ public:
   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);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index 9eb6904..f752220 100644
--- a/mgmt/Main.cc
+++ b/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");

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/Main.h
----------------------------------------------------------------------
diff --git a/mgmt/Main.h b/mgmt/Main.h
index f4b393e..12b9059 100644
--- a/mgmt/Main.h
+++ b/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);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/ProcessManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc
index 4f55d59..b582cec 100644
--- a/mgmt/ProcessManager.cc
+++ b/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.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/Rollback.cc
----------------------------------------------------------------------
diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 0399523..76ed82e 100644
--- a/mgmt/Rollback.cc
+++ b/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,19 +379,19 @@ 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;
@@ -409,7 +399,7 @@ Rollback::updateVersion_ml(textBuffer * buf, version_t 
basedOn, version_t newVer
   if (basedOn != currentVersion) {
     returnCode = VERSION_NOT_CURRENT_ROLLBACK;
   } else {
-    returnCode = internalUpdate(buf, newVersion, notifyChange);
+    returnCode = internalUpdate(buf, newVersion, notifyChange, incVersion);
   }
 
   return returnCode;
@@ -440,7 +430,7 @@ 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;
@@ -448,7 +438,6 @@ Rollback::internalUpdate(textBuffer * buf, version_t 
newVersion, bool notifyChan
   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

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/Rollback.h
----------------------------------------------------------------------
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 566f32e..c033161 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -164,7 +164,7 @@ public:
   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 @@ public:
   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 @@ private:
   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;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/mgmt/cluster/ClusterCom.cc
----------------------------------------------------------------------
diff --git a/mgmt/cluster/ClusterCom.cc b/mgmt/cluster/ClusterCom.cc
index 2625655..e0ef793 100644
--- a/mgmt/cluster/ClusterCom.cc
+++ b/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 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6cb58be3/proxy/EventName.cc
----------------------------------------------------------------------
diff --git a/proxy/EventName.cc b/proxy/EventName.cc
index e10c9d3..97bf38f 100644
--- a/proxy/EventName.cc
+++ b/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:

Reply via email to