X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC7053938C20
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1617807409;
	bh=ofyV1ZcO3Fqa2CrIoIX9ojc6RE9z+Ij8NqIJ8GdSlW0=;
	h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=PrdX20YZP0RhZ93io4venMkprMLsVu+/CVWZvZyP3nTSD1jP7KAmFZBZP2Gp695Gi
	 gJhj5kS6J4XbztZmUegnzEVlytNkYF5UQ2GcFsbd/qExStiGK34AltBcIfRNow3XIe
	 gKx+w7apIsp4vIoZj2ldGahot8iG8ve9KiN0W4f8=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0342E3938C03
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=ZmPrjZDb2C7IOmpa6lLWfsSkt8PBNR/avTWqip8+NJ+eKjFDkMAT2dRasGrONBnsF4PaImFFErWL1uFNENymXkqISMtbYEQx1c8BJb4kjGKgl0ciGpuIM3I9ShR/5VTYLWztyl5yMxy7MqGGUimN4FRsxTVNI1Bvdt9+XMN4DX9ou8Gel/lZCaKyH55hoKH4NRx4cilGCc7Gj6rTK2jux/Lu5FhWpa/zQ+wpR88FYmSN2a2dWIWez1aTLofZoj/P85unREQrtcxTUgohmmK6BuDpgvi8N+NaHQ3wW6M74lYrB5hWXB3tfF5UavvCQD+Y8TdZ718KQfsshLzlGfShDg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=xJNNgpAqLpFc680+MoKZr6QKQ99qAdk7z5QEJJEdNDs=;
 b=JPdcu8mRwN2XjT7EL3iyWFDW8IUFubpSfzbSCFaEA3bc+XlvVY3LBrgFdGLilauG+HiMpf1/bdGqEXUZKZPsKDofBIsHrRx3nHRgEPKd6dHXA7wxPUjiVEr933natappV92rol3sNG+VJm4QN7uhOhjF9u6sTtHNAxY55bW+NrCryoQVKMC3yvc9Op0zQ/7A8zB6CMwcEdDdY4pjQ0mTffvfBpl5mrk1v74pnjiKJGNM+r1462stTelTiP0aPAnerj0QtZ9pG5H696CDCFNB8M5FaJCjvy1XcAYFKDChqRY9VJhb36Ocu+4Q0nh+ag9NyIwCpIQa88FrCfBoOfLxrw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu;
 dkim=pass header.d=cornell.edu; arc=none
Subject: Re: AF_UNIX/SOCK_DGRAM is dropping messages
To: sten.kristian.ivarsson@gmail.com, cygwin@cygwin.com
References: <04cc01d71ffa$7d1e6cf0$775b46d0$@gmail.com>
 <YFo/fFC2bITvnVGr@xps13> <00d901d7208e$97c05c50$c74114f0$@gmail.com>
 <860668bf-8cf9-0969-6a01-7fbf8b782db1@cornell.edu>
 <000901d72607$55dc5a90$01950fb0$@gmail.com>
 <3346cd1c-b93f-83c4-ff26-553ac95ec692@cornell.edu>
 <7c21a430-9609-7fd4-1a02-8b7c1978d2f8@cornell.edu>
 <001901d72af4$4009cd50$c01d67f0$@gmail.com>
Message-ID: <134074c1-4c0b-0842-b88b-536a1ed4aefe@cornell.edu>
Date: Wed, 7 Apr 2021 10:56:41 -0400
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.9.0
In-Reply-To: <001901d72af4$4009cd50$c01d67f0$@gmail.com>
Content-Language: en-US
X-Originating-IP: [2603:7081:7e41:6a00:c990:1aef:9336:6d5b]
X-ClientProxiedBy: CH0PR03CA0046.namprd03.prod.outlook.com
 (2603:10b6:610:b3::21) To BN7PR04MB4388.namprd04.prod.outlook.com
 (2603:10b6:406:f8::19)
