summaryrefslogtreecommitdiffstats
path: root/src/daemon
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-12-06 16:56:50 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-12-06 16:56:50 +0100
commit47728cc3c70c2b6d3a645e5760b39b20bd946e39 (patch)
tree6fd64dc8d124d5a10dd4efddd69a71f921f4a1d1 /src/daemon
parent300a498bdc7b2912f8aaebeb87a7b4cc0a9970a5 (diff)
downloadabrt-47728cc3c70c2b6d3a645e5760b39b20bd946e39.tar.gz
abrt-47728cc3c70c2b6d3a645e5760b39b20bd946e39.tar.xz
abrt-47728cc3c70c2b6d3a645e5760b39b20bd946e39.zip
This patch changes crash data to use C structures.
The smallest data element is: struct crash_item { char *content; unsigned flags; }; where content is, eh, content, and flags is a bit flag field. crash_data_t is a map of crash_item's, implemented as a pointer to heap-allocated GHashTable. vector_of_crash_data_t is a vector of crash_data_t's, implemented as a pointer to heap-allocated GPtrArray. Most operations have light wrappers around them to hide the nature of the containers. For example, to free vector_of_crash_data, you need to use free_vector_of_crash_data(ptr) instead of open-coding g_ptr_array_free. The wrapper is thin. The goal is not so much to hide the implementation, but more to make it easier to use the correct function. dbus (un)marshalling functions convert crash_item to three-element array of strings, in order to keep compatibility with abrt-gui (python). This can be changed later to use native representation. crash_data_t and vector_of_crash_data_t are represented in "natural" way, no funny stuff there. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/CommLayerServerDBus.cpp56
-rw-r--r--src/daemon/Daemon.cpp24
-rw-r--r--src/daemon/Makefile.am2
-rw-r--r--src/daemon/MiddleWare.cpp132
-rw-r--r--src/daemon/MiddleWare.h9
5 files changed, 121 insertions, 102 deletions
diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp
index 28d6ee05..14f132b3 100644
--- a/src/daemon/CommLayerServerDBus.cpp
+++ b/src/daemon/CommLayerServerDBus.cpp
@@ -144,11 +144,12 @@ static long get_remote_uid(DBusMessage* call, const char** ppSender = NULL)
static int handle_GetCrashInfos(DBusMessage* call, DBusMessage* reply)
{
long unix_uid = get_remote_uid(call);
- vector_map_crash_data_t argout1 = GetCrashInfos(unix_uid);
+ vector_of_crash_data_t *argout1 = GetCrashInfos(unix_uid);
DBusMessageIter out_iter;
dbus_message_iter_init_append(reply, &out_iter);
- store_val(&out_iter, argout1);
+ store_vector_of_crash_data(&out_iter, argout1);
+ free_vector_of_crash_data(argout1);
send_flush_and_unref(reply);
return 0;
@@ -197,12 +198,12 @@ static int handle_CreateReport(DBusMessage* call, DBusMessage* reply)
}
long unix_uid = get_remote_uid(call);
- map_crash_data_t report;
- CreateReport(crash_id, unix_uid, /*force:*/ 0, report);
+ crash_data_t *report = NULL;
+ CreateReport(crash_id, unix_uid, /*force:*/ 0, &report);
DBusMessageIter out_iter;
dbus_message_iter_init_append(reply, &out_iter);
- store_val(&out_iter, report);
+ store_crash_data(&out_iter, report);
send_flush_and_unref(reply);
return 0;
@@ -211,19 +212,28 @@ static int handle_CreateReport(DBusMessage* call, DBusMessage* reply)
static int handle_Report(DBusMessage* call, DBusMessage* reply)
{
int r;
+ long unix_uid;
+ report_status_t argout1;
+ map_map_string_t user_conf_data;
+ vector_string_t events;
+ const char* comment = NULL;
+ const char* reproduce = NULL;
+ const char* errmsg = NULL;
DBusMessageIter in_iter;
+
dbus_message_iter_init(call, &in_iter);
- map_crash_data_t argin1;
- r = load_val(&in_iter, argin1);
+ crash_data_t *crash_data = NULL;
+ r = load_crash_data(&in_iter, &crash_data);
if (r != ABRT_DBUS_MORE_FIELDS)
{
error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
- return -1;
+ r = -1;
+ goto ret;
}
- const char* comment = get_crash_data_item_content_or_NULL(argin1, FILENAME_COMMENT) ? : "";
- const char* reproduce = get_crash_data_item_content_or_NULL(argin1, FILENAME_REPRODUCE) ? : "";
- const char* errmsg = NULL;
+//TODO? get_crash_item_content_or_die_or_empty?
+ comment = get_crash_item_content_or_NULL(crash_data, FILENAME_COMMENT) ? : "";
+ reproduce = get_crash_item_content_or_NULL(crash_data, FILENAME_REPRODUCE) ? : "";
if (strlen(comment) > LIMIT_MESSAGE)
{
errmsg = _("Comment is too long");
@@ -239,35 +249,35 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply)
if (!reply)
die_out_of_memory();
send_flush_and_unref(reply);
- return 0;
+ r = 0;
+ goto ret;
}
/* Second parameter: list of events to run */
- vector_string_t events;
r = load_val(&in_iter, events);
if (r == ABRT_DBUS_ERROR)
{
error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
- return -1;
+ r = -1;
+ goto ret;
}
/* Third parameter (optional): configuration data for plugins */
- map_map_string_t user_conf_data;
if (r == ABRT_DBUS_MORE_FIELDS)
{
r = load_val(&in_iter, user_conf_data);
if (r != ABRT_DBUS_LAST_FIELD)
{
error_msg("dbus call %s: parameter type mismatch", __func__ + 7);
- return -1;
+ r = -1;
+ goto ret;
}
}
- long unix_uid = get_remote_uid(call);
- report_status_t argout1;
+ unix_uid = get_remote_uid(call);
try
{
- argout1 = Report(argin1, events, user_conf_data, unix_uid);
+ argout1 = Report(crash_data, events, user_conf_data, unix_uid);
}
catch (CABRTException &e)
{
@@ -276,7 +286,8 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply)
if (!reply)
die_out_of_memory();
send_flush_and_unref(reply);
- return 0;
+ r = 0;
+ goto ret;
}
DBusMessageIter out_iter;
@@ -284,7 +295,10 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply)
store_val(&out_iter, argout1);
send_flush_and_unref(reply);
- return 0;
+ r = 0;
+ ret:
+ free_crash_data(crash_data);
+ return r;
}
static int handle_DeleteDebugDump(DBusMessage* call, DBusMessage* reply)
diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp
index 609b0b26..62bcdc68 100644
--- a/src/daemon/Daemon.cpp
+++ b/src/daemon/Daemon.cpp
@@ -55,15 +55,15 @@ using namespace std;
* - signal: we got SIGTERM or SIGINT
*
* DBus methods we have:
- * - GetCrashInfos(): returns a vector_map_crash_data_t (vector_map_vector_string_t)
+ * - GetCrashInfos(): returns a vector_of_crash_data
* of crashes for given uid
* v[N]["executable"/"uid"/"kernel"/"backtrace"][N] = "contents"
* - StartJob(crash_id,force): starts creating a report for /var/spool/abrt/DIR with this UID:UUID.
* Returns job id (uint64).
* After thread returns, when report creation thread has finished,
* JobDone() dbus signal is emitted.
- * - CreateReport(crash_id): returns map_crash_data_t (map_vector_string_t)
- * - Report(map_crash_data_t (map_vector_string_t[, map_map_string_t])):
+ * - CreateReport(crash_id): returns crash data (hash table of struct crash_item)
+ * - Report(crash_data[, map_map_string_t]):
* "Please report this crash": calls Report() of all registered reporter plugins.
* Returns report_status_t (map_vector_string_t) - the status of each call.
* 2nd parameter is the contents of user's abrt.conf.
@@ -542,11 +542,11 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
}
char *fullname = NULL;
+ crash_data_t *crash_data = NULL;
try
{
fullname = concat_path_file(DEBUG_DUMPS_DIR, name);
- map_crash_data_t crashinfo;
- mw_result_t res = LoadDebugDump(fullname, crashinfo);
+ mw_result_t res = LoadDebugDump(fullname, &crash_data);
switch (res)
{
case MW_OK:
@@ -557,24 +557,24 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
{
if (res != MW_OK)
{
- const char *first = get_crash_data_item_content_or_NULL(crashinfo, CD_DUMPDIR);
+ const char *first = get_crash_item_content_or_NULL(crash_data, CD_DUMPDIR);
log("Deleting crash %s (dup of %s), sending dbus signal",
strrchr(fullname, '/') + 1,
strrchr(first, '/') + 1);
delete_crash_dump_dir(fullname);
}
- const char *uid_str = get_crash_data_item_content_or_NULL(crashinfo, FILENAME_UID);
- const char *inform_all = get_crash_data_item_content_or_NULL(crashinfo, FILENAME_INFORMALL);
+ const char *uid_str = get_crash_item_content_or_NULL(crash_data, FILENAME_UID);
+ const char *inform_all = get_crash_item_content_or_NULL(crash_data, FILENAME_INFORMALL);
if (inform_all && string_to_bool(inform_all))
uid_str = NULL;
char *crash_id = xasprintf("%s:%s",
- get_crash_data_item_content_or_NULL(crashinfo, FILENAME_UID),
- get_crash_data_item_content_or_NULL(crashinfo, FILENAME_UUID)
+ get_crash_item_content_or_NULL(crash_data, FILENAME_UID),
+ get_crash_item_content_or_NULL(crash_data, FILENAME_UUID)
);
/* Send dbus signal */
- g_pCommLayer->Crash(get_crash_data_item_content_or_NULL(crashinfo, FILENAME_PACKAGE),
+ g_pCommLayer->Crash(get_crash_item_content_or_NULL(crash_data, FILENAME_PACKAGE),
crash_id, //TODO: stop passing this param, it is unused
fullname,
uid_str
@@ -598,9 +598,11 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
{
free(fullname);
free(buf);
+ free_crash_data(crash_data);
throw;
}
free(fullname);
+ free_crash_data(crash_data);
} /* while */
free(buf);
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index 34c7aa7b..d25a21b1 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -52,6 +52,7 @@ abrt_server_CPPFLAGS = \
-DDEBUG_INFO_DIR=\"$(DEBUG_INFO_DIR)\" \
-DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
-DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
+ $(GLIB_CFLAGS) \
-D_GNU_SOURCE \
-Wall -Werror
abrt_server_LDADD = \
@@ -71,6 +72,7 @@ abrt_handle_crashdump_CPPFLAGS = \
-DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
-DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
-DLIBEXEC_DIR=\"$(LIBEXEC_DIR)\" \
+ $(GLIB_CFLAGS) \
-D_GNU_SOURCE \
-Wall -Werror
abrt_handle_crashdump_LDADD = \
diff --git a/src/daemon/MiddleWare.cpp b/src/daemon/MiddleWare.cpp
index 22e49620..6abf019e 100644
--- a/src/daemon/MiddleWare.cpp
+++ b/src/daemon/MiddleWare.cpp
@@ -43,8 +43,7 @@ CPluginManager* g_pPluginManager;
* @param pCrashData A crash info.
* @return It return results of operation. See mw_result_t.
*/
-static mw_result_t FillCrashInfo(const char *dump_dir_name,
- map_crash_data_t& pCrashData);
+static crash_data_t *FillCrashInfo(const char *dump_dir_name);
/**
* Transforms a debugdump directory to inner crash
@@ -52,13 +51,13 @@ static mw_result_t FillCrashInfo(const char *dump_dir_name,
* @param dump_dir_name A debugdump dir containing all necessary data.
* @param pCrashData A created crash report.
*/
-static bool DebugDumpToCrashReport(const char *dump_dir_name, map_crash_data_t& pCrashData)
+static crash_data_t *DebugDumpToCrashReport(const char *dump_dir_name)
{
VERB3 log(" DebugDumpToCrashReport('%s')", dump_dir_name);
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (!dd)
- return false;
+ return NULL;
static const char *const must_have_files[] = {
FILENAME_ARCHITECTURE,
@@ -76,21 +75,21 @@ static bool DebugDumpToCrashReport(const char *dump_dir_name, map_crash_data_t&
{
dd_close(dd);
log("Important file '%s/%s' is missing", dump_dir_name, *v);
- return false;
+ return NULL;
}
v++;
}
- load_crash_data_from_crash_dump_dir(dd, pCrashData);
+ crash_data_t *crash_data = load_crash_data_from_crash_dump_dir(dd);
char *events = list_possible_events(dd, NULL, "");
dd_close(dd);
- add_to_crash_data_ext(pCrashData, CD_EVENTS, CD_SYS, CD_ISNOTEDITABLE, events);
+ add_to_crash_data_ext(crash_data, CD_EVENTS, events, CD_FLAG_SYS + CD_FLAG_ISNOTEDITABLE);
free(events);
- add_to_crash_data_ext(pCrashData, CD_DUMPDIR, CD_SYS, CD_ISNOTEDITABLE, dump_dir_name);
+ add_to_crash_data_ext(crash_data, CD_DUMPDIR, dump_dir_name, CD_FLAG_SYS + CD_FLAG_ISNOTEDITABLE);
- return true;
+ return crash_data;
}
static char *do_log_and_update_client(char *log_line, void *param)
@@ -118,9 +117,11 @@ static char *do_log_and_update_client(char *log_line, void *param)
static mw_result_t CreateCrashReport(const char *dump_dir_name,
long caller_uid,
int force,
- map_crash_data_t& pCrashData)
+ crash_data_t **crash_data)
{
- VERB2 log("CreateCrashReport('%s',%ld,result)", dump_dir_name, caller_uid);
+ VERB2 log("CreateCrashReport('%s',%ld)", dump_dir_name, caller_uid);
+
+ *crash_data = NULL;
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (!dd)
@@ -165,7 +166,8 @@ static mw_result_t CreateCrashReport(const char *dump_dir_name,
/* Do a load_crash_data_from_crash_dump_dir from (possibly updated)
* crash dump dir
*/
- if (!DebugDumpToCrashReport(dump_dir_name, pCrashData))
+ *crash_data = DebugDumpToCrashReport(dump_dir_name);
+ if (!*crash_data)
{
error_msg("Error loading crash data");
r = MW_ERROR;
@@ -224,23 +226,22 @@ static char *do_log_and_save_line(char *log_line, void *param)
// Do not trust client_report here!
// dbus handler passes it from user without checking
-report_status_t Report(const map_crash_data_t& client_report,
+report_status_t Report(crash_data_t *client_report,
const vector_string_t& events,
const map_map_string_t& settings,
long caller_uid)
{
// Get ID fields
- const char *UID = get_crash_data_item_content_or_NULL(client_report, FILENAME_UID);
- const char *dump_dir_name = get_crash_data_item_content_or_NULL(client_report, CD_DUMPDIR);
+ const char *UID = get_crash_item_content_or_NULL(client_report, FILENAME_UID);
+ const char *dump_dir_name = get_crash_item_content_or_NULL(client_report, CD_DUMPDIR);
if (!UID || !dump_dir_name)
{
throw CABRTException(EXCEP_ERROR, "Report(): UID or DUMPDIR is missing in client's report data");
}
// Retrieve corresponding stored record
- map_crash_data_t stored_report;
- mw_result_t r = FillCrashInfo(dump_dir_name, stored_report);
- if (r != MW_OK)
+ crash_data_t *stored_report = FillCrashInfo(dump_dir_name);
+ if (!stored_report)
{
return report_status_t();
}
@@ -249,18 +250,21 @@ report_status_t Report(const map_crash_data_t& client_report,
if (caller_uid != 0 // not called by root
&& strcmp(to_string(caller_uid).c_str(), UID) != 0
) {
- const char *inform_all = get_crash_data_item_content_or_NULL(stored_report, FILENAME_INFORMALL);
+ const char *inform_all = get_crash_item_content_or_NULL(stored_report, FILENAME_INFORMALL);
if (!inform_all || !string_to_bool(inform_all))
+ {
+ free_crash_data(stored_report);
throw CABRTException(EXCEP_ERROR, "Report(): user with uid %ld can't report crash %s",
caller_uid, dump_dir_name);
+ }
}
// Save comment, "how to reproduce", backtrace
//TODO: we should iterate through stored_report and modify all
//modifiable fields which have new data in client_report
- const char *comment = get_crash_data_item_content_or_NULL(client_report, FILENAME_COMMENT);
- const char *reproduce = get_crash_data_item_content_or_NULL(client_report, FILENAME_REPRODUCE);
- const char *backtrace = get_crash_data_item_content_or_NULL(client_report, FILENAME_BACKTRACE);
+ const char *comment = get_crash_item_content_or_NULL(client_report, FILENAME_COMMENT);
+ const char *reproduce = get_crash_item_content_or_NULL(client_report, FILENAME_REPRODUCE);
+ const char *backtrace = get_crash_item_content_or_NULL(client_report, FILENAME_BACKTRACE);
if (comment || reproduce || backtrace)
{
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
@@ -269,45 +273,47 @@ report_status_t Report(const map_crash_data_t& client_report,
if (comment)
{
dd_save_text(dd, FILENAME_COMMENT, comment);
- add_to_crash_data_ext(stored_report, FILENAME_COMMENT, CD_TXT, CD_ISEDITABLE, comment);
+ add_to_crash_data_ext(stored_report, FILENAME_COMMENT, comment, CD_FLAG_TXT + CD_FLAG_ISEDITABLE);
}
if (reproduce)
{
dd_save_text(dd, FILENAME_REPRODUCE, reproduce);
- add_to_crash_data_ext(stored_report, FILENAME_REPRODUCE, CD_TXT, CD_ISEDITABLE, reproduce);
+ add_to_crash_data_ext(stored_report, FILENAME_REPRODUCE, reproduce, CD_FLAG_TXT + CD_FLAG_ISEDITABLE);
}
if (backtrace)
{
dd_save_text(dd, FILENAME_BACKTRACE, backtrace);
- add_to_crash_data_ext(stored_report, FILENAME_BACKTRACE, CD_TXT, CD_ISEDITABLE, backtrace);
+ add_to_crash_data_ext(stored_report, FILENAME_BACKTRACE, backtrace, CD_FLAG_TXT + CD_FLAG_ISEDITABLE);
}
dd_close(dd);
}
}
/* Remove BIN filenames from stored_report if they are not present in client's data */
- map_crash_data_t::const_iterator its = stored_report.begin();
- while (its != stored_report.end())
+ GHashTableIter iter;
+ char *name;
+ struct crash_item *value;
+ g_hash_table_iter_init(&iter, stored_report);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
{
- if (its->second[CD_TYPE] == CD_BIN)
+ if (value->flags & CD_FLAG_BIN)
{
- std::string key = its->first;
- if (get_crash_data_item_content_or_NULL(client_report, key.c_str()) == NULL)
+ if (get_crash_item_content_or_NULL(client_report, name) == NULL)
{
/* client does not have it -> does not want it passed to events */
- VERB3 log("Won't report BIN file %s:'%s'", key.c_str(), its->second[CD_CONTENT].c_str());
- its++; /* move off the element we will erase */
- stored_report.erase(key);
+ VERB3 log("Won't report BIN file %s:'%s'", name, value->content);
+ g_hash_table_iter_remove(&iter);
continue;
}
}
- its++;
}
VERB3 {
log_map_crash_data(client_report, " client_report");
log_map_crash_data(stored_report, " stored_report");
}
+ free_crash_data(stored_report);
+#define stored_report stored_report_must_not_be_used_below
#define client_report client_report_must_not_be_used_below
// Export overridden settings as environment variables
@@ -409,6 +415,7 @@ report_status_t Report(const map_crash_data_t& client_report,
}
return ret;
+#undef stored_report
#undef client_report
}
@@ -489,8 +496,7 @@ static char *do_log(char *log_line, void *param)
return log_line;
}
-mw_result_t LoadDebugDump(const char *dump_dir_name,
- map_crash_data_t& pCrashData)
+mw_result_t LoadDebugDump(const char *dump_dir_name, crash_data_t **crash_data)
{
mw_result_t res;
@@ -546,7 +552,7 @@ mw_result_t LoadDebugDump(const char *dump_dir_name,
dump_dir_name = state.crash_dump_dup_name;
}
- /* Loads pCrashData (from the *first debugdump dir* if this one is a dup)
+ /* Loads crash_data (from the *first debugdump dir* if this one is a dup)
* Returns:
* 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)
@@ -567,9 +573,10 @@ mw_result_t LoadDebugDump(const char *dump_dir_name,
dd_save_text(dd, FILENAME_COUNT, new_count_str);
dd_close(dd);
- res = FillCrashInfo(dump_dir_name, pCrashData);
- if (res == MW_OK)
+ *crash_data = FillCrashInfo(dump_dir_name);
+ if (*crash_data != NULL)
{
+ res = MW_OK;
if (count > 1)
{
log("Crash dump is a duplicate of %s", dump_dir_name);
@@ -587,28 +594,27 @@ mw_result_t LoadDebugDump(const char *dump_dir_name,
return res;
}
-static mw_result_t FillCrashInfo(const char *dump_dir_name,
- map_crash_data_t& pCrashData)
+static crash_data_t *FillCrashInfo(const char *dump_dir_name)
{
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (!dd)
- return MW_ERROR;
+ return NULL;
- load_crash_data_from_crash_dump_dir(dd, pCrashData);
+ crash_data_t *crash_data = load_crash_data_from_crash_dump_dir(dd);
char *events = list_possible_events(dd, NULL, "");
dd_close(dd);
- add_to_crash_data_ext(pCrashData, CD_EVENTS, CD_SYS, CD_ISNOTEDITABLE, events);
+ add_to_crash_data_ext(crash_data, CD_EVENTS, events, CD_FLAG_SYS + CD_FLAG_ISNOTEDITABLE);
free(events);
- add_to_crash_data_ext(pCrashData, CD_DUMPDIR, CD_SYS, CD_ISNOTEDITABLE, dump_dir_name);
+ add_to_crash_data_ext(crash_data, CD_DUMPDIR, dump_dir_name, CD_FLAG_SYS + CD_FLAG_ISNOTEDITABLE);
- return MW_OK;
+ return crash_data;
}
-vector_map_crash_data_t GetCrashInfos(long caller_uid)
+vector_of_crash_data_t *GetCrashInfos(long caller_uid)
{
- vector_map_crash_data_t retval;
+ vector_of_crash_data_t *retval = new_vector_of_crash_data();
log("Getting crash infos...");
DIR *dir = opendir(DEBUG_DUMPS_DIR);
@@ -658,19 +664,15 @@ vector_map_crash_data_t GetCrashInfos(long caller_uid)
}
{
- map_crash_data_t info;
- mw_result_t res = FillCrashInfo(dump_dir_name, info);
- switch (res)
+ crash_data_t *crash_data = FillCrashInfo(dump_dir_name);
+ if (!crash_data)
+ {
+ error_msg("Dump directory %s doesn't exist or misses crucial files, deleting", dump_dir_name);
+ delete_crash_dump_dir(dump_dir_name);
+ }
+ else
{
- case MW_OK:
- retval.push_back(info);
- break;
- case MW_ERROR:
- error_msg("Dump directory %s doesn't exist or misses crucial files, deleting", dump_dir_name);
- delete_crash_dump_dir(dump_dir_name);
- break;
- default:
- break;
+ g_ptr_array_add(retval, crash_data);
}
}
next:
@@ -695,14 +697,14 @@ vector_map_crash_data_t GetCrashInfos(long caller_uid)
* StartJob dbus call already did all the processing, and we just retrieve
* the result from dump directory, which is fast.
*/
-void CreateReport(const char* crash_id, long caller_uid, int force, map_crash_data_t& crashReport)
+void CreateReport(const char* crash_id, long caller_uid, int force, crash_data_t **crash_data)
{
/* FIXME: starting from here, any shared data must be protected with a mutex. */
- mw_result_t res = CreateCrashReport(crash_id, caller_uid, force, crashReport);
+ mw_result_t res = CreateCrashReport(crash_id, caller_uid, force, crash_data);
switch (res)
{
case MW_OK:
- VERB2 log_map_crash_data(crashReport, "crashReport");
+ VERB2 log_map_crash_data(*crash_data, "crashReport");
break;
case MW_NOENT_ERROR:
error_msg("Can't find crash with id '%s'", crash_id);
@@ -737,8 +739,8 @@ static void* create_report(void* arg)
try
{
log("Creating report...");
- map_crash_data_t crashReport;
- CreateReport(thread_data->crash_id, thread_data->caller_uid, thread_data->force, crashReport);
+ crash_data_t *crash_data = NULL;
+ CreateReport(thread_data->crash_id, thread_data->caller_uid, thread_data->force, &crash_data);
g_pCommLayer->JobDone(thread_data->peer);
}
catch (CABRTException& e)
diff --git a/src/daemon/MiddleWare.h b/src/daemon/MiddleWare.h
index 78c6a839..55c84c3b 100644
--- a/src/daemon/MiddleWare.h
+++ b/src/daemon/MiddleWare.h
@@ -71,7 +71,7 @@ void RunAction(const char *pActionDir,
* @return
* A report status, which reporters ends successfuly with messages.
*/
-report_status_t Report(const map_crash_data_t& crash_data,
+report_status_t Report(crash_data_t *crash_data,
const vector_string_t& events,
const map_map_string_t& settings,
long caller_uid);
@@ -83,12 +83,11 @@ report_status_t Report(const map_crash_data_t& crash_data,
* @param pCrashData A crash info.
* @return It return results of operation. See mw_result_t.
*/
-mw_result_t LoadDebugDump(const char *dump_dir_name,
- map_crash_data_t& pCrashData);
+mw_result_t LoadDebugDump(const char *dump_dir_name, crash_data_t **crash_data);
-vector_map_crash_data_t GetCrashInfos(long caller_uid);
+vector_of_crash_data_t *GetCrashInfos(long caller_uid);
int CreateReportThread(const char* dump_dir_name, long caller_uid, int force, const char* pSender);
-void CreateReport(const char* dump_dir_name, long caller_uid, int force, map_crash_data_t&);
+void CreateReport(const char* dump_dir_name, long caller_uid, int force, crash_data_t **crash_data);
int DeleteDebugDump(const char *dump_dir_name, long caller_uid);
void GetPluginsInfo(map_map_string_t &map_of_plugin_info);