hal/hald/linux block_class_device.c, 1.29, 1.30 bus_device.c, 1.10, 1.11 class_device.c, 1.15, 1.16 osspec.c, 1.19, 1.20

Joe Shaw joe at pdx.freedesktop.org
Wed Jun 9 11:12:02 PDT 2004


Update of /cvs/hal/hal/hald/linux
In directory pdx:/tmp/cvs-serv14626/hald/linux

Modified Files:
	block_class_device.c bus_device.c class_device.c osspec.c 
Log Message:
2004-06-09  Joe Shaw  <joeshaw at novell.com>

	Fix some refcounting issues

	* hald/linux/block_class_device.c: Unref the device after we add
	it to the TDL.
	(disc_add_to_gdl): Removed; it's functionally equivalent to
	device_move_from_tdl_to_gdl() in common.c.
	(disc_remove_from_gdl): Disconnect the signal handlers before
	removing from the TDL (and thus finalizing).
	(detect_media): Unref the child after adding it to the TDL.
	Replace signal handler for "callouts_finished".

	* hald/linux/bus_device.c (bus_device_visit): Unref device after
	adding it to the TDL.
	(bus_device_got_parent): Don't unref after removing from the TDL.

	* hald/linux/class_device.c (class_device_visit): Unref device
	after adding it to TDL.
	(class_device_got_parent_device, class_device_got_sysdevice,
	class_device_got_device_file, class_device_final): Don't unref
	after removing from the TDL.

	* hald/linux/osspec.c (osspec_probe): Unref the fakeroot device
	after adding it to GDL.

Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- a/block_class_device.c	6 Jun 2004 16:58:58 -0000	1.29
+++ b/block_class_device.c	9 Jun 2004 18:11:59 -0000	1.30
@@ -105,6 +105,8 @@
 
 	d = hal_device_new ();
 	hal_device_store_add (hald_get_tdl (), d);
+	g_object_unref (d);
+
 	hal_device_property_set_string (d, "info.bus", self->hal_class_name);
 	hal_device_property_set_string (d, "linux.sysfs_path", path);
 	hal_device_property_set_string (d, "linux.sysfs_path_device", path);
@@ -391,22 +393,11 @@
 }
 
 static void
-disc_add_to_gdl (HalDevice *device, gpointer user_data)
-{
-	hal_device_store_remove (hald_get_tdl (), device);
-	hal_device_store_add (hald_get_gdl (), device);
-
-	g_signal_handlers_disconnect_by_func (device, disc_add_to_gdl, 
-					      user_data);
-}
-
-static void
 disc_remove_from_gdl (HalDevice *device, gpointer user_data)
 {
-	hal_device_store_remove (hald_get_gdl (), device);
 	g_signal_handlers_disconnect_by_func (device, disc_remove_from_gdl, 
 					      user_data);
-	g_object_unref (device);
+	hal_device_store_remove (hald_get_gdl (), device);
 }
 
 
@@ -607,6 +598,7 @@
 
 			child = hal_device_new ();
 			hal_device_store_add (hald_get_tdl (), child);
+			g_object_unref (child);
 
 			/* copy from parent */
 			hal_device_merge (child, d);
@@ -799,7 +791,7 @@
 
 			/* add new device */
 			g_signal_connect (child, "callouts_finished",
-					  G_CALLBACK (disc_add_to_gdl), NULL);
+					  G_CALLBACK (device_move_from_tdl_to_gdl), NULL);
 			hal_callout_device (child, TRUE);
 
 			/* GDL was modified */

Index: bus_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/bus_device.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- a/bus_device.c	25 May 2004 20:09:29 -0000	1.10
+++ b/bus_device.c	9 Jun 2004 18:11:59 -0000	1.11
@@ -92,6 +92,8 @@
 	/* Construct a new device and add to temporary device list */
 	d = hal_device_new ();
 	hal_device_store_add (hald_get_tdl (), d);
+	g_object_unref (d);
+
 	hal_device_property_set_string (d, "info.bus", self->hal_bus_name);
 	hal_device_property_set_string (d, "linux.sysfs_path", path);
 	hal_device_property_set_string (d, "linux.sysfs_path_device", path);
@@ -188,7 +190,6 @@
 		hal_callout_device (device_to_add, TRUE);
 	} else {
 		hal_device_store_remove (hald_get_tdl (), d);
-		g_object_unref (d);
 	}
 }
 

Index: class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/class_device.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- a/class_device.c	25 May 2004 20:09:29 -0000	1.15
+++ b/class_device.c	9 Jun 2004 18:11:59 -0000	1.16
@@ -117,6 +117,7 @@
 	/* Construct a new device and add to temporary device list */
 	d = hal_device_new ();
 	hal_device_store_add (hald_get_tdl (), d);
+	g_object_unref (d);
 
 	/* Need some properties if we are to appear in the tree on our own */
 	if (!merge_or_add) {
@@ -278,7 +279,6 @@
 			      d->udi));
 		/* get rid of temporary device */
 		hal_device_store_remove (hald_get_tdl (), d);
-		g_object_unref (d);
 		return;
 	}
 
@@ -328,7 +328,6 @@
 		HAL_WARNING (("Sysdevice for a class device never appeared!"));
 		/* get rid of temporary device */
 		hal_device_store_remove (hald_get_tdl (), d);
-		g_object_unref (d);
 		return;
 	}
 
@@ -386,7 +385,6 @@
 		HAL_WARNING (("Never got device file for class device at %s", 
 			      hal_device_property_get_string (d, ".udev.sysfs_path")));
 		hal_device_store_remove (hald_get_tdl (), d);
-		g_object_unref (d);
 		return;
 	}
 
@@ -438,7 +436,6 @@
 
 		/* get rid of temporary device */
 		hal_device_store_remove (hald_get_tdl (), d);
-		g_object_unref (d);
 
 		self->post_merge (self, sysdevice);
 	} else {
@@ -473,7 +470,6 @@
 			hal_callout_device (device_to_add, TRUE);
 		} else {
 			hal_device_store_remove (hald_get_tdl (), d);
-			g_object_unref (d);
 		}
 	}
 }

Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/osspec.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- a/osspec.c	25 May 2004 20:09:29 -0000	1.19
+++ b/osspec.c	9 Jun 2004 18:11:59 -0000	1.20
@@ -388,6 +388,7 @@
 	hal_device_property_set_bool (fakeroot, "info.virtual", TRUE);
 	hal_device_set_udi (fakeroot, "/org/freedesktop/Hal/devices/fakeroot");
 	hal_device_store_add (hald_get_gdl (), fakeroot);
+	g_object_unref (fakeroot);
 
 	/** @todo When the kernel has all devices in /sys/devices
 	 *        under either /sys/bus or /sys/class then we can





More information about the hal-commit mailing list