]> Savannah Git Hosting - gnulib.git/commitdiff
sockets: MS Windows initalization fixes
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Sep 2015 18:16:27 +0000 (11:16 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Sep 2015 18:16:49 +0000 (11:16 -0700)
Problem reported by Test User in:
http://lists.gnu.org/archive/html/help-shishi/2015-09/msg00001.html
* lib/sockets.h (SOCKETS_1_0, SOCKETS_2_0, SOCKETS_2_1):
Correct the endianness.
* lib/sockets.c (gl_sockets_startup): Return 2 on any version
number mismatch, not just on <.  Cleanup before any such failure.

ChangeLog
lib/sockets.c
lib/sockets.h

index b42d31aaeb9b001b742d01cbdc241718fd799fa1..abce49aca201e8b74a1e3f050ae5a67667efa5a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-09-25  Paul Eggert  <eggert@cs.ucla.edu>
+
+       sockets: MS Windows initalization fixes
+       Problem reported by Test User in:
+       http://lists.gnu.org/archive/html/help-shishi/2015-09/msg00001.html
+       * lib/sockets.h (SOCKETS_1_0, SOCKETS_2_0, SOCKETS_2_1):
+       Correct the endianness.
+       * lib/sockets.c (gl_sockets_startup): Return 2 on any version
+       number mismatch, not just on <.  Cleanup before any such failure.
+
 2015-09-25  Mats Erik Andersson  <gnu@gisladisker.se>
 
        gc: fix detection of installed libgcrypt version
index 0b60562c4c6acf0ef1972c92d82c41f322096896..e644ff12c95683f3ce98cda7e84ef9fd427ed409 100644 (file)
@@ -121,8 +121,11 @@ gl_sockets_startup (int version _GL_UNUSED)
       if (err != 0)
         return 1;
 
-      if (data.wVersion < version)
-        return 2;
+      if (data.wVersion != version)
+        {
+          WSACleanup ();
+          return 2;
+        }
 
       if (initialized_sockets_version == 0)
         register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket,
index c863dfbef4ba6d5126d6cc0114a0949ab89abf0e..173d03244367f56af591b2a4d7a4ab1ec4489f6b 100644 (file)
 #ifndef SOCKETS_H
 # define SOCKETS_H 1
 
-#define SOCKETS_1_0 0x100  /* don't use - does not work on Windows XP */
-#define SOCKETS_1_1 0x101
-#define SOCKETS_2_0 0x200  /* don't use - does not work on Windows XP */
-#define SOCKETS_2_1 0x201
-#define SOCKETS_2_2 0x202
+#define SOCKETS_1_0 0x0001
+#define SOCKETS_1_1 0x0101
+#define SOCKETS_2_0 0x0002
+#define SOCKETS_2_1 0x0102
+#define SOCKETS_2_2 0x0202
 
 int gl_sockets_startup (int version)
 #if !WINDOWS_SOCKETS