From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2090.outbound.protection.outlook.com [40.107.101.90]) by sourceware.org (Postfix) with ESMTPS id 81AD53944805 for ; Mon, 3 May 2021 19:48:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 81AD53944805 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cornell.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kbrown@cornell.edu ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ghaF0esw09GeYZHwCW6c7DaA5tFuvWPQC/bp4wk40dgiYVhxm5n3vW4nf+Co+Kq+cfiyw93iL9k6txlcNJM0FXvILy7T2RZC1F1MuxpEm84MFacjdkLKTgCVujFvzpZDlXyCp1QShZ31pjz4+9iUZr1z7gSGwMnvD5Sl5AdqsuOSjpMjDVR/nU9iHy5ObdqsofgzxBD3VjHMiNtJf3XhYKVEMpwWgusrkkNNNC4W3ZqJCugMAJgs6MUu4/qxUbgRL0RrP6zkuFafj1msQTSlhxDTT+e9n4dMBTXpIgJiFwxg0L3wxxQKUMGxzBqgVSEcDsJHPn8UynfJ4QSCEXEtPg== 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=sGXe/HZ5T+eZIv0VVjoRW1XBK36J19iH5ELN1g2mbj0=; b=NefvYeBMrTWAG6qSry+C6q8kU0KxHcLXMG0N4BEJ2szxKyG5yEIxjwlFULqod4QLurqV8gq496INRwTI0NvGxsNVHxqKTlHbFBtnkbHQn3sMr/Oua+TDXTDHhL3hrE5qcnuFgxvpBEgYP2Exh08KLGMJYAKWEi7A9my9oFvQ6ICoE6pDtwOI1BjKp1j/+DkFTSqdGFRMWeSbmFdhtfXwOMprTDpuH5YGvNvNcbFAPaJXfdY12EtRFSjqT7y8hh5r1ly90dKc9exy72VdvDK0zgYREUWEFCE68cw2MdPKXlm1qFzc9b9xmtcSW13tjJ+WdmUK2cW8k8EUwuqLpntXwA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sGXe/HZ5T+eZIv0VVjoRW1XBK36J19iH5ELN1g2mbj0=; b=XykEHDAymD0SPiLKMURcMh8tFVEaEn5FHOz2TDySpMwJjCdWMzsO3FKAfzBR9BBH6/PhnQUtNkFMSIJAxas/o4yOAs7DAPn5aefXWKsaCc241gIklJfo7eQ9IQP/E/R5qHywHe3SthU3wPP0mylVxDDY+9MOupaYFxNqRQGzupM= Authentication-Results: cygwin.com; dkim=none (message not signed) header.d=none;cygwin.com; dmarc=none action=none header.from=cornell.edu; Received: from BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) by BN8PR04MB6385.namprd04.prod.outlook.com (2603:10b6:408:d6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.43; Mon, 3 May 2021 19:48:52 +0000 Received: from BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::59f8:fcc4:f07e:9a89]) by BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::59f8:fcc4:f07e:9a89%4]) with mapi id 15.20.4065.039; Mon, 3 May 2021 19:48:52 +0000 Subject: Re: The unreliability of AF_UNIX datagram sockets To: cygwin-developers@cygwin.com References: <58da34ac-f2b6-d8b2-e872-834cfcb1ab51@cornell.edu> <6cac30e5-56fc-5bf1-b85b-fe6b91bc5e97@cornell.edu> <16e1d55e-15ea-6c0e-04e4-aa6cb2c0c1bd@cornell.edu> <5564e10e-9099-fc5a-3a8d-c2ffb8ca4cff@cornell.edu> From: Ken Brown Message-ID: <41fde522-4d14-a957-96ad-c5eaa0e0a801@cornell.edu> Date: Mon, 3 May 2021 15:48:50 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [24.194.34.31] X-ClientProxiedBy: BL1PR13CA0215.namprd13.prod.outlook.com (2603:10b6:208:2bf::10) To BN7PR04MB4388.namprd04.prod.outlook.com (2603:10b6:406:f8::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.0.18] (24.194.34.31) by BL1PR13CA0215.namprd13.prod.outlook.com (2603:10b6:208:2bf::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.8 via Frontend Transport; Mon, 3 May 2021 19:48:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 804b226d-ebf9-4863-3600-08d90e6c7a57 X-MS-TrafficTypeDiagnostic: BN8PR04MB6385: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gqigiVqHesQHKdKqIxYbVHwn9SnvM/q5rfQ1YyYrE4wp1YaCrOqeAxLRcb4h/sxtvW/ZfurkjxeBiXCRX1qzDmznSz6FDO/iHzyBbWLT0V5F4n+YhB1LgCo406VvROfFxK+wRD5CTuIh4ZSYUdDo6lTUc8+8dHWLLbz8ASkactgJGHqBzwjh+T3RkDSyJnMXnggtrYiB8KZpZ2s3P38bXlzlJNcuEEwuuDkgPqZSjFSNgM2PBRXdL8i6xN3wfunOYo6Bx3tOCE3WapV9esbi7Xgm62Kt6NEZ+Pxh3EHoE3HAtwz13sCzBJbfiyXITE1hpCP5ISHEF1+EUO4Z36hDwm+Z8eMBmkBA+V4U44YvRBWf+mJMQ5eJcQsJNMJ2GZEesmBDQjv+7LmOlmwolPC9vT9BPCVankdm8TdEtRIgwJHYAytcc1nfqqQif/L15j43dpgxp0MfoXErT9TGDX5OpVsIHi6eDt6vx4I96tc0/iuq04OcvWbLNxX13EoWNbHWYFRGWBE7hIbfnDaBqYE01H/WM/GK6JndMTWD9htLUdO7iCuxdfGMf6vi7aNhscuuvqHug//JO/iSWAh/h60mcqHYDrIFP9u1L99agUhCwJYVcdmlPwnvFNl2PvYRCVvlCcJRfSz+d0B73oQpf/72SQu8ecNtgKO8oXplNJbDMFYHaeuVjTesZvGAnkxUzXAYZ8QsDDj45VcuY52utg+jFA== 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)(346002)(39860400002)(366004)(396003)(136003)(376002)(66946007)(66556008)(66476007)(5660300002)(75432002)(26005)(8676002)(38350700002)(6916009)(38100700002)(478600001)(6486002)(36756003)(31686004)(2906002)(186003)(8936002)(956004)(316002)(786003)(16576012)(31696002)(53546011)(16526019)(52116002)(83380400001)(86362001)(2616005)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?Windows-1252?Q?TAUyBjSJ4iT7s4tArcpzQpneltVwX87NxPi08wxtqPpnMZqtfttb5tcp?= =?Windows-1252?Q?Scgq92K5Kh6Gr5KfXsxm3rcYcOPrFik3WklcXFsOAgLypfOXywazaT+/?= =?Windows-1252?Q?fCPJQ7CqpvViRX57ZPdOCrvvUuKct59uFTScSRG2P3F+N8V+RLk+QAzh?= =?Windows-1252?Q?hSPYsGWnzrh2eXVrEcRodki0y0Ooz/cGqRXyICox57FIlT7M9ZuUHXNT?= =?Windows-1252?Q?vK9c8mcZcQjTeFcGFEtI5dJyp0n5B57gtp1iTYjlWEjNFK6/p7AwjhpV?= =?Windows-1252?Q?aAa9ta3G+e8niycGn4LRwUe8ZVH9NTrBbg6nUUPuq2lLIAmCSYfn7SZ2?= =?Windows-1252?Q?8A4rAjs/knLhM7dHGgUpZCKlDwkzzOprbAMu28LCabspSJa1ddnaGltR?= =?Windows-1252?Q?PClqIxw1oOl3fDMjTV+wBggs80ApcvERaIXssw8zpZwrijcMzsCUaztL?= =?Windows-1252?Q?h9e1CjvGWQZx90lnrEEI+4txiADp6Wp2OxdEXTVnTpW8/m1caDJwU4mS?= =?Windows-1252?Q?neeYgKISJSWSggOcOYL7E49BXISuUF6ZGNHATG6FNAFViXX5cColpp5F?= =?Windows-1252?Q?jhhcuAV2E5Gf8z0WBjeHC/b8dEWuEcPvrNUqyqublMcbe1cRbudEFpH2?= =?Windows-1252?Q?e+JQYqLl1LLaE82354DHlPY69YmM8bAMK+ydb9O3FLnpUNfTh+2CrZvo?= =?Windows-1252?Q?6e3EjgUXyL0V6ZXfuZsDwP/eJfTVMMOAq57/BQNa4Vpnwlr2tnLHtnRj?= =?Windows-1252?Q?2LKcfkHpTZvlb1ltoT3HMnHNF/n2Q+kB1vxFhGXI7va/Nou4QIArdhLz?= =?Windows-1252?Q?zgvBVqYjR0D/rolikN/tSLToIt8KxIEODCLDgeLDQrWwAgvP1pzFi2Ha?= =?Windows-1252?Q?GwxUbuNqVSWjklaWGH5qQ+/PZJd0BTlq4AxBX8PkVqA5mT8LX1Qs6L3H?= =?Windows-1252?Q?7hWyFKHQNSSAayeFDWHMaV0qS0raI5OOLuXJeA/PUMe9lHJAVo7QPkAe?= =?Windows-1252?Q?1iBp2zWmGazd8m1CCDfv0D6KzizWmc4+ZDRbhRvzgf+dpucUeSSyMXBE?= =?Windows-1252?Q?S8IfkmcP043z3DlGRHOlOOC4qbfzb6cQlViyOvgLeeu1Qak6tN85PG2a?= =?Windows-1252?Q?P+vg5Vs3YuE4nTZ5tbuM49PBASyf6Cvs8Qh1SVB7qBn0zpTVSLa4Fr8h?= =?Windows-1252?Q?2m3YUTNo3j4Wgh3eMUbO/AuJdn85ob19jdQ6YnToeCjBEkjOGiHABQSi?= =?Windows-1252?Q?ABZxPqJ5gUEM3uDj+bO5/+3hGnY/mXLEadSFojEXanidM8JR5Lq4IrYa?= =?Windows-1252?Q?B9sTV3WG61vsBgiixDhyVcWSqrVnzR9zADJ5jnh0UeR2IjMO1VLRzuFT?= =?Windows-1252?Q?+k2HSPAG0vT6Jt9eNSWTtgRKJH+gPVVEV0ITgoK5a0SED5cqCsa+vrW+?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: 804b226d-ebf9-4863-3600-08d90e6c7a57 X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2021 19:48:52.5676 (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: uc0iLRr1eLj3OCf6poDCfSyf7qNW805+e8aAtkJs+bqjiUTS3OPYIlTr+nMpYmrL8fM3VdqIpIJMgS82UluaLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR04MB6385 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham 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-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 May 2021 19:48:56 -0000 On 5/3/2021 2:40 PM, Corinna Vinschen wrote: > On May 3 12:56, Ken Brown wrote: >> On 5/3/2021 11:45 AM, Corinna Vinschen wrote: >>> 7. The idea of _mq_recv partial reads is entirely broken. Given that >>> the information in the queue consists of header info plus payload, >>> the entire block has to be read, and then a new block with fixed >>> header and shortened payload has to be rewritten with bumped priority. >>> This in turn can only be performed by the AF_UNIX code, unless we >>> expect knowledge of the AF_UNIX packet layout in the mqueue code. >> >> The partial read is actually OK as is, since it's comparable to what happens >> on a partial read from a pipe. I already have AF_UNIX code (on the >> topic/af_unix branch) that deals with that. A boolean variable _unread >> keeps track of whether there's unread data from a previous partial read. If >> so, the next read just reads data without expecting a header. > > Ok, never mind. > > One advantage of the mqueue when utilized as above would be that this > kind of state info is not required. The content of a packet would > always be self-contained and bumping the priority would automagically > move the packet content to the top of the queue. But that's just > idle musing at this point. I thought about that but rejected it for the following reason: Suppose the receiver reads a message and tries to rewrite it with modified header, shortened payload, and bumped priority. The sender might have already written more messages between the read and the write, and the queue could be full. Now that I'm rethinking this, however, maybe we could get around that problem with an internal _mq_lock function that would block senders while the receiver decides whether it needs to do a partial read. Ken