From f9e0db779f1a74563243d2df26b7aabc42fb71f0 Mon Sep 17 00:00:00 2001 From: Eric Cano <Eric.Cano@cern.ch> Date: Tue, 16 Aug 2016 11:03:01 +0200 Subject: [PATCH] Added a suppression for helgrind complaining on pthread destroy. Fixed spurious file closing on failure to open in BackendVFS. --- objectstore/BackendVFS.cpp | 13 +++++++++++++ tests/helgrind.suppr | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/objectstore/BackendVFS.cpp b/objectstore/BackendVFS.cpp index 6072c02302..95e056e484 100644 --- a/objectstore/BackendVFS.cpp +++ b/objectstore/BackendVFS.cpp @@ -207,6 +207,11 @@ BackendVFS::Parameters* BackendVFS::getParams() { void BackendVFS::ScopedLock::release() { if (!m_fdSet) return; +#ifdef DEBUG_PRINT_LOGS + if (m_fd==-1) { + std::cout << "Warning: fd=-1!" << std::endl; + } +#endif ::flock(m_fd, LOCK_UN); ::close(m_fd); m_fdSet = false; @@ -226,6 +231,8 @@ BackendVFS::ScopedLock * BackendVFS::lockHelper( exception::Exception ex; ex.getMessage() << "In BackendVFS::lockHelper(): Failed to open file " << path << ": " << errnoStr; + // fd=-1, so there will be no need to close the file (when *ret will be destroyed). + ret->m_fdSet=false; throw ex; } @@ -236,6 +243,12 @@ BackendVFS::ScopedLock * BackendVFS::lockHelper( ": " << errnoStr; throw ex; } + +#ifdef DEBUG_PRINT_LOGS + if (ret->m_fd==-1) { + std::cout << "Warning: fd=-1!" << std::endl; + } +#endif return ret.release(); } diff --git a/tests/helgrind.suppr b/tests/helgrind.suppr index de742601b4..0228b4deff 100644 --- a/tests/helgrind.suppr +++ b/tests/helgrind.suppr @@ -199,3 +199,12 @@ fun:main } +{ + pthread_destroy_castor + Helgrind:Race + fun:my_memcmp + fun:pthread_mutex_destroy + fun:_ZN6castor6server5MutexD1Ev + ... +} + -- GitLab