diff options
-rw-r--r-- | lib/Plugins/CCpp.cpp | 3 | ||||
-rw-r--r-- | lib/Plugins/KerneloopsScanner.cpp | 3 | ||||
-rw-r--r-- | lib/Plugins/Python.cpp | 19 | ||||
-rw-r--r-- | lib/Plugins/RunApp.cpp | 1 | ||||
-rw-r--r-- | lib/Plugins/SOSreport.cpp | 3 | ||||
-rw-r--r-- | lib/Utils/DebugDump.cpp | 9 | ||||
-rw-r--r-- | lib/Utils/DebugDump.h | 2 | ||||
-rw-r--r-- | src/Daemon/MiddleWare.cpp | 20 | ||||
-rw-r--r-- | src/Hooks/CCpp.cpp | 1 |
9 files changed, 28 insertions, 33 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 995ddbeb..2f8d3559 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -190,7 +190,6 @@ static void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktra dd.Open(pDebugDumpDir); dd.LoadText(FILENAME_EXECUTABLE, executable); dd.LoadText(FILENAME_UID, UID); - dd.Close(); fTmp << "file " << executable << std::endl; fTmp << "core " << pDebugDumpDir << "/" << FILENAME_COREDUMP << std::endl; fTmp << "thread apply all backtrace full" << std::endl; @@ -479,7 +478,6 @@ void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir) dd.Open(pDebugDumpDir); if (dd.Exist(FILENAME_BACKTRACE)) { - dd.Close(); return; } dd.LoadText(FILENAME_PACKAGE, package); @@ -503,7 +501,6 @@ void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir) { dd.SaveText(FILENAME_MEMORYMAP, "memory map of the crashed C/C++ application, not implemented yet"); } - dd.Close(); } void CAnalyzerCCpp::Init() diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index 63460ba0..e1e32284 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -79,7 +79,6 @@ void CKerneloopsScanner::SaveOopsToDebugDump() update_client(_("Creating kernel oops crash reports...")); time_t t = time(NULL); - CDebugDump debugDump; std::list<COops> oopsList = m_pSysLog.GetOopsList(); m_pSysLog.ClearOopsList(); @@ -92,13 +91,13 @@ void CKerneloopsScanner::SaveOopsToDebugDump() try { + CDebugDump debugDump; debugDump.Create(path, 0); debugDump.SaveText(FILENAME_ANALYZER, "Kerneloops"); debugDump.SaveText(FILENAME_EXECUTABLE, "kernel"); debugDump.SaveText(FILENAME_KERNEL, oops.m_sVersion); debugDump.SaveText(FILENAME_PACKAGE, "not_applicable"); debugDump.SaveText(FILENAME_KERNELOOPS, oops.m_sData); - debugDump.Close(); } catch (CABRTException& e) { diff --git a/lib/Plugins/Python.cpp b/lib/Plugins/Python.cpp index c3677e7b..3e6926cd 100644 --- a/lib/Plugins/Python.cpp +++ b/lib/Plugins/Python.cpp @@ -9,21 +9,20 @@ std::string CAnalyzerPython::CreateHash(const std::string& pDebugDumpDir) { - std::string uuid; - CDebugDump dd; - dd.Open(pDebugDumpDir); - dd.LoadText("uuid", uuid); - dd.Close(); - return uuid; + std::string uuid; + CDebugDump dd; + dd.Open(pDebugDumpDir); + dd.LoadText("uuid", uuid); + return uuid; } std::string CAnalyzerPython::GetLocalUUID(const std::string& pDebugDumpDir) { - return CreateHash(pDebugDumpDir); + return CreateHash(pDebugDumpDir); } std::string CAnalyzerPython::GetGlobalUUID(const std::string& pDebugDumpDir) { - return GetLocalUUID(pDebugDumpDir); + return GetLocalUUID(pDebugDumpDir); } void CAnalyzerPython::Init() @@ -39,8 +38,8 @@ void CAnalyzerPython::Init() void CAnalyzerPython::DeInit() { - // TODO: remove copied abrt exception handler - std::ofstream fOutPySiteCustomize; + // TODO: remove copied abrt exception handler + std::ofstream fOutPySiteCustomize; fOutPySiteCustomize.open(PYHOOK_CONFIG); if (fOutPySiteCustomize.is_open()) { diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index fdbc3a75..5a5c1d44 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -84,7 +84,6 @@ void CActionRunApp::Run(const std::string& pActionDir, CDebugDump dd; dd.Open(pActionDir); dd.SaveText(args[FILENAME].c_str(), output); - dd.Close(); } } diff --git a/lib/Plugins/SOSreport.cpp b/lib/Plugins/SOSreport.cpp index c92b4fee..0e47ff84 100644 --- a/lib/Plugins/SOSreport.cpp +++ b/lib/Plugins/SOSreport.cpp @@ -159,10 +159,9 @@ void CActionSOSreport::Run(const std::string& pActionDir, CDebugDump dd; dd.Open(pActionDir); - //Not usefull + //Not useful //dd.SaveText("sosreportoutput", output); CopyFile(sosreport_filename,sosreport_dd_filename); - dd.Close(); } PLUGIN_INFO(ACTION, 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(); diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index 8c880b8c..e3b6869f 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -84,7 +84,6 @@ static void DebugDumpToCrashReport(const std::string& pDebugDumpDir, map_crash_r !dd.Exist(FILENAME_RELEASE) || !dd.Exist(FILENAME_EXECUTABLE)) { - dd.Close(); throw CABRTException(EXCEP_ERROR, "DebugDumpToCrashReport(): One or more of important file(s)'re missing."); } pCrashReport.clear(); @@ -126,7 +125,6 @@ static void DebugDumpToCrashReport(const std::string& pDebugDumpDir, map_crash_r } } } - dd.Close(); } /** @@ -189,9 +187,9 @@ mw_result_t CreateCrashReport(const std::string& pUUID, return MW_IN_DB_ERROR; } - CDebugDump dd; try { + CDebugDump dd; std::string analyzer; std::string gUUID; @@ -412,7 +410,6 @@ void DeleteDebugDumpDir(const std::string& pDebugDumpDir) CDebugDump dd; dd.Open(pDebugDumpDir); dd.Delete(); - dd.Close(); } std::string DeleteCrashInfo(const std::string& pUUID, @@ -514,21 +511,19 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta std::string description = GetDescription(packageName); std::string component = GetComponent(pExecutable); - CDebugDump dd; try { + CDebugDump dd; dd.Open(pDebugDumpDir); dd.SaveText(FILENAME_PACKAGE, package); dd.SaveText(FILENAME_DESCRIPTION, description); dd.SaveText(FILENAME_COMPONENT, component); - dd.Close(); } catch (CABRTException& e) { warn_client("SavePackageDescriptionToDebugDump(): " + e.what()); if (e.type() == EXCEP_DD_SAVE) { - dd.Close(); return MW_FILE_ERROR; } return MW_ERROR; @@ -621,24 +616,22 @@ mw_result_t SaveDebugDump(const std::string& pDebugDumpDir, std::string time; std::string analyzer; std::string executable; - CDebugDump dd; mw_result_t res; try { + CDebugDump dd; dd.Open(pDebugDumpDir); dd.LoadText(FILENAME_TIME, time); dd.LoadText(FILENAME_UID, UID); dd.LoadText(FILENAME_ANALYZER, analyzer); dd.LoadText(FILENAME_EXECUTABLE, executable); - dd.Close(); } catch (CABRTException& e) { warn_client("SaveDebugDump(): " + e.what()); if (e.type() == EXCEP_DD_SAVE) { - dd.Close(); return MW_FILE_ERROR; } return MW_ERROR; @@ -648,7 +641,8 @@ mw_result_t SaveDebugDump(const std::string& pDebugDumpDir, { return MW_IN_DB; } - if ((res = SavePackageDescriptionToDebugDump(executable, pDebugDumpDir)) != MW_OK) + res = SavePackageDescriptionToDebugDump(executable, pDebugDumpDir); + if (res != MW_OK) { return res; } @@ -669,25 +663,23 @@ mw_result_t GetCrashInfo(const std::string& pUUID, row = database->GetUUIDData(pUUID, pUID); database->DisConnect(); - CDebugDump dd; std::string package; std::string executable; std::string description; try { + CDebugDump dd; dd.Open(row.m_sDebugDumpDir); dd.LoadText(FILENAME_EXECUTABLE, executable); dd.LoadText(FILENAME_PACKAGE, package); dd.LoadText(FILENAME_DESCRIPTION, description); - dd.Close(); } catch (CABRTException& e) { warn_client("GetCrashInfo(): " + e.what()); if (e.type() == EXCEP_DD_LOAD) { - dd.Close(); return MW_FILE_ERROR; } return MW_ERROR; diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp index d30a4a3d..5bbdc8a2 100644 --- a/src/Hooks/CCpp.cpp +++ b/src/Hooks/CCpp.cpp @@ -207,7 +207,6 @@ int main(int argc, char** argv) /* close(fd); - why bother? */ /* free(executable); */ /* free(cmdline); */ - dd.Close(); log("saved core dump of pid %u to %s", (int)pid, path); } catch (CABRTException& e) |