summaryrefslogtreecommitdiff
path: root/fastboot/fastboot_driver.cpp
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2018-09-04 14:32:54 -0700
committerDavid Anderson <dvander@google.com>2018-09-04 15:01:12 -0700
commit03de645aac4dac3b19900b3d30a29b2d10249ad6 (patch)
tree4a0e3816decf6cf0250684fc1ec6f8d588ce3cc4 /fastboot/fastboot_driver.cpp
parent33dcdb808b7d60107d527c22815d586b51836836 (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/fastboot_driver.cpp')
-rw-r--r--fastboot/fastboot_driver.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/fastboot/fastboot_driver.cpp b/fastboot/fastboot_driver.cpp
index ceee066c9..6bd61282b 100644
--- a/fastboot/fastboot_driver.cpp
+++ b/fastboot/fastboot_driver.cpp
@@ -58,7 +58,6 @@ FastBootDriver::FastBootDriver(Transport* transport, std::function<void(std::str
}
FastBootDriver::~FastBootDriver() {
- set_transport(nullptr);
}
RetCode FastBootDriver::Boot(std::string* response, std::vector<std::string>* info) {
@@ -537,12 +536,9 @@ int FastBootDriver::SparseWriteCallback(std::vector<char>& tpbuf, const char* da
return 0;
}
-void FastBootDriver::set_transport(Transport* transport) {
- if (transport_) {
- transport_->Close();
- delete transport_;
- }
- transport_ = transport;
+Transport* FastBootDriver::set_transport(Transport* transport) {
+ std::swap(transport_, transport);
+ return transport;
}
} // End namespace fastboot