From de8bd5976a149b9e6d892d792b2df6e029d5574d Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Tue, 18 Feb 2014 07:43:26 -0800 Subject: [PATCH] socket-util: set_nonblocking for Windows. Co-authored-by: Linda Sun Signed-off-by: Linda Sun Signed-off-by: Gurucharan Shetty Acked-by: Ben Pfaff --- lib/socket-util.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/socket-util.c b/lib/socket-util.c index 85ca5171e..c76b11615 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -73,6 +73,7 @@ static int getsockopt_int(int fd, int level, int option, const char *optname, int set_nonblocking(int fd) { +#ifndef _WIN32 int flags = fcntl(fd, F_GETFL, 0); if (flags != -1) { if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) != -1) { @@ -85,6 +86,15 @@ set_nonblocking(int fd) VLOG_ERR("fcntl(F_GETFL) failed: %s", ovs_strerror(errno)); return errno; } +#else + unsigned long arg = 1; + if (ioctlsocket(fd, FIONBIO, &arg)) { + int error = sock_errno(); + VLOG_ERR("set_nonblocking failed: %s", sock_strerror(error)); + return error; + } + return 0; +#endif } void -- 2.43.0