summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInho Lee <inho.lee@qt.io>2022-10-06 19:46:56 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-11-01 09:02:09 +0000
commit4ee03c3978e948792d76014a17da79b9b3a90062 (patch)
treebac7e72002f61b6240f269361b3223850abc4736
parentdc6c65a18d9c08fa062a13b44ab201f90cf6e253 (diff)
downloadqtwayland-4ee03c3978e948792d76014a17da79b9b3a90062.tar.gz
Always use blocking write for data_source.send
QtWaylandClient assumes that data_source's fd is BLOCKING, but some compositors (e.g. mutter) pass an fd with O_NONBLOCK set. In this case, 'write' is not guaranteed to process all of the passed data in one call. Instead of dealing with such partial writes, remove O_NONBLOCK. Fixes: QTBUG-107076 Change-Id: Ieb446da9fdfbaaa55100f573b396ee449cadc463 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> (cherry picked from commit 5025ac15088d1b85007b3d3439c14bdc3e4979a1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/client/qwaylanddatasource.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/client/qwaylanddatasource.cpp b/src/client/qwaylanddatasource.cpp
index ef1d14d3..093c40f2 100644
--- a/src/client/qwaylanddatasource.cpp
+++ b/src/client/qwaylanddatasource.cpp
@@ -13,6 +13,7 @@
#include <unistd.h>
#include <signal.h>
+#include <fcntl.h>
QT_BEGIN_NAMESPACE
@@ -57,6 +58,13 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
action.sa_flags = 0;
sigaction(SIGPIPE, &action, &oldAction);
+ // Some compositors (e.g., mutter) make fd with O_NONBLOCK.
+ // Since wl_data_source.send describes that fd is closed here,
+ // it should be done in a loop and don't have any advantage.
+ // Blocking operation will be used.
+ // According to fcntl(2), FSETFL ignores O_WRONLY. So this
+ // call will just remove O_NONBLOCK.
+ fcntl(fd, F_SETFL, O_WRONLY);
ssize_t unused = write(fd, content.constData(), content.size());
Q_UNUSED(unused);
sigaction(SIGPIPE, &oldAction, nullptr);