public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Denis KENZIOR <denis.kenzior@trolltech.com>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] [PATCH] Fix crash when registering / unregistering external service
Date: Wed, 16 Jan 2008 10:34:48 +1000	[thread overview]
Message-ID: <200801161034.48078.denis.kenzior@trolltech.com> (raw)

[-- 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

                 reply	other threads:[~2008-01-16  0:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200801161034.48078.denis.kenzior@trolltech.com \
    --to=denis.kenzior@trolltech.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox