MCPcopy Create free account
hub / github.com/F-Stack/f-stack / selscan

Function selscan

freebsd/kern/sys_generic.c:1362–1402  ·  view source on GitHub ↗

* Perform the initial filedescriptor scan and register ourselves with * each selinfo. */

Source from the content-addressed store, hash-verified

1360 * each selinfo.
1361 */
1362static int
1363selscan(struct thread *td, fd_mask **ibits, fd_mask **obits, int nfd)
1364{
1365 struct filedesc *fdp;
1366 struct file *fp;
1367 fd_mask bit;
1368 int ev, flags, end, fd;
1369 int n, idx;
1370 int error;
1371 bool only_user;
1372
1373 fdp = td->td_proc->p_fd;
1374 n = 0;
1375 only_user = FILEDESC_IS_ONLY_USER(fdp);
1376 for (idx = 0, fd = 0; fd < nfd; idx++) {
1377 end = imin(fd + NFDBITS, nfd);
1378 for (bit = 1; fd < end; bit <<= 1, fd++) {
1379 /* Compute the list of events we're interested in. */
1380 flags = selflags(ibits, idx, bit);
1381 if (flags == 0)
1382 continue;
1383 if (only_user)
1384 error = fget_only_user(fdp, fd, &cap_event_rights, &fp);
1385 else
1386 error = fget_unlocked(fdp, fd, &cap_event_rights, &fp);
1387 if (__predict_false(error != 0))
1388 return (error);
1389 selfdalloc(td, (void *)(uintptr_t)fd);
1390 ev = fo_poll(fp, flags, td->td_ucred, td);
1391 if (only_user)
1392 fput_only_user(fdp, fp);
1393 else
1394 fdrop(fp, td);
1395 if (ev != 0)
1396 n += selsetbits(ibits, obits, idx, bit, ev);
1397 }
1398 }
1399
1400 td->td_retval[0] = n;
1401 return (0);
1402}
1403
1404int
1405sys_poll(struct thread *td, struct poll_args *uap)

Callers 1

kern_selectFunction · 0.85

Calls 7

iminFunction · 0.85
selflagsFunction · 0.85
fget_only_userFunction · 0.85
fget_unlockedFunction · 0.85
selfdallocFunction · 0.85
fo_pollFunction · 0.85
selsetbitsFunction · 0.85

Tested by

no test coverage detected