X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fsockets.c;h=ae961482aa79f7d8628b3b777a69dfd966cc8277;hb=28df8b1e1d486c3891091a5c08eb0c3311102938;hp=9a448097c47fcebaecf864ff64ab2eb37154f821;hpb=349d7fe0e307d59d508b3579317ee8d4eacfeb9c;p=gnulib.git diff --git a/lib/sockets.c b/lib/sockets.c index 9a448097c..ae961482a 100644 --- a/lib/sockets.c +++ b/lib/sockets.c @@ -1,6 +1,6 @@ /* sockets.c --- wrappers for Windows socket functions - Copyright (C) 2008-2011 Free Software Foundation, Inc. + Copyright (C) 2008-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,20 +22,13 @@ /* Specification. */ #include "sockets.h" -/* The attribute __const__ was added in gcc 2.95. */ -#undef _GL_ATTRIBUTE_CONST -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) -# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) -#else -# define _GL_ATTRIBUTE_CONST /* empty */ -#endif - #if WINDOWS_SOCKETS /* This includes winsock2.h on MinGW. */ # include # include "fd-hook.h" +# include "msvc-nothrow.h" /* Get set_winsock_errno, FD_TO_SOCKET etc. */ # include "w32sock.h" @@ -45,6 +38,10 @@ close_fd_maybe_socket (const struct fd_hook *remaining_list, gl_close_fn primary, int fd) { + /* Note about multithread-safety: There is a race condition where, between + our calls to closesocket() and the primary close(), some other thread + could make system calls that allocate precisely the same HANDLE value + as sock; then the primary close() would call CloseHandle() on it. */ SOCKET sock; WSANETWORKEVENTS ev; @@ -111,7 +108,7 @@ static int initialized_sockets_version /* = 0 */; #endif /* WINDOWS_SOCKETS */ -int _GL_ATTRIBUTE_CONST +int gl_sockets_startup (int version _GL_UNUSED) { #if WINDOWS_SOCKETS