diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index eaa3433f5..d90598d66 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2009-11-13 Corinna Vinschen + + * net.cc (fdsock): Fill _rmem and _wmem with valid values returned + from getsockopt if setsockopt with desired values failed. + 2009-11-12 Yaakov Selkowitz Corinna Vinschen diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index c766d7d08..509269a83 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -483,6 +483,8 @@ 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; @@ -506,15 +508,26 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc) be nice, though. (*) Maximum normal TCP window size. Coincidence? */ - ((fhandler_socket *) fd)->rmem () = 65535; ((fhandler_socket *) fd)->wmem () = 65535; if (::setsockopt (soc, SOL_SOCKET, SO_RCVBUF, (char *) &((fhandler_socket *) fd)->rmem (), sizeof (int))) - debug_printf ("setsockopt(SO_RCVBUF) failed, %lu", WSAGetLastError ()); + { + debug_printf ("setsockopt(SO_RCVBUF) failed, %lu", WSAGetLastError ()); + if (::getsockopt (soc, SOL_SOCKET, SO_RCVBUF, + (char *) &((fhandler_socket *) fd)->rmem (), + (size = sizeof (int), &size))) + system_printf ("getsockopt(SO_RCVBUF) failed, %lu", WSAGetLastError ()); + } if (::setsockopt (soc, SOL_SOCKET, SO_SNDBUF, (char *) &((fhandler_socket *) fd)->wmem (), sizeof (int))) - debug_printf ("setsockopt(SO_SNDBUF) failed, %lu", WSAGetLastError ()); + { + debug_printf ("setsockopt(SO_SNDBUF) failed, %lu", WSAGetLastError ()); + if (::getsockopt (soc, SOL_SOCKET, SO_SNDBUF, + (char *) &((fhandler_socket *) fd)->wmem (), + (size = sizeof (int), &size))) + system_printf ("getsockopt(SO_SNDBUF) failed, %lu", WSAGetLastError ()); + } return true; }