summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/CommLayer/CommLayerInner.cpp50
-rw-r--r--lib/CommLayer/CommLayerInner.h7
-rw-r--r--lib/Plugins/Bugzilla.cpp16
-rw-r--r--lib/Plugins/CCpp.cpp15
-rw-r--r--lib/Plugins/FileTransfer.cpp18
-rw-r--r--lib/Plugins/Kerneloops.cpp2
-rw-r--r--lib/Plugins/KerneloopsReporter.cpp2
-rw-r--r--lib/Plugins/KerneloopsScanner.cpp2
-rw-r--r--lib/Plugins/Logger.cpp2
-rw-r--r--lib/Plugins/Mailx.cpp4
-rw-r--r--lib/Plugins/RunApp.cpp2
-rw-r--r--lib/Plugins/SOSreport.cpp2
-rw-r--r--src/Daemon/CommLayerServerDBus.cpp6
-rw-r--r--src/Daemon/CommLayerServerSocket.cpp12
-rw-r--r--src/Daemon/CrashWatcher.cpp27
-rw-r--r--src/Daemon/CrashWatcher.h2
-rw-r--r--src/Daemon/Daemon.cpp34
-rw-r--r--src/Daemon/MiddleWare.cpp26
-rw-r--r--src/Daemon/PluginManager.cpp6
-rw-r--r--src/Daemon/RPM.cpp2
20 files changed, 139 insertions, 98 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";
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp
index 95c0586d..dd1a01e4 100644
--- a/src/Daemon/CommLayerServerDBus.cpp
+++ b/src/Daemon/CommLayerServerDBus.cpp
@@ -75,9 +75,9 @@ DBus::Message CCommLayerServerDBus::_CreateReport_stub(const DBus::CallMessage &
std::string argin1;
ri >> argin1;
- unsigned long unix_uid = m_pConn->sender_unix_uid(call.sender());
- uint64_t argout1 = CreateReport_t(argin1, to_string(unix_uid), call.sender());
- //map_crash_report_t argout1 = CreateReport(argin1,call.sender());
+ const char* sender = call.sender();
+ unsigned long unix_uid = m_pConn->sender_unix_uid(sender);
+ uint64_t argout1 = CreateReport_t(argin1, to_string(unix_uid), sender);
DBus::ReturnMessage reply(call);
DBus::MessageIter wi = reply.writer();
diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp
index 50018762..99fe0c26 100644
--- a/src/Daemon/CommLayerServerSocket.cpp
+++ b/src/Daemon/CommLayerServerSocket.cpp
@@ -28,7 +28,7 @@ void CCommLayerServerSocket::Send(const std::string& pData, GIOChannel *pDestina
ret = g_io_channel_write_chars(pDestination, message + offset, strlen(message + offset), &len, &err);
if (ret == G_IO_STATUS_ERROR)
{
- comm_layer_inner_warning("Error during sending data.");
+ warn_client("Error during sending data.");
}
}
@@ -76,7 +76,7 @@ gboolean CCommLayerServerSocket::client_socket_cb(GIOChannel *source, GIOConditi
ret = g_io_channel_read_chars(source, buff, 1, &len, &err);
if (ret == G_IO_STATUS_ERROR)
{
- comm_layer_inner_warning(std::string("Error while reading data from client socket: ") + err->message);
+ warn_client(std::string("Error while reading data from client socket: ") + err->message);
return FALSE;
}
message += buff[0];
@@ -105,13 +105,13 @@ gboolean CCommLayerServerSocket::server_socket_cb(GIOChannel *source, GIOConditi
condition & G_IO_ERR ||
condition & G_IO_NVAL)
{
- comm_layer_inner_warning("Server socket error.");
+ warn_client("Server socket error.");
return FALSE;
}
if ((socket = accept(serverSocket->m_nSocket, (struct sockaddr *)&remote, &len)) == -1)
{
- comm_layer_inner_warning("Server can not accept client.");
+ warn_client("Server can not accept client.");
return TRUE;
}
log("New socket client connected");
@@ -121,7 +121,7 @@ gboolean CCommLayerServerSocket::server_socket_cb(GIOChannel *source, GIOConditi
static_cast<GIOFunc>(client_socket_cb),
data))
{
- comm_layer_inner_warning("Can not init g_io_channel.");
+ warn_client("Can not init g_io_channel.");
return TRUE;
}
serverSocket->m_mapClientChannels[socket] = gSocket;
@@ -159,7 +159,7 @@ void CCommLayerServerSocket::ProcessMessage(const std::string& pMessage, GIOChan
}
else
{
- comm_layer_inner_warning("Received unknown message type.");
+ warn_client("Received unknown message type.");
}
}
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index 07dfa126..4473659e 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -118,6 +118,20 @@ static void *create_report(void *arg)
{
thread_data_t *thread_data = (thread_data_t *) arg;
map_crash_info_t crashReport;
+
+ /* Ugly hack.
+ * We use DBus signals to talk to clients.
+ * If the report thread emits a signal with embedded job id before
+ * main thread returns this job id as a CreateReport() DBus call's
+ * return value, the client will not be able to understand
+ * that this signal is for its job.
+ * By no means this is the right solution. The right one would be
+ * to ensure that CreateReport() DBus call returns _before_
+ * we continue here. This will need substantial surgery
+ * on our DBus machinery. TODO.
+ */
+ usleep(10*1000);
+
log("Creating report...");
try
{
@@ -172,22 +186,25 @@ static void *create_report(void *arg)
/* Bogus value. pthreads require us to return void* */
return NULL;
}
-uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender)
+uint64_t CreateReport_t(const std::string& pUUID, const std::string& pUID, const std::string& pSender)
{
thread_data_t *thread_data = (thread_data_t *)xzalloc(sizeof(thread_data_t));
thread_data->UUID = xstrdup(pUUID.c_str());
thread_data->UID = xstrdup(pUID.c_str());
thread_data->dest = xstrdup(pSender.c_str());
- if (pthread_create(&(thread_data->thread_id), NULL, create_report, (void *)thread_data) != 0)
+ if (pthread_create(&thread_data->thread_id, NULL, create_report, (void *)thread_data) != 0)
{
free(thread_data->UUID);
free(thread_data->UID);
free(thread_data->dest);
free(thread_data);
- throw CABRTException(EXCEP_FATAL, "CCrashWatcher::CreateReport_t(): Cannot create thread!");
+ /* The only reason this may happen is system-wide resource starvation,
+ * or ulimit is exceeded (someoune floods us with CreateReport() Dbus calls?)
+ */
+ error_msg("cannot create thread");
+ return 0;
}
- //FIXME: we don't use this value anymore, so fix the API
- return 0;
+ return uint64_t(thread_data->thread_id);
}
bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID)
diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h
index 937b3218..bf82a30b 100644
--- a/src/Daemon/CrashWatcher.h
+++ b/src/Daemon/CrashWatcher.h
@@ -56,7 +56,7 @@ class CCrashWatcher
};
vector_crash_infos_t GetCrashInfos(const std::string &pUID);
-uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender);
+uint64_t CreateReport_t(const std::string& pUUID, const std::string& pUID, const std::string& pSender);
bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID);
map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pSender);
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index f5b40b4a..7821f0f1 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -274,36 +274,34 @@ static void SetUpCron()
static void FindNewDumps(const std::string& pPath)
{
log("Scanning for unsaved entries...");
- struct dirent *ep;
struct stat stats;
DIR *dp;
std::vector<std::string> dirs;
std::string dname;
// get potential unsaved debugdumps
dp = opendir(pPath.c_str());
- if (dp != NULL)
+ if (dp == NULL)
{
- while ((ep = readdir(dp)))
+ throw CABRTException(EXCEP_FATAL, "FindNewDumps(): Couldn't open the directory:" + pPath);
+ }
+ struct dirent *ep;
+ while ((ep = readdir(dp)))
+ {
+ if (dot_or_dotdot(ep->d_name))
+ continue;
+ dname = pPath + "/" + ep->d_name;
+ if (lstat(dname.c_str(), &stats) == 0)
{
- if (dot_or_dotdot(ep->d_name))
- continue;
- dname = pPath + "/" + ep->d_name;
- if (lstat(dname.c_str(), &stats) == 0)
+ if (S_ISDIR(stats.st_mode))
{
- if (S_ISDIR(stats.st_mode))
- {
- dirs.push_back(dname);
- }
+ dirs.push_back(dname);
}
}
- (void) closedir(dp);
- }
- else
- {
- throw CABRTException(EXCEP_FATAL, "FindNewDumps(): Couldn't open the directory:" + pPath);
}
+ closedir(dp);
- for (std::vector<std::string>::iterator itt = dirs.begin(); itt != dirs.end(); ++itt){
+ for (std::vector<std::string>::iterator itt = dirs.begin(); itt != dirs.end(); ++itt)
+ {
map_crash_info_t crashinfo;
try
{
@@ -572,7 +570,7 @@ int main(int argc, char** argv)
{
pthread_mutex_init(&g_pJobsMutex, NULL); /* never fails */
/* DBus init - we want it early so that errors are reported */
- comm_layer_inner_init(&watcher);
+ init_daemon_logging(&watcher);
/* Watching DEBUG_DUMPS_DIR for new files... */
errno = 0;
int inotify_fd = inotify_init();
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index 5c86a1d3..4d4b8c68 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -180,7 +180,7 @@ mw_result_t CreateCrashReport(const std::string& pUUID,
if (pUUID == "" || row.m_sUUID != pUUID)
{
- comm_layer_inner_warning("CreateCrashReport(): UUID '"+pUUID+"' is not in database.");
+ warn_client("CreateCrashReport(): UUID '"+pUUID+"' is not in database.");
return MW_IN_DB_ERROR;
}
@@ -209,7 +209,7 @@ mw_result_t CreateCrashReport(const std::string& pUUID,
}
catch (CABRTException& e)
{
- comm_layer_inner_warning("CreateCrashReport(): " + e.what());
+ warn_client("CreateCrashReport(): " + e.what());
if (e.type() == EXCEP_DD_OPEN)
{
return MW_ERROR;
@@ -240,8 +240,8 @@ void RunAction(const std::string& pActionDir,
}
catch (CABRTException& e)
{
- comm_layer_inner_warning("RunAction(): " + e.what());
- comm_layer_inner_status("Execution of '"+pPluginName+"' was not successful: " + e.what());
+ warn_client("RunAction(): " + e.what());
+ update_client("Execution of '"+pPluginName+"' was not successful: " + e.what());
}
}
@@ -269,8 +269,8 @@ void RunActionsAndReporters(const std::string& pDebugDumpDir)
}
catch (CABRTException& e)
{
- comm_layer_inner_warning("RunActionsAndReporters(): " + e.what());
- comm_layer_inner_status("Activation of plugin '"+(*it_ar).first+"' was not successful: " + e.what());
+ warn_client("RunActionsAndReporters(): " + e.what());
+ update_client("Activation of plugin '"+(*it_ar).first+"' was not successful: " + e.what());
}
}
}
@@ -354,8 +354,8 @@ report_status_t Report(const map_crash_report_t& pCrashReport,
{
ret[ret_key].push_back("0");
ret[ret_key].push_back(e.what());
- comm_layer_inner_warning("Report(): " + e.what());
- comm_layer_inner_status("Reporting via '"+(*it_r).first+"' was not successful: " + e.what());
+ warn_client("Report(): " + e.what());
+ update_client("Reporting via '"+(*it_r).first+"' was not successful: " + e.what());
}
}
}
@@ -482,7 +482,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta
}
catch (CABRTException& e)
{
- comm_layer_inner_warning("SavePackageDescriptionToDebugDump(): " + e.what());
+ warn_client("SavePackageDescriptionToDebugDump(): " + e.what());
if (e.type() == EXCEP_DD_SAVE)
{
dd.Close();
@@ -520,8 +520,8 @@ static void RunAnalyzerActions(const std::string& pAnalyzer, const std::string&
}
catch (CABRTException& e)
{
- comm_layer_inner_warning("RunAnalyzerActions(): " + e.what());
- comm_layer_inner_status("Action performed by '"+(*it_a).first+"' was not successful: " + e.what());
+ warn_client("RunAnalyzerActions(): " + e.what());
+ update_client("Action performed by '"+(*it_a).first+"' was not successful: " + e.what());
}
}
}
@@ -593,7 +593,7 @@ mw_result_t SaveDebugDump(const std::string& pDebugDumpDir,
}
catch (CABRTException& e)
{
- comm_layer_inner_warning("SaveDebugDump(): " + e.what());
+ warn_client("SaveDebugDump(): " + e.what());
if (e.type() == EXCEP_DD_SAVE)
{
dd.Close();
@@ -642,7 +642,7 @@ mw_result_t GetCrashInfo(const std::string& pUUID,
}
catch (CABRTException& e)
{
- comm_layer_inner_warning("GetCrashInfo(): " + e.what());
+ warn_client("GetCrashInfo(): " + e.what());
if (e.type() == EXCEP_DD_LOAD)
{
dd.Close();
diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp
index 01c2ef97..acabc93b 100644
--- a/src/Daemon/PluginManager.cpp
+++ b/src/Daemon/PluginManager.cpp
@@ -180,8 +180,8 @@ void CPluginManager::LoadPlugin(const std::string& pName)
catch (CABRTException& e)
{
delete abrtPlugin;
- comm_layer_inner_warning("CPluginManager::LoadPlugin(): " + e.what());
- comm_layer_inner_warning("Failed to load plugin " + pName);
+ warn_client("CPluginManager::LoadPlugin(): " + e.what());
+ warn_client("Failed to load plugin " + pName);
}
}
}
@@ -214,7 +214,7 @@ void CPluginManager::RegisterPlugin(const std::string& pName)
}
catch (CABRTException& e)
{
- comm_layer_inner_warning("Can not initialize plugin " + pName + "("
+ warn_client("Can not initialize plugin " + pName + "("
+ std::string(plugin_type_str[m_mapABRTPlugins[pName]->GetType()])
+ "): " + e.what());
UnLoadPlugin(pName);
diff --git a/src/Daemon/RPM.cpp b/src/Daemon/RPM.cpp
index d2451ada..f5377bcb 100644
--- a/src/Daemon/RPM.cpp
+++ b/src/Daemon/RPM.cpp
@@ -20,7 +20,7 @@ void CRPM::LoadOpenGPGPublicKey(const std::string& pFileName)
if (pgpReadPkts(pFileName.c_str(), &pkt, &pklen) != PGPARMOR_PUBKEY)
{
free(pkt);
- comm_layer_inner_warning("CRPM::LoadOpenGPGPublicKey(): Can not load public key " + pFileName);
+ warn_client("CRPM::LoadOpenGPGPublicKey(): Can not load public key " + pFileName);
return;
}
if (pgpPubkeyFingerprint(pkt, pklen, keyID) == 0)