MIME-Version: 1.0
X-MS-Exchange-MessageSentRepresentingType: 1
Received: from [IPv6:2603:7081:7e41:6a00:c990:1aef:9336:6d5b]
 (2603:7081:7e41:6a00:c990:1aef:9336:6d5b) by
 CH0PR03CA0046.namprd03.prod.outlook.com (2603:10b6:610:b3::21) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.4020.17 via Frontend Transport; Wed, 7 Apr 2021 14:56:43 +0000
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: 4103f1f0-421d-478e-6021-08d8f9d55bed
X-MS-TrafficTypeDiagnostic: BN3PR04MB2178:
X-Microsoft-Antispam-PRVS: <BN3PR04MB2178DC9930D6251814E45486D8759@BN3PR04MB2178.namprd04.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:9508;
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: 5yb4TnxYYqJaemtc85XONo6NXKtDT25AYSfiP4lZAF2myBBM3R99fXk9gJWP6DjFXMCYVF/evtBCOgpX6XU6QLsP9E5t+abXMABAWAV0Eyy9klwXB+BBJp9S824hlf36IgePAhJOgJRBYbHCxcnbDNcKGLERMXMxFNweX5XzLDGjpG2gt7Dq1tBjySAC9XjfNq26r/juHi3vxLAYeDiLruC5baBnHl6i0b5T/TJ68u9Yl7GEekbxllCZz3Ny0HOT0eGn2NhkofovU9x7yh27NA7hUhNmgICuC+bkWHA9JjODLPzhxDheMtGUL8NHIrMcR0etB1+/wsdAKLVGsZy9Nbs4LwfYbgZLAIdzxlgvKemGe55urneWnQQv8WZ2diJDyAj2KPnAJJC1y11CR8Tq7dgjMSZOGRCS1WhcBoZbG5v+Uy1htn+IrX0QXAgEBARMEGqCf21RGM3qHy08APmuko5RRwccCVIRkUQ/OmXHcg2o1ub6r5Mv9omQTdYE257uAdx732x8xJFzAdsbUZ3/gB/nrtX91WokoSk5QVwh4YylqF7anfFXer4wihPcH7dwHiHpMK0ApZnN6+qphn4WhXSwUOIxdLR0wNj3I50NG4AsufFqy55jEnY11KVtWmvN3kzuWpYiwcrhiPgCEk9/ZOubHfarTLkZYlUSnM8/CkqQCTaGsySJ1GIYM5zg8Bs1Hf/ltLHGPCGtf8ALYMMS1A==
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:BN7PR04MB4388.namprd04.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(4636009)(136003)(376002)(346002)(396003)(366004)(39860400002)(31686004)(66574015)(5660300002)(786003)(16526019)(186003)(2906002)(66476007)(83380400001)(8676002)(8936002)(66556008)(6486002)(36756003)(75432002)(15650500001)(52116002)(2616005)(86362001)(478600001)(53546011)(38100700001)(316002)(66946007)(31696002)(43740500002)(45980500001);
 DIR:OUT; SFP:1102; 
X-MS-Exchange-AntiSpam-MessageData: =?Windows-1252?Q?54RBOtq5PlEBTQnOvhrVFPiubG7cdIhF4xptoEWfxEqFWsHrtbTeSQfg?=
 =?Windows-1252?Q?GBErAd0axiHvNNFexhv+JWreZUOtfUuraw974lI4gL32j4UshPqPGcn/?=
 =?Windows-1252?Q?dLxIh8EtJJpYslV25TL79pN0MtlAzf3k5YgfBPi+UGjClk5qnahcAhJO?=
 =?Windows-1252?Q?OTV0xU4/xrw8T2w3XzvEZRZHCh3sJM3Az2tYq7isx1EG2i3vmbFvs5nL?=
 =?Windows-1252?Q?++Ai6r8MyquRCFFkd5G2RkcHghWlI/1XSf3EfxjeiOarD2buO9b5wb7/?=
 =?Windows-1252?Q?0bqRQLRwvsEIkfcB+fGtNe1/ckjmPrV/nQM3RvSpYuosNU10tibOIIb8?=
 =?Windows-1252?Q?Wt7HvAKCKoyI5UylBv0QzjEvl4EEQTTRaQjQ89DvazYlJW7mOUyXzd0J?=
 =?Windows-1252?Q?Pwst8sZr1WTFE00VDyAelHMvCBKQmnZRt51wCTp3UEfsVQ0pHAYp367Q?=
 =?Windows-1252?Q?GsX5/vMPCIH3vcg667PxEpSoNINrXYbqayeVoBUgiL5W3TObm43qyFuK?=
 =?Windows-1252?Q?+xROC/J0q9K0TNJXkBflxeTeiD1I15pE2n+ymzYDRhWQa9UPYcWuH0ls?=
 =?Windows-1252?Q?060I79EI/jyAQugk0u42HNOCXMCfXr32PoomA4d4C+P3fcGRi7Q4W3EA?=
 =?Windows-1252?Q?pyYxrajB0Ift15NrSm1quNQifTbuqe3/VgbgGsQz8lAmTc9R+aJr7POt?=
 =?Windows-1252?Q?zqsHns8GQaOd5gv+FxH2zlncXgH6Z+R/nWih74JnIafJ3dnJuc4AqjpM?=
 =?Windows-1252?Q?POTJyAwgeQuXjzg2NPkVfJrSqiJJo8DWpt1pV6WUTayB/D3FKwSboWqo?=
 =?Windows-1252?Q?nXhAZX0fdLqVmAhJDruJqq22ckzBZyn3bT+/nxPku16rGwi3NYbHWVMs?=
 =?Windows-1252?Q?5Pu8Oey8gtDKB2F+DSZ7o93P5uLBfums6BfRdlDPohAXl3YiKPyz/XmH?=
 =?Windows-1252?Q?A6LwV5tq9Sk62CzZPDYwcP6yJqlvSs3CYMXOHvu0UW8pz7trUoOz7I+c?=
 =?Windows-1252?Q?lvhIHEzaiCSr/UwvMfrTRaYKcYB3KtAWtR3EsshtVgOwimOYsFbiHpow?=
 =?Windows-1252?Q?aGfswwUwRv4xecJB8yuyZLlSa7LIfJGoFQBo4g1rOmdZoav6INW7JG0n?=
 =?Windows-1252?Q?SInTkCI58PNPLbdKaDcj9ox9bTbtWkOln3/VEadEwnfyBZr+ftsdSM03?=
 =?Windows-1252?Q?yW4JR5g+FETCsUQ7O5+f54GeK+UoWRhgKg00x9Zvuf+vuzfWMICLAXTd?=
 =?Windows-1252?Q?a9wQ5ICmbvvEriPgcCIAFkLZ/rhI7dKdiI6F3YQRLREPWQz1Nplbrp8O?=
 =?Windows-1252?Q?nxnKGodO0htBYrffYtO9A12A7DWmR1bGDpUxqDsCHp1Qx42FKLvAVzOD?=
 =?Windows-1252?Q?7SXoFSTNmS4d/uMfVSgcu9hGP3vaA/iyoywFuwtOXyG/LphZBznR2oEU?=
 =?Windows-1252?Q?HOPvboJtSlxyj3JLVcMiKjACNEwmAmL0nBSqJw1Zke3fBu9hyWbQVEPz?=
 =?Windows-1252?Q?vbcf/2fR?=
X-OriginatorOrg: cornell.edu
X-MS-Exchange-CrossTenant-Network-Message-Id: 4103f1f0-421d-478e-6021-08d8f9d55bed
X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2021 14:56:44.1846 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 5d7e4366-1b9b-45cf-8e79-b14b27df46e1
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: HvvExi4KFkYEMMNmSIVaktqkQ+ReNWaufHNyIDpYyRQjobfNcmbzEqyHX7P0c3gszJ3jwcalTwM/tMQHmKZlIg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR04MB2178
X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00, DKIM_INVALID,
 DKIM_SIGNED, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER,
 NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS,
 TXREP autolearn=no autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Ken Brown via Cygwin <cygwin@cygwin.com>
Reply-To: Ken Brown <kbrown@cornell.edu>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"
Errors-To: cygwin-bounces@cygwin.com
Sender: "Cygwin" <cygwin-bounces@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id 137EurLY027157

On 4/6/2021 10:50 AM, sten.kristian.ivarsson@gmail.com wrote:
> 
>>>>>>>> Using AF_UNIX/SOCK_DGRAM with current version (3.2.0) seems to
>>>>>>>> drop messages or at least they are not received in the same order
>>>>>>>> they are  sent
>>>>
>>>> [snip]
>>>>
>>>>> Thanks for the test case.  I can confirm the problem.  I'm not
>>>>> familiar enough with the current AF_UNIX implementation to debug
>>>>> this easily.  I'd rather spend my time on the new implementation (on
>>>>> the topic/af_unix branch).  It turns out that your test case fails
>>>>> there too, but in a completely different way, due to a bug in sendto
>>>>> for datagrams.  I'll see if I can fix that bug and then try again.
>>>>>
>>>>> Ken
>>>>
>>>> Ok, too bad it wasn't our own code base but good that the "mystery"
>>>> is verified
>>>>
>>>> I finally succeed to build topic/af_unix (after finding out what
>>>> version of zlib was needed), but not with -D__WITH_AF_UNIX to
>>>> CXXFLAGS though and thus I haven’t tested it yet
>>>>
>>>> Is it sufficient to add the define to the "main" Makefile or do you
>>>> have to add it to all the Makefile:s ? I guess I can find out though
>>>
>>> I do it on the configure line, like this:
>>>
>>>    ../af_unix/configure CXXFLAGS="-g -O0 -D__WITH_AF_UNIX" --prefix=...
>>>
>>>> Is topic/af_unix fairly up to date with master branch ?
>>>
>>> Yes, I periodically cherry-pick commits from master to topic/af_unix.
>>> I'lldo that again right now.
>>>
>>>> Either way, I'll be glad to help out testing topic/af_unix
>>>
>>> Thanks!
>>
>> I've now pushed a fix for that sendto bug, and your test case runs without
>> error on the topic/af_unix branch.
> 
> It seems like the test-case do work now with topic/af_unix in blocking mode, but when using non-blocking (with MSG_DONTWAIT) there are some issues I think
> 
> 1. When the queue is empty with non-blocking recv(), errno is set to EPIPE but I think it should be EAGAIN (or maybe the pipe is getting broken for real of some reason ?)
> 
> 2. When using non-blocking recv() and no message is written at all, it seems like recv() blocks forever
> 
> 3. Using non-blocking recv() where the "client" does send less than "count" messages, sometimes recv() blocks forever (as well)
> 
> 
> My naïve analysis of this is that for the first issue (if any) the wrong errno is set and for the second issue it blocks if no sendto() is done after the first recv(), i.e. nothing kicks the "reader thread" in the butt to realise the queue is empty. It is not super clear though what POSIX says about creating blocking descriptors and then using non-blocking-flags with recv(), but this works in Linux any way

The explanation is actually much simpler.  In the recv code where a bound 
datagram socket waits for a remote socket to connect to the pipe, I simply 
forget to handle MSG_DONTWAIT.  I've pushed a fix.  Please retest.

I should add that in all my work so far on the topic/af_unix branch, I've 
thought mainly about stream sockets.  So there may still be things remaining to 
be implemented for the datagram case.

Ken
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

