From 2e6a6e8aed825e456600d01c8a805b6f6fd24c3a Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Tue, 28 Apr 2009 17:08:09 +0200 Subject: new commlayerinner interface --- lib/CommLayer/CommLayerInner.h | 132 ++++++++++++++++++++++++------------- lib/CommLayer/Makefile.am | 6 +- lib/CommLayer/Observer.h | 1 + lib/MiddleWare/Makefile.am | 4 +- lib/MiddleWare/PluginManager.cpp | 36 +++++----- lib/Plugins/Bugzilla.cpp | 9 ++- lib/Plugins/CCpp.cpp | 12 ++-- lib/Plugins/Kerneloops.cpp | 9 +++ lib/Plugins/KerneloopsReporter.cpp | 4 +- lib/Plugins/Logger.cpp | 3 + lib/Plugins/Mailx.cpp | 5 ++ lib/Plugins/Makefile.am | 14 ++-- lib/Plugins/RunApp.cpp | 3 + lib/Utils/DebugDump.cpp | 16 +++-- lib/Utils/Makefile.am | 1 + src/Daemon/CrashWatcher.cpp | 10 +-- src/Daemon/CrashWatcher.h | 4 +- src/Daemon/Makefile.am | 4 +- src/Hooks/CCpp.cpp | 13 ++-- src/Hooks/Makefile.am | 2 +- 20 files changed, 182 insertions(+), 106 deletions(-) diff --git a/lib/CommLayer/CommLayerInner.h b/lib/CommLayer/CommLayerInner.h index 7edd2578..70e1c309 100644 --- a/lib/CommLayer/CommLayerInner.h +++ b/lib/CommLayer/CommLayerInner.h @@ -4,62 +4,102 @@ #include #include "Observer.h" -namespace CommLayerInner +class CDebugCommLayer { - - class CDebug - { - private: - CObserver *m_pObs; - public: - CDebug(CObserver *pObs) : - m_pObs(pObs) - {} - void Message(const std::string& pMsg) + private: + CObserver *m_pObserver; + public: + CDebugCommLayer(CObserver *pObs) : + m_pObserver(pObs) + {} + void Message(const std::string& pMsg) + { + if(m_pObserver) { - if(m_pObs) - m_pObs->Debug(pMsg); + m_pObserver->Debug(pMsg); } - }; + } +}; - class CWarning - { - private: - CObserver *m_pObs; - public: - CWarning(CObserver *pObs) : - m_pObs(pObs) - {} - void Message(const std::string& pMsg) +class CWarningCommLayer +{ + private: + CObserver *m_pObserver; + public: + CWarningCommLayer(CObserver *pObs) : + m_pObserver(pObs) + {} + void Message(const std::string& pMsg) + { + if(m_pObserver) { - if(m_pObs) - m_pObs->Warning(pMsg); + m_pObserver->Warning(pMsg); } - }; + } +}; - class CStatus - { - private: - CObserver *m_pObs; - public: - CStatus(CObserver *pObs) : - m_pObs(pObs) - {} - void Message(const std::string& pMsg) +class CStatusCommLayer +{ + private: + CObserver *m_pObserver; + public: + CStatusCommLayer(CObserver *pObs) : + m_pObserver(pObs) + {} + void Message(const std::string& pMsg) + { + if(m_pObserver) { - if(m_pObs) - m_pObs->Status(pMsg); + m_pObserver->Status(pMsg); } - }; - - - void init_debug(CObserver* pObserver); - void init_warning(CObserver* pObserver); - void init_status(CObserver* pObserver); + } +}; - void debug(const std::string& pMessage); - void warning(const std::string& pMessage); - void status(const std::string& pMessage); +class CCommLayerInner +{ + private: + CDebugCommLayer* m_pDebugCommLayer; + CWarningCommLayer* m_pWarningCommLayer; + CStatusCommLayer* m_pStatusCommLayer; + public: + CDebugCommLayer* GetDebugCommLayer() + { + return m_pDebugCommLayer; + } + CWarningCommLayer* GetWarningCommLayer() + { + return m_pWarningCommLayer; + } + CStatusCommLayer* GetStatusCommLayer() + { + return m_pStatusCommLayer; + } + CCommLayerInner(CObserver *pObs, const bool& pDebug, const bool pWarning) + { + m_pDebugCommLayer = NULL; + m_pWarningCommLayer = NULL; + if (pDebug) + { + m_pDebugCommLayer = new CDebugCommLayer(pObs); + } + if (pWarning) + { + m_pWarningCommLayer = new CWarningCommLayer(pObs); + } + m_pStatusCommLayer = new CStatusCommLayer(pObs); + } + ~CCommLayerInner() + { + if (m_pDebugCommLayer) + { + delete m_pDebugCommLayer; + } + if (m_pWarningCommLayer) + { + delete m_pWarningCommLayer; + } + delete m_pStatusCommLayer; + } }; #endif /* COMMLAYERINNER_H_ */ diff --git a/lib/CommLayer/Makefile.am b/lib/CommLayer/Makefile.am index d17cdc8b..c9cd7484 100644 --- a/lib/CommLayer/Makefile.am +++ b/lib/CommLayer/Makefile.am @@ -3,12 +3,12 @@ libABRTCommLayer_la_SOURCES = CommLayerServer.h CommLayerServer.cpp \ CommLayerServerSocket.h CommLayerServerSocket.cpp \ CommLayerServerDBus.h CommLayerServerDBus.cpp \ DBusServerProxy.h Observer.h DBusCommon.h \ - CommLayerInner.h CommLayerInner.cpp + CommLayerInner.h libABRTCommLayer_la_LIBADD = ../../lib/MiddleWare/libABRTMiddleWare.la $(DL_LIBS) $(DBUSCPP_LIBS) libABRTCommLayer_la_LDFLAGS = -version-info 0:1:0 -libABRTCommLayer_la_CPPFLAGS = -Wall -Werror -I../../lib/MiddleWare\ - -I../../lib/DBus \ +libABRTCommLayer_la_CPPFLAGS = -Wall -Werror -I$(srcdir)/../../lib/MiddleWare\ + -I$(srcdir)/../../lib/DBus -I$(srcdir)/../../inc\ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(GLIB_CFLAGS) $(DBUSCPP_CFLAGS) \ -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ diff --git a/lib/CommLayer/Observer.h b/lib/CommLayer/Observer.h index a26b7b74..d691bcae 100644 --- a/lib/CommLayer/Observer.h +++ b/lib/CommLayer/Observer.h @@ -2,6 +2,7 @@ #define OBSERVER_H_ #include "CrashTypes.h" +#include class CObserver { public: diff --git a/lib/MiddleWare/Makefile.am b/lib/MiddleWare/Makefile.am index c6aa8cf5..d29b9137 100644 --- a/lib/MiddleWare/Makefile.am +++ b/lib/MiddleWare/Makefile.am @@ -3,12 +3,12 @@ libABRTMiddleWare_la_SOURCES = MiddleWare.cpp MiddleWare.h PluginManager.cpp \ PluginManager.h ABRTPlugin.cpp \ ABRTPlugin.h DynamicLibrary.cpp \ DynamicLibrary.h \ - RPM.cpp RPM.h Plugin.h CrashTypes.h \ + RPM.cpp RPM.h Plugin.h \ MiddleWareTypes.h Action.h Database.h \ Reporter.h Analyzer.h libABRTMiddleWare_la_LIBADD = $(DL_LIBS) ../Utils/libABRTUtils.la $(RPM_LIBS) libABRTMiddleWare_la_LDFLAGS = -version-info 0:1:0 -libABRTMiddleWare_la_CPPFLAGS = -I$(srcdir)/../Utils -I$(srcdir)/../CommLayer $(RPM_CFLAGS) +libABRTMiddleWare_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils $(RPM_CFLAGS) check_PROGRAMS = test test_SOURCES = test.cpp diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp index f3d89e52..8b01f478 100644 --- a/lib/MiddleWare/PluginManager.cpp +++ b/lib/MiddleWare/PluginManager.cpp @@ -22,7 +22,7 @@ #include #include "PluginManager.h" #include "ABRTException.h" -#include "CommLayer.h" +#include "ABRTCommLayer.h" #include #include #include @@ -84,7 +84,7 @@ void CPluginManager::LoadPlugin(const std::string& pName) { throw CABRTException(EXCEP_PLUGIN, "CPluginManager::LoadPlugin(): non-compatible plugin"); } - CommLayerInner::debug("Plugin " + pName + " (" + abrtPlugin->GetVersion() + ") succesfully loaded."); + ABRTCommLayer::debug("Plugin " + pName + " (" + abrtPlugin->GetVersion() + ") succesfully loaded."); m_mapABRTPlugins[pName] = abrtPlugin; } catch (CABRTException& e) @@ -93,8 +93,8 @@ void CPluginManager::LoadPlugin(const std::string& pName) { delete abrtPlugin; } - CommLayerInner::debug("CPluginManager::LoadPlugin(): " + e.what()); - CommLayerInner::debug("Failed to load plugin " + pName); + ABRTCommLayer::warning("CPluginManager::LoadPlugin(): " + e.what()); + ABRTCommLayer::warning("Failed to load plugin " + pName); } } } @@ -106,7 +106,7 @@ void CPluginManager::UnLoadPlugin(const std::string& pName) UnRegisterPlugin(pName); delete m_mapABRTPlugins[pName]; m_mapABRTPlugins.erase(pName); - CommLayerInner::debug("Plugin " + pName + " sucessfully unloaded."); + ABRTCommLayer::debug("Plugin " + pName + " sucessfully unloaded."); } } @@ -126,14 +126,14 @@ void CPluginManager::RegisterPlugin(const std::string& pName) } catch (std::string sError) { - CommLayerInner::debug("Can not initialize plugin " + pName + "(" - + std::string(plugin_type_str_t[m_mapABRTPlugins[pName]->GetType()]) - + ")"); + ABRTCommLayer::warning("Can not initialize plugin " + pName + "(" + + std::string(plugin_type_str_t[m_mapABRTPlugins[pName]->GetType()]) + + ")"); UnLoadPlugin(pName); return; } m_mapPlugins[pName] = plugin; - CommLayerInner::debug("Registred plugin " + pName + "(" + ABRTCommLayer::debug("Registred plugin " + pName + "(" + std::string(plugin_type_str_t[m_mapABRTPlugins[pName]->GetType()]) + ")"); } @@ -149,7 +149,7 @@ void CPluginManager::UnRegisterPlugin(const std::string& pName) m_mapPlugins[pName]->DeInit(); delete m_mapPlugins[pName]; m_mapPlugins.erase(pName); - CommLayerInner::debug("UnRegistred plugin " + pName + "(" + ABRTCommLayer::debug("UnRegistred plugin " + pName + "(" + std::string(plugin_type_str_t[m_mapABRTPlugins[pName]->GetType()]) + ")"); } @@ -160,8 +160,8 @@ CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName) { if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { - throw std::string("CPluginManager::GetAnalyzer():" - "Analyzer plugin: '"+pName+"' is not loaded."); + throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAnalyzer():" + "Analyzer plugin: '"+pName+"' is not loaded."); } return dynamic_cast(m_mapPlugins[pName]); } @@ -170,8 +170,8 @@ CReporter* CPluginManager::GetReporter(const std::string& pName) { if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { - throw std::string("CPluginManager::GetReporter():" - "Reporter plugin: '"+pName+"' is not loaded."); + throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetReporter():" + "Reporter plugin: '"+pName+"' is not loaded."); } return dynamic_cast(m_mapPlugins[pName]); } @@ -180,8 +180,8 @@ CAction* CPluginManager::GetAction(const std::string& pName) { if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { - throw std::string("CPluginManager::GetAction():" - "Action plugin: '"+pName+"' is not loaded."); + throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAction():" + "Action plugin: '"+pName+"' is not loaded."); } return dynamic_cast(m_mapPlugins[pName]); } @@ -190,8 +190,8 @@ CDatabase* CPluginManager::GetDatabase(const std::string& pName) { if (m_mapPlugins.find(pName) == m_mapPlugins.end()) { - throw std::string("CPluginManager::GetDatabase():" - "Database plugin: '"+pName+"' is not loaded."); + throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetDatabase():" + "Database plugin: '"+pName+"' is not loaded."); } return dynamic_cast(m_mapPlugins[pName]); } diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index ed9e02c2..7a56966a 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -4,6 +4,7 @@ #include "PluginSettings.h" #include "DebugDump.h" #include "ABRTException.h" +#include "ABRTCommLayer.h" #include CReporterBugzilla::CReporterBugzilla() : @@ -34,7 +35,7 @@ void CReporterBugzilla::Login() { rpc->call(m_pXmlrpcClient, m_pCarriageParm); ret = xmlrpc_c::value_struct(rpc->getResult()); - std::cerr << "Login id: " << xmlrpc_c::value_int(ret["id"]) << std::endl; + ABRTCommLayer::debug("Login id: " + xmlrpc_c::value_int(ret["id"])); } catch (std::exception& e) { @@ -155,7 +156,7 @@ void CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport) { rpc->call(m_pXmlrpcClient, m_pCarriageParm); ret = xmlrpc_c::value_struct(rpc->getResult()); - std::cerr << "New bug id: " << xmlrpc_c::value_int(ret["id"]) << std::endl; + ABRTCommLayer::debug("New bug id: " + xmlrpc_c::value_int(ret["id"])); } catch (std::exception& e) { @@ -169,11 +170,15 @@ void CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, const std std::string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT]; std::string component = package.substr(0, package.rfind("-", package.rfind("-")-1)); std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; + ABRTCommLayer::status("Logging into bugzilla..."); Login(); + ABRTCommLayer::status("Checking for duplicates..."); if (!CheckUUIDInBugzilla(component, uuid)) { + ABRTCommLayer::status("Creating new bug..."); NewBug(pCrashReport); } + ABRTCommLayer::status("Logging out..."); Logout(); } diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 7aacc2fc..da52d0b2 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -23,7 +23,7 @@ #include "ABRTException.h" #include "DebugDump.h" #include "PluginSettings.h" -#include "CommLayer.h" +#include "ABRTCommLayer.h" #include #include #include @@ -89,7 +89,7 @@ std::string CAnalyzerCCpp::CreateHash(const std::string& pInput) void CAnalyzerCCpp::InstallDebugInfos(const std::string& pPackage) { - CommLayerInner::status("Installing debug infos..."); + ABRTCommLayer::status("Installing debug infos..."); std::string packageName = pPackage.substr(0, pPackage.rfind("-", pPackage.rfind("-")-1)); char buff[1024]; @@ -195,7 +195,7 @@ void CAnalyzerCCpp::InstallDebugInfos(const std::string& pPackage) void CAnalyzerCCpp::GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktrace) { - CommLayerInner::status("Getting backtrace..."); + ABRTCommLayer::status("Getting backtrace..."); std::string tmpFile = "/tmp/" + pDebugDumpDir.substr(pDebugDumpDir.rfind("/")); std::ofstream fTmp; @@ -422,7 +422,7 @@ void CAnalyzerCCpp::ExecVP(const char* pCommand, char* const pArgs[], const std: std::string CAnalyzerCCpp::GetLocalUUID(const std::string& pDebugDumpDir) { - CommLayerInner::status("Getting global universal unique identification..."); + ABRTCommLayer::status("Getting local universal unique identification..."); CDebugDump dd; std::string UID; @@ -446,7 +446,7 @@ std::string CAnalyzerCCpp::GetLocalUUID(const std::string& pDebugDumpDir) } std::string CAnalyzerCCpp::GetGlobalUUID(const std::string& pDebugDumpDir) { - CommLayerInner::status("Getting local universal unique identification..."); + ABRTCommLayer::status("Getting global universal unique identification..."); std::string backtrace; std::string executable; @@ -464,7 +464,7 @@ std::string CAnalyzerCCpp::GetGlobalUUID(const std::string& pDebugDumpDir) void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir) { - CommLayerInner::status("Starting report creation..."); + ABRTCommLayer::status("Starting report creation..."); std::string package; std::string backtrace; diff --git a/lib/Plugins/Kerneloops.cpp b/lib/Plugins/Kerneloops.cpp index 179ba410..3b8fce6a 100644 --- a/lib/Plugins/Kerneloops.cpp +++ b/lib/Plugins/Kerneloops.cpp @@ -29,6 +29,7 @@ #include "DebugDump.h" #include "PluginSettings.h" #include "ABRTException.h" +#include "ABRTCommLayer.h" #include #include @@ -58,6 +59,8 @@ void CAnalyzerKerneloops::WriteSysLog(int m_nCount) std::string CAnalyzerKerneloops::GetLocalUUID(const std::string& pDebugDumpDir) { + ABRTCommLayer::status("Getting local/global universal unique identification..."); + std::string m_sOops; std::stringstream m_sHash; CDebugDump m_pDebugDump; @@ -85,6 +88,8 @@ std::string CAnalyzerKerneloops::GetGlobalUUID(const std::string& pDebugDumpDir) void CAnalyzerKerneloops::Report() { + ABRTCommLayer::status("Creating crash reports..."); + CDebugDump m_pDebugDump; char m_sPath[PATH_MAX]; std::list m_pOopsList; @@ -157,6 +162,8 @@ void CAnalyzerKerneloops::Init() void CAnalyzerKerneloops::ScanDmesg() { + ABRTCommLayer::debug("Scanning dmesg..."); + int m_nFoundOopses; char *buffer; @@ -172,6 +179,8 @@ void CAnalyzerKerneloops::ScanDmesg() void CAnalyzerKerneloops::ScanSysLogFile(const char *filename, int issyslog) { + ABRTCommLayer::debug("Scanning syslog..."); + char *buffer; struct stat statb; FILE *file; diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp index 15af3ac0..cbefe0ed 100644 --- a/lib/Plugins/KerneloopsReporter.cpp +++ b/lib/Plugins/KerneloopsReporter.cpp @@ -25,8 +25,8 @@ */ #include "KerneloopsReporter.h" -#include "DebugDump.h" #include "PluginSettings.h" +#include "ABRTCommLayer.h" #include #include @@ -59,6 +59,8 @@ size_t writefunction(void *ptr, size_t size, size_t nmemb, void __attribute((unu void CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { + ABRTCommLayer::status("Creating and submitting a report..."); + CURL *handle; struct curl_httppost *post = NULL; struct curl_httppost *last = NULL; diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index 43c219f0..9d972e3f 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -24,6 +24,7 @@ #include "PluginSettings.h" #include #include "DebugDump.h" +#include "ABRTCommLayer.h" CLogger::CLogger() : m_sLogPath("/var/log/abrt-logger"), @@ -47,6 +48,8 @@ void CLogger::LoadSettings(const std::string& pPath) void CLogger::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { + ABRTCommLayer::status("Creating a report..."); + std::stringstream binaryFiles, commonFiles, bigTextFiles, additionalFiles, UUIDFile; std::ofstream fOut; diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index 6a5cb59d..069e0133 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -25,6 +25,7 @@ #include "DebugDump.h" #include "ABRTException.h" #include "PluginSettings.h" +#include "ABRTCommLayer.h" #define MAILX_COMMAND "/bin/mailx" @@ -40,6 +41,8 @@ CMailx::CMailx() : void CMailx::SendEmail(const std::string& pSubject, const std::string& pText) { + ABRTCommLayer::status("Sending an email..."); + FILE* command; std::string mailx_command = MAILX_COMMAND + m_sAttachments + " " + m_sParameters + @@ -61,6 +64,8 @@ void CMailx::SendEmail(const std::string& pSubject, const std::string& pText) void CMailx::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { + ABRTCommLayer::status("Creating a report..."); + std::stringstream emailBody; std::stringstream binaryFiles, commonFiles, bigTextFiles, additionalFiles, UUIDFile; diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am index 3b91de2e..3e4aec62 100644 --- a/lib/Plugins/Makefile.am +++ b/lib/Plugins/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils +AM_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils pluginslibdir=$(PLUGINS_LIB_DIR) pluginslib_LTLIBRARIES = libCCpp.la \ libMailx.la \ @@ -17,18 +17,18 @@ dist_pluginsconf_DATA = CCpp.conf Mailx.conf SQLite3.conf Logger.conf Kerneloops libCCpp_la_SOURCES = CCpp.cpp CCpp.h PluginSettings.h libCCpp_la_LDFLAGS = -avoid-version libCCpp_la_LIBADD = $(NSS_LIBS) -libCCpp_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -I$(srcdir)/../CommLayer -DCCPP_HOOK_PATH=\"${libexecdir}/hookCCpp\" -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(NSS_CFLAGS) +libCCpp_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -DCCPP_HOOK_PATH=\"${libexecdir}/hookCCpp\" -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(NSS_CFLAGS) # Kerneloops libKerneloops_la_SOURCES = Kerneloops.cpp Kerneloops.h KerneloopsSysLog.cpp KerneloopsSysLog.h PluginSettings.h libKerneloops_la_LDFLAGS = -avoid-version -libKerneloops_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" -DCCPP_HOOK_PATH=\"${libexecdir}/hookKerneloopsoops\" +libKerneloops_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" -DCCPP_HOOK_PATH=\"${libexecdir}/hookKerneloopsoops\" # KerneloopsReporter libKerneloopsReporter_la_SOURCES = KerneloopsReporter.cpp KerneloopsReporter.h PluginSettings.h libKerneloopsReporter_la_LDFLAGS = -avoid-version libKerneloopsReporter_la_LIBADD = $(CURL_LIBS) -libKerneloopsReporter_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils $(CURL_CFLAGS) +libKerneloopsReporter_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare $(CURL_CFLAGS) # Mailx libMailx_la_SOURCES = Mailx.cpp Mailx.h PluginSettings.h @@ -38,7 +38,7 @@ libMailx_la_LDFLAGS = -avoid-version libSQLite3_la_SOURCES = SQLite3.cpp SQLite3.h PluginSettings.h libSQLite3_la_LDFLAGS = -avoid-version libSQLite3_la_LIBADD = $(SQLITE3_LIBS) -libSQLite3_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils $(SQLITE3_CFLAGS) +libSQLite3_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils $(SQLITE3_CFLAGS) # Logger libLogger_la_SOURCES = Logger.cpp Logger.h PluginSettings.h @@ -52,11 +52,11 @@ libRunApp_la_LDFLAGS = -avoid-version libBugzilla_la_SOURCES = Bugzilla.h Bugzilla.cpp libBugzilla_la_LIBADD = $(XMLRPC_CPP_LIBS) $(XMLRPC_CLIENT_CPP_LIBS) libBugzilla_la_LDFLAGS = -avoid-version -libBugzilla_la_CPPFLAGS = $(XMLRPC_CPP_CFLAGS) $(XMLRPC_CLIENT_CPP_CFLAGS) -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils +libBugzilla_la_CPPFLAGS = $(XMLRPC_CPP_CFLAGS) $(XMLRPC_CLIENT_CPP_CFLAGS) -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils # Python libPython_la_SOURCES = Python.h Python.cpp #libPython_la_LIBADD = $(NSS_LIBS) libPython_la_LDFLAGS = -avoid-version -libPython_la_CPPFLAGS = $(NSS_CFLAGS) -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils +libPython_la_CPPFLAGS = $(NSS_CFLAGS) -I$(srcdir)/../../inc -I$(srcdir)/../MiddleWare -I$(srcdir)/../Utils diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index 8a8db08a..5a20283c 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -24,6 +24,7 @@ #include #include "DebugDump.h" #include "ABRTException.h" +#include "ABRTCommLayer.h" #define COMMAND 0 #define FILENAME 1 @@ -58,6 +59,8 @@ void CActionRunApp::ParseArgs(const std::string& psArgs, vector_args_t& pArgs) void CActionRunApp::Run(const std::string& pDebugDumpDir, const std::string& pArgs) { + ABRTCommLayer::status("Executing RunApp plugin..."); + char line[1024]; std::string output = ""; diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index 8dd3114f..421deb6a 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() diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am index a5c35f33..c873920b 100644 --- a/lib/Utils/Makefile.am +++ b/lib/Utils/Makefile.am @@ -2,6 +2,7 @@ lib_LTLIBRARIES = libABRTUtils.la libABRTUtils_la_SOURCES = DebugDump.cpp DebugDump.h libABRTUtils_la_LDFLAGS = -version-info 0:1:0 libABRTUtils_la_LIBADD = -lmagic +libABRTUtils_la_CPPFLAGS = -I$(srcdir)/../../inc install-data-local: $(mkdir_p) '$(DESTDIR)/$(DEBUG_DUMPS_DIR)' \ No newline at end of file diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 85a705ca..0146fab4 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -30,7 +30,7 @@ #include #include #include -#include "CommLayer.h" +#include "ABRTCommLayer.h" #include "ABRTException.h" /* just a helper function @@ -212,11 +212,10 @@ CCrashWatcher::CCrashWatcher(const std::string& pPath) int watch = 0; m_sTarget = pPath; - // TODO: initialize object according parameters -w -i + // TODO: initialize object according parameters -w -d // status has to be always created. - CommLayerInner::init_status(this); - CommLayerInner::init_warning(this); - CommLayerInner::init_debug(this); + m_pCommLayerInner = new CCommLayerInner(this, true, true); + ABRTCommLayer::init_comm_layer_inner(m_pCommLayerInner); m_pSettings = new CSettings(); m_pSettings->LoadSettings(std::string(CONF_DIR) + "/abrt.conf"); @@ -255,6 +254,7 @@ CCrashWatcher::~CCrashWatcher() delete m_pCommLayer; delete m_pMW; delete m_pSettings; + delete m_pCommLayerInner; } void CCrashWatcher::FindNewDumps(const std::string& pPath) { diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index d20cecff..deba9014 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -28,7 +28,6 @@ //#include "DBusServerProxy.h" #include "MiddleWare.h" #include "Settings.h" -#include "CommLayerInner.h" //FIXME remove when it gets to autoconf #include "CommLayerServerDBus.h" @@ -37,11 +36,11 @@ #elif HAVE_SOCKET #include "CommLayerServerSocket.h" #endif +#include "CommLayerInner.h" // 1024 simultaneous actions #define INOTIFY_BUFF_SIZE ((sizeof(struct inotify_event)+FILENAME_MAX)*1024) - class CCrashWatcher //: public CDBusServer_adaptor, // public DBus::IntrospectableAdaptor, @@ -64,6 +63,7 @@ class CCrashWatcher std::string m_sTarget; CMiddleWare *m_pMW; CCommLayerServer *m_pCommLayer; + CCommLayerInner *m_pCommLayerInner; /*FIXME not needed */ //DBus::Connection *m_pConn; CSettings *m_pSettings; diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am index ca3a4703..84013d49 100644 --- a/src/Daemon/Makefile.am +++ b/src/Daemon/Makefile.am @@ -1,8 +1,8 @@ sbin_PROGRAMS = abrt abrt_SOURCES = CrashWatcher.cpp CrashWatcher.h Daemon.cpp DBusServerProxy.h \ DBusCommon.h Settings.h Settings.cpp -abrt_CPPFLAGS = -Wall -Werror -rdynamic -I../../lib/MiddleWare -I../../lib/CommLayer\ - -I../../lib/DBus -I../../lib/Utils\ +abrt_CPPFLAGS = -Wall -Werror -rdynamic -I$(srcdir)/../../lib/MiddleWare -I$(srcdir)/../../lib/CommLayer\ + -I$(srcdir)/../../inc -I$(srcdir)/../../lib/Utils\ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(GLIB_CFLAGS) $(DBUSCPP_CFLAGS) \ -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp index 646beaff..05e0b568 100644 --- a/src/Hooks/CCpp.cpp +++ b/src/Hooks/CCpp.cpp @@ -20,6 +20,7 @@ */ #include "DebugDump.h" +#include "ABRTException.h" #include #include #include @@ -132,7 +133,7 @@ int main(int argc, char** argv) { free(executable); free(cmdline); - throw std::string("Can not get proc info."); + throw CABRTException(EXCEP_FATAL, "Can not get proc info."); } snprintf(path, sizeof(path), "%s/ccpp-%ld-%s", dddir, time(NULL), pid); @@ -148,7 +149,7 @@ int main(int argc, char** argv) { dd.Delete(); dd.Close(); - throw std::string("Can not open the file ") + path; + throw CABRTException(EXCEP_FATAL, std::string("Can not open the file ") + path); } // TODO: rewrite this while ((byte = getc(stdin)) != EOF) @@ -158,7 +159,7 @@ int main(int argc, char** argv) fclose(fp); dd.Delete(); dd.Close(); - throw std::string("Can not write to the file %s."); + throw CABRTException(EXCEP_FATAL, "Can not write to the file %s."); } } @@ -168,10 +169,10 @@ int main(int argc, char** argv) dd.Close(); write_success_log(pid); } - catch (std::string sError) + catch (std::exception& e) { - fprintf(stderr, "%s: %s\n", program_name, sError.c_str()); - write_faliure_log(sError.c_str()); + fprintf(stderr, "%s: %s\n", program_name, e.what()); + write_faliure_log(e.what()); return -2; } return 0; diff --git a/src/Hooks/Makefile.am b/src/Hooks/Makefile.am index 48d34e84..88361c6b 100644 --- a/src/Hooks/Makefile.am +++ b/src/Hooks/Makefile.am @@ -3,5 +3,5 @@ libexec_PROGRAMS = hookCCpp # CCpp hookCCpp_SOURCES = CCpp.cpp hookCCpp_LDADD = ../../lib/Utils/libABRTUtils.la -hookCCpp_CPPFLAGS = -I$(srcdir)/../../lib/Utils \ +hookCCpp_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../../lib/Utils \ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" -- cgit