public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Dup'd sockets lose error information
Date: Mon, 05 May 2014 09:08:00 -0000	[thread overview]
Message-ID: <20140505090825.GA30918@calimero.vinschen.de> (raw)
In-Reply-To: <20140424141444.GR2339@calimero.vinschen.de>

[-- Attachment #1: Type: text/plain, Size: 2826 bytes --]

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.  Since FD_SETSIZE is only 64 on
> > > Cygwin, the app uses dup()'s to lower the descriptors as it checks
> > > them for completion.  There 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).
> > 
> > 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.
> > 
> > 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 
> http://cygwin.com/snapshots/ a try.

Any feedback?  Did you test my patch?


Thanks,
Corinna

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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

      reply	other threads:[~2014-05-05  9:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-23 14:25 qq qq
2014-04-23 15:38 ` Corinna Vinschen
2014-04-24 14:14   ` Corinna Vinschen
2014-05-05  9:08     ` Corinna Vinschen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140505090825.GA30918@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).