FreeBSD/sys/cam/ctl/ctl_ha.c
/*
 * Receive a message of the specified size.
 */
Receive a message of the specified size.
Receive a message of the specified size .
ctl_ha_status
ctl_ha_msg_recv(ctl_ha_channel channel, void *addr, size_t len,
		int wait)
{
	struct ha_softc *softc = &ha_softc;
	struct uio uio;
	struct iovec iov;
	int error, flags;
	if (!softc->ha_connected)
		return (CTL_HA_STATUS_DISCONNECT);
	iov.iov_base = addr;
	iov.iov_len = len;
	uio.uio_iov = &iov;
	uio.uio_iovcnt = 1;
	uio.uio_rw = UIO_READ;
	uio.uio_segflg = UIO_SYSSPACE;
	uio.uio_td = curthread;
	uio.uio_resid = len;
	flags = wait ? 0 : MSG_DONTWAIT;
	error = soreceive(softc->ha_so, NULL, &uio, NULL, NULL, &flags);
	if (error == 0)
		return (CTL_HA_STATUS_SUCCESS);
	mtx_lock(&softc->ha_lock);
	if (softc->ha_connected) {
		softc->ha_disconnect = 1;
		softc->ha_wakeup = 1;
		wakeup(&softc->ha_wakeup);
	}
	mtx_unlock(&softc->ha_lock);
	return (CTL_HA_STATUS_ERROR);
}
ctl_ha_status ctl_ha_msg_recv ( ctl_ha_channel channel , void * addr , size_t len , int wait ) { struct ha_softc * softc = & ha_softc ; struct uio uio ; struct iovec iov ; int error , flags ; if ( ! softc -> ha_connected ) return ( CTL_HA_STATUS_DISCONNECT ) ; iov . iov_base = addr ; iov . iov_len = len ; uio . uio_iov = & iov ; uio . uio_iovcnt = 1 ; uio . uio_rw = UIO_READ ; uio . uio_segflg = UIO_SYSSPACE ; uio . uio_td = curthread ; uio . uio_resid = len ; flags = wait ? 0 : MSG_DONTWAIT ; error = soreceive ( softc -> ha_so , NULL , & uio , NULL , NULL , & flags ) ; if ( error == 0 ) return ( CTL_HA_STATUS_SUCCESS ) ; mtx_lock ( & softc -> ha_lock ) ; if ( softc -> ha_connected ) { softc -> ha_disconnect = 1 ; softc -> ha_wakeup = 1 ; wakeup ( & softc -> ha_wakeup ) ; } mtx_unlock ( & softc -> ha_lock ) ; return ( CTL_HA_STATUS_ERROR ) ; }
Receive a message of the specified size.
Receive a message of the specified size .
/* Consider all errors fatal for HA sanity. */