From 6e02ea92ec8af1da74f55e616b7cda82740dccc0 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 17 Nov 2016 11:24:07 -0800 Subject: applypatch: Use unique_fd to avoid leaking FDs. Add unique_fd that calls ota_close() instead of the default closer. Test: recovery_component_test passes. Test: Apply a package that calls apply_patch(). Change-Id: I0c19921731757934f76cf7d5215916673a8f2777 --- otafault/ota_io.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'otafault') diff --git a/otafault/ota_io.h b/otafault/ota_io.h index 84187a76e..e119eef08 100644 --- a/otafault/ota_io.h +++ b/otafault/ota_io.h @@ -26,6 +26,8 @@ #include #include +#include + #define OTAIO_CACHE_FNAME "/cache/saved.file" void ota_set_fault_files(); @@ -50,4 +52,12 @@ ssize_t ota_write(int fd, const void* buf, size_t nbyte); int ota_fsync(int fd); +struct OtaCloser { + static void Close(int fd) { + ota_close(fd); + } +}; + +using unique_fd = android::base::unique_fd_impl; + #endif -- cgit v1.2.3