--- gnome-vfs-2.20.1/modules/sftp-method.c.BAD	2007-11-29 12:23:14.000000000 +0100
+++ gnome-vfs-2.20.1/modules/sftp-method.c	2007-11-29 12:22:10.000000000 +0100
@@ -1539,6 +1539,8 @@
 	return res;
 }
 
+static void sftp_connection_unref (SftpConnection *) ;
+
 static GnomeVFSResult
 sftp_get_connection (SftpConnection **connection, const GnomeVFSURI *uri) 
 {
@@ -1575,6 +1577,18 @@
 
 	*connection = g_hash_table_lookup (sftp_connection_table, hash_name);
 
+	/* 
+	 * if current connection is stalled with status GNOME_VFS_ERROR_EOF
+	 * it may mean that the sftp subprocess timed out or just
+	 * aborted abnormally. In this case, we try to transparently
+	 * reconnect.
+	 */
+	if (*connection && (*connection)->status == GNOME_VFS_ERROR_EOF) {
+		DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
+			      "%s: IO Error occured, reconnecting.", G_GNUC_FUNCTION));
+		sftp_connection_unref((*connection));
+		*connection = NULL;
+	}
 	if (*connection == NULL) {
 		DEBUG (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
 			      "%s: Connection not found. Opening new one.", G_GNUC_FUNCTION));
