[cpp-sp] branch main updated: Fix a deadlock, some other locking tweaks.

Scott Cantor cantor.2 at osu.edu
Wed Jun 18 17:27:51 UTC 2025


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=efaa5470dcff106603369798473024dbdd399882

The following commit(s) were added to refs/heads/main by this push:
     new efaa5470 Fix a deadlock, some other locking tweaks.
efaa5470 is described below

commit efaa5470dcff106603369798473024dbdd399882
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jun 18 13:27:44 2025 -0400

    Fix a deadlock, some other locking tweaks.
---
 shibsp/remoting/impl/AbstractHTTPRemotingService.cpp |  9 ++++++---
 shibsp/remoting/impl/CurlHTTPRemotingService.cpp     | 10 +++++-----
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
index 0aa3f7b4..5528e118 100644
--- a/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/AbstractHTTPRemotingService.cpp
@@ -91,12 +91,12 @@ AbstractHTTPRemotingService::AbstractHTTPRemotingService(ptree& pt)
     m_authCachingCookie = props.getString(AUTH_CACHING_COOKIE_PROP_NAME, AUTH_CACHING_COOKIE_PROP_DEFAULT);
     if (!m_authCachingCookie.empty()) {
 #if defined(HAVE_CXX17)
-            m_authcachelock.reset(new shared_mutex());
+        m_authcachelock.reset(new shared_mutex());
 #elif defined(HAVE_CXX14)
-            m_lock.reset(new shared_timed_mutex());
+        m_lock.reset(new shared_timed_mutex());
 #else
         Category::getInstance(SHIBSP_LOGCAT ".RemotingService").warn(
-            "disabling agent authentication caching due to older C++ compiler");
+            "disabling agent authentication caching due to age of C++ compiler used");
         m_authCachingCookie.clear();
 #endif
     }
@@ -119,6 +119,9 @@ DDF AbstractHTTPRemotingService::send(const DDF& in) const
 #endif
                 m_authCachingValue = latestValue;
             }
+            else {
+                m_authcachelock->unlock_shared();
+            }
         }
     }
 
diff --git a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
index 461beea3..37a7f54c 100644
--- a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
@@ -221,20 +221,20 @@ CURL* CurlHTTPRemotingService::checkout() const
 {
     m_log.debug("getting connection handle");
 
-    m_lock.lock();
+    unique_lock<mutex> locker(m_lock);
 
     // If a free connection exists, return it.
     if (!m_pool.empty()) {
         CURL* m_handle = m_pool.back();
         m_pool.pop_back();
         m_poolsize--;
-        m_lock.unlock();
+        locker.unlock();
         attachCachedAuthentication(m_handle);
         m_log.debug("returning existing connection handle from pool");
         return m_handle;
     }
 
-    m_lock.unlock();
+    locker.unlock();
     m_log.debug("nothing free in pool, returning new connection handle");
 
     // Create a new connection and set non-varying options.
@@ -292,7 +292,7 @@ CURL* CurlHTTPRemotingService::checkout() const
 
 void CurlHTTPRemotingService::checkin(CURL* handle) const
 {
-    m_lock.lock();
+    unique_lock<mutex> locker(m_lock);
     m_pool.push_back(handle);
 
     CURL* killit=nullptr;
@@ -302,7 +302,7 @@ void CurlHTTPRemotingService::checkin(CURL* handle) const
         m_pool.pop_front();
         m_poolsize--;
     }
-    m_lock.unlock();
+    locker.unlock();
 
     if (killit) {
         curl_easy_cleanup(killit);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list