From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12587 invoked by alias); 5 May 2014 09:08:31 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 12436 invoked by uid 89); 5 May 2014 09:08:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: calimero.vinschen.de Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 May 2014 09:08:28 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id A28B88E09EA; Mon, 5 May 2014 11:08:25 +0200 (CEST) Date: Mon, 05 May 2014 09:08:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Dup'd sockets lose error information Message-ID: <20140505090825.GA30918@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <20140423142541.156360@gmx.com> <20140423153830.GN2339@calimero.vinschen.de> <20140424141444.GR2339@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RnlQjJ0d97Da+TV1" Content-Disposition: inline In-Reply-To: <20140424141444.GR2339@calimero.vinschen.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-05/txt/msg00050.txt.bz2 --RnlQjJ0d97Da+TV1 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 2792 qq qq? Ping? On Apr 24 16:14, Corinna Vinschen wrote: > On Apr 23 17:38, Corinna Vinschen wrote: > > On Apr 23 16:25, qq qq wrote: > > > The following code is a simplified app that was used to test-connect > > > to local ports 55000+ (none of which were actually listening) and > > > received false-positive "connected" results because Cygwin's dup() > > > for socket causes SO_ERROR to be lost. =C2=A0Since FD_SETSIZE is only= 64 on > > > Cygwin, the app uses dup()'s to lower the descriptors as it checks > > > them for completion. =C2=A0There is no such problem on Linux. > > > Also, strangely that Cygwin does not accept sin_addr as 0 to connect > > > locally (and either localhost or local host IP must be stuffed in > > > there, otherwise resulting in the "Cannot assign requested address" > > > error). > >=20 > > This is Winsock at work. Cygwin doesn't check the AF_INET address > > when calling Winsock's connect, so Winsock's connect itself seems to > > have this issue. > >=20 > > As for the SO_ERROR value, I have to check. Thanks for the testcase. >=20 > I've applied a patch which should solve both problems. >=20 > Cygwin is using socket events to implement select. It turned out that, > when using the original socket, the socket event as well as the socket's > SO_ERROR value were set correctly. However, when calling select with > the dup'ed socket handle, the socket event contained the correct error > code, but the SO_ERROR value wasn't set. I added code to write back the > error code from the socket event entry to the SO_ERROR socket option and > that seems to do the trick. >=20 > As for connecting or sending to INADDR_ANY or in6addr_any, this simply > doesn't work with Winsock. It just returns WSAEADDRNOTAVAIL. I now > added a conversion from INADDR_ANY and in6addr_any to INADDR_LOOPBACK > and in6addr_loopback in calls to connect, sendto, and sendmsg to emulate > the Linux behaviour. >=20 > Apart from that it turned out that 64 bit Cygwin was suffering from a > definition problem of a couple of Winsock types used in the Cygwin > socket code. As the (hopefully) only user-visible effect, this led > to a broken address output in /proc/net/if_inet6. This is fixed now > as well. >=20 > As for FD_SETSIZE, it's defined as 64 by default, but the user code > can override the value by defining FD_SETSIZE to another value prior > to including the standard headers. The underlying code does not > restrict the file descriptor values to < FD_SETSIZE. >=20 > Please give the today's developer snapshot from=20 > http://cygwin.com/snapshots/ a try. Any feedback? Did you test my patch? Thanks, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --RnlQjJ0d97Da+TV1 Content-Type: application/pgp-signature Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJTZ1UJAAoJEPU2Bp2uRE+gaYUP+gLSBQ9y+yG8Uz+uvq0+QTcE jYj7l34v2mc36YjGtJMg3vwMc8Zz5sKB/Evuvo5g0Uo2GSqYFY7nKVe2uSm0pyuC zk0TIDfjF43Pc4K6PQvQ4HWuZCxjS/69uAaDXryoWw6j5X35B/wHa/ff8d9mxKKo B9ZOvEF5k8gkhCTfZ77fptnFZgyDzZOibh85k/PLYUbZVdgza6UPLNUvMUY5UI6P VJIjqcSpRiiPbEaqIGniLRuIL9KgUaLIhv0sE21U8Sy4jgTJY3NRX0HMSl6rn2XS QSfpfMBCUdC9fyWHIkjeh12RiwGwygcAnvMUK3Cz2LVoirKENlW8aR7hWQyO10v3 BbdB2ezgfl+BOXs/hCplz6T4vJMgmSOGxNAJCZrVkBQY6BKBiIZHx/4f6VIKOxsJ Kc1bxMSScdoeRBTggiyGxABDjUCe3Ny0Q244UIzuhq7U42iYaWTy7vWv1lpgsj0f XyHo/rFaRDUaud0H/kHRP7X3VpsOOdfSFGQ8Nnk1Sj5cGh+tHazPiwoCCbRxKGQ/ 3Oxv6nKvc7LIe3UifaREOIy9Jy2LHHzeSY2g6pJzrpMRtzfEA/cp+jJLKcnWseXD qFmfLR3l5w28ykUuVKF4JpsAM0h0t4pop4E4yMA+HCxjFzD0JNIDWQxRlzUUMRHK jFi5adN1GDfA5yizrsAi =J06b -----END PGP SIGNATURE----- --RnlQjJ0d97Da+TV1--