summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2017-08-11 13:05:27 +0200
committerOndrej Holy <oholy@redhat.com>2017-08-18 13:10:08 +0200
commit0496270865f90e35b5d89f7fb3e7da2cc6aad942 (patch)
treee58605091d4056e764102dac94b34bbeb791c2a9
parent4b6910e795c98368b6f4b14e35d5695ac481c5f1 (diff)
downloadgvfs-0496270865f90e35b5d89f7fb3e7da2cc6aad942.tar.gz
channel: Set sockets as nonblocking to prevent deadlocks when copying
The channel socket pair is not set as nonblocking currently, which may cause deadlocks in some cases (e.g. in-mount copy over read-write fallback), because g_output_stream_write_async may block. This issue appears after increasing max size of buffer in read channel: https://bugzilla.gnome.org/show_bug.cgi?id=773826 Set channel sockets as nonblocking to be sure that _async methods don't block. https://bugzilla.gnome.org/show_bug.cgi?id=785391
-rw-r--r--daemon/gvfschannel.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/daemon/gvfschannel.c b/daemon/gvfschannel.c
index 021d292a..c3586603 100644
--- a/daemon/gvfschannel.c
+++ b/daemon/gvfschannel.c
@@ -209,7 +209,11 @@ g_vfs_channel_init (GVfsChannel *channel)
channel->priv->cancellable = g_cancellable_new ();
channel->priv->reply_stream = g_unix_output_stream_new (socket_fds[0], FALSE);
channel->priv->remote_fd = socket_fds[1];
-
+
+ /* Set as nonblocking to be sure that _async methods don't block. */
+ fcntl (socket_fds[0], F_SETFL, O_NONBLOCK);
+ fcntl (socket_fds[1], F_SETFL, O_NONBLOCK);
+
start_request_reader (channel);
}
}