Skip to content

Commit 4cdd52d

Browse files
Fix a crash in the NetworkCurl. (#701)
Crash happens when the curl handle is duplicated in different request handles, and then used concurrently with curl_slist_append/curl_slist_free_all. Keep the mutex lock longer. Add missing handle release. OLPEDGE-1687 Signed-off-by: Mykhailo Kuchma <[email protected]>
1 parent 397ebf1 commit 4cdd52d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ void NetworkCurl::CompleteMessage(CURL* handle, CURLcode result) {
908908
return;
909909
}
910910

911-
lock.unlock();
912911
std::string error("Success");
913912
int status;
914913
if ((result == CURLE_OK) || (result == CURLE_HTTP_RETURNED_ERROR)) {
@@ -955,7 +954,6 @@ void NetworkCurl::CompleteMessage(CURL* handle, CURLcode result) {
955954
<< handles_[index].id << ", url=" << url
956955
<< " err=(" << status << ") " << error);
957956
handles_[index].count = 0;
958-
lock.lock();
959957
events_.emplace_back(EventInfo::Type::SEND_EVENT, &handles_[index]);
960958
return;
961959
}
@@ -968,7 +966,7 @@ void NetworkCurl::CompleteMessage(CURL* handle, CURLcode result) {
968966
.WithRequestId(handles_[index].id)
969967
.WithStatus(status)
970968
.WithError(error);
971-
ReleaseHandle(&handles_[index]);
969+
ReleaseHandleUnlocked(&handles_[index]);
972970
callback(response);
973971
} else {
974972
OLP_SDK_LOG_WARNING(kLogTag, "Complete message to unknown request");
@@ -1078,6 +1076,7 @@ void NetworkCurl::Run() {
10781076
lock.lock();
10791077
}
10801078
curl_multi_remove_handle(curl_, handles_[handle_index].handle);
1079+
ReleaseHandleUnlocked(&handles_[handle_index]);
10811080
} else {
10821081
OLP_SDK_LOG_ERROR(
10831082
kLogTag,

0 commit comments

Comments
 (0)