[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new module 'shutdown'
From: |
Bruno Haible |
Subject: |
new module 'shutdown' |
Date: |
Sat, 11 Oct 2008 15:00:55 +0200 |
User-agent: |
KMail/1.5.4 |
Another function part of the usual socket API is shutdown() [1][2].
This implements it for mingw, using the same idioms as for the other socket
functions.
[1] http://www.opengroup.org/susv3/functions/shutdown.html
[2] http://msdn.microsoft.com/en-us/library/ms740481(VS.85).aspx
2008-10-11 Bruno Haible <address@hidden>
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.
============================= modules/shutdown ============================
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
===========================================================================
*** lib/sys_socket.in.h.orig 2008-10-11 14:53:54.000000000 +0200
--- lib/sys_socket.in.h 2008-10-11 14:46:50.000000000 +0200
***************
*** 364,369 ****
--- 364,386 ----
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
*** lib/winsock.c.orig 2008-10-11 14:53:54.000000000 +0200
--- lib/winsock.c 2008-10-11 14:49:22.000000000 +0200
***************
*** 42,50 ****
#undef recvfrom
#undef sendto
#undef setsockopt
! # 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
--- 42,51 ----
#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))
static inline void
***************
*** 332,334 ****
--- 333,348 ----
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
*** m4/sys_socket_h.m4.orig 2008-10-11 14:53:54.000000000 +0200
--- m4/sys_socket_h.m4 2008-10-11 14:48:09.000000000 +0200
***************
*** 1,4 ****
! # sys_socket_h.m4 serial 10
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,
--- 1,4 ----
! # 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,118 ****
--- 115,119 ----
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])
])
*** modules/sys_socket.orig 2008-10-11 14:53:54.000000000 +0200
--- modules/sys_socket 2008-10-11 14:47:21.000000000 +0200
***************
*** 45,50 ****
--- 45,51 ----
-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)' \
*** doc/posix-functions/shutdown.texi.orig 2008-10-11 14:53:54.000000000
+0200
--- doc/posix-functions/shutdown.texi 2008-10-11 14:44:12.000000000 +0200
***************
*** 4,18 ****
POSIX specification: @url{http://www.opengroup.org/susv3xsh/shutdown.html}
! Gnulib module: ---
Portability problems fixed by Gnulib:
@itemize
@end itemize
Portability problems not fixed by Gnulib:
@itemize
- @item
- This function is missing on some platforms:
- mingw.
@end itemize
--- 4,18 ----
POSIX specification: @url{http://www.opengroup.org/susv3xsh/shutdown.html}
! 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
@end itemize
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- new module 'shutdown',
Bruno Haible <=