Page MenuHomeFreeBSD

D62011.1795646595.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D62011.1795646595.diff

diff --git a/sys/dev/hyperv/hvsock/hv_sock.h b/sys/dev/hyperv/hvsock/hv_sock.h
--- a/sys/dev/hyperv/hvsock/hv_sock.h
+++ b/sys/dev/hyperv/hvsock/hv_sock.h
@@ -109,6 +109,7 @@
struct uio *, struct mbuf **, struct mbuf **, int *);
int hvs_trans_sosend(struct socket *, struct sockaddr *, struct uio *,
struct mbuf *, struct mbuf *, int, struct thread *);
+int hvs_trans_sopoll(struct socket *, int, struct thread *);
int hvs_trans_disconnect(struct socket *);
int hvs_trans_shutdown(struct socket *, enum shutdown_how);
diff --git a/sys/dev/hyperv/hvsock/hv_sock.c b/sys/dev/hyperv/hvsock/hv_sock.c
--- a/sys/dev/hyperv/hvsock/hv_sock.c
+++ b/sys/dev/hyperv/hvsock/hv_sock.c
@@ -30,6 +30,7 @@
#include <sys/bus.h>
#include <sys/domain.h>
#include <sys/lock.h>
+#include <sys/poll.h>
#include <sys/kernel.h>
#include <sys/types.h>
#include <sys/malloc.h>
@@ -99,6 +100,7 @@
.pr_sockaddr = hvs_trans_sockaddr,
.pr_soreceive = hvs_trans_soreceive,
.pr_sosend = hvs_trans_sosend,
+ .pr_sopoll = hvs_trans_sopoll,
.pr_disconnect = hvs_trans_disconnect,
.pr_close = hvs_trans_close,
.pr_detach = hvs_trans_detach,
@@ -876,6 +878,79 @@
return (error);
}
+int
+hvs_trans_sopoll(struct socket *so, int events, struct thread *td)
+{
+ struct hvs_pcb *pcb;
+ int revents;
+
+ HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
+ "%s: HyperV Socket hvs_trans_sopoll called\n", __func__);
+
+ (void) hvs_trans_lock();
+ SOCK_LOCK(so);
+ if (SOLISTENING(so)) {
+ if (!(events & (POLLIN | POLLRDNORM)))
+ revents = 0;
+ else if (!TAILQ_EMPTY(&so->sol_comp))
+ revents = events & (POLLIN | POLLRDNORM);
+ else if ((events & POLLINIGNEOF) == 0 && so->so_error)
+ revents = (events & (POLLIN | POLLRDNORM)) | POLLHUP;
+ else {
+ selrecord(td, &so->so_rdsel);
+ revents = 0;
+ }
+ } else {
+ pcb = so2hvspcb(so);
+ if (pcb == NULL) {
+ revents = POLLERR;
+ goto out;
+ }
+
+ revents = 0;
+ SOCK_SENDBUF_LOCK(so);
+ SOCK_RECVBUF_LOCK(so);
+ if (events & (POLLIN | POLLRDNORM))
+ if (hvsock_poll_readable(pcb) || so->so_error || so->so_rerror)
+ revents |= events & (POLLIN | POLLRDNORM);
+ if (events & (POLLOUT | POLLWRNORM))
+ if (hvsock_canwrite_check(pcb) > 0 ||
+ (so->so_snd.sb_state & SBS_CANTSENDMORE) || so->so_error)
+ revents |= events & (POLLOUT | POLLWRNORM);
+ if (events & (POLLPRI | POLLRDBAND))
+ if (so->so_oobmark ||
+ (so->so_rcv.sb_state & SBS_RCVATMARK))
+ revents |= events & (POLLPRI | POLLRDBAND);
+ if ((events & POLLINIGNEOF) == 0) {
+ if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
+ revents |= events & (POLLIN | POLLRDNORM);
+ if (so->so_snd.sb_state & SBS_CANTSENDMORE)
+ revents |= POLLHUP;
+ }
+ }
+ if (so->so_rcv.sb_state & SBS_CANTRCVMORE)
+ revents |= events & POLLRDHUP;
+ if (revents == 0) {
+ if (events &
+ (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND | POLLRDHUP)) {
+ selrecord(td, &so->so_rdsel);
+ so->so_rcv.sb_flags |= SB_SEL;
+ }
+ if (events & (POLLOUT | POLLWRNORM)) {
+ selrecord(td, &so->so_wrsel);
+ so->so_snd.sb_flags |= SB_SEL;
+ }
+ }
+ SOCK_RECVBUF_UNLOCK(so);
+ SOCK_SENDBUF_UNLOCK(so);
+ }
+out:
+ SOCK_UNLOCK(so);
+ hvs_trans_unlock();
+
+ return (revents);
+}
+
int
hvs_trans_peeraddr(struct socket *so, struct sockaddr *sa)
{

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 25, 10:43 PM (21 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41997889
Default Alt Text
D62011.1795646595.diff (3 KB)

Event Timeline