socket-util: closesocket() for Windows.
authorGurucharan Shetty <gshetty@nicira.com>
Tue, 18 Feb 2014 23:09:18 +0000 (15:09 -0800)
committerGurucharan Shetty <gshetty@nicira.com>
Fri, 21 Feb 2014 16:12:53 +0000 (08:12 -0800)
For Windows sockets, one has to call closesocket() to
close the sockets.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/socket-util.c
lib/socket-util.h
lib/stream-ssl.c

index a30408a..357594d 100644 (file)
@@ -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;
 }
 
index 6e55a4c..d2bd109 100644 (file)
@@ -111,4 +111,8 @@ static inline int sock_errno(void)
 #endif
 }
 
+#ifndef _WIN32
+#define closesocket close
+#endif
+
 #endif /* socket-util.h */
index 0dc832d..14d62c4 100644 (file)
@@ -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);