gwakeup: Use O_NONBLOCK to avoid a fcntl() syscall where possible

Create the wakeup pipe using the `O_NONBLOCK` flag for `pipe2()`, where
possible.

This saves a couple of `fcntl()` syscalls every time a wakeup pipe is
created, which is at least once per `GMainContext`.

This uses the `O_NONBLOCK` support added to `g_unix_open_pipe()` in the
previous commit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2023-03-23 00:55:59 +00:00
parent 5c65437d73
commit aab9cea326

View File

@ -160,7 +160,7 @@ g_wakeup_new (void)
/* for any failure, try a pipe instead */
#endif
if (!g_unix_open_pipe (wakeup->fds, FD_CLOEXEC, &error))
if (!g_unix_open_pipe (wakeup->fds, FD_CLOEXEC | O_NONBLOCK, &error))
g_error ("Creating pipes for GWakeup: %s", error->message);
if (!g_unix_set_fd_nonblocking (wakeup->fds[0], TRUE, &error) ||