delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/01/09/09:13:34

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=veyURYdoBwbwYGchTCQjl7Q7Fl0kHmV+AIb6hoWObFygl0y+zPYBa
tzJrxeL7eSbeMYuDzCyDgXnFH6RyAn7wuo5Z+m3HRjncj3mA0MtW+4lRKeVP55Vm
PDtc3c8Ph1H6BnKCELYlUZV/7wAAqUkDziQF33c6Ya3L0bDxTJzJXo=
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=BtAdADWhJGzjZRCnn5p7HYXlY0o=; b=lMUWVoagr95S7ixaqYZi8IdHgf2h
UT9KUIYG8w77lRDKYUdgUG1V9fGmn06536+j0j4URod1aB4DKPqC9yhSKx6nJM1+
o6D2JnqygiCdIHSzXQ79KAmG6HYsu4hEAn5yrAiCBAIF+lAJQAQQQnUKr+C5ue+3
HuGMjzmVzQ2okKE=
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=-101.6 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=chicken, Hx-languages-length:2826, credentials, H*MI:sk:CAOTD34
X-HELO: drew.franken.de
Date: Mon, 9 Jan 2017 15:13:06 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Hangs on connect to UNIX socket being listened on in the same process (was: Cygwin hanging in pselect)
Message-ID: <20170109141306.GB843@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CAOTD34aMu6DLP-8kaRXZRoihGxW9Jusf1pDBeM3cTWeNRfLVWw AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <CAOTD34aMu6DLP-8kaRXZRoihGxW9Jusf1pDBeM3cTWeNRfLVWw@mail.gmail.com>
User-Agent: Mutt/1.7.1 (2016-10-04)

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

Hi Erik,

On Jan  9 14:29, Erik Bray wrote:
> On Mon, Jan 9, 2017 at 12:01 PM, Erik Bray <erik DOT m DOT bray AT gmail DOT com> wrote:
> > On Fri, Jan 6, 2017 at 12:40 PM, Erik Bray <erik DOT m DOT bray AT gmail DOT com> wrot=
e:
> >> Hello, and happy new-ish year,
> >>
> >> I've been working on and off over the past few months on bringing
> >> Python's compatibility with Cygwin up to snuff, including having all
> >> pertinent tests passing.  I've noticed that there are several tests
> >> (which I currently skip) that cause the process to hang indefinitely,
> >> and not respond to any signals from Cygwin (it can only be killed from
> >> Windows).  This is Cygwin 64-bit--I have not tested 32-bit.
> >> [...]
> > I made a little bit of progress debugging this, but now I'm stumped.
> > It seems the problem is this:
> >
> > For each socket whose fd is passed to select() a thread_socket is
> > started which calls peek_socket until there are bits ready on the

Yes and no.  One thread_socket is called per 62 sockets, to account
for the maximum number of handles per WaitForMultipleObjects call.

> > socket, or until the timeout is reached.  This in turn calls
> > fhandler_socket::evaluate_events.
> > [...]
> After playing around with this a bit more I came up with a much
> simpler example.  This has nothing to do with select( ) at all,
> directly.

Right.  It has to do with how connect/accept works on AF_LOCAL sockets.
The handshake doesn't work well for situations like yours, where the
same thread tries to connect and accept on the same socket.

This has been found a problem in porting postfix already and at the time
we added a patch to circumvent the problem.  Before calling connect, add
this:

  setsockopt (sock_server, SOL_SOCKET, SO_PEERCRED, NULL, 0);
  setsockopt (sock_client, SOL_SOCKET, SO_PEERCRED, NULL, 0);

This is, of course, a hack.  The problem here is that server and client
of a socket are independent of each other, and there's typically no
way to know which process created the server side unless you already
are connected.  Chicken/egg.

While replying to your mail, a thought occured to me, though.

We might get away without the above setsockopt calls by adding a check
to connect.  It could test if the socket has already been opened by
the same process and is bound.  This could be accomplished by scanning
the file descriptor table (dtable) of the process.  If we find it,
we set the above socket option on both ends and continue without the
secret and credential check.  Credentials could be set manually since we
know user, group, and pid at this point.

It's a bit of work but might be feasible.


Corinna

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

--7iMSBzlTiPOCCT2k
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJYc5pxAAoJEPU2Bp2uRE+gogoP/iK/5A2Krs/t8soVpN4SfarU
3gDRXyS3uGLhDHTaXPWMIVK2h56LNBHXK8USLNrI6I0N/po6wQlSnlBxGMA5F+J/
kWa3QvQ+GXWiI+2U/jm6uj5ftaY1KsAc8U5ElhZovnS9wm+KnneW6LJ6HpEKZT1g
X6UiY8Y9/lAWtLUsMJ7jd8/nCiILTcvkuEXFUSW3PRirr3v7I8PC6Yr8k0N2BQFG
dfnCKIoDunm7omK9oBFYvYHc3+qU+/0GEk8aBhpDfdaQF2sJKehxSFZ3VIzw5NZH
Qjw8A296/AM42ripzASTv5vEIVfxorOIaY/aJADcDebnjCEj6VDDtWmIK0OGWNs3
hxleuM0NdR4/4HvYhD9SSdJp0BbUN12Qou4/m8rLDZ8b9ulR5YMyLXE3GAQsLebr
Nk0A7GHWe3V9MXXbHzu+t0JFvMJl5aYgnT3tz01LHFW4JQBLvS9EC1jhbju+oahl
WfrSH+TF8+gPNLoC+TtcTPKCP+u6aTJCT3Ea63/Zz9lbl+CjtF2IxKYy0er7vubX
1aVIUKN8Ig8X9SwuYvu8QVQmMIB3rDmTNQZ+cHouGGS6+Tlt2sGi5LrevAJToVg8
GGVHjoE3wmGAK5wGKJIi00FOQg5g/UTX0CHp7hdjBNig2verbcXjV3skiLsVtOVx
/O6U2Ml+A9TkYtYIV3yk
=uzLB
-----END PGP SIGNATURE-----

--7iMSBzlTiPOCCT2k--

- Raw text -


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