From 0eadaec2d8bfd3297c0d8c11696351354dab4ce8 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 3 Sep 2024 20:18:13 +0100 Subject: [PATCH] Port EI fixes to use `pipe2` instead of `pipe` and `fcntl` (#7470) * Kill build to prevent multiple processes running in dev * Port EI fixes to use `pipe2` instead of `pipe` and `fcntl` --- .vscode/launch.json | 8 ++++---- src/lib/platform/EiEventQueueBuffer.cpp | 8 +------- src/lib/platform/XWindowsEventQueueBuffer.cpp | 8 +------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 238ac908a..2448274b4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -58,7 +58,7 @@ "cwd": "${workspaceRoot}", "request": "launch", "program": "${workspaceFolder}/build/bin/synergys", - "preLaunchTask": "build" + "preLaunchTask": "kill-build" }, { "name": "server windows", @@ -67,7 +67,7 @@ "request": "launch", "program": "${workspaceFolder}/build/bin/synergys", "internalConsoleOptions": "openOnSessionStart", - "preLaunchTask": "build" + "preLaunchTask": "kill-build" }, { "name": "client unix", @@ -75,7 +75,7 @@ "cwd": "${workspaceRoot}", "request": "launch", "program": "${workspaceFolder}/build/bin/synergyc", - "preLaunchTask": "build" + "preLaunchTask": "kill-build" }, { "name": "client windows", @@ -84,7 +84,7 @@ "request": "launch", "program": "${workspaceFolder}/build/bin/synergyc", "internalConsoleOptions": "openOnSessionStart", - "preLaunchTask": "build" + "preLaunchTask": "kill-build" }, { "name": "daemon windows", diff --git a/src/lib/platform/EiEventQueueBuffer.cpp b/src/lib/platform/EiEventQueueBuffer.cpp index 819aeba47..a7c4efe80 100644 --- a/src/lib/platform/EiEventQueueBuffer.cpp +++ b/src/lib/platform/EiEventQueueBuffer.cpp @@ -40,15 +40,9 @@ EiEventQueueBuffer::EiEventQueueBuffer( events_(events) { // We need a pipe to signal ourselves when addEvent() is called int pipefd[2]; - int result = pipe(pipefd); + int result = pipe2(pipefd, O_NONBLOCK); assert(result == 0); - int pipeflags; - pipeflags = fcntl(pipefd[0], F_GETFL); - fcntl(pipefd[0], F_SETFL, pipeflags | O_NONBLOCK); - pipeflags = fcntl(pipefd[1], F_GETFL); - fcntl(pipefd[1], F_SETFL, pipeflags | O_NONBLOCK); - pipe_r_ = pipefd[0]; pipe_w_ = pipefd[1]; } diff --git a/src/lib/platform/XWindowsEventQueueBuffer.cpp b/src/lib/platform/XWindowsEventQueueBuffer.cpp index ad40817d0..9c36772eb 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/XWindowsEventQueueBuffer.cpp @@ -51,14 +51,8 @@ XWindowsEventQueueBuffer::XWindowsEventQueueBuffer( m_userEvent = XInternAtom(m_display, "SYNERGY_USER_EVENT", False); // set up for pipe hack - int result = pipe(m_pipefd); + int result = pipe2(m_pipefd, O_NONBLOCK); assert(result == 0); - - int pipeflags; - pipeflags = fcntl(m_pipefd[0], F_GETFL); - fcntl(m_pipefd[0], F_SETFL, pipeflags | O_NONBLOCK); - pipeflags = fcntl(m_pipefd[1], F_GETFL); - fcntl(m_pipefd[1], F_SETFL, pipeflags | O_NONBLOCK); } XWindowsEventQueueBuffer::~XWindowsEventQueueBuffer() {