Skip to content

Commit

Permalink
Reapply "Update PipeTsFileResourceManager.java"
Browse files Browse the repository at this point in the history
This reverts commit fd4f50f.
  • Loading branch information
SteveYurongSu committed Oct 25, 2024
1 parent fd4f50f commit f04a5ca
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ public File increaseFileReference(
throws IOException {
// If the file is already a hardlink or copied file,
// just increase reference count and return it
if (increaseReferenceIfExists(file)) {
return file;
segmentLock.lock(file);
try {
if (increaseReferenceIfExists(file)) {
return file;
}
} finally {
segmentLock.unlock(file);
}

// If the file is not a hardlink or copied file, check if there is a related hardlink or
Expand Down Expand Up @@ -171,18 +176,13 @@ public File increaseFileReference(
}

private boolean increaseReferenceIfExists(final File file) {
segmentLock.lock(file);
try {
final PipeTsFileResource resource =
hardlinkOrCopiedFileToPipeTsFileResourceMap.get(file.getPath());
if (resource != null) {
resource.increaseAndGetReference();
return true;
}
return false;
} finally {
segmentLock.unlock(file);
final PipeTsFileResource resource =
hardlinkOrCopiedFileToPipeTsFileResourceMap.get(file.getPath());
if (resource != null) {
resource.increaseAndGetReference();
return true;
}
return false;
}

public static File getHardlinkOrCopiedFileInPipeDir(final File file) throws IOException {
Expand Down

0 comments on commit f04a5ca

Please sign in to comment.