volume monitor refcounting code freeze break



The bug reported at:
http://bugzilla.gnome.org/show_bug.cgi?id=151244

Seems to be a crasher problem for the Perl bindings.
I've attached a patch to the bug and this mail.

What it does is allow you to refcount the gobject volume manager
singleton (if you want), but still shut down all the corba stuff when
gnome-vfs shuts down.

Release-team, do you think this is important enough to go in after the
code freeze?

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's an all-American vegetarian cyborg possessed of the uncanny powers of an 
insect. She's a brilliant hypochondriac stripper from the wrong side of the 
tracks. They fight crime! 
Index: libgnomevfs/gnome-vfs-volume-monitor-client.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor-client.c,v
retrieving revision 1.4
diff -u -p -r1.4 gnome-vfs-volume-monitor-client.c
--- libgnomevfs/gnome-vfs-volume-monitor-client.c	14 Jul 2004 09:34:42 -0000	1.4
+++ libgnomevfs/gnome-vfs-volume-monitor-client.c	31 Aug 2004 08:20:36 -0000
@@ -108,7 +108,11 @@ read_drives_from_daemon (GnomeVFSVolumeM
 	GnomeVFSVolumeMonitor *volume_monitor;
 	int i;
 
+	if (volume_monitor_client->is_shutdown)
+		return;
+	
 	volume_monitor = GNOME_VFS_VOLUME_MONITOR (volume_monitor_client);
+
 	client = _gnome_vfs_get_client ();
 	daemon = _gnome_vfs_client_get_daemon (client);
 
@@ -147,7 +151,11 @@ read_volumes_from_daemon (GnomeVFSVolume
 	GnomeVFSVolumeMonitor *volume_monitor;
 	int i;
 
+	if (volume_monitor_client->is_shutdown)
+		return;
+	
 	volume_monitor = GNOME_VFS_VOLUME_MONITOR (volume_monitor_client);
+	
 	client = _gnome_vfs_get_client ();
 	daemon = _gnome_vfs_client_get_daemon (client);
 
@@ -188,25 +196,10 @@ static void
 gnome_vfs_volume_monitor_client_finalize (GObject *object)
 {
 	GnomeVFSVolumeMonitorClient *volume_monitor_client;
-        CORBA_Environment ev;
-	GNOME_VFS_Daemon daemon;
-	GnomeVFSClient *client;
 
 	volume_monitor_client = GNOME_VFS_VOLUME_MONITOR_CLIENT (object);
 
-	client = _gnome_vfs_get_client ();
-	daemon = _gnome_vfs_client_get_daemon (client);
-
-	if (daemon != CORBA_OBJECT_NIL) {
-		GNOME_VFS_Daemon_deRegisterVolumeMonitor (daemon, BONOBO_OBJREF (client), &ev);
-		CORBA_exception_init (&ev);
-		
-		if (BONOBO_EX (&ev)) {
-			CORBA_exception_free (&ev);
-		}
-	
-		CORBA_Object_release (daemon, NULL);
-	}
+	g_assert (volume_monitor_client->is_shutdown);
 	
 	if (G_OBJECT_CLASS (parent_class)->finalize)
 		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
@@ -224,4 +217,31 @@ _gnome_vfs_volume_monitor_client_daemon_
 
 	read_drives_from_daemon (volume_monitor_client);
 	read_volumes_from_daemon (volume_monitor_client);
+}
+
+void
+_gnome_vfs_volume_monitor_client_shutdown (GnomeVFSVolumeMonitorClient *volume_monitor_client)
+{
+        CORBA_Environment ev;
+	GNOME_VFS_Daemon daemon;
+	GnomeVFSClient *client;
+
+	if (volume_monitor_client->is_shutdown)
+		return;
+	
+	volume_monitor_client->is_shutdown = TRUE;
+	
+	client = _gnome_vfs_get_client ();
+	daemon = _gnome_vfs_client_get_daemon (client);
+	
+	if (daemon != CORBA_OBJECT_NIL) {
+		GNOME_VFS_Daemon_deRegisterVolumeMonitor (daemon, BONOBO_OBJREF (client), &ev);
+		CORBA_exception_init (&ev);
+		
+		if (BONOBO_EX (&ev)) {
+			CORBA_exception_free (&ev);
+		}
+		
+		CORBA_Object_release (daemon, NULL);
+	}
 }
Index: libgnomevfs/gnome-vfs-volume-monitor-client.h
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor-client.h,v
retrieving revision 1.2
diff -u -p -r1.2 gnome-vfs-volume-monitor-client.h
--- libgnomevfs/gnome-vfs-volume-monitor-client.h	5 Nov 2003 15:44:53 -0000	1.2
+++ libgnomevfs/gnome-vfs-volume-monitor-client.h	31 Aug 2004 08:20:36 -0000
@@ -42,6 +42,7 @@ typedef struct _GnomeVFSVolumeMonitorCli
 
 struct _GnomeVFSVolumeMonitorClient {
 	GnomeVFSVolumeMonitor parent;
+	gboolean is_shutdown;
 };
 
 struct _GnomeVFSVolumeMonitorClientClass {
@@ -51,6 +52,7 @@ struct _GnomeVFSVolumeMonitorClientClass
 GType gnome_vfs_volume_monitor_client_get_type (void) G_GNUC_CONST;
 
 void _gnome_vfs_volume_monitor_client_daemon_died (GnomeVFSVolumeMonitorClient *volume_monitor_client);
+void _gnome_vfs_volume_monitor_client_shutdown (GnomeVFSVolumeMonitorClient *volume_monitor_client);
 
 G_END_DECLS
 
Index: libgnomevfs/gnome-vfs-volume-monitor.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor.c,v
retrieving revision 1.7
diff -u -p -r1.7 gnome-vfs-volume-monitor.c
--- libgnomevfs/gnome-vfs-volume-monitor.c	16 Aug 2004 08:44:06 -0000	1.7
+++ libgnomevfs/gnome-vfs-volume-monitor.c	31 Aug 2004 08:20:36 -0000
@@ -270,6 +270,10 @@ _gnome_vfs_volume_monitor_shutdown (void
 	G_LOCK (the_volume_monitor);
 	
 	if (the_volume_monitor != NULL) {
+		if (!gnome_vfs_get_is_daemon ()) {
+			_gnome_vfs_volume_monitor_client_shutdown (GNOME_VFS_VOLUME_MONITOR_CLIENT (the_volume_monitor));
+		}
+		
 		gnome_vfs_volume_monitor_unref (the_volume_monitor);
 		the_volume_monitor = NULL;
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]