Fix some issues with select()

This commit is contained in:
Justine Tunney 2023-10-04 09:10:58 -07:00
parent 6918c3ffc2
commit 982dc4db87
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
4 changed files with 67 additions and 37 deletions

View file

@ -43,14 +43,15 @@ const char *(DescribeFdSet)(char buf[N], ssize_t rc, int nfds, fd_set *fds) {
for (int fd = 0; fd < nfds; fd += 64) {
uint64_t w = fds->fds_bits[fd >> 6];
while (w) {
unsigned o = _bsr(w);
w &= ~((uint64_t)1 << o);
if (fd + o < nfds) {
unsigned m = _bsr(w);
w &= ~((uint64_t)1 << m);
if (fd + m < nfds) {
if (!gotsome) {
gotsome = true;
} else {
append(", ");
append("%d", fd);
}
append("%d", fd + m);
}
}
}