diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-06-22 03:23:26 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-06-22 03:23:26 +0000 |
commit | a7a78009cae0f94cff8d16430522a8901d1c4b90 (patch) | |
tree | 8783d50bac3401aa6bdd13e5e729c533b3071d3a /hcid | |
parent | ffd959d87bdbdfc823b1e7722c09c08c61a2390f (diff) |
Handle local connection disconnects
Diffstat (limited to 'hcid')
-rw-r--r-- | hcid/dbus-database.c | 4 | ||||
-rw-r--r-- | hcid/dbus-service.c | 19 | ||||
-rw-r--r-- | hcid/dbus-service.h | 4 | ||||
-rw-r--r-- | hcid/server.c | 5 |
4 files changed, 18 insertions, 14 deletions
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c index 2f904956..8dd327d1 100644 --- a/hcid/dbus-database.c +++ b/hcid/dbus-database.c @@ -337,7 +337,7 @@ static DBusHandlerResult register_service(DBusConnection *conn, sender = dbus_message_get_sender(msg); - if (service_register(sender, ident, name, desc) < 0) + if (service_register(conn, sender, ident, name, desc) < 0) return error_failed(conn, msg, EIO); reply = dbus_message_new_method_return(msg); @@ -367,7 +367,7 @@ static DBusHandlerResult unregister_service(DBusConnection *conn, if (!service->external || strcmp(sender, service->bus_name)) return error_not_authorized(conn, msg); - if (service_unregister(service) < 0) + if (service_unregister(conn, service) < 0) return error_failed(conn, msg, EIO); reply = dbus_message_new_method_return(msg); diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c index 1fa7a96b..c7c2b766 100644 --- a/hcid/dbus-service.c +++ b/hcid/dbus-service.c @@ -727,7 +727,8 @@ static int register_service(struct service *service) return 0; } -static int unregister_service(struct service *service) +static int unregister_service_for_connection(DBusConnection *connection, + struct service *service) { DBusConnection *conn = get_dbus_connection(); @@ -737,7 +738,7 @@ static int unregister_service(struct service *service) goto cleanup; if (service->bus_name) - name_listener_remove(conn, service->bus_name, + name_listener_remove(connection, service->bus_name, (name_cb_t) service_exit, service); dbus_connection_emit_signal(conn, service->object_path, @@ -770,6 +771,11 @@ cleanup: return 0; } +static int unregister_service(struct service *service) +{ + return unregister_service_for_connection(get_dbus_connection(), service); +} + void release_services(DBusConnection *conn) { debug("release_services"); @@ -1030,10 +1036,9 @@ static void external_service_exit(const char *name, struct service *service) service_free(service); } -int service_register(const char *bus_name, const char *ident, +int service_register(DBusConnection *conn, const char *bus_name, const char *ident, const char *name, const char *description) { - DBusConnection *conn = get_dbus_connection(); struct service *service; if (!conn) @@ -1053,14 +1058,14 @@ int service_register(const char *bus_name, const char *ident, name_listener_add(conn, bus_name, (name_cb_t) external_service_exit, service); - dbus_connection_emit_signal(conn, service->object_path, + dbus_connection_emit_signal(get_dbus_connection(), service->object_path, SERVICE_INTERFACE, "Started", DBUS_TYPE_INVALID); return 0; } -int service_unregister(struct service *service) +int service_unregister(DBusConnection *conn, struct service *service) { - return unregister_service(service); + return unregister_service_for_connection(conn, service); } diff --git a/hcid/dbus-service.h b/hcid/dbus-service.h index 141d703f..ee38611c 100644 --- a/hcid/dbus-service.h +++ b/hcid/dbus-service.h @@ -59,9 +59,9 @@ int service_start(struct service *service, DBusConnection *conn); int init_services(const char *path); -int service_register(const char *bus_name, const char *ident, +int service_register(DBusConnection *conn, const char *bus_name, const char *ident, const char *name, const char *description); -int service_unregister(struct service *service); +int service_unregister(DBusConnection *conn, struct service *service); #endif /* __BLUEZ_DBUS_SERVICE_H */ diff --git a/hcid/server.c b/hcid/server.c index 49f9ff54..a9878f06 100644 --- a/hcid/server.c +++ b/hcid/server.c @@ -38,12 +38,11 @@ static DBusHandlerResult filter_function(DBusConnection *conn, { if (dbus_message_is_signal(msg, DBUS_INTERFACE_LOCAL, "Disconnected") && strcmp(dbus_message_get_path(msg), DBUS_PATH_LOCAL) == 0) { - debug("Received disconnected signal"); + debug("Received local disconnected signal"); + name_listener_indicate_disconnect(conn); return DBUS_HANDLER_RESULT_HANDLED; } - name_listener_indicate_disconnect(conn); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } |