summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2018-02-07 18:24:02 +0100
committerCarlos Garnacho <carlosg@gnome.org>2018-02-07 19:29:28 +0100
commit006cdac531fd7de983f7675406187bab5c2b8a3f (patch)
treeac164b13ffe8b02dbcd4b72eaadfcf33c0e040ef /src
parent61bc1a7d6fa035a2f6d0d9468b020bbc851dc8bf (diff)
downloadmutter-006cdac531fd7de983f7675406187bab5c2b8a3f.tar.gz
wayland: Use read_all() when reading wayland selections
Plain input stream read() calls don't provide hard guarantees about the number of bytes read, but the async method callback sort of relies on bytes being less than requested only when reaching the end of the transmitted data. If that happens mid transfer, that doesn't bode well. This is actually the behavior of g_input_stream_read_all(), so switch to using it.
Diffstat (limited to 'src')
-rw-r--r--src/wayland/meta-xwayland-selection.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/wayland/meta-xwayland-selection.c b/src/wayland/meta-xwayland-selection.c
index 24b8cd2c1..8201b014f 100644
--- a/src/wayland/meta-xwayland-selection.c
+++ b/src/wayland/meta-xwayland-selection.c
@@ -689,9 +689,8 @@ wayland_data_read_cb (GObject *object,
GError *error = NULL;
gsize bytes_read;
- bytes_read = g_input_stream_read_finish (G_INPUT_STREAM (object),
- res, &error);
- if (error)
+ if (!g_input_stream_read_all_finish (G_INPUT_STREAM (object),
+ res, &bytes_read, &error))
{
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
@@ -762,10 +761,10 @@ wayland_selection_data_read (MetaSelectionBridge *selection)
{
WaylandSelectionData *data = selection->wayland_selection;
- g_input_stream_read_async (data->stream, data->buffer,
- INCR_CHUNK_SIZE, G_PRIORITY_DEFAULT,
- data->cancellable,
- wayland_data_read_cb, selection);
+ g_input_stream_read_all_async (data->stream, data->buffer,
+ INCR_CHUNK_SIZE, G_PRIORITY_DEFAULT,
+ data->cancellable,
+ wayland_data_read_cb, selection);
}
static void