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

Function pollrescan

freebsd/kern/sys_generic.c:1553–1601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1551}
1552
1553static int
1554pollrescan(struct thread *td)
1555{
1556 struct seltd *stp;
1557 struct selfd *sfp;
1558 struct selfd *sfn;
1559 struct selinfo *si;
1560 struct filedesc *fdp;
1561 struct file *fp;
1562 struct pollfd *fd;
1563 int n, error;
1564 bool only_user;
1565
1566 n = 0;
1567 fdp = td->td_proc->p_fd;
1568 stp = td->td_sel;
1569 only_user = FILEDESC_IS_ONLY_USER(fdp);
1570 STAILQ_FOREACH_SAFE(sfp, &stp->st_selq, sf_link, sfn) {
1571 fd = (struct pollfd *)sfp->sf_cookie;
1572 si = sfp->sf_si;
1573 selfdfree(stp, sfp);
1574 /* If the selinfo wasn't cleared the event didn't fire. */
1575 if (si != NULL)
1576 continue;
1577 if (only_user)
1578 error = fget_only_user(fdp, fd->fd, &cap_event_rights, &fp);
1579 else
1580 error = fget_unlocked(fdp, fd->fd, &cap_event_rights, &fp);
1581 if (__predict_false(error != 0)) {
1582 fd->revents = POLLNVAL;
1583 n++;
1584 continue;
1585 }
1586 /*
1587 * Note: backend also returns POLLHUP and
1588 * POLLERR if appropriate.
1589 */
1590 fd->revents = fo_poll(fp, fd->events, td->td_ucred, td);
1591 if (only_user)
1592 fput_only_user(fdp, fp);
1593 else
1594 fdrop(fp, td);
1595 if (fd->revents != 0)
1596 n++;
1597 }
1598 stp->st_flags = 0;
1599 td->td_retval[0] = n;
1600 return (0);
1601}
1602
1603static int
1604pollout(struct thread *td, struct pollfd *fds, struct pollfd *ufds, u_int nfd)

Callers 1

kern_pollFunction · 0.85

Calls 4

selfdfreeFunction · 0.85
fget_only_userFunction · 0.85
fget_unlockedFunction · 0.85
fo_pollFunction · 0.85

Tested by

no test coverage detected