Skip to content

Commit 9cef6c4

Browse files
committed
Fixed deadlock in S3fsCurl::DestroyCurlHandle.
1 parent 5e50345 commit 9cef6c4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/curl.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ bool S3fsCurl::CreateCurlHandle(bool only_pool, bool remake)
18471847
AutoLock lock(&S3fsCurl::curl_handles_lock);
18481848

18491849
if(hCurl && remake){
1850-
if(!DestroyCurlHandle(false)){
1850+
if(!DestroyCurlHandle(false, true, /*lock_already_held=*/ true)){
18511851
S3FS_PRN_ERR("could not destroy handle.");
18521852
return false;
18531853
}
@@ -1872,7 +1872,7 @@ bool S3fsCurl::CreateCurlHandle(bool only_pool, bool remake)
18721872
return true;
18731873
}
18741874

1875-
bool S3fsCurl::DestroyCurlHandle(bool restore_pool, bool clear_internal_data)
1875+
bool S3fsCurl::DestroyCurlHandle(bool restore_pool, bool clear_internal_data, bool lock_already_held)
18761876
{
18771877
// [NOTE]
18781878
// If type is REQTYPE_IAMCRED or REQTYPE_IAMROLE, do not clear type.
@@ -1888,7 +1888,7 @@ bool S3fsCurl::DestroyCurlHandle(bool restore_pool, bool clear_internal_data)
18881888
}
18891889

18901890
if(hCurl){
1891-
AutoLock lock(&S3fsCurl::curl_handles_lock);
1891+
AutoLock lock(&S3fsCurl::curl_handles_lock, lock_already_held ? AutoLock::ALREADY_LOCKED : AutoLock::NONE);
18921892

18931893
S3fsCurl::curl_times.erase(hCurl);
18941894
S3fsCurl::curl_progress.erase(hCurl);

src/curl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class S3fsCurl
337337

338338
// methods
339339
bool CreateCurlHandle(bool only_pool = false, bool remake = false);
340-
bool DestroyCurlHandle(bool restore_pool = true, bool clear_internal_data = true);
340+
bool DestroyCurlHandle(bool restore_pool = true, bool clear_internal_data = true, bool lock_already_held = false);
341341

342342
bool GetRAMCredentials(const char* cred_url, const char* iam_v2_token, const char* ibm_secret_access_key, std::string& response);
343343
bool GetRAMRoleFromMetaData(const char* cred_url, const char* iam_v2_token, std::string& token);

0 commit comments

Comments
 (0)