summaryrefslogtreecommitdiff
path: root/daemon/gvfsreadchannel.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2008-02-04 09:51:48 +0000
committerAlexander Larsson <alexl@src.gnome.org>2008-02-04 09:51:48 +0000
commit8de5afd3423f99485156a82739e09550fb655f29 (patch)
treeb18f4ab42d922086eee14bf24d4f68ce6c6ff0e8 /daemon/gvfsreadchannel.c
parent0d312e4d6e88b26e86ec6982a46429b842fcc474 (diff)
downloadgvfs-8de5afd3423f99485156a82739e09550fb655f29.tar.gz
Init seq_nr to 1 so that seq_nr 0 is special (used for e.g. readahead ops)
2008-02-04 Alexander Larsson <alexl@redhat.com> * client/gdaemonfileinputstream.c: * client/gdaemonfileoutputstream.c: Init seq_nr to 1 so that seq_nr 0 is special (used for e.g. readahead ops) * daemon/gvfschannel.[ch]: * daemon/gvfsreadchannel.c: Implement readahead. svn path=/trunk/; revision=1221
Diffstat (limited to 'daemon/gvfsreadchannel.c')
-rw-r--r--daemon/gvfsreadchannel.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/daemon/gvfsreadchannel.c b/daemon/gvfsreadchannel.c
index ea49f4ff..75532661 100644
--- a/daemon/gvfsreadchannel.c
+++ b/daemon/gvfsreadchannel.c
@@ -59,6 +59,8 @@ static GVfsJob *read_channel_handle_request (GVfsChannel *channel,
gpointer data,
gsize data_len,
GError **error);
+static GVfsJob *read_channel_readahead (GVfsChannel *channel,
+ GVfsJob *job);
static void
g_vfs_read_channel_finalize (GObject *object)
@@ -80,6 +82,7 @@ g_vfs_read_channel_class_init (GVfsReadChannelClass *klass)
gobject_class->finalize = g_vfs_read_channel_finalize;
channel_class->close = read_channel_close;
channel_class->handle_request = read_channel_handle_request;
+ channel_class->readahead = read_channel_readahead;
}
static void
@@ -186,6 +189,35 @@ read_channel_handle_request (GVfsChannel *channel,
return job;
}
+static GVfsJob *
+read_channel_readahead (GVfsChannel *channel,
+ GVfsJob *job)
+{
+ GVfsJob *readahead_job;
+ GVfsReadChannel *read_channel;
+ GVfsJobRead *read_job;
+
+ readahead_job = NULL;
+ if (!job->failed &&
+ G_VFS_IS_JOB_READ (job))
+ {
+ read_job = G_VFS_JOB_READ (job);
+ read_channel = G_VFS_READ_CHANNEL (channel);
+
+ if (read_job->data_count != 0)
+ {
+ read_channel->read_count++;
+ readahead_job = g_vfs_job_read_new (read_channel,
+ g_vfs_channel_get_backend_handle (channel),
+ modify_read_size (read_channel, 8192),
+ g_vfs_channel_get_backend (channel));
+ }
+ }
+
+ return readahead_job;
+}
+
+
/* Might be called on an i/o thread
*/
void