+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/.
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
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
#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
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
-# 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,
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])
])
--- /dev/null
+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
-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)' \