diff options
author | Simon Josefsson <simon@josefsson.org> | 2009-08-06 16:30:15 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2009-08-06 16:30:15 +0200 |
commit | 92a5cd11f9b33f427c495dca22d9aac1cf7b1f3d (patch) | |
tree | b3bb68a392114cd82b5f174061b0d6ab77cfa1f2 /lib/gl/sockets.c | |
parent | a532faf3bd6d95bf41ba75733a72b504090667af (diff) | |
download | gnutls-92a5cd11f9b33f427c495dca22d9aac1cf7b1f3d.tar.gz |
Update gnulib files.
Diffstat (limited to 'lib/gl/sockets.c')
-rw-r--r-- | lib/gl/sockets.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/gl/sockets.c b/lib/gl/sockets.c index 758bad98ae..f0bf0acfb4 100644 --- a/lib/gl/sockets.c +++ b/lib/gl/sockets.c @@ -69,23 +69,31 @@ close_fd_maybe_socket (int fd, const struct close_hook *remaining_list) static struct close_hook close_sockets_hook; +static int initialized_sockets_version /* = 0 */; + #endif int gl_sockets_startup (int version) { #if WINDOWS_SOCKETS - WSADATA data; - int err; + if (version > initialized_sockets_version) + { + WSADATA data; + int err; - err = WSAStartup (version, &data); - if (err != 0) - return 1; + err = WSAStartup (version, &data); + if (err != 0) + return 1; + + if (data.wVersion < version) + return 2; - if (data.wVersion < version) - return 2; + if (initialized_sockets_version == 0) + register_close_hook (close_fd_maybe_socket, &close_sockets_hook); - register_close_hook (close_fd_maybe_socket, &close_sockets_hook); + initialized_sockets_version = version; + } #endif return 0; @@ -97,6 +105,8 @@ gl_sockets_cleanup (void) #if WINDOWS_SOCKETS int err; + initialized_sockets_version = 0; + unregister_close_hook (&close_sockets_hook); err = WSACleanup (); |