[cpp-xmltooling] 02/03: Revert "CPPXT-106 Apache Deadlock in load thread/lock thread"
Scott Cantor
cantor.2 at osu.edu
Thu Nov 16 16:17:03 EST 2017
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch maint-1.6
in repository cpp-xmltooling.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-xmltooling.git;a=commit;h=ba87372a0bef819b1ce6425375776906e941c3d4
commit ba87372a0bef819b1ce6425375776906e941c3d4
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: 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();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list