delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/04/24/10:15:08

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=DFJawF/3dXpVfoIqonlqWjIsio2UXZz3A36IYmVRlLljKRHkNDcFC
hRZLu4EoyFEql4pLWg/RNAGzi5RWOvjZdLsX4UGH8SAvFRTlqCmaKJNFn6MQTbRn
AOdjvo0Bb8TPsZyL5L7hSXWPqoZRVQl5ZiObI44fJR8Ap3FwqBD+qU=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=BT3gCIIanXF0KmOI9cpnscznDeg=; b=rSogLffcAPySL6gAELKgs+WiSk/W
VOh+/H/4K7nL1WHUQwPFW6FJ2RoENRuTWmqDjJbpdyvtIRRCAHATlaZtYv835ODD
V1FflGBqpHBaRsbtO/my+2TsynCl+7adPkZy8/PtnsNGneKDhGsBytRf00KK75Yo
yLWeS+ig1RdnzQg=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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
Date: Thu, 24 Apr 2014 16:14:44 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Dup'd sockets lose error information
Message-ID: <20140424141444.GR2339@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20140423142541 DOT 156360 AT gmx DOT com> <20140423153830 DOT GN2339 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20140423153830.GN2339@calimero.vinschen.de>
User-Agent: Mutt/1.5.21 (2010-09-15)

--Ie5iOtK4e9kgqh2F
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 6=
4 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.

I've applied a patch which should solve both problems.

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.

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.

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.

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.

Please give the today's developer snapshot from=20
http://cygwin.com/snapshots/ a try.


Thanks,
Corinna

--=20
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--Ie5iOtK4e9kgqh2F
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJTWRxUAAoJEPU2Bp2uRE+gZvsP/jpRzT0BSh2EdHuN8Zl/NFAP
W7gfIjlZw9vItsMPOZnWf9wMnZsnGDgWRU8i0JttlXQ0rhvTOaLw6Eaz2E9tbhyy
lImVmrm6Kyno4ji/X/l/1fj5TgHIc+t9dE4ZT1rpHB1PD4XVtnJ0VpF4xuY497fN
nVbALnfN9qCieHFaMrQ/OUFGripcOh2DeQvC/rsW4klOTRfmdKzaj6ZduvM5Cao5
7a/o8NcDbdNhBk6OliLCSB2XzfqGfLPkRoMskFYyh/6QtRH7PZoK6vaQ3HkyPjLc
APmginNv6Iq9jMI+6xjJYQcutBTWEWxAUZ5NteDAq8annGceWViqARXbzdYdjm1B
G/zxaFQXtvWRw5sxjc/kLdqaplljvvputmkJbSvbldacFa+rrD9E6jitCyLZpA15
t0SvN0nD/toSY8XQw9R4wD0wc1T/1Ip7gfF0kq6ko0AulQeH2BlC9B4CEIXlA5en
O4Iu2w8imxYt3bCtUqq/yd6YblPTk8MGyxpOQuaa/kxhAhiFxSgcZgJ1ISqmYbgD
8HLfXwW3eFNs3IIsGDpalMOcyZBC6EMwQD2Myh2bXGy87j3/yKGu+wR5c+8AXRGJ
CcUaowASyOokqhCHnL+VUcbbd3u7tgejiVYKdXCjGu8uLPJFvdjqVB9+CALMnH99
rvcdNqvXMRQj8yTQodZV
=RygH
-----END PGP SIGNATURE-----

--Ie5iOtK4e9kgqh2F--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019