summaryrefslogtreecommitdiffstats
path: root/lib/Utils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-09 19:04:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-09 19:04:42 +0200
commit39d77b6cfa633b94a31de5ec387949a7c7b85623 (patch)
tree37dbbb2f84ff2e8d524cdf8ece16401e8955d6dd /lib/Utils
parent08ec5a72cd334fffc8aa343ab48f4b6d1c88e3a7 (diff)
downloadabrt-39d77b6cfa633b94a31de5ec387949a7c7b85623.tar.gz
abrt-39d77b6cfa633b94a31de5ec387949a7c7b85623.tar.xz
abrt-39d77b6cfa633b94a31de5ec387949a7c7b85623.zip
fix the bug where lock file was not removed
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Utils')
-rw-r--r--lib/Utils/DebugDump.cpp9
-rw-r--r--lib/Utils/DebugDump.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp
index 6eb58369..03fb7c64 100644
--- a/lib/Utils/DebugDump.cpp
+++ b/lib/Utils/DebugDump.cpp
@@ -48,6 +48,7 @@ static bool isdigit_str(const char *str)
if (*str < '0' || *str > '9') return false;
str++;
}
+ return true;
}
static std::string RemoveBackSlashes(const std::string& pDir);
@@ -105,6 +106,7 @@ static int GetAndSetLock(const char* pLockFile, const char* pPID)
if (errno != EEXIST)
perror_msg_and_die("Can't create lock file '%s'", pLockFile);
fd = open(pLockFile, O_RDONLY);
+log("opened O_RDONLY: '%s'", pLockFile);
if (fd < 0)
{
if (errno == ENOENT)
@@ -123,6 +125,7 @@ static int GetAndSetLock(const char* pLockFile, const char* pPID)
continue;
}
pid_buf[r] = '\0';
+log("read: '%s'", pid_buf);
if (strcmp(pid_buf, pPID) == 0)
{
log("Lock file '%s' is already locked by us", pLockFile);
@@ -140,6 +143,7 @@ static int GetAndSetLock(const char* pLockFile, const char* pPID)
/* The file may be deleted by now by other process. Ignore errors */
unlink(pLockFile);
}
+log("created O_EXCL: '%s'", pLockFile);
int len = strlen(pPID);
if (write(fd, pPID, len) != len)
@@ -304,6 +308,11 @@ void CDebugDump::Delete()
void CDebugDump::Close()
{
UnLock();
+ if (m_pGetNextFileDir != NULL)
+ {
+ closedir(m_pGetNextFileDir);
+ m_pGetNextFileDir = NULL;
+ }
m_bOpened = false;
}
diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h
index 473f8d45..4b1ec8ed 100644
--- a/lib/Utils/DebugDump.h
+++ b/lib/Utils/DebugDump.h
@@ -55,6 +55,8 @@ class CDebugDump
public:
CDebugDump();
+ ~CDebugDump() { Close(); }
+
void Open(const std::string& pDir);
void Create(const std::string& pDir, uid_t nUID);
void Delete();