summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--daemon/main.c9
-rw-r--r--daemon/mount.c24
-rw-r--r--daemon/mount.h3
3 files changed, 30 insertions, 6 deletions
diff --git a/daemon/main.c b/daemon/main.c
index 2a247bdd..3a15da46 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -72,7 +72,13 @@ on_name_acquired (GDBusConnection *connection,
g_warning ("main.c: Acquired the name %s on the session message bus\n", name);
already_acquired = TRUE;
- mount_init ();
+ if (! mount_init ())
+ {
+ /* we were not able to properly initialize ourselves, bail out */
+ g_main_loop_quit (loop);
+ return;
+ }
+
#ifdef HAVE_FUSE
if (!no_fuse)
@@ -194,6 +200,7 @@ main (int argc, char *argv[])
g_main_loop_run (loop);
+ mount_finalize ();
#if 0
/* FIXME: crashing */
if (daemon != NULL)
diff --git a/daemon/mount.c b/daemon/mount.c
index 58eecc92..47a41912 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -73,6 +73,9 @@ static GList *mounts = NULL;
static gboolean fuse_available;
+static GVfsDBusMountTracker *mount_tracker = NULL;
+
+
static void lookup_mount (GVfsDBusMountTracker *object,
GDBusMethodInvocation *invocation,
GMountSpec *spec,
@@ -1020,15 +1023,17 @@ reload_pipes_cb (GIOChannel *io,
return TRUE;
}
-void
+gboolean
mount_init (void)
{
GDBusConnection *conn;
struct sigaction sa;
GIOChannel *io;
- GVfsDBusMountTracker *mount_tracker;
GError *error;
+ gboolean res;
+ res = TRUE;
+
read_mountable_config ();
if (pipe (reload_pipes) != -1)
@@ -1050,7 +1055,7 @@ mount_init (void)
g_warning ("Error connecting to session bus: %s (%s, %d)\n",
error->message, g_quark_to_string (error->domain), error->code);
g_error_free (error);
- return; /* FIXME: gracefully return */
+ return FALSE;
}
mount_tracker = gvfs_dbus_mount_tracker_skeleton_new ();
@@ -1072,9 +1077,20 @@ mount_init (void)
error->message, g_quark_to_string (error->domain), error->code);
g_error_free (error);
g_object_unref (mount_tracker);
+ mount_tracker = NULL;
+ res = FALSE;
}
g_object_unref (conn);
- /* TODO: keep reference for 'mount_tracker' */
+ return res;
}
+void
+mount_finalize (void)
+{
+ if (mount_tracker != NULL)
+ {
+ g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (mount_tracker));
+ g_object_unref (mount_tracker);
+ }
+}
diff --git a/daemon/mount.h b/daemon/mount.h
index 800ebda5..7fe16ade 100644
--- a/daemon/mount.h
+++ b/daemon/mount.h
@@ -29,7 +29,8 @@
G_BEGIN_DECLS
-void mount_init (void);
+gboolean mount_init (void);
+void mount_finalize (void);
G_END_DECLS