[ovs-dev] [PATCH 09/14] socket-util: closesocket() for Windows.

Gurucharan Shetty shettyg at nicira.com
Wed Feb 19 23:36:20 UTC 2014


For Windows sockets, one has to call closesocket() to
close the sockets.

Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 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 4ec7201..9095418 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -870,7 +870,7 @@ exit:
             memset(ssp, 0, sizeof *ssp);
         }
         if (fd >= 0) {
-            close(fd);
+            closesocket(fd);
             fd = -1;
         }
     } else {
@@ -1018,7 +1018,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 cf2f96d..ba4d686 100644
--- a/lib/socket-util.h
+++ b/lib/socket-util.h
@@ -113,4 +113,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 0dc832d..14d62c4 100644
--- a/lib/stream-ssl.c
+++ b/lib/stream-ssl.c
@@ -60,8 +60,6 @@
  * compiled with /MD is not tested. */
 #include <openssl/applink.c>
 #define SHUT_RDWR SD_BOTH
-#else
-#define closesocket close
 #endif
 
 VLOG_DEFINE_THIS_MODULE(stream_ssl);
-- 
1.7.9.5




More information about the dev mailing list