mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
LibCore: Always reset the polled revents field back to 0
One benefit of using `poll` over `select` is that we can re-use the poll structure list. But there's no guarantee that the underlying system will reset the `revents` field back to 0. So let's explicitly do so. (cherry picked from commit f46b721c57b9ccde9ad3de3034f626e0a7607e92, tweaked due to additional Userland/ prefix in path)
This commit is contained in:
1 parent
bd261325f8
commit
b385e357cd
1 file changed
+5
-1
@@ -1771,10 +1771,14 @@ ErrorOr<ByteString> readlink(StringView pathname)
|
||||
|
||||
ErrorOr<int> poll(Span<struct pollfd> poll_fds, int timeout)
|
||||
{
|
||||
for (auto& poll_fd : poll_fds)
|
||||
poll_fd.revents = 0;
|
||||
|
||||
auto const rc = ::poll(poll_fds.data(), poll_fds.size(), timeout);
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("poll"sv, -errno);
|
||||
return { rc };
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
||||
Reference in new issue
Block a user