diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 19:40:28 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 19:40:28 +0200 |
commit | caf38bbfe3279b9bea861e4d5b70f3c50c6e1755 (patch) | |
tree | 5ed7f83b0bdb584422f2e99489cfc81aac645500 /lib | |
parent | fca6fa371006186d12a720cd48c270789c67d2e6 (diff) | |
download | abrt-caf38bbfe3279b9bea861e4d5b70f3c50c6e1755.tar.gz abrt-caf38bbfe3279b9bea861e4d5b70f3c50c6e1755.tar.xz abrt-caf38bbfe3279b9bea861e4d5b70f3c50c6e1755.zip |
add job ids (== thread ids) to warning/update DBus messages
renamed:
comm_layer_inner_warning -> warn_client
comm_layer_inner_status -> update_client
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CommLayer/CommLayerInner.cpp | 50 | ||||
-rw-r--r-- | lib/CommLayer/CommLayerInner.h | 7 | ||||
-rw-r--r-- | lib/Plugins/Bugzilla.cpp | 16 | ||||
-rw-r--r-- | lib/Plugins/CCpp.cpp | 15 | ||||
-rw-r--r-- | lib/Plugins/FileTransfer.cpp | 18 | ||||
-rw-r--r-- | lib/Plugins/Kerneloops.cpp | 2 | ||||
-rw-r--r-- | lib/Plugins/KerneloopsReporter.cpp | 2 | ||||
-rw-r--r-- | lib/Plugins/KerneloopsScanner.cpp | 2 | ||||
-rw-r--r-- | lib/Plugins/Logger.cpp | 2 | ||||
-rw-r--r-- | lib/Plugins/Mailx.cpp | 4 | ||||
-rw-r--r-- | lib/Plugins/RunApp.cpp | 2 | ||||
-rw-r--r-- | lib/Plugins/SOSreport.cpp | 2 |
12 files changed, 74 insertions, 48 deletions
diff --git a/lib/CommLayer/CommLayerInner.cpp b/lib/CommLayer/CommLayerInner.cpp index ec569e44..1a58814f 100644 --- a/lib/CommLayer/CommLayerInner.cpp +++ b/lib/CommLayer/CommLayerInner.cpp @@ -1,28 +1,52 @@ +#include <pthread.h> /* pthread_self() */ +#include "abrtlib.h" #include "CommLayerInner.h" -static CObserver *g_pObs = NULL; +static CObserver *s_pObs; +static pthread_t s_main_id; - -void comm_layer_inner_init(CObserver *pObs) +void init_daemon_logging(CObserver *pObs) { - if (!g_pObs) - { - g_pObs = pObs; - } + s_pObs = pObs; + s_main_id = pthread_self(); } -void comm_layer_inner_warning(const std::string& pMessage) +void warn_client(const std::string& pMessage) { - if (g_pObs) + if (!s_pObs) + return; + pthread_t self = pthread_self(); + if (self != s_main_id) { - g_pObs->Warning(pMessage); + std::string s = ssprintf("%%%llx: %s", (unsigned long long)self, pMessage.c_str()); + s_pObs->Warning(s); +//log("w: '%s'", s.c_str()); + } + else + { + s_pObs->Warning(pMessage); +// debug: this should not happen - if it is, we are trying to log to a client +// but we have no job id! +log("W: '%s'", pMessage.c_str()); } } -void comm_layer_inner_status(const std::string& pMessage) +void update_client(const std::string& pMessage) { - if (g_pObs) + if (!s_pObs) + return; + pthread_t self = pthread_self(); + if (self != s_main_id) + { + std::string s = ssprintf("%%%llx: %s", (unsigned long long)self, pMessage.c_str()); + s_pObs->Status(s); +//log("u: '%s'", s.c_str()); + } + else { - g_pObs->Status(pMessage); + s_pObs->Status(pMessage); +// debug: this should not happen - if it is, we are trying to log to a client +// but we have no job id! +log("U: '%s'", pMessage.c_str()); } } diff --git a/lib/CommLayer/CommLayerInner.h b/lib/CommLayer/CommLayerInner.h index 43faac05..2b4f63a3 100644 --- a/lib/CommLayer/CommLayerInner.h +++ b/lib/CommLayer/CommLayerInner.h @@ -3,16 +3,17 @@ #include "Observer.h" -void comm_layer_inner_init(CObserver *pObs); +void init_daemon_logging(CObserver *pObs); /* Ask a client to warn the user about a non-fatal, but unexpected condition. * In GUI, it will usually be presented as a popup message. */ -void comm_layer_inner_warning(const std::string& pMessage); +void warn_client(const std::string& pMessage); /* Logs a message to a client. * In UI, it will usually appear as a new status line message in GUI, * or as a new message line in CLI. */ -void comm_layer_inner_status(const std::string& pMessage); +void update_client(const std::string& pMessage); #endif /* COMMLAYERINNER_H_ */ + diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index b92aa157..f2fb13a5 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -215,7 +215,7 @@ std::string CReporterBugzilla::CheckUUIDInBugzilla(const std::string& pComponent ss << xmlrpc_c::value_int(bug["bug_id"]); log("Bug is already reported: %s", ss.str().c_str()); - comm_layer_inner_status("Bug is already reported: " + ss.str()); + update_client("Bug is already reported: " + ss.str()); if (!CheckCCAndReporter(ss.str())) { @@ -274,8 +274,8 @@ void CReporterBugzilla::CreateNewBugDescription(const map_crash_report_t& pCrash } else if (it->second[CD_TYPE] == CD_BIN) { - comm_layer_inner_warning("Binary file "+it->first+" will not be reported."); - comm_layer_inner_status("Binary file "+it->first+" will not be reported."); + warn_client("Binary file "+it->first+" will not be reported."); + update_client("Binary file "+it->first+" will not be reported."); } } } @@ -343,7 +343,7 @@ std::string CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport) ret = xmlrpc_c::value_struct(rpc->getResult()); bugId << xmlrpc_c::value_int(ret["id"]); log("New bug id: %s", bugId.str().c_str()); - comm_layer_inner_status("New bug id: " + bugId.str()); + update_client("New bug id: " + bugId.str()); } catch (std::exception& e) { @@ -404,20 +404,20 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, co std::string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT]; std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; std::string bugId; - comm_layer_inner_status("Logging into bugzilla..."); + update_client("Logging into bugzilla..."); NewXMLRPCClient(); try { Login(); - comm_layer_inner_status("Checking for duplicates..."); + update_client("Checking for duplicates..."); if ((bugId = CheckUUIDInBugzilla(component, uuid)) == "") { - comm_layer_inner_status("Creating new bug..."); + update_client("Creating new bug..."); bugId = NewBug(pCrashReport); AddAttachments(bugId, pCrashReport); } - comm_layer_inner_status("Logging out..."); + update_client("Logging out..."); Logout(); } catch (CABRTException& e) diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index b9fcb215..ba4e78cd 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -79,7 +79,7 @@ static std::string CreateHash(const std::string& pInput) static void InstallDebugInfos(const std::string& pPackage) { - comm_layer_inner_status("Searching for debug-info packages..."); + update_client("Searching for debug-info packages..."); std::string packageName = pPackage.substr(0, pPackage.rfind("-", pPackage.rfind("-")-1)); char buff[1024]; @@ -117,7 +117,7 @@ static void InstallDebugInfos(const std::string& pPackage) safe_write(pipein[1], "y\n", sizeof("y\n")-1); close(pipein[1]); - comm_layer_inner_status("Downloading and installing debug-info packages..."); + update_client("Downloading and installing debug-info packages..."); FILE *pipeout_fp = fdopen(pipeout[0], "r"); if (pipeout_fp == NULL) /* never happens */ @@ -141,7 +141,7 @@ static void InstallDebugInfos(const std::string& pPackage) buff[last] = '\0'; log(buff); - comm_layer_inner_status(buff); + update_client(buff); #ifdef COMPLAIN_IF_NO_DEBUGINFO if (already_installed == false) @@ -177,7 +177,7 @@ static void InstallDebugInfos(const std::string& pPackage) static void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktrace) { - comm_layer_inner_status("Getting backtrace..."); + update_client("Getting backtrace..."); std::string tmpFile = "/tmp/" + pDebugDumpDir.substr(pDebugDumpDir.rfind("/")); std::ofstream fTmp; @@ -426,7 +426,8 @@ I think the below code has absolutely the same effect: std::string CAnalyzerCCpp::GetLocalUUID(const std::string& pDebugDumpDir) { - comm_layer_inner_status("Getting local universal unique identification..."); +/// + update_client("Getting local universal unique identification..."); CDebugDump dd; std::string UID; @@ -450,7 +451,7 @@ std::string CAnalyzerCCpp::GetLocalUUID(const std::string& pDebugDumpDir) std::string CAnalyzerCCpp::GetGlobalUUID(const std::string& pDebugDumpDir) { - comm_layer_inner_status("Getting global universal unique identification..."); + update_client("Getting global universal unique identification..."); std::string backtrace; std::string executable; @@ -468,7 +469,7 @@ std::string CAnalyzerCCpp::GetGlobalUUID(const std::string& pDebugDumpDir) void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir) { - comm_layer_inner_status("Starting report creation..."); + update_client("Starting report creation..."); std::string package; std::string backtrace; diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index 4ed9a236..dbda17fa 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -49,7 +49,7 @@ void CFileTransfer::SendFile(const std::string& pURL, if (pURL == "") { - comm_layer_inner_warning("FileTransfer: URL not specified"); + warn_client("FileTransfer: URL not specified"); return; } protocol = ""; @@ -64,7 +64,7 @@ void CFileTransfer::SendFile(const std::string& pURL, } } - comm_layer_inner_status("Sending archive " + pFilename + " via " + protocol); + update_client("Sending archive " + pFilename + " via " + protocol); if( pURL[len-1] == '/' ) { @@ -116,7 +116,7 @@ void CFileTransfer::CreateArchive(const std::string& pArchiveName, std::string cmdline; int result; - comm_layer_inner_status("Creating an archive..."); + update_client("Creating an archive..."); /*TODO: consider library for archive creation, if there is any*/ @@ -171,7 +171,7 @@ void CFileTransfer::Run(const std::string& pActiveDir, const std::string& pArgs) std::string dirname, archivename; char hostname[HBLEN]; - comm_layer_inner_status("File Transfer: Creating a report..."); + update_client("File Transfer: Creating a report..."); if (pArgs == "store") { @@ -192,8 +192,8 @@ void CFileTransfer::Run(const std::string& pActiveDir, const std::string& pArgs) } catch (CABRTException& e) { - comm_layer_inner_warning("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); - comm_layer_inner_status("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); + warn_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); + update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); } unlink(archivename.c_str()); } @@ -221,8 +221,8 @@ void CFileTransfer::Run(const std::string& pActiveDir, const std::string& pArgs) } catch (CABRTException& e) { - comm_layer_inner_warning("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); - comm_layer_inner_status("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); + warn_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); + update_client("CFileTransfer::Run(): Cannot create and send an archive: " + e.what()); } unlink(archivename.c_str()); } @@ -242,7 +242,7 @@ void CFileTransfer::SetSettings(const map_plugin_settings_t& pSettings) } else { - comm_layer_inner_warning("FileTransfer: URL not specified"); + warn_client("FileTransfer: URL not specified"); } if (pSettings.find("RetryCount") != pSettings.end()) diff --git a/lib/Plugins/Kerneloops.cpp b/lib/Plugins/Kerneloops.cpp index 2dcd0c34..ed27eb4e 100644 --- a/lib/Plugins/Kerneloops.cpp +++ b/lib/Plugins/Kerneloops.cpp @@ -35,7 +35,7 @@ std::string CAnalyzerKerneloops::GetLocalUUID(const std::string& pDebugDumpDir) { - comm_layer_inner_status("Getting local/global universal unique identification..."); + update_client("Getting local/global universal unique identification..."); std::string m_sOops; std::stringstream m_sHash; diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp index 647ff8f9..b3d63321 100644 --- a/lib/Plugins/KerneloopsReporter.cpp +++ b/lib/Plugins/KerneloopsReporter.cpp @@ -98,7 +98,7 @@ std::string CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport, int ret = -1; map_crash_report_t::const_iterator it; - comm_layer_inner_status("Creating and submitting a report..."); + update_client("Creating and submitting a report..."); it = pCrashReport.begin(); it = pCrashReport.find(FILENAME_KERNELOOPS); diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index 77a62246..3915b831 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -76,7 +76,7 @@ void CKerneloopsScanner::Run(const std::string& pActionDir, void CKerneloopsScanner::SaveOopsToDebugDump() { - comm_layer_inner_status("Creating kernel oops crash reports..."); + update_client("Creating kernel oops crash reports..."); time_t t = time(NULL); CDebugDump debugDump; diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index 72e00880..3d2d6937 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -55,7 +55,7 @@ map_plugin_settings_t CLogger::GetSettings() std::string CLogger::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { - comm_layer_inner_status("Creating a report..."); + update_client("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 977499ec..5129038f 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -107,7 +107,7 @@ void CMailx::ExecMailx(uid_t uid, const std::string& pText) void CMailx::SendEmail(const std::string& pSubject, const std::string& pText, const std::string& pUID) { - comm_layer_inner_status("Sending an email..."); + update_client("Sending an email..."); AddMailxArg("-s"); AddMailxArg(pSubject); @@ -121,7 +121,7 @@ void CMailx::SendEmail(const std::string& pSubject, const std::string& pText, co std::string CMailx::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { - comm_layer_inner_status("Creating a report..."); + update_client("Creating a report..."); std::stringstream emailBody; std::stringstream binaryFiles, commonFiles, bigTextFiles, additionalFiles, UUIDFile; diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index 8d37f11c..29c00066 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -59,7 +59,7 @@ void CActionRunApp::ParseArgs(const std::string& psArgs, vector_args_t& pArgs) void CActionRunApp::Run(const std::string& pActionDir, const std::string& pArgs) { - comm_layer_inner_status("Executing RunApp plugin..."); + update_client("Executing RunApp plugin..."); char line[1024]; std::string output = ""; diff --git a/lib/Plugins/SOSreport.cpp b/lib/Plugins/SOSreport.cpp index 513adfb1..fa10f813 100644 --- a/lib/Plugins/SOSreport.cpp +++ b/lib/Plugins/SOSreport.cpp @@ -87,7 +87,7 @@ std::string CActionSOSreport::ParseFilename(const std::string& pOutput) void CActionSOSreport::Run(const std::string& pActionDir, const std::string& pArgs) { - comm_layer_inner_status("Executing SOSreportAction plugin..."); + update_client("Executing SOSreportAction plugin..."); const char command[] = "sosreport --batch --no-progressbar -k rpm.rpmva=off 2>&1"; |