diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 2ff2148f0..fd903b112 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -517,8 +517,6 @@ cygwin_getprotobynumber (int number) bool fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc) { - int size; - fd = build_fh_dev (*dev); if (!fd.isopen ()) return false; @@ -607,6 +605,13 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc) Mbits/sec with a 65535 send buffer. We want this to be a multiple of 1k, but since 64k breaks WSADuplicateSocket we use 63Kb. + NOTE 4. Tests with iperf uncover a problem in setting the SO_RCVBUF + and SO_SNDBUF sizes. Windows is using autotuning since Windows Vista. + Manually setting SO_RCVBUF/SO_SNDBUF disables autotuning and leads to + inferior send/recv performance in scenarios with larger RTTs, as is + basically standard when accessing the internet. For a discussion, + see https://cygwin.com/ml/cygwin-patches/2017-q1/msg00010.html. + (*) Maximum normal TCP window size. Coincidence? */ #ifdef __x86_64__ ((fhandler_socket *) fd)->rmem () = 212992; @@ -615,6 +620,9 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc) ((fhandler_socket *) fd)->rmem () = 64512; ((fhandler_socket *) fd)->wmem () = 64512; #endif +#if 0 /* See NOTE 4 above. */ + int size; + if (::setsockopt (soc, SOL_SOCKET, SO_RCVBUF, (char *) &((fhandler_socket *) fd)->rmem (), sizeof (int))) { @@ -633,7 +641,7 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc) (size = sizeof (int), &size))) system_printf ("getsockopt(SO_SNDBUF) failed, %u", WSAGetLastError ()); } - +#endif /* A unique ID is necessary to recognize fhandler entries which are duplicated by dup(2) or fork(2). This is used in BSD flock calls to identify the descriptor. */