Mercurial > hg > octave-lojdl > gnulib-hg
changeset 10624:175cb8a02a3e
New module 'shutdown'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 11 Oct 2008 15:00:33 +0200 |
parents | cce8e54214d5 |
children | e6dd7076d2cf |
files | ChangeLog doc/posix-functions/shutdown.texi lib/sys_socket.in.h lib/winsock.c m4/sys_socket_h.m4 modules/shutdown modules/sys_socket |
diffstat | 7 files changed, 78 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-10-11 Bruno Haible <bruno@clisp.org> + + New module 'shutdown'. + * modules/shutdown: New file. + * lib/sys_socket.in.h (shutdown): New declaration. + * lib/winsock.c (shutdown): New function. + * m4/sys_socket_h.m4 (gl_SYS_SOCKET_H_DEFAULTS): Initialize + GNULIB_SHUTDOWN. + * modules/sys_socket (Makefile.am): Substitute GNULIB_SHUTDOWN. + * doc/posix-functions/shutdown.texi: Document the new module. + 2008-10-11 Jim Meyering <meyering@redhat.com> * lib/fclose.c: Fix typo in comment: s/close/fclose/.
--- a/doc/posix-functions/shutdown.texi +++ b/doc/posix-functions/shutdown.texi @@ -4,15 +4,15 @@ POSIX specification: @url{http://www.opengroup.org/susv3xsh/shutdown.html} -Gnulib module: --- +Gnulib module: shutdown Portability problems fixed by Gnulib: @itemize +@item +On Windows platforms (excluding Cygwin), error codes for @code{shutdown} are +not placed in @code{errno}, and @code{WSAGetLastError} must be used instead. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on some platforms: -mingw. @end itemize
--- a/lib/sys_socket.in.h +++ b/lib/sys_socket.in.h @@ -364,6 +364,23 @@ setsockopt (s, lvl, o, v, l)) # endif +# if @GNULIB_SHUTDOWN@ +# if @HAVE_WINSOCK2_H@ +# undef shutdown +# define shutdown rpl_shutdown +extern int rpl_shutdown (int, int); +# endif +# elif @HAVE_WINSOCK2_H@ +# undef shutdown +# define shutdown shutdown_used_without_requesting_gnulib_module_shutdown +# elif defined GNULIB_POSIXCHECK +# undef shutdown +# define shutdown(s,h) \ + (GL_LINK_WARNING ("shutdown is not always POSIX compliant - " \ + "use gnulib module shutdown for portability"), \ + shutdown (s, h)) +# endif + # if @HAVE_WINSOCK2_H@ # undef select # define select select_used_without_including_sys_select_h
--- a/lib/winsock.c +++ b/lib/winsock.c @@ -42,9 +42,10 @@ #undef recvfrom #undef sendto #undef setsockopt +#undef shutdown -# define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) -# define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY)) +#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) +#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY)) static inline void @@ -332,3 +333,16 @@ return r; } #endif + +#if GNULIB_SHUTDOWN +int +rpl_shutdown (int fd, int how) +{ + SOCKET sock = FD_TO_SOCKET (fd); + int r = shutdown (sock, how); + if (r < 0) + set_winsock_errno (); + + return r; +} +#endif
--- a/m4/sys_socket_h.m4 +++ b/m4/sys_socket_h.m4 @@ -1,4 +1,4 @@ -# sys_socket_h.m4 serial 10 +# sys_socket_h.m4 serial 11 dnl Copyright (C) 2005-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -115,4 +115,5 @@ GNULIB_RECVFROM=0; AC_SUBST([GNULIB_RECVFROM]) GNULIB_SENDTO=0; AC_SUBST([GNULIB_SENDTO]) GNULIB_SETSOCKOPT=0; AC_SUBST([GNULIB_SETSOCKOPT]) + GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN]) ])
new file mode 100644 --- /dev/null +++ b/modules/shutdown @@ -0,0 +1,27 @@ +Description: +shutdown() function: initiate a graceful shutdown of a socket. + +Files: +lib/winsock.c + +Depends-on: +sys_socket +errno + +configure.ac: +AC_REQUIRE([gl_HEADER_SYS_SOCKET]) +if test "$ac_cv_header_winsock2_h" = yes; then + AC_LIBOBJ([winsock]) +fi +gl_SYS_SOCKET_MODULE_INDICATOR([shutdown]) + +Makefile.am: + +Include: +<sys/socket.h> + +License: +LGPLv2+ + +Maintainer: +Paolo Bonzini, Simon Josefsson, Bruno Haible
--- a/modules/sys_socket +++ b/modules/sys_socket @@ -45,6 +45,7 @@ -e 's|@''GNULIB_RECVFROM''@|$(GNULIB_RECVFROM)|g' \ -e 's|@''GNULIB_SENDTO''@|$(GNULIB_SENDTO)|g' \ -e 's|@''GNULIB_SETSOCKOPT''@|$(GNULIB_SETSOCKOPT)|g' \ + -e 's|@''GNULIB_SHUTDOWN''@|$(GNULIB_SHUTDOWN)|g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \