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 2013/03/09 01:48:37 UTC

[16/50] git commit: TS-1645: increase the file stat resolution on config files

TS-1645: increase the file stat resolution on config files


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

Branch: refs/heads/3.3.x
Commit: 5d7fb725d4bc0e3f66d476198a69b2ded0a5c15e
Parents: 476c1fa
Author: Yakov Kopel <yk...@websense.com>
Authored: Mon Feb 25 17:09:08 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Mon Feb 25 17:10:26 2013 -0800

----------------------------------------------------------------------
 CHANGES          |    4 ++++
 configure.ac     |    5 +++++
 mgmt/Rollback.cc |   12 ++++++------
 mgmt/Rollback.h  |    8 ++++++++
 4 files changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5d7fb725/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index f31f335..c4b4cc4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 3.3.1
 
+
+  *) [TS-1645] increase the file stat resolution on config files
+   Author: Yakov Kopel <yk...@websense.com>
+
   *) [TS-1557] update ua_begin_write
    Author: Aidan McGurn <ai...@openwave.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5d7fb725/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 69f2bed..09ca9e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1387,6 +1387,11 @@ if test "x${enable_hwloc}" = "xyes"; then
   )
 fi
 
+# Check for high-resolution timestamps in struct stat
+AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
+AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
+
+
 #
 # Configure sockopt value for TPROXY. Look at the enable flag.
 # Value 'no' means user forced disable, don't check anything else.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5d7fb725/mgmt/Rollback.cc
----------------------------------------------------------------------
diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 7af7b95..39c747c 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -170,9 +170,9 @@ root_access_needed(root_access_needed_)
       // 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 = fileInfo.st_mtime;
+        fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
       } else {
-        fileLastModified = time(NULL) - ink_timezone();
+        fileLastModified = (time(NULL) - ink_timezone()) * 1000000000;
       }
 
     } else {
@@ -183,7 +183,7 @@ root_access_needed(root_access_needed_)
     }
   } else {
 
-    fileLastModified = fileInfo.st_mtime;
+    fileLastModified = TS_ARCHIVE_STAT_MTIME(fileInfo);
     currentVersion = highestSeen + 1;
 
     // Make sure that we have a backup of the file
@@ -524,12 +524,12 @@ Rollback::internalUpdate(textBuffer * buf, version_t newVersion, bool notifyChan
 
   // Now we need to get the modification time off of the new active file
   if (statFile(ACTIVE_VERSION, &fileInfo) >= 0) {
-    fileLastModified = fileInfo.st_mtime;
+    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();
+    fileLastModified = (time(NULL) - ink_timezone()) * 1000000000;
   }
 
   // Check to see if we need to delete an excess backup versions
@@ -995,7 +995,7 @@ Rollback::checkForUserUpdate()
     return false;
   }
 
-  if (fileLastModified < fileInfo.st_mtime) {
+  if (fileLastModified < TS_ARCHIVE_STAT_MTIME(fileInfo)) {
 
     // We've been modified, Roll a new version
     currentVersion_local = this->getCurrentVersion();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5d7fb725/mgmt/Rollback.h
----------------------------------------------------------------------
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index 40adbde..04e03ed 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -42,6 +42,14 @@
 #define ACTIVE_VERSION 0
 #define INVALID_VERSION -1
 
+#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
+#define TS_ARCHIVE_STAT_MTIME(t)    ((t).st_mtime * 1000000000 + (t).st_mtimespec.tv_nsec)
+#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+#define TS_ARCHIVE_STAT_MTIME(t)    ((t).st_mtime * 1000000000 + (t).st_mtim.tv_nsec)
+#else
+#define TS_ARCHIVE_STAT_MTIME(t)    ((t).st_mtime * 1000000000)
+#endif
+
 typedef int version_t;
 
 enum RollBackCodes