Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-08-28 14:18:20 +0400
committerCorinna Vinschen <corinna@vinschen.de>2002-08-28 14:18:20 +0400
commit281d8a3232538514a316fc4ed1f4b7cda86b8170 (patch)
treeea9d3641c057f582ee2f42969146f5ff54c70ae4 /winsup/cygwin/fhandler_socket.cc
parent667599f4787dd14cb1e989b8e385e2ac4c9dd1f2 (diff)
* fhandler_socket.cc (fhandler_socket::recvfrom): Eliminate flags
not understood by WinSock. (fhandler_socket::sendto): Ditto. If WinSock sendto() returns WSAESHUTDOWN, change errno to EPIPE and raise SIGPIPE if MSG_NOSIGNAL isn't set in flags. * include/cygwin/socket.h: Define MSG_WINMASK and MSG_NOSIGNAL. * include/cygwin/version.h: Bump API minor number.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r--winsup/cygwin/fhandler_socket.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 2057a9eec..85b210752 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -674,6 +674,7 @@ fhandler_socket::recvfrom (void *ptr, size_t len, int flags,
wsock_event wsock_evt;
LPWSAOVERLAPPED ovr;
+ flags &= MSG_WINMASK;
if (is_nonblocking () || !(ovr = wsock_evt.prepare ()))
{
debug_printf ("Fallback to winsock 1 recvfrom call");
@@ -765,7 +766,8 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
if (is_nonblocking () || !(ovr = wsock_evt.prepare ()))
{
debug_printf ("Fallback to winsock 1 sendto call");
- if ((res = ::sendto (get_socket (), (const char *) ptr, len, flags,
+ if ((res = ::sendto (get_socket (), (const char *) ptr, len,
+ flags & MSG_WINMASK,
(to ? (sockaddr *) &sin : NULL),
tolen)) == SOCKET_ERROR)
{
@@ -777,7 +779,8 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
{
WSABUF wsabuf = { len, (char *) ptr };
DWORD ret = 0;
- if (WSASendTo (get_socket (), &wsabuf, 1, &ret, (DWORD)flags,
+ if (WSASendTo (get_socket (), &wsabuf, 1, &ret,
+ (DWORD)(flags & MSG_WINMASK),
(to ? (sockaddr *) &sin : NULL),
tolen,
ovr, NULL) != SOCKET_ERROR)
@@ -791,6 +794,13 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
set_winsock_errno ();
}
+ /* Special handling for SIGPIPE */
+ if (get_errno () == ESHUTDOWN)
+ {
+ set_errno (EPIPE);
+ if (! (flags & MSG_NOSIGNAL))
+ _raise (SIGPIPE);
+ }
return res;
}