summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-26 19:40:28 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-26 19:40:28 +0200
commitcaf38bbfe3279b9bea861e4d5b70f3c50c6e1755 (patch)
tree5ed7f83b0bdb584422f2e99489cfc81aac645500 /src
parentfca6fa371006186d12a720cd48c270789c67d2e6 (diff)
downloadabrt-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 'src')
-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
8 files changed, 65 insertions, 50 deletions
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)