summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2008-03-28 16:15:31 +0000
committerBenjamin Otte <otte@src.gnome.org>2008-03-28 16:15:31 +0000
commitc3a3a4d6a917eb466fcbdcb15899ddbe7e247099 (patch)
treec20f2d396eef92f6aed70a9530a4fd9481b4c08d /daemon
parentee1e9e23ad6d5c87fca38ae328dc67d480b8dc50 (diff)
downloadgvfs-c3a3a4d6a917eb466fcbdcb15899ddbe7e247099.tar.gz
fix race that could cause uploads to stop
2008-03-28 Benjamin Otte <otte@gnome.org> * daemon/gvfsbackendftp.c: (ftp_connection_pop_job): fix race that could cause uploads to stop svn path=/trunk/; revision=1696
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsbackendftp.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 853670af..788c8ac4 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -173,22 +173,32 @@ static gboolean
ftp_connection_pop_job (FtpConnection *conn)
{
gboolean result;
+ GError *error;
+ GVfsJob *job;
g_return_val_if_fail (conn->job != NULL, FALSE);
- if (ftp_connection_in_error (conn))
+ /* sending a reply is racy after the reply is sent. The connection may be
+ * reused in a different thread before the reply sending returns. This is
+ * racy in particular when the connection is used as a read/write handle.
+ */
+ error = conn->error;
+ conn->error = NULL;
+ job = conn->job;
+ conn->job = NULL;
+
+ if (error)
{
- g_vfs_job_failed_from_error (conn->job, conn->error);
- g_clear_error (&conn->error);
+ g_vfs_job_failed_from_error (job, error);
+ g_clear_error (&error);
result = FALSE;
}
else
{
- g_vfs_job_succeeded (conn->job);
+ g_vfs_job_succeeded (job);
result = TRUE;
}
- conn->job = NULL;
return result;
}