summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-06-22 01:34:51 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-06-22 01:34:51 +0000
commit1a2e7943da42619730e442d1ff6ab08b9c2c621d (patch)
tree77d8548772fffbeb0f7312c548e1a5af9d8a6f67
parentdc910eeb1f381a883ad9e1617a7f72efd04a2d46 (diff)
Fix handling of name_listeners without a sender
-rw-r--r--common/dbus.c20
-rw-r--r--common/dbus.h1
2 files changed, 19 insertions, 2 deletions
diff --git a/common/dbus.c b/common/dbus.c
index ef3188d9..17f340b6 100644
--- a/common/dbus.c
+++ b/common/dbus.c
@@ -88,7 +88,8 @@ static struct name_data *name_data_find(const char *name)
{
GSList *current;
- for (current = name_listeners; current != NULL; current = current->next) {
+ for (current = name_listeners;
+ current != NULL; current = current->next) {
struct name_data *data = current->data;
if (strcmp(name, data->name) == 0)
return data;
@@ -98,7 +99,7 @@ static struct name_data *name_data_find(const char *name)
}
static struct name_callback *name_callback_find(GSList *callbacks,
- name_cb_t func, void *user_data)
+ name_cb_t func, void *user_data)
{
GSList *current;
@@ -228,6 +229,9 @@ int name_listener_add(DBusConnection *connection, const char *name,
name_listener_initialized = 1;
}
+ if (!name)
+ return -1;
+
first = name_data_add(name, func, user_data);
/* The filter is already added if this is not the first callback
* registration for the name */
@@ -262,6 +266,9 @@ int name_listener_remove(DBusConnection *connection, const char *name,
DBusError err;
char match_string[128];
+ if (!name)
+ return -1;
+
debug("name_listener_remove(%s)", name);
data = name_data_find(name);
@@ -302,6 +309,11 @@ int name_listener_remove(DBusConnection *connection, const char *name,
return 0;
}
+int name_listener_indicate_disconnect(DBusConnection *connection)
+{
+ return 0;
+}
+
dbus_bool_t dbus_bus_get_unix_process_id(DBusConnection *conn, const char *name,
unsigned long *pid)
{
@@ -598,6 +610,8 @@ static void dispatch_status_cb(DBusConnection *conn,
void setup_dbus_server_with_main_loop(DBusServer *server)
{
#ifdef HAVE_DBUS_GLIB
+ debug("Using D-Bus GLib server setup");
+
dbus_server_setup_with_g_main(server, NULL);
#else
dbus_server_allocate_data_slot(&server_slot);
@@ -617,6 +631,8 @@ void setup_dbus_server_with_main_loop(DBusServer *server)
void setup_dbus_with_main_loop(DBusConnection *conn)
{
#ifdef HAVE_DBUS_GLIB
+ debug("Using D-Bus GLib connection setup");
+
dbus_connection_setup_with_g_main(conn, NULL);
#else
dbus_connection_set_watch_functions(conn, add_watch, remove_watch,
diff --git a/common/dbus.h b/common/dbus.h
index 23448cf7..e91fd3cf 100644
--- a/common/dbus.h
+++ b/common/dbus.h
@@ -46,6 +46,7 @@ int name_listener_add(DBusConnection *connection, const char *name,
name_cb_t func, void *user_data);
int name_listener_remove(DBusConnection *connection, const char *name,
name_cb_t func, void *user_data);
+int name_listener_indicate_disconnect(DBusConnection *connection);
dbus_bool_t dbus_bus_get_unix_process_id(DBusConnection *conn, const char *name,
unsigned long *pid);