From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2095.outbound.protection.outlook.com [40.107.94.95]) by sourceware.org (Postfix) with ESMTPS id C59BE385BF92 for ; Wed, 1 Apr 2020 16:15:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C59BE385BF92 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FYAJvoQBQYdRZdtbMNwtHEKItwWpBlA7HlgJQ38sXAGlwV23QGKlPreMrgh7O67puchl0jFEN/g/buAIk8PMY8jIosQ9XY7Cznb5mHA/6Kca4RGHeLaWbL5K1lBBYGeRB00cj4oCm/HK42qZfmDSmqnUu5QT48yJCkq/czxdSLQiTRQUSSoY3uGGfy/rIsfsJbJRVt9hQ7d65YQxKGLwF0iwBQEjRZ+QC5J6s5blo4dWuW2PHtNQFwO50Nq7vkwvt6oa+j6xDLDFSQUPXTu/at6LgbupjGxT7hvGbGWvHX++hytepGpf6o/RpLfDV44ijKeOp726kcC1bvP7wkZSdQ== 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=pTmEPFp8UDU35WUXBI6nBIAGH/toyfEuHQkIsMmzaL0=; b=P1Pn009P/TQJmBnD1O+PBREXgBj6t1/Hr1fkNq1KBcf/bBKCSYdT9tcNmsiwnR0eDf1X74UqQOe8rkqsB3Hw02GAukASWjZSKZocO1GOkQ4u7dH/llPS1kpmISdmSpnsNPEUo00TaWTpp4SLhF8esZut+Os3hgQgYRSboFITwEQbBZs0K2xos7ih4uPxnjMlV77mG9U91usQ/RgxZ0mZDBocGiX2fGuJB1DBN3r8PLJEIylnm+5l9Y54wazXCklO3Jx5RLcqD2TH2eseAbIx+zz4P0RnY6E4n/GjyW0NyoczTHpfjtltZZh5pkLzsMJF0p+2VY+YnLD12unrw2Xl4g== 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 Received: from DM6PR04MB6075.namprd04.prod.outlook.com (2603:10b6:5:127::31) by DM6PR04MB6027.namprd04.prod.outlook.com (2603:10b6:5:125::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.20; Wed, 1 Apr 2020 16:15:31 +0000 Received: from DM6PR04MB6075.namprd04.prod.outlook.com ([fe80::e806:ecfb:c187:4e5a]) by DM6PR04MB6075.namprd04.prod.outlook.com ([fe80::e806:ecfb:c187:4e5a%4]) with mapi id 15.20.2856.018; Wed, 1 Apr 2020 16:15:31 +0000 Subject: Re: Sv: Sv: Sv: Sv: Sv: Sv: Named pipes and multiple writers To: sten.kristian.ivarsson@gmail.com Cc: 'cygwin' References: <1b1401d60296$2769e690$763db3b0$@gmail.com> <716e2076-f607-454e-2723-937c3959e2a3@cornell.edu> <18be01d602ab$0bbfca30$233f5e90$@gmail.com> <35b43b59-6410-f21f-710c-385e39cbae0b@cornell.edu> <005201d603ba$2bc8ab20$835a0160$@gmail.com> <472d1df6-531a-ebd7-4ffa-583a06e270ff@cornell.edu> <00b901d60447$7ecb4c50$7c61e4f0$@gmail.com> <00e001d604f9$d0aa0720$71fe1560$@gmail.com> <8c6c5655-c162-8361-9f44-376bbd7cf114@cornell.edu> <3fe06192-7300-382a-8c98-f1bc2ff81e36@cornell.edu> <003701d607a0$c975f140$5c61d3c0$@gmail.com> <249be61e-da8a-7da1-ca67-0c4c6433a415@cornell.edu> <000a01d60802$d1525900$73f70b00$@gmail.com> From: Ken Brown Message-ID: Date: Wed, 1 Apr 2020 12:15:28 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 In-Reply-To: <000a01d60802$d1525900$73f70b00$@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: CH2PR19CA0012.namprd19.prod.outlook.com (2603:10b6:610:4d::22) To DM6PR04MB6075.namprd04.prod.outlook.com (2603:10b6:5:127::31) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.0.17] (68.175.129.7) by CH2PR19CA0012.namprd19.prod.outlook.com (2603:10b6:610:4d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15 via Frontend Transport; Wed, 1 Apr 2020 16:15:30 +0000 X-Originating-IP: [68.175.129.7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 44c8b17c-8a61-4634-5027-08d7d657e612 X-MS-TrafficTypeDiagnostic: DM6PR04MB6027: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 03607C04F0 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6075.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10019020)(4636009)(366004)(39860400002)(396003)(376002)(136003)(346002)(16526019)(186003)(26005)(31686004)(5660300002)(8676002)(75432002)(2616005)(478600001)(86362001)(956004)(66476007)(66946007)(36756003)(66556008)(52116002)(81166006)(6916009)(31696002)(4326008)(2906002)(81156014)(16576012)(6486002)(53546011)(786003)(8936002)(316002); DIR:OUT; SFP:1102; Received-SPF: None (protection.outlook.com: cornell.edu does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lKxXBD3oa/6NchJKDlNKRL3Il1a6+Sz8Ujl38HMKvyBx6jqQ1+dxNJuU89icvnipHbcwtPvffvmlR6yUMvdRFXMmT2D47jQyVvlWyaIkHu+DnID5r4HY/o8//EMIutTGgDzGVT1Wjb5ZBkwSc7bl9xjskmwBVnzmlaSPbQNpeSewYjTYrVLBo8MbsPJG9ciyfKu2JkIQ3t4cxwsjSVBm/TXOIohhVito8ZEtSxbUjGFv9PuRDmN1McSd1EKiuUMpBvrhhlyZU8WN+x1nqycdJZ26TlSqx/psALuu9dDs2JYXimfip6b2JLUqQlpUzSd/lSRrVFc2bvcEa8QlPIvLne6DN3Wl0vneUTWHQWOyleq+LFnT4WPEA/hpk9F9qCG24pSeT4Sxu3p3Ws7DI0YEIjTf5BLgq+0IBgEKsvamCiUHoG82Kg3Lx9BWTltQXz76 X-MS-Exchange-AntiSpam-MessageData: gc9olAkvOgGHwvnpjFJItTnEcpSv/MtCabB6LQKdxjX4zoStFp665WYh5kYjSn3BVp8UkBSuoVxkcTwJzmCK8/jdHK1slm1fhWmtUl+ucZPGx18wt/ndZbxt+VEKwfakUp8SQyuME//Qz96I4fZ5Qg== X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 44c8b17c-8a61-4634-5027-08d7d657e612 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2020 16:15:30.8981 (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: exBzoxVpzXxDqC4BF6dK8rzGO3KGiyW261QDz21MnErweJfXnr3pFAOLUyAOFiaDfNxSMljW0VWJNEWmBWCA4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6027 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2020 16:15:34 -0000 On 4/1/2020 4:52 AM, sten.kristian.ivarsson@gmail.com wrote: >> On 3/31/2020 5:10 PM, sten.kristian.ivarsson@gmail.com wrote: >>>> On 3/28/2020 10:19 PM, Ken Brown via Cygwin wrote: >>>>> On 3/28/2020 11:43 AM, Ken Brown via Cygwin wrote: >>>>>> On 3/28/2020 8:10 AM, sten.kristian.ivarsson@gmail.com wrote: >>>>>>>> On 3/27/2020 10:53 AM, sten.kristian.ivarsson@gmail.com wrote: >>>>>>>>>> On 3/26/2020 7:19 PM, Ken Brown via Cygwin wrote: >>>>>>>>>>> On 3/26/2020 6:39 PM, Ken Brown via Cygwin wrote: >>>>>>>>>>>> On 3/26/2020 6:01 PM, sten.kristian.ivarsson@gmail.com wrote: >>>>>>>>>>>>> The ENIXIO occurs when parallel child-processes >>>>>>>>>>>>> simultaneously using O_NONBLOCK opening the descriptor. >>>>>>>>>>>> >>>>>>>>>>>> This is consistent with my guess that the error is generated >>>>>>>>>>>> by fhandler_fifo::wait.  I have a feeling that read_ready >>>>>>>>>>>> should have been created as a manual-reset event, and that >>>>>>>>>>>> more care is needed to make sure it's set when it should be. >>>>>>>>>>>> >>>>>>>>>>>>> I could provide a code-snippet to reproduce it if wanted ? >>>>>>>>>>>> >>>>>>>>>>>> Yes, please! >>>>>>>>>>> >>>>>>>>>>> That might not be necessary.  If you're able to build the git >>>>>>>>>>> repo master branch, please try the attached patch. >>>>>>>>> >>>>>>>>>> Here's a better patch. >>>>>>>>> >>>>>>>>> >>>>>>>>> I finally succeeded to build latest master (make is not my >>>>>>>>> favourite >>>>>>>>> tool) and added the patch, but still no success in my little >>>>>>>>> test-program (see >>>>>>>>> attachment) when creating a write-file-descriptor with >>>>>>>>> O_NONBLOCK >>>>>>> >>>>>>>> Your test program fails for me on Linux too.  Here's the output >>>>>>>> from one >>>>>>> run: >>>>>>> >>>>>>> You're right. That was extremely careless of me to not test this >>>>>>> in Linux first :-) >>>>>> >>>>>> No problem. >>>>>> >>>>>>> I can assure that we have a use case that works on Linux but not >>>>>>> in Cygwin, but it seems like I failed to narrow it down in the >>>>>>> wrong way >>>>>>> >>>>>>> I'll try to rearrange my code (that works in Linux) to mimic our >>>>>>> application but in a simple way (I'll be back) >>>>>> >>>>>> OK, I'll be waiting for you.  BTW, if it's not too hard to write >>>>>> your test case in plain C, or at least less modern C++, that would >>>>>> simplify things for me.  For example, your pipe.cpp failed to >>>>>> compile on one Linux machine I wanted to test it on, presumably >>>>>> because that >>> machine had an older C++ compiler. >>>>> >>>>> Never mind.  I was able to reproduce the problem and find the cause. >>>>> What happens is that when the first subprocess exits, >>>>> fhandler_fifo::close resets read_ready.  That causes the second and >>>>> subsequent subprocesses to think that there's no reader open, so >>>>> their attempts to open a writer with O_NONBLOCK fail with ENXIO. >>>>> >>>>> I should be able to fix this tomorrow. >>> >>>> I've pushed what I think is a fix to the topic/fifo branch. I tested >>>> it >>> with the attached program, which is a variant of the test case you >>> sent last week. >>>> Please test it in your use case. >>> >>>> Note: If you've previously pulled the topic/fifo branch, then you >>>> will >>> probably get a lot of conflicts when you pull again, because I did a >>> forced push a few days ago. If that happens, just do >>> >>>> git reset --hard origin/topic/fifo >>> >>>> It turned out that the fix required some of the ideas that I've been >>> working on in connection with allowing multiple readers. Even though >>> the code allows a FIFO to be *explicitly* opened for reading only >>> once, there can still be several open file descriptors for readers >>> because of dup and fork. The existing code on git master doesn't >>> handle those situations properly. >>> >>>> The code on topic/fifo doesn't completely fix that yet, but I think >>>> it >>> should work under the following assumptions: >>> >>>> 1. The FIFO is opened only once for reading. >>> >>>> 2. The file descriptor obtained from this is the only one on which a >>>> read >>> is attempted. >>> >>>> I'm working on removing both of these restrictions. >>> >>>> Ken >>> >>> We finally took the time to make some kind of a simplified "hack" that >>> works on Ubuntu and BSD/OSX but with latest on master newlib-cygwin gave > "ENXIO" >>> now and then but with your previous patch attached, there was no ENXIO >>> but ::read returns EAGIN (until exhausted) (with cygwin) almost every >>> run >>> >>> I will try your newest things tomorrow >>> >>> See latest attatched test-program (starts to get bloated but this time >>> more C-compatible though:-) >> >> Thanks. This runs fine with the current HEAD of topic/fifo. > > I wrote in a previous mail in this topic that it seemed to work fine for me > as well, but when I bumped up the numbers of writers and/or the number of > messages (e.g. 25/25) it starts to fail again > > The initial thought is that we're bumping into some kind of system resource > limit, but I haven't had the time to dig into details (yet) (I'm sorry for > that) Yes, it is a resource issue. There is a limit on the number of writers that can be open at one time, currently 64. I chose that number arbitrarily, with no idea what might actually be needed in practice, and it can easily be changed. In addition, a writer isn't recognized as closed until a reader tries to read and gets an error. In your example with 25/25, the list of writers quickly gets to 64 before the parent ever tries to read. I'll see if I can find a better way to manage this. Ken