Windows send() does not have a MSG_DONTWAIT. So, use the get_socket_error() function.
Co-authored-by: Linda Sun <l...@vmware.com> Signed-off-by: Linda Sun <l...@vmware.com> Signed-off-by: Gurucharan Shetty <gshe...@nicira.com> --- lib/socket-util.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/socket-util.c b/lib/socket-util.c index 0132133..2e3f4a9 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -282,12 +282,28 @@ lookup_hostname(const char *host_name, struct in_addr *addr) } } +#ifdef _WIN32 +/* Returns the error condition associated with socket 'fd' and resets the + * socket's error status. */ +static int +get_socket_error(int fd) +{ + int error; + + if (getsockopt_int(fd, SOL_SOCKET, SO_ERROR, "SO_ERROR", &error)) { + error = sock_errno(); + } + return error; +} +#endif + int check_connection_completion(int fd) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10); - struct pollfd pfd; int retval; +#ifndef _WIN32 + struct pollfd pfd; pfd.fd = fd; pfd.events = POLLOUT; @@ -311,6 +327,22 @@ check_connection_completion(int fd) } else { return EAGAIN; } +#else + WSAPOLLFD pfd; + pfd.fd = fd; + pfd.events = POLLWRNORM; + + retval = WSAPoll(&pfd, 1, 0); + if (retval == 1) { + return get_socket_error(fd); + } else if (retval == SOCKET_ERROR) { + int error = sock_errno(); + VLOG_ERR_RL(&rl, "poll: %s", sock_strerror(error)); + return error; + } else { + return EAGAIN; + } +#endif } /* Drain all the data currently in the receive queue of a datagram socket (and -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev