--- net.cc_orig 2017-01-09 09:37:54.301210600 -0800 +++ net.cc 2017-01-09 14:15:57.998895500 -0800 @@ -517,7 +517,7 @@ bool fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc) { - int size; +// int size; fd = build_fh_dev (*dev); if (!fd.isopen ()) @@ -584,6 +584,7 @@ fd->set_flags (O_RDWR | O_BINARY); debug_printf ("fd %d, name '%s', soc %p", (int) fd, dev->name (), soc); + /* Raise default buffer sizes (instead of WinSock default 8K). 64K appear to have the best size/performance ratio for a default @@ -608,6 +609,8 @@ of 1k, but since 64k breaks WSADuplicateSocket we use 63Kb. (*) Maximum normal TCP window size. Coincidence? */ + + #ifdef __x86_64__ ((fhandler_socket *) fd)->rmem () = 212992; ((fhandler_socket *) fd)->wmem () = 212992; @@ -615,6 +618,14 @@ ((fhandler_socket *) fd)->rmem () = 64512; ((fhandler_socket *) fd)->wmem () = 64512; #endif + +/* Please don't do this. Windows doesn't have a default buffer of 8K it uses autotuning. + The thing about network buffers is they have to be chosen dynamically. Both Windows + and Linux do this. However, this code sets the SO_SNDBUF and SO_RCVBUF size statically. + This will limit Internet speeds and cause bufferbloat. Let the OS dynamically choose + the SO_SNDBUF and SO_RCVBUF sizes. + + if (::setsockopt (soc, SOL_SOCKET, SO_RCVBUF, (char *) &((fhandler_socket *) fd)->rmem (), sizeof (int))) { @@ -632,7 +643,9 @@ (char *) &((fhandler_socket *) fd)->wmem (), (size = sizeof (int), &size))) system_printf ("getsockopt(SO_SNDBUF) failed, %u", WSAGetLastError ()); - } + } */ + + /* 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