FreeBSD/sys/net/bpf.c
/*
 * 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.
 */
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.
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 .
static int
bpfpoll(struct cdev *dev, int events, struct thread *td)
{
	struct bpf_d *d;
	int revents;
	if (devfs_get_cdevpriv((void **)&d) != 0 || d->bd_bif == NULL)
		return (events &
		    (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM));
	revents = events & (POLLOUT | POLLWRNORM);
	BPFD_LOCK(d);
	BPF_PID_REFRESH(d, td);
	if (events & (POLLIN | POLLRDNORM)) {
		if (bpf_ready(d))
			revents |= events & (POLLIN | POLLRDNORM);
		else {
			selrecord(td, &d->bd_sel);
			if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) {
				callout_reset(&d->bd_callout, d->bd_rtout,
				    bpf_timed_out, d);
				d->bd_state = BPF_WAITING;
			}
		}
	}
	BPFD_UNLOCK(d);
	return (revents);
}
static int bpfpoll ( struct cdev * dev , int events , struct thread * td ) { struct bpf_d * d ; int revents ; if ( devfs_get_cdevpriv ( ( void * * ) & d ) != 0 || d -> bd_bif == NULL ) return ( events & ( POLLHUP | POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM ) ) ; revents = events & ( POLLOUT | POLLWRNORM ) ; BPFD_LOCK ( d ) ; BPF_PID_REFRESH ( d , td ) ; if ( events & ( POLLIN | POLLRDNORM ) ) { if ( bpf_ready ( d ) ) revents |= events & ( POLLIN | POLLRDNORM ) ; else { selrecord ( td , & d -> bd_sel ) ; if ( d -> bd_rtout > 0 && d -> bd_state == BPF_IDLE ) { callout_reset ( & d -> bd_callout , d -> bd_rtout , bpf_timed_out , d ) ; d -> bd_state = BPF_WAITING ; } } } BPFD_UNLOCK ( d ) ; return ( revents ) ; }
Support for select() and poll() system calls
 Return true iff the specific operation will not block indefinitely.
Support for select () and poll () system calls Return true iff the specific operation will not block indefinitely .
/*
	 * Refresh PID associated with this descriptor.
	 */ /* Start the read timeout if necessary. */