summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2014-08-03 11:03:28 +0100
committerRoss Lagerwall <rosslagerwall@gmail.com>2014-08-03 17:05:52 +0100
commita4016460538ea8be22aa0d8289922b389a93ef78 (patch)
tree675d574cea80298505e3a87bccaa73cbfaa43b4d /daemon
parent5b4fdbeb6b1e19aa1bbc3824c5955ee2f9c1f85b (diff)
downloadgvfs-a4016460538ea8be22aa0d8289922b389a93ef78.tar.gz
afp: Try to prevent idle disconnects
Some servers (e.g. OS X 10.8) disconnect clients who don't respond to server notifications. Prevent this by sending FPGetVolParms, as the spec suggests. https://bugzilla.gnome.org/show_bug.cgi?id=734194
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsafpconnection.h1
-rw-r--r--daemon/gvfsafpvolume.c21
2 files changed, 22 insertions, 0 deletions
diff --git a/daemon/gvfsafpconnection.h b/daemon/gvfsafpconnection.h
index 367f983c..5d90cf64 100644
--- a/daemon/gvfsafpconnection.h
+++ b/daemon/gvfsafpconnection.h
@@ -165,6 +165,7 @@ enum
enum
{
AFP_ATTENTION_CODE_MESSAGE_AVAILABLE = 0x2,
+ AFP_ATTENTION_CODE_SERVER_NOTIFICATION = 0x3,
AFP_ATTENTION_CODE_IMMEDIATE_SHUTDOWN = 0x4,
AFP_ATTENTION_CODE_SHUTDOWN_NO_MESSAGE = 0x8,
AFP_ATTENTION_CODE_DISCONNECT_NO_MESSAGE = 0x9,
diff --git a/daemon/gvfsafpvolume.c b/daemon/gvfsafpvolume.c
index b0e44ded..1a0b6672 100644
--- a/daemon/gvfsafpvolume.c
+++ b/daemon/gvfsafpvolume.c
@@ -41,6 +41,9 @@ struct _GVfsAfpVolumePrivate
};
static void
+attention_cb (GVfsAfpConnection *conn, guint attention, GVfsAfpVolume *volume);
+
+static void
g_vfs_afp_volume_init (GVfsAfpVolume *volume)
{
GVfsAfpVolumePrivate *priv;
@@ -53,7 +56,13 @@ g_vfs_afp_volume_init (GVfsAfpVolume *volume)
static void
g_vfs_afp_volume_finalize (GObject *object)
{
+ GVfsAfpVolume *volume;
+ GVfsAfpVolumePrivate *priv;
+
/* TODO: Add deinitalization code here */
+ volume = G_VFS_AFP_VOLUME (object);
+ priv = volume->priv;
+ g_signal_handlers_disconnect_by_func (priv->conn, attention_cb, volume);
G_OBJECT_CLASS (g_vfs_afp_volume_parent_class)->finalize (object);
}
@@ -82,6 +91,7 @@ g_vfs_afp_volume_new (GVfsAfpServer *server, GVfsAfpConnection *conn)
priv->server = server;
priv->conn = conn;
+ g_signal_connect (priv->conn, "attention", G_CALLBACK (attention_cb), volume);
return volume;
}
@@ -2887,3 +2897,14 @@ g_vfs_afp_volume_read_from_fork_finish (GVfsAfpVolume *volume,
return TRUE;
}
+
+static void
+attention_cb (GVfsAfpConnection *conn, guint attention, GVfsAfpVolume *volume)
+{
+ /* Respond to the server notification with FPGetVolParms as the spec
+ * suggests. Some servers disconnect us if we don't. */
+ if (attention == AFP_ATTENTION_CODE_SERVER_NOTIFICATION)
+ g_vfs_afp_volume_get_parms (volume,
+ AFP_VOLUME_BITMAP_VOL_ID_BIT,
+ NULL, NULL, NULL);
+}