summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-27 14:13:53 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-27 14:13:53 +0200
commit8c0d6a2a3eb9ed0f31e9dbd4ff1c18929932b982 (patch)
tree010709b30117a40e62ad888692b57177a921bd2e
parent1dbb6423000e2fcd3fe9a1b6ddbf6200d522d470 (diff)
downloadabrt-8c0d6a2a3eb9ed0f31e9dbd4ff1c18929932b982.tar.gz
abrt-8c0d6a2a3eb9ed0f31e9dbd4ff1c18929932b982.tar.xz
abrt-8c0d6a2a3eb9ed0f31e9dbd4ff1c18929932b982.zip
eliminate global variable g_cw
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--lib/Plugins/CCpp.cpp4
-rw-r--r--src/Daemon/CrashWatcher.cpp35
-rw-r--r--src/Daemon/Daemon.cpp13
-rw-r--r--src/Daemon/Daemon.h8
4 files changed, 29 insertions, 31 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index ba4e78cd..b7416563 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -140,8 +140,8 @@ static void InstallDebugInfos(const std::string& pPackage)
if (last >= 0 && buff[last] == '\n')
buff[last] = '\0';
- log(buff);
- update_client(buff);
+ /* log(buff); - update_client logs it too */
+ update_client(buff); /* maybe only if buff != ""? */
#ifdef COMPLAIN_IF_NO_DEBUGINFO
if (already_installed == false)
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index 288ecc0f..67121a67 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -46,7 +46,6 @@ void CCrashWatcher::Debug(const std::string& pMessage)
CCrashWatcher::CCrashWatcher()
{
- g_cw = this;
}
CCrashWatcher::~CCrashWatcher()
@@ -75,15 +74,15 @@ vector_crash_infos_t GetCrashInfos(const std::string &pUID)
retval.push_back(info);
break;
case MW_ERROR:
- g_cw->Warning("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database");
- g_cw->Status("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database");
+ warn_client("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database");
+ update_client("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database");
DeleteCrashInfo(UUIDsUIDs[ii].first, UUIDsUIDs[ii].second);
break;
case MW_FILE_ERROR:
{
std::string debugDumpDir;
- g_cw->Warning("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting ");
- g_cw->Status("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting ");
+ warn_client("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting ");
+ update_client("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting ");
debugDumpDir = DeleteCrashInfo(UUIDsUIDs[ii].first, UUIDsUIDs[ii].second);
DeleteDebugDumpDir(debugDumpDir);
}
@@ -99,8 +98,8 @@ vector_crash_infos_t GetCrashInfos(const std::string &pUID)
{
throw e;
}
- g_cw->Warning(e.what());
- g_cw->Status(e.what());
+ warn_client(e.what());
+ update_client(e.what());
}
//retval = GetCrashInfos(pUID);
@@ -131,17 +130,17 @@ static void *create_report(void *arg)
case MW_OK:
break;
case MW_IN_DB_ERROR:
- g_cw->Warning(std::string("Did not find crash with UUID ")+thread_data->UUID+ " in database.",(uint64_t)thread_data->thread_id);
+ warn_client(std::string("Did not find crash with UUID ") + thread_data->UUID + " in database");
break;
case MW_PLUGIN_ERROR:
- g_cw->Warning(std::string("Particular analyzer plugin isn't loaded or there is an error within plugin(s)."),(uint64_t)thread_data->thread_id);
+ warn_client(std::string("Particular analyzer plugin isn't loaded or there is an error within plugin(s)"));
break;
case MW_CORRUPTED:
case MW_FILE_ERROR:
default:
{
std::string debugDumpDir;
- g_cw->Warning(std::string("Corrupted crash with UUID ")+thread_data->UUID+", deleting.",(uint64_t)thread_data->thread_id);
+ warn_client(std::string("Corrupted crash with UUID ") + thread_data->UUID + ", deleting");
debugDumpDir = DeleteCrashInfo(thread_data->UUID, thread_data->UID);
DeleteDebugDumpDir(debugDumpDir);
}
@@ -164,7 +163,7 @@ static void *create_report(void *arg)
free(thread_data);
throw e;
}
- g_cw->Warning(e.what(),(uint64_t)thread_data->thread_id);
+ warn_client(e.what());
}
/* free strduped strings */
free(thread_data->UUID);
@@ -210,8 +209,8 @@ bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID)
{
throw e;
}
- g_cw->Warning(e.what());
- g_cw->Status(e.what());
+ warn_client(e.what());
+ update_client(e.what());
return false;
}
return true;
@@ -238,7 +237,7 @@ vector_map_string_string_t GetPluginsInfo()
{
throw e;
}
- g_cw->Warning(e.what());
+ warn_client(e.what());
}
// TODO: is it right? I added it just to disable a warning...
// but maybe returning empty map is wrong here?
@@ -257,7 +256,7 @@ map_plugin_settings_t GetPluginSettings(const std::string& pName, const std::str
{
throw e;
}
- g_cw->Warning(e.what());
+ warn_client(e.what());
}
// TODO: is it right? I added it just to disable a warning...
// but maybe returning empty map is wrong here?
@@ -276,7 +275,7 @@ void RegisterPlugin(const std::string& pName)
{
throw e;
}
- g_cw->Warning(e.what());
+ warn_client(e.what());
}
}
@@ -292,7 +291,7 @@ void UnRegisterPlugin(const std::string& pName)
{
throw e;
}
- g_cw->Warning(e.what());
+ warn_client(e.what());
}
}
@@ -308,6 +307,6 @@ void SetPluginSettings(const std::string& pName, const std::string& pUID, const
{
throw e;
}
- g_cw->Warning(e.what());
+ warn_client(e.what());
}
}
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 7821f0f1..a7252ac9 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -49,7 +49,6 @@ typedef struct cron_callback_data_t
static uint8_t sig_caught; /* = 0 */
static GMainLoop* g_pMainloop;
-CCrashWatcher *g_cw;
CCommLayerServer *g_pCommLayer;
/*
* Map to cache the results from CreateReport_t
@@ -324,7 +323,7 @@ static void FindNewDumps(const std::string& pPath)
case MW_GPG_ERROR:
case MW_FILE_ERROR:
default:
- g_cw->Warning("Corrupted, bad or already saved crash, deleting.");
+ warn_client("Corrupted, bad or already saved crash, deleting.");
DeleteDebugDumpDir(*itt);
break;
}
@@ -335,7 +334,7 @@ static void FindNewDumps(const std::string& pPath)
{
throw e;
}
- g_cw->Warning(e.what());
+ warn_client(e.what());
}
}
}
@@ -431,7 +430,7 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe
err = g_io_channel_read(gio, buf, INOTIFY_BUFF_SIZE, &len);
if (err != G_IO_ERROR_NONE)
{
- g_cw->Warning("Error reading inotify fd.");
+ warn_client("Error reading inotify fd.");
delete[] buf;
return FALSE;
}
@@ -469,8 +468,8 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe
break;
case MW_REPORTED:
case MW_OCCURED:
- /* send message to dbus */
log("Already saved crash, deleting...");
+ /* Send dbus signal */
g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT], crashinfo[CD_UID][CD_CONTENT]);
DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name);
break;
@@ -481,14 +480,14 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe
case MW_IN_DB:
case MW_FILE_ERROR:
default:
- g_cw->Warning("Corrupted or bad crash, deleting...");
+ warn_client("Corrupted or bad crash, deleting...");
DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name);
break;
}
}
catch (CABRTException& e)
{
- g_cw->Warning(e.what());
+ warn_client(e.what());
if (e.type() == EXCEP_FATAL)
{
delete[] buf;
diff --git a/src/Daemon/Daemon.h b/src/Daemon/Daemon.h
index 8d0a4c69..c47d1622 100644
--- a/src/Daemon/Daemon.h
+++ b/src/Daemon/Daemon.h
@@ -29,23 +29,23 @@ class CCommLayerServer;
class CPluginManager;
class CRPM;
-/* Used only for ->Warning() calls */
-extern CCrashWatcher *g_cw;
-/* Conduit for these messages */
+/* Used for sending dbus signals */
extern CCommLayerServer *g_pCommLayer;
+
/* Collection of loaded plugins */
extern CPluginManager* g_pPluginManager;
+
/**
* An instance of CRPM used for package checking.
* @see RPM.h
*/
+
extern CRPM g_RPM;
/**
* A set of blacklisted packages.
*/
extern set_strings_t g_setBlackList;
-
/* Map <UID, <UUID, result>> to cache the results from CreateReport_t() */
extern std::map<const std::string, std::map<int, map_crash_report_t> > g_pending_jobs;
/* Mutex to protect g_pending_jobs */