summaryrefslogtreecommitdiffstats
path: root/src/daemon/Daemon.cpp
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/Daemon.cpp
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/Daemon.cpp')
-rw-r--r--src/daemon/Daemon.cpp24
1 files changed, 13 insertions, 11 deletions
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);