[xmltooling] 02/04: Revert "CPPXT-106 Apache Deadlock in load thread/lock thread"

Ferenc Wágner wferi at moszumanska.debian.org
Fri Nov 17 08:48:27 UTC 2017


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

wferi pushed a commit to branch maint-1.6
in repository xmltooling.

commit ba87372a0bef819b1ce6425375776906e941c3d4
Author: Scott Cantor <cantor.2 at osu.edu>
Date:   Thu Nov 16 16:13:13 2017 -0500

    Revert "CPPXT-106 Apache Deadlock in load thread/lock thread"
    
    This reverts commit f6150b10d4c18bf155fa41e6abe665e073b9f238.
---
 xmltooling/util/ReloadableXMLFile.cpp | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/xmltooling/util/ReloadableXMLFile.cpp b/xmltooling/util/ReloadableXMLFile.cpp
index 4880577..7505616 100644
--- a/xmltooling/util/ReloadableXMLFile.cpp
+++ b/xmltooling/util/ReloadableXMLFile.cpp
@@ -287,26 +287,7 @@ void* ReloadableXMLFile::reload_fn(void* pv)
             r->m_reload_wait->timedwait(mutex.get(), r->m_reloadInterval);
         if (r->m_shutdown)
             break;
-		
-#ifdef WIN32
-        struct _stat stat_buf;
-        if (_stat(r->m_source.c_str(), &stat_buf) != 0)
-            continue;
-#else
-        struct stat stat_buf;
-        if (stat(r->m_source.c_str(), &stat_buf) != 0)
-            continue
-#endif
-        if (r->m_filestamp >= stat_buf.st_mtime)
-            continue;
 
-        // Elevate lock and recheck.
-        r->m_log.debug("timestamp of local resource changed, obtaining write lock");
-        r->m_lock->wrlock();
-        r->m_filestamp = stat_buf.st_mtime;
-        r->m_log.debug("timestamp of local resource changed, releasing write lock");
-        r->m_lock->unlock();
-		
         try {
             r->m_log.info("reloading %s resource...", r->m_local ? "local" : "remote");
             pair<bool,DOMElement*> ret = r->background_load();
@@ -359,6 +340,20 @@ Lockable* ReloadableXMLFile::lock()
         if (m_filestamp >= stat_buf.st_mtime)
             return this;
 
+        // Elevate lock and recheck.
+        m_log.debug("timestamp of local resource changed, elevating to a write lock");
+        m_lock->unlock();
+        m_lock->wrlock();
+        if (m_filestamp >= stat_buf.st_mtime) {
+            // Somebody else handled it, just downgrade.
+            m_log.debug("update of local resource handled by another thread, downgrading lock");
+            m_lock->unlock();
+            m_lock->rdlock();
+            return this;
+        }
+
+        // Update the timestamp regardless.
+        m_filestamp = stat_buf.st_mtime;
         if (m_reload_wait) {
             m_log.info("change detected, signaling reload thread...");
             m_reload_wait->signal();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/xmltooling.git



More information about the Pkg-shibboleth-devel mailing list