2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 22:35:15 +00:00

socket-util: poll() for Windows.

Also, Windows does not have a MSG_DONTWAIT. Get rid of it
as we always use non-blocking sockets.

Co-authored-by: Linda Sun <lsun@vmware.com>
Signed-off-by: Linda Sun <lsun@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Gurucharan Shetty
2014-02-18 12:52:01 -08:00
parent 1bbd172824
commit 1bada7ab12

View File

@@ -224,14 +224,19 @@ check_connection_completion(int fd)
pfd.fd = fd;
pfd.events = POLLOUT;
#ifndef _WIN32
do {
retval = poll(&pfd, 1, 0);
} while (retval < 0 && errno == EINTR);
#else
retval = WSAPoll(&pfd, 1, 0);
#endif
if (retval == 1) {
if (pfd.revents & POLLERR) {
ssize_t n = send(fd, "", 1, MSG_DONTWAIT);
ssize_t n = send(fd, "", 1, 0);
if (n < 0) {
return errno;
return sock_errno();
} else {
VLOG_ERR_RL(&rl, "poll return POLLERR but send succeeded");
return EPROTO;
@@ -239,7 +244,7 @@ check_connection_completion(int fd)
}
return 0;
} else if (retval < 0) {
VLOG_ERR_RL(&rl, "poll: %s", ovs_strerror(errno));
VLOG_ERR_RL(&rl, "poll: %s", sock_strerror(sock_errno()));
return errno;
} else {
return EAGAIN;
@@ -271,8 +276,7 @@ drain_rcvbuf(int fd)
* On other Unix-like OSes, MSG_TRUNC has no effect in the flags
* argument. */
char buffer[LINUX_DATAPATH ? 1 : 2048];
ssize_t n_bytes = recv(fd, buffer, sizeof buffer,
MSG_TRUNC | MSG_DONTWAIT);
ssize_t n_bytes = recv(fd, buffer, sizeof buffer, MSG_TRUNC);
if (n_bytes <= 0 || n_bytes >= rcvbuf) {
break;
}