>From 16acceb42ac05eaf3a9d5a9fe60fb4160f4dd64c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 25 Sep 2015 11:16:27 -0700 Subject: [PATCH] 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. --- ChangeLog | 10 ++++++++++ lib/sockets.c | 7 +++++-- lib/sockets.h | 10 +++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index b42d31a..abce49a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2015-09-25 Paul Eggert + + 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 gc: fix detection of installed libgcrypt version diff --git a/lib/sockets.c b/lib/sockets.c index 0b60562..e644ff1 100644 --- a/lib/sockets.c +++ b/lib/sockets.c @@ -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, diff --git a/lib/sockets.h b/lib/sockets.h index c863dfb..173d032 100644 --- a/lib/sockets.h +++ b/lib/sockets.h @@ -20,11 +20,11 @@ #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 -- 2.1.0