Skip to content

Commit

Permalink
wayland: Dramatically lower the timeout when reading/writing pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo authored and slouken committed Apr 10, 2021
1 parent cf12496 commit c59d4dc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/video/wayland/SDL_waylanddatamanager.c
Expand Up @@ -36,6 +36,11 @@

#include "SDL_waylanddyn.h"

/* FIXME: This is arbitrary, but we want this to be less than a frame because
* any longer can potentially spin an infinite loop of PumpEvents (!)
*/
#define PIPE_MS_TIMEOUT 10

static ssize_t
write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos)
{
Expand All @@ -47,7 +52,7 @@ write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos)
sigset_t old_sig_set;
struct timespec zerotime = {0};

ready = SDL_IOReady(fd, SDL_TRUE, 1 * 1000);
ready = SDL_IOReady(fd, SDL_TRUE, PIPE_MS_TIMEOUT);

sigemptyset(&sig_set);
sigaddset(&sig_set, SIGPIPE);
Expand Down Expand Up @@ -93,7 +98,7 @@ read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate)
ssize_t bytes_read = 0;
size_t pos = 0;

ready = SDL_IOReady(fd, SDL_FALSE, 1 * 1000);
ready = SDL_IOReady(fd, SDL_FALSE, PIPE_MS_TIMEOUT);

if (ready == 0) {
bytes_read = SDL_SetError("Pipe timeout");
Expand Down

0 comments on commit c59d4dc

Please sign in to comment.