mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-10 22:44:30 +00:00
libc: reduce file descriptor lookup exceptions in 'select()'
Fixes #3908
This commit is contained in:
parent
058f2e687c
commit
5c47fa0d41
@ -1222,13 +1222,19 @@ int Socket_fs::Plugin::select(int nfds,
|
|||||||
|
|
||||||
for (int fd = 0; fd < nfds; ++fd) {
|
for (int fd = 0; fd < nfds; ++fd) {
|
||||||
|
|
||||||
|
bool fd_in_readfds = FD_ISSET(fd, &in_readfds);
|
||||||
|
bool fd_in_writefds = FD_ISSET(fd, &in_writefds);
|
||||||
|
|
||||||
|
if (!fd_in_readfds && !fd_in_writefds)
|
||||||
|
continue;
|
||||||
|
|
||||||
File_descriptor *fdo = file_descriptor_allocator()->find_by_libc_fd(fd);
|
File_descriptor *fdo = file_descriptor_allocator()->find_by_libc_fd(fd);
|
||||||
|
|
||||||
/* handle only fds that belong to this plugin */
|
/* handle only fds that belong to this plugin */
|
||||||
if (!fdo || (fdo->plugin != this))
|
if (!fdo || (fdo->plugin != this))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (FD_ISSET(fd, &in_readfds)) {
|
if (fd_in_readfds) {
|
||||||
try {
|
try {
|
||||||
Socket_fs::Context *context = dynamic_cast<Socket_fs::Context *>(fdo->context);
|
Socket_fs::Context *context = dynamic_cast<Socket_fs::Context *>(fdo->context);
|
||||||
|
|
||||||
@ -1239,7 +1245,7 @@ int Socket_fs::Plugin::select(int nfds,
|
|||||||
} catch (Socket_fs::Context::Inaccessible) { }
|
} catch (Socket_fs::Context::Inaccessible) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(fd, &in_writefds)) {
|
if (fd_in_writefds) {
|
||||||
try {
|
try {
|
||||||
Socket_fs::Context *context = dynamic_cast<Socket_fs::Context *>(fdo->context);
|
Socket_fs::Context *context = dynamic_cast<Socket_fs::Context *>(fdo->context);
|
||||||
|
|
||||||
|
@ -2080,6 +2080,12 @@ int Libc::Vfs_plugin::select(int nfds,
|
|||||||
auto fn = [&] {
|
auto fn = [&] {
|
||||||
for (int fd = 0; fd < nfds; ++fd) {
|
for (int fd = 0; fd < nfds; ++fd) {
|
||||||
|
|
||||||
|
bool fd_in_readfds = FD_ISSET(fd, &in_readfds);
|
||||||
|
bool fd_in_writefds = FD_ISSET(fd, &in_writefds);
|
||||||
|
|
||||||
|
if (!fd_in_readfds && !fd_in_writefds)
|
||||||
|
continue;
|
||||||
|
|
||||||
File_descriptor *fdo =
|
File_descriptor *fdo =
|
||||||
file_descriptor_allocator()->find_by_libc_fd(fd);
|
file_descriptor_allocator()->find_by_libc_fd(fd);
|
||||||
|
|
||||||
@ -2090,7 +2096,7 @@ int Libc::Vfs_plugin::select(int nfds,
|
|||||||
Vfs::Vfs_handle *handle = vfs_handle(fdo);
|
Vfs::Vfs_handle *handle = vfs_handle(fdo);
|
||||||
if (!handle) continue;
|
if (!handle) continue;
|
||||||
|
|
||||||
if (FD_ISSET(fd, &in_readfds)) {
|
if (fd_in_readfds) {
|
||||||
if (handle->fs().read_ready(handle)) {
|
if (handle->fs().read_ready(handle)) {
|
||||||
FD_SET(fd, readfds);
|
FD_SET(fd, readfds);
|
||||||
++nready;
|
++nready;
|
||||||
@ -2099,7 +2105,7 @@ int Libc::Vfs_plugin::select(int nfds,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(fd, &in_writefds)) {
|
if (fd_in_writefds) {
|
||||||
if (true /* XXX always writeable */) {
|
if (true /* XXX always writeable */) {
|
||||||
FD_SET(fd, writefds);
|
FD_SET(fd, writefds);
|
||||||
++nready;
|
++nready;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user