summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2010-02-06 11:09:09 +0100
committerKarel Klic <kklic@redhat.com>2010-02-06 11:09:09 +0100
commit1e76e071620e1f9bf110dacf3cf8caffccef324b (patch)
tree2903f342a04a6fcff25a80f3e8b3a0255a642f29 /src
parentab8001110061f099a1f4ab27afb954943876d79e (diff)
parentab0b3530d71464b316657656a4116d292880a915 (diff)
downloadabrt-1e76e071620e1f9bf110dacf3cf8caffccef324b.tar.gz
abrt-1e76e071620e1f9bf110dacf3cf8caffccef324b.tar.xz
abrt-1e76e071620e1f9bf110dacf3cf8caffccef324b.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/Daemon.cpp58
-rw-r--r--src/Daemon/MiddleWare.cpp22
-rw-r--r--src/Daemon/MiddleWare.h9
3 files changed, 56 insertions, 33 deletions
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 511d45d6..99214230 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -316,9 +316,12 @@ static void FindNewDumps(const char* pPath)
}
closedir(dp);
- log("Checking for unsaved crashdumps (%u dirs to check)", (unsigned)dirs.size());
+ unsigned size = dirs.size();
+ if (size == 0)
+ return;
+ log("Checking for unsaved crashes (dirs to check:%u)", size);
- /* Get potential unsaved debugdumps */
+ /* Get potentially non-processed debugdumps */
vector_string_t::iterator itt = dirs.begin();
for (; itt != dirs.end(); ++itt)
{
@@ -332,19 +335,22 @@ static void FindNewDumps(const char* pPath)
case MW_OK:
/* Not VERB1: this is new, unprocessed crash dump.
* Last abrtd somehow missed it - need to inform user */
- log("Non-processed crashdump in %s, saving into database", dir_name);
- RunActionsAndReporters(get_crash_data_item_content(crashinfo, CD_DUMPDIR).c_str());
+ log("Non-processed crash in %s, saving into database", dir_name);
+ /* Run automatic actions and reporters on it (if we have them configured) */
+ RunActionsAndReporters(dir_name);
break;
case MW_IN_DB:
+ /* This debugdump was found in DB, nothing else was done
+ * by SaveDebugDump or needs to be done by us */
VERB1 log("%s is already saved in database", dir_name);
break;
- case MW_REPORTED:
- case MW_OCCURED:
- VERB1 log("Already saved crash %s, deleting", dir_name);
+ case MW_REPORTED: /* already reported dup */
+ case MW_OCCURRED: /* not-yet-reported dup */
+ VERB1 log("Duplicate crash %s, deleting", dir_name);
delete_debug_dump_dir(dir_name);
break;
default:
- log("Corrupted or bad crashdump %s (res:%d), deleting", dir_name, (int)res);
+ log("Corrupted or bad crash %s (res:%d), deleting", dir_name, (int)res);
delete_debug_dump_dir(dir_name);
break;
}
@@ -354,6 +360,7 @@ static void FindNewDumps(const char* pPath)
error_msg("%s", e.what());
}
}
+ log("Done checking for unsaved crashes");
}
static int CreatePidFile()
@@ -483,27 +490,37 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
try
{
std::string fullname = concat_path_file(DEBUG_DUMPS_DIR, name);
-//todo: rename SaveDebugDump to ???? it does not save crashinfo, it FETCHES crashinfo
+ /* Note: SaveDebugDump does not save crashinfo, it _fetches_ crashinfo */
map_crash_data_t crashinfo;
mw_result_t res = SaveDebugDump(fullname.c_str(), crashinfo);
switch (res)
{
case MW_OK:
- log("New crash, saving");
- RunActionsAndReporters(get_crash_data_item_content(crashinfo, CD_DUMPDIR).c_str());
+ log("New crash %s, processing", fullname.c_str());
+ /* Run automatic actions and reporters on it (if we have them configured) */
+ RunActionsAndReporters(fullname.c_str());
/* Fall through */
- case MW_REPORTED:
- case MW_OCCURED:
+
+ case MW_REPORTED: /* already reported dup */
+ case MW_OCCURRED: /* not-yet-reported dup */
{
if (res != MW_OK)
- log("Already saved crash, just sending dbus signal");
+ {
+ const char *first = get_crash_data_item_content(crashinfo, CD_DUMPDIR).c_str();
+ log("Deleting crash %s (dup of %s), sending dbus signal",
+ strrchr(fullname.c_str(), '/') + 1,
+ strrchr(first, '/') + 1);
+ delete_debug_dump_dir(fullname.c_str());
+ }
+#define fullname fullname_should_not_be_used_here
const char *analyzer = get_crash_data_item_content(crashinfo, FILENAME_ANALYZER).c_str();
const char *uid_str = get_crash_data_item_content(crashinfo, FILENAME_UID).c_str();
/* Autoreport it if configured to do so */
- if (analyzer_has_AutoReportUIDs(analyzer, uid_str))
- {
+ if (res != MW_REPORTED
+ && analyzer_has_AutoReportUIDs(analyzer, uid_str)
+ ) {
VERB1 log("Reporting the crash automatically");
map_crash_data_t crash_report;
mw_result_t crash_result = CreateCrashReport(
@@ -531,15 +548,18 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
uid_str = NULL;
g_pCommLayer->Crash(get_crash_data_item_content(crashinfo, FILENAME_PACKAGE).c_str(), uid_str);
break;
+#undef fullname
}
+ case MW_IN_DB:
+ log("Huh, this crash is already in db?! Nothing to do");
+ break;
case MW_BLACKLISTED:
case MW_CORRUPTED:
case MW_PACKAGE_ERROR:
case MW_GPG_ERROR:
- case MW_IN_DB:
case MW_FILE_ERROR:
default:
- log("Corrupted or bad crash, deleting");
+ log("Corrupted or bad crash %s (res:%d), deleting", fullname.c_str(), (int)res);
delete_debug_dump_dir(fullname.c_str());
break;
}
@@ -859,7 +879,7 @@ int main(int argc, char** argv)
{
/* This may take a while, therefore we don't do it in init section */
FindNewDumps(DEBUG_DUMPS_DIR);
- log("Running...");
+ log("Init complete, entering main loop");
run_main_loop(pMainloop);
}
catch (CABRTException& e)
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index c3f9061a..ebd5c0fc 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -702,10 +702,6 @@ static mw_result_t SavePackageDescriptionToDebugDump(
catch (CABRTException& e)
{
error_msg("%s", e.what());
- if (e.type() == EXCEP_DD_SAVE)
- {
- return MW_FILE_ERROR;
- }
return MW_ERROR;
}
@@ -832,15 +828,16 @@ static mw_result_t SaveDebugDumpToDatabase(const char *pUUID,
mw_result_t res = FillCrashInfo(pUUID, pUID, pCrashData);
if (res == MW_OK)
{
+ const char *first = get_crash_data_item_content(pCrashData, CD_DUMPDIR).c_str();
if (row.m_sReported == "1")
{
- log("Crash is already reported");
+ log("Crash is in database already (dup of %s) and is reported", first);
return MW_REPORTED;
}
if (row.m_sCount != "1")
{
- log("Crash is in database already");
- return MW_OCCURED;
+ log("Crash is in database already (dup of %s)", first);
+ return MW_OCCURRED;
}
}
return res;
@@ -876,10 +873,6 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir,
catch (CABRTException& e)
{
error_msg("%s", e.what());
- if (e.type() == EXCEP_DD_SAVE)
- {
- return MW_FILE_ERROR;
- }
return MW_ERROR;
}
@@ -898,6 +891,13 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir,
const char *uid_str = analyzer_has_InformAllUsers(analyzer.c_str())
? "-1"
: UID.c_str();
+ /* Loads pCrashData (from the *first debugdump dir* if this one is a dup)
+ * Returns:
+ * MW_REPORTED: "the crash is flagged as reported in DB" (which also means it's a dup)
+ * MW_OCCURRED: "crash count is != 1" (iow: it is > 1 - dup)
+ * MW_OK: "crash count is 1" (iow: this is a new crash, not a dup)
+ * else: an error code
+ */
return SaveDebugDumpToDatabase(lUUID.c_str(), uid_str, time.c_str(), pDebugDumpDir, pCrashData);
}
diff --git a/src/Daemon/MiddleWare.h b/src/Daemon/MiddleWare.h
index 71d17f35..aa37e3ed 100644
--- a/src/Daemon/MiddleWare.h
+++ b/src/Daemon/MiddleWare.h
@@ -37,7 +37,7 @@ typedef enum {
MW_PACKAGE_ERROR, /**< Cannot determine package name.*/
MW_GPG_ERROR, /**< Package is not signed properly.*/
MW_REPORTED, /**< Crash is already reported.*/
- MW_OCCURED, /**< Crash occurred in the past, but it is not reported yet.*/
+ MW_OCCURRED, /**< Crash occurred in the past, but it is not reported yet.*/
MW_IN_DB, /**< Debugdump directory is already saved in a database.*/
MW_IN_DB_ERROR, /**< Error while working with a database.*/
MW_PLUGIN_ERROR, /**< plugin wasn't found or error within plugin*/
@@ -105,8 +105,11 @@ report_status_t Report(const map_crash_data_t& pCrashData,
std::string getDebugDumpDir( const char *pUUID,
const char *pUID);
/**
- * Saves debugdump into database. If saving is successful,
- * it fills crash info.
+ * Adds package name and description to debugdump dir.
+ * Saves debugdump into database.
+ * Detects whether it's a duplicate crash.
+ * Fills crash info.
+ * Note that if it's a dup, loads _first crash_ info, not this one's.
* @param pDebugDumpDir A debugdump directory.
* @param pCrashData A crash info.
* @return It return results of operation. See mw_result_t.