Skip to content

Commit c59d4dc

Browse files
flibitijibiboslouken
authored andcommitted
wayland: Dramatically lower the timeout when reading/writing pipes
1 parent cf12496 commit c59d4dc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/video/wayland/SDL_waylanddatamanager.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636

3737
#include "SDL_waylanddyn.h"
3838

39+
/* FIXME: This is arbitrary, but we want this to be less than a frame because
40+
* any longer can potentially spin an infinite loop of PumpEvents (!)
41+
*/
42+
#define PIPE_MS_TIMEOUT 10
43+
3944
static ssize_t
4045
write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos)
4146
{
@@ -47,7 +52,7 @@ write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos)
4752
sigset_t old_sig_set;
4853
struct timespec zerotime = {0};
4954

50-
ready = SDL_IOReady(fd, SDL_TRUE, 1 * 1000);
55+
ready = SDL_IOReady(fd, SDL_TRUE, PIPE_MS_TIMEOUT);
5156

5257
sigemptyset(&sig_set);
5358
sigaddset(&sig_set, SIGPIPE);
@@ -93,7 +98,7 @@ read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate)
9398
ssize_t bytes_read = 0;
9499
size_t pos = 0;
95100

96-
ready = SDL_IOReady(fd, SDL_FALSE, 1 * 1000);
101+
ready = SDL_IOReady(fd, SDL_FALSE, PIPE_MS_TIMEOUT);
97102

98103
if (ready == 0) {
99104
bytes_read = SDL_SetError("Pipe timeout");

0 commit comments

Comments
 (0)