diff options
author | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-04-28 17:08:09 +0200 |
---|---|---|
committer | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-04-28 17:08:09 +0200 |
commit | 2e6a6e8aed825e456600d01c8a805b6f6fd24c3a (patch) | |
tree | c58cba2913350fed9674813b3fe0a27e6639fbd2 /lib/Utils/DebugDump.cpp | |
parent | b08d5c2cf630ecb89d2f22b985dcdfcf25494258 (diff) | |
download | abrt-2e6a6e8aed825e456600d01c8a805b6f6fd24c3a.tar.gz abrt-2e6a6e8aed825e456600d01c8a805b6f6fd24c3a.tar.xz abrt-2e6a6e8aed825e456600d01c8a805b6f6fd24c3a.zip |
new commlayerinner interface
Diffstat (limited to 'lib/Utils/DebugDump.cpp')
-rw-r--r-- | lib/Utils/DebugDump.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index 8dd3114..421deb6 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -100,12 +100,14 @@ bool CDebugDump::GetAndSetLock(const std::string& pLockFile, const std::string& getline(fIn, line); if (line == pPID) { + fIn.close(); m_bUnlock = false; return true; } ss << "/proc/" << line << "/"; if (!ExistFileDir(ss.str())) { + fIn.close(); remove(pLockFile.c_str()); Delete(); throw CABRTException(EXCEP_ERROR, "CDebugDump::GetAndSetLock(): dead lock found"); @@ -117,17 +119,21 @@ bool CDebugDump::GetAndSetLock(const std::string& pLockFile, const std::string& void CDebugDump::Lock() { - std::string lockPath = m_sDebugDumpDir + ".lock"; + int ii = 0; + std::string lockFile = m_sDebugDumpDir + ".lock"; pid_t nPID = getpid(); std::stringstream ss; ss << nPID; - std::cerr << "CDebugDump::Lock(): waiting..."; - while (!GetAndSetLock(lockPath, ss.str())) + while (!GetAndSetLock(lockFile, ss.str())) { - std::cerr << "."; usleep(5000); + // 40000 is about 20s, that should be enough. + if (ii > 40000) + { + throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::Lock(): timeout occurs when opening '"+m_sDebugDumpDir+"'"); + } + ii++; } - std::cerr << "done." << std::endl; } void CDebugDump::UnLock() |