summaryrefslogtreecommitdiff
path: root/client/gdaemonfileinputstream.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-04-04 19:08:02 +0200
committerAlexander Larsson <alexl@redhat.com>2013-04-04 19:34:32 +0200
commitf25b407fdc1ea5624ebe8b8b0e026615f1f14243 (patch)
tree0d192ea8d7ea922c8d697a161eb4ea652a1accb0 /client/gdaemonfileinputstream.c
parent46f9c79cb7b289676128555646721d18a6c4c062 (diff)
downloadgvfs-f25b407fdc1ea5624ebe8b8b0e026615f1f14243.tar.gz
channel: Unqueue cancelled requests
We put a channel request on the output buffer and start writing, but if the write is cancelled on the first call (i.e. no partial writes) we abort immediately without ever writing the request. However, if we do this we also need to unqueue the request from the output buffer, as otherwise this will be sent with the next operation. This can be problematic for seeks as the seek generation is then not in sync. https://bugzilla.gnome.org/show_bug.cgi?id=675181
Diffstat (limited to 'client/gdaemonfileinputstream.c')
-rw-r--r--client/gdaemonfileinputstream.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/client/gdaemonfileinputstream.c b/client/gdaemonfileinputstream.c
index bfe02bde..f73c6816 100644
--- a/client/gdaemonfileinputstream.c
+++ b/client/gdaemonfileinputstream.c
@@ -394,6 +394,16 @@ error_is_cancel (GError *error)
}
static void
+unappend_request (GDaemonFileInputStream *stream)
+{
+ g_assert (stream->output_buffer->len >= G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_SIZE);
+
+ stream->seq_nr--;
+ g_string_truncate (stream->output_buffer,
+ stream->output_buffer->len - G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_SIZE);
+}
+
+static void
append_request (GDaemonFileInputStream *stream, guint32 command,
guint32 arg1, guint32 arg2, guint32 data_len,
guint32 *seq_nr)
@@ -623,6 +633,8 @@ iterate_read_state_machine (GDaemonFileInputStream *file, IOOperationData *io_op
case READ_STATE_WROTE_COMMAND:
if (io_op->io_cancelled)
{
+ if (!op->sent_cancel)
+ unappend_request (file);
op->ret_val = -1;
g_set_error_literal (&op->ret_error,
G_IO_ERROR,
@@ -894,6 +906,8 @@ iterate_close_state_machine (GDaemonFileInputStream *file, IOOperationData *io_o
case CLOSE_STATE_WROTE_REQUEST:
if (io_op->io_cancelled)
{
+ if (!op->sent_cancel)
+ unappend_request (file);
op->ret_val = FALSE;
g_set_error_literal (&op->ret_error,
G_IO_ERROR,
@@ -1142,6 +1156,8 @@ iterate_seek_state_machine (GDaemonFileInputStream *file, IOOperationData *io_op
case SEEK_STATE_WROTE_REQUEST:
if (io_op->io_cancelled)
{
+ if (!op->sent_cancel)
+ unappend_request (file);
op->ret_val = -1;
g_set_error_literal (&op->ret_error,
G_IO_ERROR,
@@ -1384,6 +1400,8 @@ iterate_query_state_machine (GDaemonFileInputStream *file,
case QUERY_STATE_WROTE_REQUEST:
if (io_op->io_cancelled)
{
+ if (!op->sent_cancel)
+ unappend_request (file);
op->info = NULL;
g_set_error_literal (&op->ret_error,
G_IO_ERROR,