Only set fd to non-block if there is an EventManager

Fixes #4630
This commit is contained in:
Maxime Coste 2022-06-03 15:54:55 +10:00
parent ac6f928ad4
commit 503e5bc507

View File

@ -258,6 +258,7 @@ void write(int fd, StringView data)
ssize_t count = (int)data.length(); ssize_t count = (int)data.length();
int flags = fcntl(fd, F_GETFL, 0); int flags = fcntl(fd, F_GETFL, 0);
if (EventManager::has_instance())
fcntl(fd, F_SETFL, flags | O_NONBLOCK); fcntl(fd, F_SETFL, flags | O_NONBLOCK);
auto restore_flags = on_scope_end([&] { fcntl(fd, F_SETFL, flags); }); auto restore_flags = on_scope_end([&] { fcntl(fd, F_SETFL, flags); });