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

Function bpfpoll

freebsd/net/bpf.c:2096–2127  ·  view source on GitHub ↗

* Support for select() and poll() system calls * * Return true iff the specific operation will not block indefinitely. * Otherwise, return false but make a note that a selwakeup() must be done. */

Source from the content-addressed store, hash-verified

2094 * Otherwise, return false but make a note that a selwakeup() must be done.
2095 */
2096static int
2097bpfpoll(struct cdev *dev, int events, struct thread *td)
2098{
2099 struct bpf_d *d;
2100 int revents;
2101
2102 if (devfs_get_cdevpriv((void **)&d) != 0 || d->bd_bif == NULL)
2103 return (events &
2104 (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM));
2105
2106 /*
2107 * Refresh PID associated with this descriptor.
2108 */
2109 revents = events & (POLLOUT | POLLWRNORM);
2110 BPFD_LOCK(d);
2111 BPF_PID_REFRESH(d, td);
2112 if (events & (POLLIN | POLLRDNORM)) {
2113 if (bpf_ready(d))
2114 revents |= events & (POLLIN | POLLRDNORM);
2115 else {
2116 selrecord(td, &d->bd_sel);
2117 /* Start the read timeout if necessary. */
2118 if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) {
2119 callout_reset(&d->bd_callout, d->bd_rtout,
2120 bpf_timed_out, d);
2121 d->bd_state = BPF_WAITING;
2122 }
2123 }
2124 }
2125 BPFD_UNLOCK(d);
2126 return (revents);
2127}
2128
2129/*
2130 * Support for kevent() system call. Register EVFILT_READ filters and

Callers

nothing calls this directly

Calls 2

bpf_readyFunction · 0.85
selrecordFunction · 0.85

Tested by

no test coverage detected