[cpp-sp] branch main updated: Start adding _DEBUG lock instrumentation.
Codeberg
noreply at shibboleth.net
Thu Sep 3 15:10:01 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository cpp-sp.
View the commit online:
https://codeberg.org/Shibboleth/cpp-sp/commit/41437c603b02a85dc84c13eafbe19c245519f16d
The following commit(s) were added to refs/heads/main by this push:
new 41437c60 Start adding _DEBUG lock instrumentation.
41437c60 is described below
commit 41437c603b02a85dc84c13eafbe19c245519f16d
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Thu Sep 3 11:09:51 2026 -0400
Start adding _DEBUG lock instrumentation.
---
shibsp/session/impl/AbstractSessionCache.cpp | 53 +++++++++++++++++++++++++-
shibsp/session/impl/FilesystemSessionCache.cpp | 2 +
2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/shibsp/session/impl/AbstractSessionCache.cpp b/shibsp/session/impl/AbstractSessionCache.cpp
index dd18f266..ce3e7559 100644
--- a/shibsp/session/impl/AbstractSessionCache.cpp
+++ b/shibsp/session/impl/AbstractSessionCache.cpp
@@ -392,6 +392,10 @@ string AbstractSessionCache::create(SPRequest& request, DDF& data)
// Lock the cache and insert the new session.
+#ifdef _DEBUG
+ request.debug("create locking cache to add session (%s) (released at end of method)", key.c_str());
+#endif
+
// Note, the C23 standard includes a typeof operator, but until then...
#if defined(HAVE_CXX17)
lock_guard<shared_mutex> locker(m_lock);
@@ -690,12 +694,21 @@ void AbstractSessionCache::dormant(const SPRequest* request, const string& key)
log(DEBUG_MARK, "deleting local copy of session (%s)", key.c_str());
// lock the cache for writing, which means we know nobody is sitting in a lookup.
+#ifdef _DEBUG
+ log(DEBUG_MARK, "dormant locking cache to remove session (%s)", key.c_str());
+#endif
m_lock.lock();
+#ifdef _DEBUG
+ log(DEBUG_MARK, "dormant locked cache to remove session (%s)", key.c_str());
+#endif
// grab the entry from the table
const auto& i = m_hashtable.find(key);
if (i == m_hashtable.end()) {
m_lock.unlock();
+#ifdef _DEBUG
+ log(DEBUG_MARK, "dormant unlocked cache after search failed for session (%s)", key.c_str());
+#endif
return;
}
@@ -710,6 +723,10 @@ void AbstractSessionCache::dormant(const SPRequest* request, const string& key)
// unlock the cache
m_lock.unlock();
+#ifdef _DEBUG
+ log(DEBUG_MARK, "dormant unlocked cache after removing session (%s)", key.c_str());
+#endif
+
// we can release the cache entry lock because we know we're not in the cache anymore
session->unlock();
}
@@ -761,21 +778,35 @@ void* AbstractSessionCache::cleanup_fn(void* p)
pcache->m_log.debug("cleanup thread running");
+#ifdef _DEBUG
+ pcache->m_log.debug("cleanup thread locking cache");
+#endif
#ifdef HAVE_CXX14
pcache->m_lock.lock_shared();
+# ifdef _DEBUG
+ pcache->m_log.debug("cleanup thread holding cache read lock");
+# endif
#else
pcache->m_lock.lock();
+# ifdef _DEBUG
+ pcache->m_log.debug("cleanup thread holding cache exclusive lock");
+# endif
#endif
+
for (const auto& session : pcache->m_hashtable) {
// If the last access was BEFORE the stale timeout...
session.second->lock();
time_t last = session.second->getLastAccess();
session.second->unlock();
- if (last < stale)
+ if (last < stale) {
stale_keys.push_back(session.first);
+ }
}
pcache->m_lock.unlock();
+#ifdef _DEBUG
+ pcache->m_log.debug("cleanup thread released cache lock");
+#endif
if (!stale_keys.empty()) {
pcache->m_log.info("purging %u old sessions", stale_keys.size());
@@ -958,15 +989,33 @@ time_t BasicSession::getLastAccess() const
void BasicSession::lock()
{
+#ifdef _DEBUG
+ AbstractSessionCache::log(nullptr, m_cache.logger(), Priority::SHIB_DEBUG, "locking session (%s)", getID());
+#endif
m_lock.lock();
+#ifdef _DEBUG
+ AbstractSessionCache::log(nullptr, m_cache.logger(), Priority::SHIB_DEBUG, "locked session (%s)", getID());
+#endif
}
bool BasicSession::try_lock()
{
- return m_lock.try_lock();
+#ifdef _DEBUG
+ AbstractSessionCache::log(nullptr, m_cache.logger(), Priority::SHIB_DEBUG, "try_locking session (%s)", getID());
+#endif
+ bool ret = m_lock.try_lock();
+#ifdef _DEBUG
+ if (ret) {
+ AbstractSessionCache::log(nullptr, m_cache.logger(), Priority::SHIB_DEBUG, "locked session (%s)", getID());
+ }
+#endif
+ return ret;
}
void BasicSession::unlock()
{
m_lock.unlock();
+#ifdef _DEBUG
+ AbstractSessionCache::log(nullptr, m_cache.logger(), Priority::SHIB_DEBUG, "unlocked session (%s)", getID());
+#endif
}
diff --git a/shibsp/session/impl/FilesystemSessionCache.cpp b/shibsp/session/impl/FilesystemSessionCache.cpp
index 06356393..b7f41bfc 100644
--- a/shibsp/session/impl/FilesystemSessionCache.cpp
+++ b/shibsp/session/impl/FilesystemSessionCache.cpp
@@ -234,6 +234,8 @@ string FilesystemSessionCache::cache_create(SPRequest* request, DDF& sessionData
int e = errno;
if (e != EEXIST) {
log(ERROR_MARK, "error opening new session file (%s), errno=%d", path.c_str(), e);
+ } else {
+ log(DEBUG_MARK, "error opening new session file (%s), errno=%d", path.c_str(), e);
}
} while (++attempts < 3);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list