summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kellner <gicmo@gnome.org>2008-03-31 12:22:30 +0000
committerChristian Kellner <gicmo@src.gnome.org>2008-03-31 12:22:30 +0000
commit86f81fb7eb4b042844a6e33c97a2a5b4ab413dd3 (patch)
treedb12ccc43bd04c288686e1aef98f4f251c9549c6
parentc9c7e228b6998ceb6942b6e137a0ea58ea9fd198 (diff)
downloadgvfs-86f81fb7eb4b042844a6e33c97a2a5b4ab413dd3.tar.gz
Make sure we send (error) replies to all outstanding jobs and unmount the
2008-03-31 Christian Kellner <gicmo@gnome.org> * daemon/gvfsbackendsftp.c: Make sure we send (error) replies to all outstanding jobs and unmount the mount in case of an error occures while reading data from the pipe to the ssh agent (e.g. if the ssh process died). svn path=/trunk/; revision=1708
-rw-r--r--ChangeLog7
-rw-r--r--daemon/gvfsbackendsftp.c55
2 files changed, 44 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 27444387..288f5bc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-03-31 Christian Kellner <gicmo@gnome.org>
+
+ * daemon/gvfsbackendsftp.c: Make sure we send (error)
+ replies to all outstanding jobs and unmount the mount
+ in case of an error occures while reading data from
+ the pipe to the ssh agent (e.g. if the ssh process died).
+
2008-03-31 Alexander Larsson <alexl@redhat.com>
* client/gvfsdaemondbus.[ch]:
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index f463f0ab..9d897b37 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -997,6 +997,41 @@ handle_login (GVfsBackend *backend,
return ret_val;
}
+static void
+fail_jobs_and_die (GVfsBackendSftp *backend, GError *error)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init (&iter, backend->expected_replies);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ ExpectedReply *expected_reply = (ExpectedReply *) value;
+ g_vfs_job_failed_from_error (expected_reply->job, error);
+ }
+
+ g_error_free (error);
+
+ _exit (1);
+}
+
+static void
+check_input_stream_read_result (GVfsBackendSftp *backend, gssize res, GError *error)
+{
+ if (G_UNLIKELY (res <= 0))
+ {
+ if (res == 0 || error == NULL)
+ {
+ g_clear_error (&error);
+ g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("Internal error: %s"),
+ res == 0 ? "The underlying ssh process died" : "Unkown Error");
+ }
+
+ fail_jobs_and_die (backend, error);
+ }
+}
+
static void read_reply_async (GVfsBackendSftp *backend);
static void
@@ -1015,14 +1050,7 @@ read_reply_async_got_data (GObject *source_object,
error = NULL;
res = g_input_stream_read_finish (G_INPUT_STREAM (source_object), result, &error);
- if (res <= 0)
- {
- /* TODO: unmount, etc */
- g_warning ("Error reading results: %s", res < 0 ? error->message : "end of stream");
- if (error)
- g_error_free (error);
- return;
- }
+ check_input_stream_read_result (backend, res, error);
backend->reply_size_read += res;
@@ -1069,16 +1097,7 @@ read_reply_async_got_len (GObject *source_object,
error = NULL;
res = g_input_stream_read_finish (G_INPUT_STREAM (source_object), result, &error);
- if (res <= 0)
- {
- /* TODO: unmount, etc */
- g_warning ("Error reading results: %s", res < 0 ? error->message : "end of stream");
- if (error)
- g_error_free (error);
- error = NULL;
- look_for_stderr_errors (G_VFS_BACKEND (backend), &error);
- return;
- }
+ check_input_stream_read_result (backend, res, error);
backend->reply_size_read += res;