From 7009a5941e4920155544aafb071e5beca4500968 Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Tue, 18 Feb 2014 15:09:18 -0800 Subject: [PATCH] socket-util: closesocket() for Windows. For Windows sockets, one has to call closesocket() to close the sockets. Signed-off-by: Gurucharan Shetty Acked-by: Ben Pfaff --- lib/socket-util.c | 4 ++-- lib/socket-util.h | 4 ++++ lib/stream-ssl.c | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/socket-util.c b/lib/socket-util.c index a30408a24..357594d0a 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -810,7 +810,7 @@ exit: memset(ssp, 0, sizeof *ssp); } if (fd >= 0) { - close(fd); + closesocket(fd); fd = -1; } } else { @@ -958,7 +958,7 @@ error: if (ssp) { memset(ssp, 0, sizeof *ssp); } - close(fd); + closesocket(fd); return -error; } diff --git a/lib/socket-util.h b/lib/socket-util.h index 6e55a4c6a..d2bd109bd 100644 --- a/lib/socket-util.h +++ b/lib/socket-util.h @@ -111,4 +111,8 @@ static inline int sock_errno(void) #endif } +#ifndef _WIN32 +#define closesocket close +#endif + #endif /* socket-util.h */ diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c index 0dc832de9..14d62c429 100644 --- a/lib/stream-ssl.c +++ b/lib/stream-ssl.c @@ -60,8 +60,6 @@ * compiled with /MD is not tested. */ #include #define SHUT_RDWR SD_BOTH -#else -#define closesocket close #endif VLOG_DEFINE_THIS_MODULE(stream_ssl); -- 2.43.0