Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions app/rest/transport_curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,19 +394,12 @@ BackgroundTransportCurl::~BackgroundTransportCurl() {
request_header_ = nullptr;
}

// If this is an asynchronous operation, MarkFailed() or MarkCompleted()
// could end up attempting to tear down TransportCurl so we signal
// completion here.
if (transport_curl_->is_async()) {
transport_curl_->SignalTransferComplete();
CompleteOperation();
} else {
// Synchronous operations need all data present in the response before
// Perform() returns so signal complete after MarkFailed() or
// MarkCompleted().
CompleteOperation();
transport_curl_->SignalTransferComplete();
}
// Complete the operation before signaling, so that request_/response_ are
// still valid when MarkCompleted()/MarkFailed() is called. Signaling first
// would allow the waiting thread to destroy the Request/Response objects
// before CompleteOperation() can use them, causing a pure virtual call crash.
CompleteOperation();
transport_curl_->SignalTransferComplete();
}

void BackgroundTransportCurl::CompleteOperation() {
Expand Down
Loading