summaryrefslogtreecommitdiff
path: root/src/xwayland/Server.cpp
diff options
context:
space:
mode:
authorTom Englund <tomenglund26@gmail.com>2025-03-24 19:33:07 +0100
committerGitHub <noreply@github.com>2025-03-24 19:33:07 +0100
commit2a6d070774df4c17ca7d7d427065b04d0c77250a (patch)
treec9b844ed590e118bd9e5841db11d81a057ecd5dc /src/xwayland/Server.cpp
parentaec69131cd3daa6915facef21b32c4914d22af90 (diff)
xwl: dont close the fd to early (#9715)
dont close the fd until the wl_event_source is removed, so we dont get another event triggered with an already closed fd.
Diffstat (limited to 'src/xwayland/Server.cpp')
-rw-r--r--src/xwayland/Server.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/xwayland/Server.cpp b/src/xwayland/Server.cpp
index 6f057f9e..dd6206d2 100644
--- a/src/xwayland/Server.cpp
+++ b/src/xwayland/Server.cpp
@@ -177,8 +177,7 @@ static void startServer(void* data) {
}
static int xwaylandReady(int fd, uint32_t mask, void* data) {
- CFileDescriptor xwlFd{fd};
- return g_pXWayland->pServer->ready(std::move(xwlFd), mask);
+ return g_pXWayland->pServer->ready(fd, mask);
}
static bool safeRemove(const std::string& path) {
@@ -300,7 +299,7 @@ void CXWaylandServer::runXWayland(CFileDescriptor& notifyFD) {
}
auto cmd =
- std::format("Xwayland {} -rootless -core -listenfd {} -listenfd {} -displayfd {} -wm {}", displayName, xFDs[0].get(), xFDs[1].get(), notifyFD.get(), xwmFDs[1].get());
+ std::format("Xwayland {} -rootless -core -listenfd {} -listenfd {} -displayfd {} -wm {}", displayName, xFDs[0].get(), xFDs[1].get(), notifyFD.take(), xwmFDs[1].get());
auto waylandSocket = std::format("{}", waylandFDs[1].get());
setenv("WAYLAND_SOCKET", waylandSocket.c_str(), true);
@@ -392,11 +391,11 @@ bool CXWaylandServer::start() {
return true;
}
-int CXWaylandServer::ready(CFileDescriptor fd, uint32_t mask) {
+int CXWaylandServer::ready(int fd, uint32_t mask) {
if (mask & WL_EVENT_READABLE) {
// xwayland writes twice
char buf[64];
- ssize_t n = read(fd.get(), buf, sizeof(buf));
+ ssize_t n = read(fd, buf, sizeof(buf));
if (n < 0 && errno != EINTR) {
Debug::log(ERR, "Xwayland: read from displayFd failed");
mask = 0;
@@ -421,6 +420,7 @@ int CXWaylandServer::ready(CFileDescriptor fd, uint32_t mask) {
Debug::log(LOG, "XWayland is ready");
+ close(fd);
wl_event_source_remove(pipeSource);
pipeSource = nullptr;