Skip to content

Commit

Permalink
Pass ctime to the TimestampGranularityMonitor
Browse files Browse the repository at this point in the history
We're now using ctime to detect file changes, so the timestamp granularity monitor should as well.

Unfortunately, we currently get nanosecond ctime from Linux, but then only return millis from FileStatus, so this doesn't change the accuracy of the monitor at all.

PiperOrigin-RevId: 184536539
  • Loading branch information
ulfjack authored and Copybara-Service committed Feb 5, 2018
1 parent f0d3715 commit 5a48ecc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,10 @@ private static RegularFileStateValue fromPath(Path path, FileStatusWithDigest st
try {
byte[] digest = tryGetDigest(path, stat);
if (digest == null) {
long mtime = stat.getLastModifiedTime();
// Note that TimestampGranularityMonitor#notifyDependenceOnFileTime is a thread-safe
// method.
if (tsgm != null) {
tsgm.notifyDependenceOnFileTime(path.asFragment(), mtime);
tsgm.notifyDependenceOnFileTime(path.asFragment(), stat.getLastChangeTime());
}
return new RegularFileStateValue(stat.getSize(), null, FileContentsProxy.create(stat));
} else {
Expand Down Expand Up @@ -256,10 +255,9 @@ public SpecialFileStateValue(FileContentsProxy contentsProxy) {

static SpecialFileStateValue fromStat(PathFragment path, FileStatus stat,
@Nullable TimestampGranularityMonitor tsgm) throws IOException {
long mtime = stat.getLastModifiedTime();
// Note that TimestampGranularityMonitor#notifyDependenceOnFileTime is a thread-safe method.
if (tsgm != null) {
tsgm.notifyDependenceOnFileTime(path, mtime);
tsgm.notifyDependenceOnFileTime(path, stat.getLastChangeTime());
}
return new SpecialFileStateValue(FileContentsProxy.create(stat));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ public void setCommandStartTime() {
* of a build file or source file with the specified time stamp.
*/
@ThreadSafe
public void notifyDependenceOnFileTime(PathFragment path, long mtime) {
if (mtime == this.commandStartTimeMillis) {
public void notifyDependenceOnFileTime(PathFragment path, long ctimeMillis) {
if (ctimeMillis == this.commandStartTimeMillis) {
logger.info("Will have to wait for a millisecond on completion because of " + path);
this.waitAMillisecond = true;
}
if (mtime == this.commandStartTimeMillisRounded) {
if (ctimeMillis == this.commandStartTimeMillisRounded) {
logger.info("Will have to wait for a second on completion because of " + path);
this.waitASecond = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public long getLastModifiedTime() throws IOException {

@Override
public long getLastChangeTime() throws IOException {
return original.getLastChangeTime();
throw new IOException();
}
};
}
Expand Down

0 comments on commit 5a48ecc

Please sign in to comment.