diff options
author | David Anderson <dvander@google.com> | 2018-09-04 14:32:54 -0700 |
---|---|---|
committer | David Anderson <dvander@google.com> | 2018-09-04 15:01:12 -0700 |
commit | 03de645aac4dac3b19900b3d30a29b2d10249ad6 (patch) | |
tree | 4a0e3816decf6cf0250684fc1ec6f8d588ce3cc4 /fastboot/usb_linux.cpp | |
parent | 33dcdb808b7d60107d527c22815d586b51836836 (diff) |
fastbootd: Fix transport ownership.
This change moves Transport ownership back out of FastBootDriver.
Callers of set_transport must ensure that the previous transport is
destroyed. In addition, deleting a transport now ensures that it is
closed.
Bug: 78793464
Test: fastboot, fuzzy_fastboot works
Change-Id: I8f9ed2f7d5b09fd0820b2677d087a027378f26db
Diffstat (limited to 'fastboot/usb_linux.cpp')
-rw-r--r-- | fastboot/usb_linux.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fastboot/usb_linux.cpp b/fastboot/usb_linux.cpp index 9b779ddea..6363aa547 100644 --- a/fastboot/usb_linux.cpp +++ b/fastboot/usb_linux.cpp @@ -95,7 +95,7 @@ class LinuxUsbTransport : public UsbTransport { public: explicit LinuxUsbTransport(std::unique_ptr<usb_handle> handle, uint32_t ms_timeout = 0) : handle_(std::move(handle)), ms_timeout_(ms_timeout) {} - ~LinuxUsbTransport() override = default; + ~LinuxUsbTransport() override; ssize_t Read(void* data, size_t len) override; ssize_t Write(const void* data, size_t len) override; @@ -387,6 +387,10 @@ static std::unique_ptr<usb_handle> find_usb_device(const char* base, ifc_match_f return usb; } +LinuxUsbTransport::~LinuxUsbTransport() { + Close(); +} + ssize_t LinuxUsbTransport::Write(const void* _data, size_t len) { unsigned char *data = (unsigned char*) _data; |