Bring lots of fixes from upstream to fix several crashes.

This commit is contained in:
ajacoutot 2013-04-05 14:07:31 +00:00
parent 6dab856256
commit e8a103a2c6
12 changed files with 726 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.89 2013/04/04 12:17:22 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.90 2013/04/05 14:07:31 ajacoutot Exp $
COMMENT-main= GNOME Virtual File System
COMMENT-smb= GVFS mount module for samba
@ -11,7 +11,7 @@ PKGNAME-main= ${DISTNAME}
PKGNAME-smb= ${GNOME_PROJECT}-smb-${GNOME_VERSION}
PKGNAME-goa= ${GNOME_PROJECT}-goa-${GNOME_VERSION}
REVISION-main= 2
REVISION-main= 3
REVISION-smb= 0
SHARED_LIBS += gvfscommon 4.0 # .0.0

View File

@ -0,0 +1,97 @@
$OpenBSD: patch-client_gdaemonfileinputstream_c,v 1.5 2013/04/05 14:07:31 ajacoutot Exp $
From 6141549ed4660e888fb6438434c789db47b6f665 Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 17:08:02 +0000
Subject: channel: Unqueue cancelled requests
From e1be69f4bcec01c007016ae33dbb48514b09ba75 Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 17:13:05 +0000
Subject: GVfsChannels: Verify that replies are for the right serial
--- client/gdaemonfileinputstream.c.orig Fri Apr 5 15:52:50 2013
+++ client/gdaemonfileinputstream.c Fri Apr 5 15:51:31 2013
@@ -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 *fi
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 *f
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,
@@ -1021,7 +1035,8 @@ iterate_close_state_machine (GDaemonFileInputStream *f
op->state = CLOSE_STATE_HANDLE_INPUT_BLOCK;
break;
}
- else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_CLOSED)
+ else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_CLOSED &&
+ reply.seq_nr == op->seq_nr)
{
op->ret_val = TRUE;
g_string_truncate (file->input_buffer, 0);
@@ -1142,6 +1157,8 @@ iterate_seek_state_machine (GDaemonFileInputStream *fi
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,
@@ -1285,7 +1302,8 @@ iterate_seek_state_machine (GDaemonFileInputStream *fi
op->state = SEEK_STATE_HANDLE_INPUT_BLOCK;
break;
}
- else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SEEK_POS)
+ else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SEEK_POS &&
+ reply.seq_nr == op->seq_nr)
{
op->ret_val = TRUE;
op->ret_offset = ((goffset)reply.arg2) << 32 | (goffset)reply.arg1;
@@ -1384,6 +1402,8 @@ iterate_query_state_machine (GDaemonFileInputStream *f
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,
@@ -1562,7 +1582,8 @@ iterate_query_state_machine (GDaemonFileInputStream *f
op->state = QUERY_STATE_HANDLE_INPUT_BLOCK;
break;
}
- else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_INFO)
+ else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_INFO &&
+ reply.seq_nr == op->seq_nr)
{
op->info = gvfs_file_info_demarshal (data, reply.arg2);
g_string_truncate (file->input_buffer, 0);

View File

@ -0,0 +1,106 @@
$OpenBSD: patch-client_gdaemonfileoutputstream_c,v 1.5 2013/04/05 14:07:31 ajacoutot Exp $
From 6141549ed4660e888fb6438434c789db47b6f665 Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 17:08:02 +0000
Subject: channel: Unqueue cancelled requests
From e1be69f4bcec01c007016ae33dbb48514b09ba75 Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 17:13:05 +0000
Subject: GVfsChannels: Verify that replies are for the right serial
--- client/gdaemonfileoutputstream.c.orig Fri Apr 5 15:52:55 2013
+++ client/gdaemonfileoutputstream.c Fri Apr 5 15:51:31 2013
@@ -316,6 +316,15 @@ error_is_cancel (GError *error)
}
static void
+unappend_request (GDaemonFileOutputStream *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 (GDaemonFileOutputStream *stream, guint32 command,
guint32 arg1, guint32 arg2, guint32 data_len, guint32 *seq_nr)
{
@@ -499,6 +508,8 @@ iterate_write_state_machine (GDaemonFileOutputStream *
case WRITE_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,
@@ -588,7 +599,8 @@ iterate_write_state_machine (GDaemonFileOutputStream *
g_string_truncate (file->input_buffer, 0);
return STATE_OP_DONE;
}
- else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_WRITTEN)
+ else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_WRITTEN &&
+ reply.seq_nr == op->seq_nr)
{
op->ret_val = reply.arg1;
g_string_truncate (file->input_buffer, 0);
@@ -674,6 +686,8 @@ iterate_close_state_machine (GDaemonFileOutputStream *
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,
@@ -744,7 +758,8 @@ iterate_close_state_machine (GDaemonFileOutputStream *
g_string_truncate (file->input_buffer, 0);
return STATE_OP_DONE;
}
- else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_CLOSED)
+ else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_CLOSED &&
+ reply.seq_nr == op->seq_nr)
{
op->ret_val = TRUE;
if (reply.arg2 > 0)
@@ -866,6 +881,8 @@ iterate_seek_state_machine (GDaemonFileOutputStream *f
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,
@@ -936,7 +953,8 @@ iterate_seek_state_machine (GDaemonFileOutputStream *f
g_string_truncate (file->input_buffer, 0);
return STATE_OP_DONE;
}
- else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SEEK_POS)
+ else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SEEK_POS &&
+ reply.seq_nr == op->seq_nr)
{
op->ret_val = TRUE;
op->ret_offset = ((goffset)reply.arg2) << 32 | (goffset)reply.arg1;
@@ -1045,6 +1063,8 @@ iterate_query_state_machine (GDaemonFileOutputStream *
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,
@@ -1116,7 +1136,8 @@ iterate_query_state_machine (GDaemonFileOutputStream *
g_string_truncate (file->input_buffer, 0);
return STATE_OP_DONE;
}
- else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_INFO)
+ else if (reply.type == G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_INFO &&
+ reply.seq_nr == op->seq_nr)
{
op->info = gvfs_file_info_demarshal (data, reply.arg2);
g_string_truncate (file->input_buffer, 0);

View File

@ -0,0 +1,33 @@
$OpenBSD: patch-daemon_Makefile_in,v 1.1 2013/04/05 14:07:31 ajacoutot Exp $
From d667f6fe956d8661710f9fe5ad3e54d9b24aa04a Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 08:25:29 +0000
Subject: Fix daemon crash when cancelling channel operations
--- daemon/Makefile.in.orig Fri Apr 5 15:55:20 2013
+++ daemon/Makefile.in Fri Apr 5 15:56:14 2013
@@ -119,6 +119,7 @@ am_libdaemon_la_OBJECTS = gvfsdaemon.lo gvfsbackend.lo
gvfsjobstartmountable.lo gvfsjobstopmountable.lo \
gvfsjobpollmountable.lo gvfsjobopenforread.lo \
gvfsjobopeniconforread.lo gvfsjobread.lo gvfsjobseekread.lo \
+ gvfsjoberror.lo gvfsjoberror.lo \
gvfsjobcloseread.lo gvfsjobopenforwrite.lo gvfsjobwrite.lo \
gvfsjobseekwrite.lo gvfsjobclosewrite.lo gvfsjobqueryinfo.lo \
gvfsjobqueryinforead.lo gvfsjobqueryinfowrite.lo \
@@ -729,6 +730,7 @@ libdaemon_la_SOURCES = \
gvfsjobpollmountable.c gvfsjobpollmountable.h \
gvfsjobopenforread.c gvfsjobopenforread.h \
gvfsjobopeniconforread.c gvfsjobopeniconforread.h \
+ gvfsjoberror.c gvfsjoberror.h \
gvfsjobread.c gvfsjobread.h \
gvfsjobseekread.c gvfsjobseekread.h \
gvfsjobcloseread.c gvfsjobcloseread.h \
@@ -1358,6 +1360,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvfsjobopenforread.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvfsjobopenforwrite.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvfsjobopeniconforread.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvfsjoberror.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvfsjobpollmountable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvfsjobprogress.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvfsjobpull.Plo@am__quote@

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-daemon_gvfsbackend_h,v 1.1 2013/04/05 14:07:31 ajacoutot Exp $
From d667f6fe956d8661710f9fe5ad3e54d9b24aa04a Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 08:25:29 +0000
Subject: Fix daemon crash when cancelling channel operations
--- daemon/gvfsbackend.h.orig Fri Apr 5 15:52:39 2013
+++ daemon/gvfsbackend.h Fri Apr 5 15:49:41 2013
@@ -74,6 +74,7 @@ typedef struct _GVfsJobPull GVfsJobPull;
typedef struct _GVfsJobSetAttribute GVfsJobSetAttribute;
typedef struct _GVfsJobQueryAttributes GVfsJobQueryAttributes;
typedef struct _GVfsJobCreateMonitor GVfsJobCreateMonitor;
+typedef struct _GVfsJobError GVfsJobError;
typedef gpointer GVfsBackendHandle;

View File

@ -0,0 +1,100 @@
$OpenBSD: patch-daemon_gvfschannel_c,v 1.1 2013/04/05 14:07:31 ajacoutot Exp $
From a376e0808c2e8212462025d8065e60d091995d36 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Wed, 03 Apr 2013 13:08:20 +0000
Subject: gvfschannel: Return proper error if we're out of free fds
From d667f6fe956d8661710f9fe5ad3e54d9b24aa04a Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 08:25:29 +0000
Subject: Fix daemon crash when cancelling channel operations
From 6141549ed4660e888fb6438434c789db47b6f665 Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 17:08:02 +0000
Subject: channel: Unqueue cancelled requests
--- daemon/gvfschannel.c.orig Fri Apr 5 15:52:20 2013
+++ daemon/gvfschannel.c Fri Apr 5 15:50:45 2013
@@ -40,6 +40,7 @@
#include <gvfsdaemonutils.h>
#include <gvfsjobcloseread.h>
#include <gvfsjobclosewrite.h>
+#include <gvfsjoberror.h>
#include <gvfsfileinfo.h>
static void g_vfs_channel_job_source_iface_init (GVfsJobSourceIface *iface);
@@ -200,7 +201,7 @@ g_vfs_channel_init (GVfsChannel *channel)
ret = socketpair (AF_UNIX, SOCK_STREAM, 0, socket_fds);
if (ret == -1)
- g_warning ("Error creating socket pair: %d\n", errno);
+ g_warning ("Error creating socket pair: %s\n", g_strerror (errno));
else
{
channel->priv->command_stream = g_unix_input_stream_new (socket_fds[0], TRUE);
@@ -312,39 +313,36 @@ start_queued_request (GVfsChannel *channel)
channel->priv->queued_requests =
g_list_delete_link (channel->priv->queued_requests,
channel->priv->queued_requests);
-
+
error = NULL;
- job = NULL;
- if (req->cancelled)
+ /* This passes on ownership of req->data */
+ job = class->handle_request (channel,
+ req->command, req->seq_nr,
+ req->arg1, req->arg2,
+ req->data, req->data_len,
+ &error);
+
+ if (job != NULL && req->cancelled)
{
- error =
- g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CANCELLED,
- _("Operation was cancelled"));
- g_free (req->data); /* Did no pass ownership */
+ /* Ignore the job, although we need to create it to rely
+ on handle_request side effects like seek generations, etc */
+ g_object_unref (job);
+ job = NULL;
+ error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CANCELLED,
+ _("Operation was cancelled"));
}
- else
+
+ if (job == NULL)
{
- /* This passes on ownership of req->data */
- job = class->handle_request (channel,
- req->command, req->seq_nr,
- req->arg1, req->arg2,
- req->data, req->data_len,
- &error);
- }
-
- if (job)
- {
- channel->priv->current_job = job;
- channel->priv->current_job_seq_nr = req->seq_nr;
- g_vfs_job_source_new_job (G_VFS_JOB_SOURCE (channel), channel->priv->current_job);
- started_job = TRUE;
- }
- else
- {
- g_vfs_channel_send_error (channel, error);
+ job = g_vfs_job_error_new (channel, error);
g_error_free (error);
}
-
+
+ channel->priv->current_job = job;
+ channel->priv->current_job_seq_nr = req->seq_nr;
+ g_vfs_job_source_new_job (G_VFS_JOB_SOURCE (channel), channel->priv->current_job);
+ started_job = TRUE;
+
g_free (req);
}

View File

@ -0,0 +1,121 @@
$OpenBSD: patch-daemon_gvfsjoberror_c,v 1.1 2013/04/05 14:07:31 ajacoutot Exp $
From d667f6fe956d8661710f9fe5ad3e54d9b24aa04a Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 08:25:29 +0000
Subject: Fix daemon crash when cancelling channel operations
From 5e614ee502ced670a681e33ea2d0c8363d9068ca Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 17:50:56 +0000
Subject: remove debug spew
--- daemon/gvfsjoberror.c.orig Fri Apr 5 15:52:42 2013
+++ daemon/gvfsjoberror.c Fri Apr 5 15:52:00 2013
@@ -0,0 +1,106 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Alexander Larsson <alexl@redhat.com>
+ */
+
+#include <config.h>
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include "gvfsjoberror.h"
+#include "gvfsdaemonutils.h"
+
+G_DEFINE_TYPE (GVfsJobError, g_vfs_job_error, G_VFS_TYPE_JOB)
+
+static void run (GVfsJob *job);
+static gboolean try (GVfsJob *job);
+static void send_reply (GVfsJob *job);
+
+static void
+g_vfs_job_error_finalize (GObject *object)
+{
+ GVfsJobError *job;
+
+ job = G_VFS_JOB_ERROR (object);
+ g_object_unref (job->channel);
+ g_error_free (job->error);
+
+ if (G_OBJECT_CLASS (g_vfs_job_error_parent_class)->finalize)
+ (*G_OBJECT_CLASS (g_vfs_job_error_parent_class)->finalize) (object);
+}
+
+static void
+g_vfs_job_error_class_init (GVfsJobErrorClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GVfsJobClass *job_class = G_VFS_JOB_CLASS (klass);
+
+ gobject_class->finalize = g_vfs_job_error_finalize;
+
+ job_class->run = run;
+ job_class->try = try;
+ job_class->send_reply = send_reply;
+}
+
+static void
+g_vfs_job_error_init (GVfsJobError *job)
+{
+}
+
+GVfsJob *
+g_vfs_job_error_new (GVfsChannel *channel,
+ GError *error)
+{
+ GVfsJobError *job;
+
+ job = g_object_new (G_VFS_TYPE_JOB_ERROR,
+ NULL);
+ job->channel = g_object_ref (channel);
+ job->error = g_error_copy (error);
+
+ return G_VFS_JOB (job);
+}
+
+/* Might be called on an i/o thread */
+static void
+send_reply (GVfsJob *job)
+{
+ GVfsJobError *op_job = G_VFS_JOB_ERROR (job);
+
+ g_assert (job->failed);
+
+ g_vfs_channel_send_error (G_VFS_CHANNEL (op_job->channel), job->error);
+}
+
+static void
+run (GVfsJob *job)
+{
+}
+
+static gboolean
+try (GVfsJob *job)
+{
+ g_vfs_job_failed_from_error (job, G_VFS_JOB_ERROR (job)->error);
+}

View File

@ -0,0 +1,71 @@
$OpenBSD: patch-daemon_gvfsjoberror_h,v 1.1 2013/04/05 14:07:31 ajacoutot Exp $
From d667f6fe956d8661710f9fe5ad3e54d9b24aa04a Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Thu, 04 Apr 2013 08:25:29 +0000
Subject: Fix daemon crash when cancelling channel operations
--- daemon/gvfsjoberror.h.orig Fri Apr 5 15:52:46 2013
+++ daemon/gvfsjoberror.h Fri Apr 5 15:49:41 2013
@@ -0,0 +1,61 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Alexander Larsson <alexl@redhat.com>
+ */
+
+#ifndef __G_VFS_JOB_ERROR_H__
+#define __G_VFS_JOB_ERROR_H__
+
+#include <gvfsjob.h>
+#include <gvfsbackend.h>
+#include <gvfschannel.h>
+
+G_BEGIN_DECLS
+
+#define G_VFS_TYPE_JOB_ERROR (g_vfs_job_error_get_type ())
+#define G_VFS_JOB_ERROR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_VFS_TYPE_JOB_ERROR, GVfsJobError))
+#define G_VFS_JOB_ERROR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_VFS_TYPE_JOB_ERROR, GVfsJobErrorClass))
+#define G_VFS_IS_JOB_ERROR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_VFS_TYPE_JOB_ERROR))
+#define G_VFS_IS_JOB_ERROR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_VFS_TYPE_JOB_ERROR))
+#define G_VFS_JOB_ERROR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_VFS_TYPE_JOB_ERROR, GVfsJobErrorClass))
+
+typedef struct _GVfsJobErrorClass GVfsJobErrorClass;
+
+struct _GVfsJobError
+{
+ GVfsJob parent_instance;
+
+ GVfsChannel *channel;
+ GError *error;
+};
+
+struct _GVfsJobErrorClass
+{
+ GVfsJobClass parent_class;
+};
+
+GType g_vfs_job_error_get_type (void) G_GNUC_CONST;
+
+GVfsJob *g_vfs_job_error_new (GVfsChannel *channel,
+ GError *error);
+
+G_END_DECLS
+
+#endif /* __G_VFS_JOB_ERROR_H__ */

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-daemon_gvfsjobopenforread_c,v 1.1 2013/04/05 14:07:31 ajacoutot Exp $
From a376e0808c2e8212462025d8065e60d091995d36 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Wed, 03 Apr 2013 13:08:20 +0000
Subject: gvfschannel: Return proper error if we're out of free fds
--- daemon/gvfsjobopenforread.c.orig Mon Mar 25 15:00:16 2013
+++ daemon/gvfsjobopenforread.c Fri Apr 5 15:41:04 2013
@@ -174,7 +174,17 @@ create_reply (GVfsJob *job,
open_job->pid);
remote_fd = g_vfs_channel_steal_remote_fd (G_VFS_CHANNEL (channel));
-
+ if (remote_fd < 0)
+ {
+ /* expecting we're out of fds when remote_fd == -1 */
+ g_dbus_method_invocation_return_error_literal (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_TOO_MANY_OPEN_FILES,
+ _("Couldn't get stream file descriptor"));
+ g_object_unref (channel);
+ return;
+ }
+
fd_list = g_unix_fd_list_new ();
error = NULL;
fd_id = g_unix_fd_list_append (fd_list, remote_fd, &error);

View File

@ -0,0 +1,26 @@
$OpenBSD: patch-daemon_gvfsjobopenforwrite_c,v 1.1 2013/04/05 14:07:31 ajacoutot Exp $
From a376e0808c2e8212462025d8065e60d091995d36 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Wed, 03 Apr 2013 13:08:20 +0000
Subject: gvfschannel: Return proper error if we're out of free fds
--- daemon/gvfsjobopenforwrite.c.orig Mon Mar 25 15:00:16 2013
+++ daemon/gvfsjobopenforwrite.c Fri Apr 5 15:41:04 2013
@@ -258,6 +258,16 @@ create_reply (GVfsJob *job,
open_job->pid);
remote_fd = g_vfs_channel_steal_remote_fd (G_VFS_CHANNEL (channel));
+ if (remote_fd < 0)
+ {
+ /* expecting we're out of fds when remote_fd == -1 */
+ g_dbus_method_invocation_return_error_literal (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_TOO_MANY_OPEN_FILES,
+ _("Couldn't get stream file descriptor"));
+ g_object_unref (channel);
+ return;
+ }
fd_list = g_unix_fd_list_new ();
error = NULL;

View File

@ -0,0 +1,34 @@
$OpenBSD: patch-daemon_gvfsmonitor_c,v 1.1 2013/04/05 14:07:31 ajacoutot Exp $
From adbe1bade2d3d9ba41c29d745cfa5ae433063554 Mon Sep 17 00:00:00 2001
From: Philip Langdale <philipl@overt.org>
Date: Sun, 24 Mar 2013 05:55:40 +0000
Subject: Daemon: Ensure monitors are not prematurally finalized.
--- daemon/gvfsmonitor.c.orig Mon Mar 25 15:00:16 2013
+++ daemon/gvfsmonitor.c Fri Apr 5 15:40:04 2013
@@ -71,7 +71,14 @@ backend_died (GVfsMonitor *monitor,
GObject *old_backend)
{
Subscriber *subscriber;
-
+
+ /*
+ * Take an extra ref on the monitor because
+ * unsubscribing may lead to the last ref
+ * being released.
+ */
+ g_object_ref (G_OBJECT (monitor));
+
monitor->priv->backend = NULL;
while (monitor->priv->subscribers != NULL)
@@ -79,6 +86,8 @@ backend_died (GVfsMonitor *monitor,
subscriber = monitor->priv->subscribers->data;
unsubscribe (subscriber);
}
+
+ g_object_unref (G_OBJECT (monitor));
}
static void

View File

@ -0,0 +1,91 @@
$OpenBSD: patch-daemon_gvfsreadchannel_c,v 1.1 2013/04/05 14:07:31 ajacoutot Exp $
From c9b8fc094d7a95386641901957cca890d5345aa1 Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Fri, 05 Apr 2013 12:06:37 +0000
Subject: Fix readahead behaviour
From e0941e88ffdd3b4d89e8d2db9dabbb86ff9d81e1 Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Fri, 05 Apr 2013 12:33:21 +0000
Subject: daemons: Tweak read sizes
--- daemon/gvfsreadchannel.c.orig Fri Apr 5 15:40:41 2013
+++ daemon/gvfsreadchannel.c Fri Apr 5 15:42:53 2013
@@ -96,27 +96,38 @@ read_channel_close (GVfsChannel *channel)
}
/* Always request large chunks. Its very inefficient
- to do network requests for smaller chunks. */
+ * to do network requests for smaller chunks.
+ *
+ * gstreamer tends to do 4k reads and seeks, and
+ * the first read when sniffing is also small, so
+ * it makes sense to never read more that 4k
+ * (one page) on the first read. It should not affect
+ * long-file copy performance anyway.
+ */
static guint32
modify_read_size (GVfsReadChannel *channel,
guint32 requested_size)
{
guint32 real_size;
-
+
if (channel->read_count <= 1)
- real_size = 16*1024;
+ real_size = 4*1024;
else if (channel->read_count <= 2)
+ real_size = 8*1024;
+ else if (channel->read_count <= 3)
+ real_size = 16*1024;
+ else if (channel->read_count <= 4)
real_size = 32*1024;
else
real_size = 64*1024;
-
+
if (requested_size > real_size)
- real_size = requested_size;
+ real_size = requested_size;
/* Don't do ridicoulously large requests as this
is just stupid on the network */
- if (real_size > 512 * 1024)
- real_size = 512 * 1024;
+ if (real_size > 128 * 1024)
+ real_size = 128 * 1024;
return real_size;
}
@@ -209,7 +220,20 @@ read_channel_readahead (GVfsChannel *channel,
read_job = G_VFS_JOB_READ (job);
read_channel = G_VFS_READ_CHANNEL (channel);
- if (read_job->data_count != 0)
+ /* If the last operation was a read and it succeeded then we
+ might want to start a readahead. We don't do this for the
+ first read op as we're not sure we're streaming larger
+ parts of the file yet. However, after the second read we
+ queue a readahead read. After this the reading side will
+ constantly be one read operation behind, such that by
+ the time the second read operation is done and a third
+ read() is done we will send a read request but start
+ reading the readahead data, and after that is done
+ send a new request but start reading the result of the
+ previous read request. This way the reading will be
+ fully pipelined. */
+ if (read_job->data_count != 0 &&
+ read_channel->read_count == 2)
{
read_channel->read_count++;
readahead_job = g_vfs_job_read_new (read_channel,
@@ -218,7 +242,7 @@ read_channel_readahead (GVfsChannel *channel,
g_vfs_channel_get_backend (channel));
}
}
-
+
return readahead_job;
}