summaryrefslogtreecommitdiff
path: root/client/gdaemonvfs.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2007-11-14 09:41:58 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-11-14 09:41:58 +0000
commit08c4d5abf517c0b45942d6156eaf34bc7463cba0 (patch)
tree622a5344c8cf880f82c5e44a1e23fef078505136 /client/gdaemonvfs.c
parent7fa39ef58aef397f0549c24f2bf81640c1cca5c0 (diff)
downloadgvfs-08c4d5abf517c0b45942d6156eaf34bc7463cba0.tar.gz
Make sure we somewhat cleanly handle the various dbus daemons going down.
2007-11-14 Alexander Larsson <alexl@redhat.com> * client/gdaemonvfs.[ch]: * client/gvfsdaemondbus.c: Make sure we somewhat cleanly handle the various dbus daemons going down. By somewhat I mean that no problem should be persistant even if you might get some transient error messages. Unfortunately the only way to be able to cleanly handle this involves globally ignoring SIGPIPE. What can I say, unix sucks. * common/gsysutils.c: (_g_socket_receive_fd): Handle errors if e.g. the fd is closed svn path=/trunk/; revision=1023
Diffstat (limited to 'client/gdaemonvfs.c')
-rw-r--r--client/gdaemonvfs.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/client/gdaemonvfs.c b/client/gdaemonvfs.c
index a5b8ae5f..59223db7 100644
--- a/client/gdaemonvfs.c
+++ b/client/gdaemonvfs.c
@@ -22,6 +22,7 @@
#include <config.h>
#include <string.h>
+#include <signal.h>
#include <stdlib.h>
#include <dbus/dbus.h>
#include "gdaemonvfs.h"
@@ -182,16 +183,28 @@ g_daemon_vfs_init (GDaemonVfs *vfs)
GVfsUriMapper *mapper;
int i;
+ vfs->async_bus = dbus_bus_get_private (DBUS_BUS_SESSION, NULL);
+
+ if (vfs->async_bus == NULL)
+ return; /* Not supported, return here and return false in vfs_is_active() */
+
g_assert (the_vfs == NULL);
the_vfs = vfs;
-
+
if (g_thread_supported ())
dbus_threads_init_default ();
-
- vfs->async_bus = dbus_bus_get_private (DBUS_BUS_SESSION, NULL);
- if (vfs->async_bus == NULL)
- return;
+ /* We disable SIGPIPE globally. This is sort of bad
+ for s library to do since its a global resource.
+ However, without this there is no way to be able
+ to handle mount daemons dying without client apps
+ crashing, which is much worse.
+
+ I blame Unix, there really should be a portable
+ way to do this on all unixes, but there isn't,
+ even for somewhat modern ones like solaris.
+ */
+ signal (SIGPIPE, SIG_IGN);
vfs->wrapped_vfs = g_vfs_get_local ();
@@ -505,6 +518,30 @@ lookup_mount_info_in_cache (GMountSpec *spec,
return info;
}
+void
+_g_daemon_vfs_invalidate_dbus_id (const char *dbus_id)
+{
+ GMountInfo *info;
+ GList *l, *next;
+
+ G_LOCK (mount_cache);
+ info = NULL;
+ for (l = the_vfs->mount_cache; l != NULL; l = next)
+ {
+ GMountInfo *mount_info = l->data;
+ next = l->next;
+
+ if (strcmp (mount_info->dbus_id, dbus_id) == 0)
+ {
+ the_vfs->mount_cache = g_list_delete_link (the_vfs->mount_cache, l);
+ g_mount_info_unref (mount_info);
+ }
+ }
+
+ G_UNLOCK (mount_cache);
+}
+
+
static GMountInfo *
handler_lookup_mount_reply (DBusMessage *reply,
GError **error)