Skip to content

Commit 85917bc

Browse files
AnohkkaCOM8
authored andcommitted
Remove an early return in ~MultiPerform
This curl_multi_remove_handle call is a bit more error-prone with the changes we've made, and skipping over sessions in the cleanup process leads to sessions that can't be used due to isUsedInMultiPerform being set to true, along with other potential, undesired consequences as a result of improper cleanup. We could remove the curl_multi_remove_handle call entirely, but that, too, will cause issues if any part of the code throws after we've added handles to the multi stack and before removing them. It's not something that's very likely to happen with the existing code, but that could easily change in the future and the call to that function doesn't seem to be doing any harm, aside from some wasted CPU cycles.
1 parent b3304d1 commit 85917bc

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

cpr/multiperform.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ MultiPerform::~MultiPerform() {
4949
const CURLMcode error_code = curl_multi_remove_handle(multicurl_->handle, session->curl_->handle);
5050
if (error_code) {
5151
std::cerr << "curl_multi_remove_handle() failed, code " << static_cast<int>(error_code) << '\n';
52-
return;
5352
}
5453
}
5554
}
@@ -74,7 +73,6 @@ void MultiPerform::AddSession(std::shared_ptr<Session>& session, HttpMethod meth
7473
}
7574

7675
void MultiPerform::RemoveSession(const std::shared_ptr<Session>& session) {
77-
// Has to be handled before calling curl_multi_remove_handle to avoid it returning something != CURLM_OK.
7876
if (sessions_.empty()) {
7977
throw std::invalid_argument("Failed to find session!");
8078
}

0 commit comments

Comments
 (0)