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>2014-05-05 19:18:17 +0400
committerCorinna Vinschen <corinna@vinschen.de>2014-05-05 19:18:17 +0400
commit67797a9560f77c1061ad5c901400abc7e9a4fcc2 (patch)
tree82594f5a2019f8456e2a3f54081a26968c4d4340 /winsup/cygwin/net.cc
parent7e9b67846448ee0b5897c2ab403d497e2b77059e (diff)
* net.cc (cygwin_getsockopt): Rearrange code slightly and handle
TCP_NODELAY just like SO_KEEPALIVE and SO_DONTROUTE.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc43
1 files changed, 19 insertions, 24 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 5ccfc96fd..ab36a30b4 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -923,32 +923,27 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval,
(int *) optlen);
if (res == SOCKET_ERROR)
set_winsock_errno ();
- else if (level == SOL_SOCKET)
+ else if (level == SOL_SOCKET && optname == SO_ERROR)
{
- switch (optname)
+ int *e = (int *) optval;
+ debug_printf ("WinSock SO_ERROR = %d", *e);
+ *e = find_winsock_errno (*e);
+ }
+ else if (*optlen == 1)
+ {
+ /* Regression in Vista and later: instead of a 4 byte BOOL value,
+ a 1 byte BOOLEAN value is returned, in contrast to older systems
+ and the documentation. Since an int type is expected by the
+ calling application, we convert the result here. For some reason
+ only three BSD-compatible socket options seem to be affected. */
+ if ((level == SOL_SOCKET
+ && (optname == SO_KEEPALIVE || optname == SO_DONTROUTE))
+ || (level == IPPROTO_TCP && optname == TCP_NODELAY))
{
- case SO_ERROR:
- {
- int *e = (int *) optval;
- debug_printf ("WinSock SO_ERROR = %d", *e);
- *e = find_winsock_errno (*e);
- }
- break;
- case SO_KEEPALIVE:
- case SO_DONTROUTE:
- /* Regression in Vista and later: instead of a 4 byte BOOL
- value, a 1 byte BOOLEAN value is returned, in contrast
- to older systems and the documentation. Since an int
- type is expected by the calling application, we convert
- the result here. */
- if (*optlen == 1)
- {
- BOOLEAN *in = (BOOLEAN *) optval;
- int *out = (int *) optval;
- *out = *in;
- *optlen = 4;
- }
- break;
+ BOOLEAN *in = (BOOLEAN *) optval;
+ int *out = (int *) optval;
+ *out = *in;
+ *optlen = 4;
}
}
}