Use raw pointer instead of shared_ptr
Throughout update_engine, there are many places we pass a shared_ptr of
FileDescriptor, for memory safety. But in many cases, functions only
need to use the pointer througout execution of the function, and do not
need to store these pointers. In these cases, it's perfectly safe to use
a raw pointer. Furthermore, the overuse of shared_ptr make life time of
FileDescriptors unpredictable. This is harmful in context of VABC, where
presence of a file descriptor can cause UnmapAllPartitions() to fail.
Therefore, we switch some of the safe usecases to raw pointer.
Test: th
Bug: 216391325
Change-Id: I3d986688e81fcc1d761b7f4926a3c81ac691788a
diff --git a/payload_consumer/verity_writer_android.h b/payload_consumer/verity_writer_android.h
index 8339528..a6a4920 100644
--- a/payload_consumer/verity_writer_android.h
+++ b/payload_consumer/verity_writer_android.h
@@ -34,7 +34,7 @@
bool Init(const InstallPlan::Partition& partition);
bool Update(uint64_t offset, const uint8_t* buffer, size_t size) override;
- bool Finalize(FileDescriptorPtr read_fd, FileDescriptorPtr write_fd) override;
+ bool Finalize(FileDescriptor* read_fd, FileDescriptor* write_fd) override;
// Read [data_offset : data_offset + data_size) from |path| and encode FEC
// data, if |verify_mode|, then compare the encoded FEC with the one in
@@ -42,8 +42,8 @@
// in each Update() like hash tree, because for every rs block, its data are
// spreaded across entire |data_size|, unless we can cache all data in
// memory, we have to re-read them from disk.
- static bool EncodeFEC(FileDescriptorPtr read_fd,
- FileDescriptorPtr write_fd,
+ static bool EncodeFEC(FileDescriptor* read_fd,
+ FileDescriptor* write_fd,
uint64_t data_offset,
uint64_t data_size,
uint64_t fec_offset,