public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] Fix crash when registering / unregistering external service
@ 2008-01-16  0:34 Denis KENZIOR
  0 siblings, 0 replies; only message in thread
From: Denis KENZIOR @ 2008-01-16  0:34 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

This patch fixes a crash in hcid when an external service is registered and 
then unregistered (either via UnregisterService method or due to service 
exiting)

-Denis

[-- Attachment #2: external-service-unregister-crash-fix.patch --]
[-- Type: text/x-diff, Size: 2602 bytes --]

Index: dbus-service.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-service.c,v
retrieving revision 1.142
diff -u -5 -r1.142 dbus-service.c
--- dbus-service.c	26 Nov 2007 13:43:18 -0000	1.142
+++ dbus-service.c	16 Jan 2008 00:31:52 -0000
@@ -63,10 +63,12 @@
 #define SERVICE_SUFFIX ".service"
 #define SERVICE_GROUP "Bluetooth Service"
 
 #define NAME_MATCH "interface=" DBUS_INTERFACE_DBUS ",member=NameOwnerChanged"
 
+static void external_service_exit(const char *name, struct service *service);
+
 static GSList *services = NULL;
 static GSList *removed = NULL;
 
 static void service_free(struct service *service)
 {
@@ -758,28 +760,31 @@
 	debug("Unregistering service object: %s", service->object_path);
 
 	if (!conn)
 		goto cleanup;
 
-	if (service->bus_name)
+	if (service->bus_name) {
+		name_cb_t cb = (name_cb_t) (service->external ? 
+			external_service_exit : service_exit);
 		name_listener_remove(connection, service->bus_name,
-					(name_cb_t) service_exit, service);
+					cb, service);
+	}
 
 	dbus_connection_emit_signal(conn, service->object_path,
 					SERVICE_INTERFACE,
 					"Stopped", DBUS_TYPE_INVALID);
 
-	if (!dbus_connection_destroy_object_path(conn, service->object_path)) {
-		error("D-Bus failed to unregister %s object", service->object_path);
-		return -1;
-	}
-
 	dbus_connection_emit_signal(conn, BASE_PATH, MANAGER_INTERFACE,
 					"ServiceRemoved",
 					DBUS_TYPE_STRING, &service->object_path,
 					DBUS_TYPE_INVALID);
 
+	if (!dbus_connection_destroy_object_path(conn, service->object_path)) {
+		error("D-Bus failed to unregister %s object", service->object_path);
+		return -1;
+	}
+
 cleanup:
 	if (service->pid) {
 		if (service->startup_timer) {
 			abort_startup(service, conn, ECANCELED);
 			services = g_slist_remove(services, service);
@@ -1040,23 +1045,23 @@
 
 static void external_service_exit(const char *name, struct service *service)
 {
 	DBusConnection *conn = get_dbus_connection();
 
-	service_exit(name, service);
-
 	if (!conn)
 		return;
 
-	if (!dbus_connection_destroy_object_path(conn, service->object_path))
-		return;
+	service_exit(name, service);
 
 	dbus_connection_emit_signal(conn, BASE_PATH, MANAGER_INTERFACE,
 					"ServiceRemoved",
 					DBUS_TYPE_STRING, &service->object_path,
 					DBUS_TYPE_INVALID);
 
+	if (!dbus_connection_destroy_object_path(conn, service->object_path))
+		return;
+
 	services = g_slist_remove(services, service);
 	service_free(service);
 }
 
 int service_register(DBusConnection *conn, const char *bus_name, const char *ident,

[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-01-16  0:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-16  0:34 [Bluez-devel] [PATCH] Fix crash when registering / unregistering external service Denis KENZIOR

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox