From 47728cc3c70c2b6d3a645e5760b39b20bd946e39 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 6 Dec 2010 16:56:50 +0100 Subject: 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 --- src/daemon/CommLayerServerDBus.cpp | 56 ++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'src/daemon/CommLayerServerDBus.cpp') 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) -- cgit From 816f3e001271ed8ab7fdadb6d90aeb2c61362dac Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 8 Dec 2010 14:51:47 +0100 Subject: removal of C++isms from libabrt, part 1 This patch converts libabrt usage of C++ map to a glib-based container, GHashTable. It is typedef-ed to map_string_h. We can't typedef it to map_string_t, since other parts of ABRT (daemon, cli) still use that name for C++ container. Also, exceptions are removed everywhere. Signed-off-by: Denys Vlasenko --- src/daemon/CommLayerServerDBus.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/daemon/CommLayerServerDBus.cpp') diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp index 14f132b3..b9b7f20b 100644 --- a/src/daemon/CommLayerServerDBus.cpp +++ b/src/daemon/CommLayerServerDBus.cpp @@ -19,7 +19,6 @@ #include #include "abrtlib.h" #include "abrt_dbus.h" -#include "abrt_exception.h" #include "comm_layer_inner.h" #include "dbus_common.h" #include "MiddleWare.h" @@ -275,20 +274,7 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply) } unix_uid = get_remote_uid(call); - try - { - argout1 = Report(crash_data, events, user_conf_data, unix_uid); - } - catch (CABRTException &e) - { - dbus_message_unref(reply); - reply = dbus_message_new_error(call, DBUS_ERROR_FAILED, e.what()); - if (!reply) - die_out_of_memory(); - send_flush_and_unref(reply); - r = 0; - goto ret; - } + argout1 = Report(crash_data, events, user_conf_data, unix_uid); DBusMessageIter out_iter; dbus_message_iter_init_append(reply, &out_iter); @@ -353,12 +339,13 @@ static int handle_GetPluginSettings(DBusMessage* call, DBusMessage* reply) //long unix_uid = get_remote_uid(call); //VERB1 log("got %s('%s') call from uid %ld", "GetPluginSettings", PluginName, unix_uid); - map_plugin_settings_t plugin_settings; - GetPluginSettings(PluginName, plugin_settings); + map_string_h *plugin_settings = GetPluginSettings(PluginName); DBusMessageIter out_iter; dbus_message_iter_init_append(reply, &out_iter); - store_val(&out_iter, plugin_settings); + store_map_string(&out_iter, plugin_settings); + + free_map_string(plugin_settings); send_flush_and_unref(reply); return 0; -- cgit From 21b7afb11405bc7ff24b43e6f441a40faff3a539 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 17:19:18 +0100 Subject: disable SetSettings dbus call code Signed-off-by: Denys Vlasenko --- src/daemon/CommLayerServerDBus.cpp | 45 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'src/daemon/CommLayerServerDBus.cpp') diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp index b9b7f20b..477e25d9 100644 --- a/src/daemon/CommLayerServerDBus.cpp +++ b/src/daemon/CommLayerServerDBus.cpp @@ -363,25 +363,25 @@ static int handle_GetSettings(DBusMessage* call, DBusMessage* reply) return 0; } -static int handle_SetSettings(DBusMessage* call, DBusMessage* reply) -{ - int r; - DBusMessageIter in_iter; - dbus_message_iter_init(call, &in_iter); - map_abrt_settings_t param1; - r = load_val(&in_iter, param1); - if (r != ABRT_DBUS_LAST_FIELD) - { - error_msg("dbus call %s: parameter type mismatch", __func__ + 7); - return -1; - } - - const char * sender = dbus_message_get_sender(call); - SetSettings(param1, sender); - - send_flush_and_unref(reply); - return 0; -} +//static int handle_SetSettings(DBusMessage* call, DBusMessage* reply) +//{ +// int r; +// DBusMessageIter in_iter; +// dbus_message_iter_init(call, &in_iter); +// map_abrt_settings_t param1; +// r = load_val(&in_iter, param1); +// if (r != ABRT_DBUS_LAST_FIELD) +// { +// error_msg("dbus call %s: parameter type mismatch", __func__ + 7); +// return -1; +// } +// +// const char * sender = dbus_message_get_sender(call); +// SetSettings(param1, sender); +// +// send_flush_and_unref(reply); +// return 0; +//} /* @@ -414,8 +414,11 @@ static DBusHandlerResult message_received(DBusConnection* conn, DBusMessage* msg r = handle_GetPluginSettings(msg, reply); else if (strcmp(member, "GetSettings") == 0) r = handle_GetSettings(msg, reply); - else if (strcmp(member, "SetSettings") == 0) - r = handle_SetSettings(msg, reply); +// looks unused to me. +// Ok to grep for SetSettings and delete after 2011-04-01. +// else if (strcmp(member, "SetSettings") == 0) +// r = handle_SetSettings(msg, reply); + // NB: C++ binding also handles "Introspect" method, which returns a string. // It was sending "dummy" introspection answer whick looks like this: // " Date: Fri, 21 Jan 2011 17:33:43 +0100 Subject: s/QuotaExceed/QuotaExceeded/g Signed-off-by: Denys Vlasenko --- src/daemon/CommLayerServerDBus.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/daemon/CommLayerServerDBus.cpp') diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp index 477e25d9..654a1ad4 100644 --- a/src/daemon/CommLayerServerDBus.cpp +++ b/src/daemon/CommLayerServerDBus.cpp @@ -83,13 +83,13 @@ void CCommLayerServerDBus::Crash(const char *package_name, send_flush_and_unref(msg); } -void CCommLayerServerDBus::QuotaExceed(const char* str) +void CCommLayerServerDBus::QuotaExceeded(const char* str) { - DBusMessage* msg = new_signal_msg("QuotaExceed"); + DBusMessage* msg = new_signal_msg("QuotaExceeded"); dbus_message_append_args(msg, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID); - VERB2 log("Sending signal QuotaExceed('%s')", str); + VERB2 log("Sending signal QuotaExceeded('%s')", str); send_flush_and_unref(msg); } -- cgit From 5d3a66f0b6cc2e9fd6a5dc5815d65d6708050ccc Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 21 Jan 2011 17:34:29 +0100 Subject: remove CCommLayerServer[DBus] classes Signed-off-by: Denys Vlasenko --- src/daemon/CommLayerServerDBus.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/daemon/CommLayerServerDBus.cpp') diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp index 654a1ad4..be1f30f3 100644 --- a/src/daemon/CommLayerServerDBus.cpp +++ b/src/daemon/CommLayerServerDBus.cpp @@ -23,7 +23,6 @@ #include "dbus_common.h" #include "MiddleWare.h" #include "Settings.h" -#include "Daemon.h" #include "CommLayerServerDBus.h" // 16kB message limit @@ -47,6 +46,11 @@ static DBusMessage* new_signal_msg(const char* member, const char* peer = NULL) } static void send_flush_and_unref(DBusMessage* msg) { + if (!g_dbus_conn) + { + /* Not logging this, it may recurse */ + return; + } if (!dbus_connection_send(g_dbus_conn, msg, NULL /* &serial */)) error_msg_and_die("Error sending DBus message"); dbus_connection_flush(g_dbus_conn); @@ -55,7 +59,7 @@ static void send_flush_and_unref(DBusMessage* msg) } /* Notify the clients (UI) about a new crash */ -void CCommLayerServerDBus::Crash(const char *package_name, +void send_dbus_sig_Crash(const char *package_name, const char *crash_id, const char *dir, const char *uid_str @@ -83,7 +87,7 @@ void CCommLayerServerDBus::Crash(const char *package_name, send_flush_and_unref(msg); } -void CCommLayerServerDBus::QuotaExceeded(const char* str) +void send_dbus_sig_QuotaExceeded(const char* str) { DBusMessage* msg = new_signal_msg("QuotaExceeded"); dbus_message_append_args(msg, @@ -93,14 +97,14 @@ void CCommLayerServerDBus::QuotaExceeded(const char* str) send_flush_and_unref(msg); } -void CCommLayerServerDBus::JobDone(const char* peer) +void send_dbus_sig_JobDone(const char* peer) { DBusMessage* msg = new_signal_msg("JobDone", peer); VERB2 log("Sending signal JobDone() to peer %s", peer); send_flush_and_unref(msg); } -void CCommLayerServerDBus::Update(const char* pMessage, const char* peer) +void send_dbus_sig_Update(const char* pMessage, const char* peer) { DBusMessage* msg = new_signal_msg("Update", peer); dbus_message_append_args(msg, @@ -109,7 +113,7 @@ void CCommLayerServerDBus::Update(const char* pMessage, const char* peer) send_flush_and_unref(msg); } -void CCommLayerServerDBus::Warning(const char* pMessage, const char* peer) +void send_dbus_sig_Warning(const char* pMessage, const char* peer) { DBusMessage* msg = new_signal_msg("Warning", peer); dbus_message_append_args(msg, @@ -464,7 +468,7 @@ static void handle_dbus_err(bool error_flag, DBusError *err) ABRTD_DBUS_NAME); } -CCommLayerServerDBus::CCommLayerServerDBus() +int init_dbus() { DBusConnection* conn; DBusError err; @@ -514,9 +518,11 @@ CCommLayerServerDBus::CCommLayerServerDBus() int cnt = 10; while (dbus_connection_dispatch(conn) != DBUS_DISPATCH_COMPLETE && --cnt) VERB3 log("processed initial buffered dbus message"); + + return 0; } -CCommLayerServerDBus::~CCommLayerServerDBus() +void deinit_dbus() { dbus_connection_unref(g_dbus_conn); } -- cgit From bcd903fc77dd54e2e360375a7df7c362c7f70718 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Mon, 7 Feb 2011 14:09:39 +0100 Subject: fix problem with daemon shutdown when abrt.conf file is wrong - it gives this message abrtd: Loading settings abrtd: abrt.conf: Invalid syntax on line 38 abrtd: Error while initializing daemon process 20610: arguments to dbus_connection_unref() were incorrect, assertion "connection != NULL" failed in file dbus-connection.c line 2791. This is normally a bug in some application using the D-Bus library. D-Bus not built with -rdynamic so unable to print a backtrace Aborted --- src/daemon/CommLayerServerDBus.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/daemon/CommLayerServerDBus.cpp') diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp index be1f30f3..84c2ea15 100644 --- a/src/daemon/CommLayerServerDBus.cpp +++ b/src/daemon/CommLayerServerDBus.cpp @@ -524,5 +524,6 @@ int init_dbus() void deinit_dbus() { - dbus_connection_unref(g_dbus_conn); + if(g_dbus_conn != NULL) + dbus_connection_unref(g_dbus_conn); } -- cgit From 2abf0fc078221715abbd20c8451d300eaf787848 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 10 Feb 2011 18:04:43 +0100 Subject: abrt-gtk: make Delete key actually delete the dump dir Signed-off-by: Denys Vlasenko --- src/daemon/CommLayerServerDBus.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/daemon/CommLayerServerDBus.cpp') diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp index 84c2ea15..2a02b051 100644 --- a/src/daemon/CommLayerServerDBus.cpp +++ b/src/daemon/CommLayerServerDBus.cpp @@ -20,7 +20,6 @@ #include "abrtlib.h" #include "abrt_dbus.h" #include "comm_layer_inner.h" -#include "dbus_common.h" #include "MiddleWare.h" #include "Settings.h" #include "CommLayerServerDBus.h" @@ -524,6 +523,9 @@ int init_dbus() void deinit_dbus() { - if(g_dbus_conn != NULL) + if (g_dbus_conn != NULL) + { dbus_connection_unref(g_dbus_conn); + g_dbus_conn = NULL; + } } -- cgit From 72a31a2a391e6c37255ed08b3bdbf1c38f20d753 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 22 Feb 2011 18:17:13 +0100 Subject: gui-wizard-gtk: add forward_page_func which skips analyze step when it is missing Signed-off-by: Denys Vlasenko --- src/daemon/CommLayerServerDBus.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/daemon/CommLayerServerDBus.cpp') diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp index 2a02b051..133feb7b 100644 --- a/src/daemon/CommLayerServerDBus.cpp +++ b/src/daemon/CommLayerServerDBus.cpp @@ -488,7 +488,7 @@ int init_dbus() // // dbus-daemon drops connections if it recvs a malformed message // (we actually observed this when we sent bad UTF-8 string). - // Currently, in this case abrtd just exits with exitcode 1. + // Currently, in this case abrtd just exits with exit code 1. // (symptom: last two log messages are "abrtd: remove_watch()") // If we want to have better logging or other nontrivial handling, // here we need to do: -- cgit