From a3d27ebd2802fd6031cc928a67752541775bf52b Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Thu, 11 May 2017 13:50:59 +0100 Subject: ScopedFlock: Refactor it to be a subclass of FdFile. Makes callers cleaner, since they only have to worry about dealing with regular File objects that they know will be locked for the duration of their existence. Prevents issues and other clunky code relating to acquire Test: scoped_flock_test, test_art_host Bug: 36369345 Change-Id: I2c9644e448acde6ddac472d88108c7d9a4e1a892 --- patchoat/patchoat.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'patchoat/patchoat.cc') diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index ec3481b622..848eb8d329 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -304,8 +304,10 @@ bool PatchOat::WriteImage(File* out) { TimingLogger::ScopedTiming t("Writing image File", timings_); std::string error_msg; - ScopedFlock img_flock; - img_flock.Init(out, &error_msg); + // No error checking here, this is best effort. The locking may or may not + // succeed and we don't really care either way. + ScopedFlock img_flock = LockedFile::DupOf(out->Fd(), out->GetPath(), + true /* read_only_mode */, &error_msg); CHECK(image_ != nullptr); CHECK(out != nullptr); -- cgit v1.2.3-59-g8ed1b