FreeBSD/sys/cam/scsi/scsi_target.c
/* Writes are always ready, reads wait for user_ccb_queue or abort_queue */
Writes are always ready, reads wait for user_ccb_queue or abort_queue
Writes are always ready reads wait for user_ccb_queue or abort_queue
static int
targpoll(struct cdev *dev, int poll_events, struct thread *td)
{
	struct targ_softc *softc;
	int	revents;
	devfs_get_cdevpriv((void **)&softc);
	revents = poll_events & (POLLOUT | POLLWRNORM);
	if ((poll_events & (POLLIN | POLLRDNORM)) != 0) {
		cam_periph_lock(softc->periph);
		if (!TAILQ_EMPTY(&softc->user_ccb_queue) ||
		    !TAILQ_EMPTY(&softc->abort_queue)) {
			revents |= poll_events & (POLLIN | POLLRDNORM);
		}
		cam_periph_unlock(softc->periph);
		if (revents == 0)
			selrecord(td, &softc->read_select);
	}
	return (revents);
}
static int targpoll ( struct cdev * dev , int poll_events , struct thread * td ) { struct targ_softc * softc ; int revents ; devfs_get_cdevpriv ( ( void * * ) & softc ) ; revents = poll_events & ( POLLOUT | POLLWRNORM ) ; if ( ( poll_events & ( POLLIN | POLLRDNORM ) ) != 0 ) { cam_periph_lock ( softc -> periph ) ; if ( ! TAILQ_EMPTY ( & softc -> user_ccb_queue ) || ! TAILQ_EMPTY ( & softc -> abort_queue ) ) { revents |= poll_events & ( POLLIN | POLLRDNORM ) ; } cam_periph_unlock ( softc -> periph ) ; if ( revents == 0 ) selrecord ( td , & softc -> read_select ) ; } return ( revents ) ; }
Writes are always ready, reads wait for user_ccb_queue or abort_queue
Writes are always ready reads wait for user_ccb_queue or abort_queue
/* Poll for write() is always ok. */ /* Poll for read() depends on user and abort queues. */ /* Only sleep if the user didn't poll for write. */