summaryrefslogtreecommitdiff
path: root/daemon/gvfsafpconnection.c
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2014-08-03 10:49:53 +0100
committerRoss Lagerwall <rosslagerwall@gmail.com>2014-08-03 17:06:23 +0100
commite9c320e49cace543450b961af32ea7ffeb8d512f (patch)
tree0c09402eefe185070bca64b8958285dddaf3687e /daemon/gvfsafpconnection.c
parenta4016460538ea8be22aa0d8289922b389a93ef78 (diff)
downloadgvfs-e9c320e49cace543450b961af32ea7ffeb8d512f.tar.gz
afp: Don't retry read if connection closes
Don't retry the read if the remote host closes the connection. Instead, exit (semi-)gracefully with exit(0) and exit with an error if there was an actual error. https://bugzilla.gnome.org/show_bug.cgi?id=710490
Diffstat (limited to 'daemon/gvfsafpconnection.c')
-rw-r--r--daemon/gvfsafpconnection.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/daemon/gvfsafpconnection.c b/daemon/gvfsafpconnection.c
index 9e81b725..97d1f538 100644
--- a/daemon/gvfsafpconnection.c
+++ b/daemon/gvfsafpconnection.c
@@ -20,6 +20,7 @@
* Author: Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
*/
+#include <stdlib.h>
#include <string.h>
#include <glib/gi18n.h>
#include <gio/gnetworking.h>
@@ -879,6 +880,12 @@ read_all_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
g_simple_async_result_take_error (simple, err);
goto done;
}
+ else if (bytes_read == 0)
+ {
+ g_simple_async_result_set_error (simple, G_IO_ERROR, G_IO_ERROR_CLOSED,
+ _("Got EOS"));
+ goto done;
+ }
read_data = g_simple_async_result_get_op_res_gpointer (simple);
@@ -1049,8 +1056,15 @@ read_data_cb (GObject *object, GAsyncResult *res, gpointer user_data)
result = read_all_finish (input, res, NULL, &err);
if (!result)
{
- g_warning ("FAIL!!! \"%s\"\n", err->message);
- g_error_free (err);
+ if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CLOSED))
+ {
+ g_message (_("Host closed connection"));
+ exit(0);
+ }
+ else
+ {
+ g_error ("FAIL!!! \"%s\"\n", err->message);
+ }
}
dispatch_reply (afp_connection);
@@ -1083,8 +1097,15 @@ read_dsi_header_cb (GObject *object, GAsyncResult *res, gpointer user_data)
result = read_all_finish (input, res, NULL, &err);
if (!result)
{
- g_warning ("FAIL!!! \"%s\"\n", err->message);
- g_error_free (err);
+ if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CLOSED))
+ {
+ g_message (_("Host closed connection"));
+ exit(0);
+ }
+ else
+ {
+ g_error ("FAIL!!! \"%s\"\n", err->message);
+ }
}
dsi_header = &priv->read_dsi_header;