From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2110.outbound.protection.outlook.com [40.107.212.110]) by sourceware.org (Postfix) with ESMTPS id D17A2393BC36 for ; Mon, 3 May 2021 20:50:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D17A2393BC36 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=FGH/Dg5oI+3QLwZum7Cnucl9ZGQEcB6/2qU5lnDgwPDauMHqXtXx9hbh7qMNAojl5J6OhyuwH2DoCbI+9EL72XOYNYVQw6qsA+VemSJlV3AVi4XEM5OSgvkAAYTBCe+Ynz5VXrebbkFZGO9YpxiT34/QgeQm4Sk87AfLeojP3sHy0uXW07hJk3qbwsjt1Zx9zW25CMslyfo0GTk5OW9jJGp7RJiYsh278GIgq9ZHVyOT8+H9GfTeil0RYXjZdevYohy6jyAyP1U/z6iIA2dGtwzH7+qCWTWa3P7NSqbpSokgnqONEufx0nKj8Kh44Cwp2jHUuhVOYCqmk//ZaZDwxA== 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=ypzxbWw6QukhAiaIlvc8k97XlpgkVm2RQoAFQF+wLxU=; b=EddtP3qaFxD6jPy5Y9LJDzkllX0PSFYdIKmqNV1dAgtXtskd4NuiNOXRpuFYc342behTAcB/tEkDf4Aa966tdA4oAcuBjFg/JDPvfkqY7c8n13H1kxSxoIbc1uEcKJtb/DQbcYazSiUmr6V8VloXddhX7pj6FmBqR0C9NXLk1Cyzmkjn1VBPcDaqZ3rjWpByNTNaV64RZVV69diFlIA8wxRiDiQ9G7xgDO14nhGqwJopf9FDS8WJZobjWy1W4bR7HLclVg18AxEj7rtkD+Ddxbl7e4Ktb1iT5j9yOCqxzgl3tjB1DUeynyJZCfyRZvN37GQfA+i5wJQRODVOS483Rw== 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=ypzxbWw6QukhAiaIlvc8k97XlpgkVm2RQoAFQF+wLxU=; b=YXV9CMGs2amx6fpLMZG126wOzY/rf4F/kIhDIAN7GyLxPhk1J9RMQxvpnxXo70es0ehcJq1c8xA3OmOAMrsbBTyROd9LI8iaHw4H5P4g1Cbj7Ab+F+zNurhTMJ2GWkGCgk9rJ/5OH5yy6BhS6FRW1IcPbfObsAa5G+ahpzp+DYo= 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 BN8PR04MB6067.namprd04.prod.outlook.com (2603:10b6:408:57::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.24; Mon, 3 May 2021 20:50:45 +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 20:50:45 +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> <41fde522-4d14-a957-96ad-c5eaa0e0a801@cornell.edu> From: Ken Brown Message-ID: <1aa91ec3-ae10-0e83-470d-a8a2dcfd83b0@cornell.edu> Date: Mon, 3 May 2021 16:50:43 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 In-Reply-To: <41fde522-4d14-a957-96ad-c5eaa0e0a801@cornell.edu> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [24.194.34.31] X-ClientProxiedBy: CH0PR03CA0006.namprd03.prod.outlook.com (2603:10b6:610:b0::11) 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 CH0PR03CA0006.namprd03.prod.outlook.com (2603:10b6:610:b0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Mon, 3 May 2021 20:50:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: caaa7906-a0eb-4ca1-3cfa-08d90e751f97 X-MS-TrafficTypeDiagnostic: BN8PR04MB6067: 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: ufnFIhagBcs0DqBkqLnuZazUZ+SFnSkjmd7TFaIRFLinnTHE5rOHLrcB+haYZ+6PxCOjYsDjJ0C/q1wUh6e29oPAOHgMFe6+GFS6Wv1W0/DKnwSnXc4Soxrad3uQIW78yWygm9cY0dcwAVc4iqeGthlshD2NVJmCvQ3sBOcDCPmDsxG2kq5DO62e/Cky0NkgYsM5HfuAY+yS9T3EDFwONsAIMGfs8DRFxiol0i/KWQJ55k4UjC7t3gMsTl1UxqAriUNWDHGHYc3t8+wcNs5yZXxe2NAr+AKNOvCrzOiQA95X4KOHcHIfsPWJd3LxFIHBVxv74lx+Rrf/uYP/o0DXxeAmX2LB/fP2MsfMX+dzqtSpo901bZ3dS5yz5jLCJXiR57fiHobOxo1AkYy5DF5GI/G3NSqP6UQab/aBb1TNTcJNeJl9M6wDEBo4/nz2ITj2x8Esn/K0UeEzm4zvVdi4hQjXWXDimsMIV9VtYaMLGp+34FgEHyJu6n0s2mACes3tzDkvX/lTEw9ulPubeOeGAOi3+jRatv5RKSU8pOrwr4RUcmuSFKRu0pTtAsv7WF7aq+wcnoegYZR++ZoYQS1olrjjOJnk0UPdpe1E43Uzppha3DVuZNarZwKhFi+nA3kqmxW6sJ8za4yCPwoEfeOQ8i6i1z2lvSgS0EsskubQFQAIdN47wVUCSSTk4aT04IsGB5hs1YLdlCWdE59emiXXJg== 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)(366004)(396003)(136003)(39840400004)(376002)(38350700002)(16526019)(8936002)(86362001)(52116002)(6486002)(36756003)(75432002)(186003)(53546011)(8676002)(5660300002)(26005)(31696002)(38100700002)(316002)(956004)(16576012)(2616005)(6916009)(2906002)(66556008)(66476007)(83380400001)(66946007)(478600001)(31686004)(786003)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?Windows-1252?Q?249bS4u2RDIIrWjovNTJekrHZKktONhYsnhdV+5OG7C2CS3Swqt2/Uh2?= =?Windows-1252?Q?ugVTdGTu1IWCahYh91SpQYFTTso5Ct8CCmQvYLJnLBJ66eRNRhbPlr/h?= =?Windows-1252?Q?n9umRR3vDjMMBQkyGxdYoM6Y2/CLdbvnuFdTR3FV6LW1tI1713SXqfJZ?= =?Windows-1252?Q?xIQROL1RPIXxgYmxx0LwP6g01iSSkrAnE4MlYCe6RoIkL7QKj7iaNwci?= =?Windows-1252?Q?lHispDzILtf/hV5opW++Ymj3bHg1faYsetkAwdICvxkaCdreomP0fdpJ?= =?Windows-1252?Q?oqmvVCFByhByannL2bH2T2Fwl/BfOqyHVGmmLcKPiZIB/RA8Mo6jo3k1?= =?Windows-1252?Q?t5+Dy9okIe1RDzx8vhOHBgMI7wBlqs5hHftN1jS4suC0EGLq+0wqSc2N?= =?Windows-1252?Q?lcdxuVOSQr7cbdsO92Q5ZUZqPr2nbcEjaUUg7VqmXk87UGflggAsE673?= =?Windows-1252?Q?zYgzrgSdP1tGiIXpKU6QoqMl2lnPSJBldGfnF7cp9wiLf3zxh6UElFBs?= =?Windows-1252?Q?kSit1pqx8U06DG3P9AABU+iW0ae5adkYqntmUHr3AJ2+v6Ygf2kfP66l?= =?Windows-1252?Q?Oz2tfZ3l2PbgtGMCEO25tPek7EV2Fkcxz9aYW4Dlp0Ls836WazepYAh7?= =?Windows-1252?Q?lqYk6E7wSmokWZGMPDC+Wvk8ofUrSMjvip+BUxqSfGCCizqR2dWnAwag?= =?Windows-1252?Q?iAJZV2T0vs5RE86FuU9RtZGftxXMu98zvD4ONnJAbzi5cmISTHb6WR9R?= =?Windows-1252?Q?1mAUBS8jmJJiYcufAiY2iNi44ad7QWTVOMX96VJJfRphZe9kVjJ9vPxX?= =?Windows-1252?Q?ezfuu1jmCiPqtJPavjz7qHVsl0j4KaTpBJqCKzcJqK8/v9EeYsvk46Nc?= =?Windows-1252?Q?9ZiZzRdb3WsJcAcTMRVuM9R0FM9KPDufaWck845mEyJCPw/oa2sqVjgn?= =?Windows-1252?Q?+3gZDva8DLX6CpX77ZzaVHuQx+GLVYxToyBkTKc/JL7gUIbitHOpWKz2?= =?Windows-1252?Q?4w9GvMyaX5JWR1UgLlxniUheqbPmHEH4yneGDwdBaHYAz8AtpUp8iGi9?= =?Windows-1252?Q?oHgrq4tWH42bh/cHa21eb9fdqeIGN2wM5jMvAQzHEFE7vdRy5LyPugw7?= =?Windows-1252?Q?kcnxxVul8pQzxR5+fiNqiw5CHMRfu49FI8RyeE0hmT5QvAY7nyBDZZWC?= =?Windows-1252?Q?fihbOpxwWvDIEY2ISqV9R95uKgaVG7hgaouavWIkKncap70T5/VwL/ob?= =?Windows-1252?Q?HXs0ZtuG8xDBiZNKw17MqJktpGOOGJEgpWXtJam75kFq6BgoX4V2goAU?= =?Windows-1252?Q?uXSeyhxHtHcCcbhAHL/gnDMQ36fp57dE+HthJIdEPSDuATZcHgSbrjeq?= =?Windows-1252?Q?04dKHBPKaZYFblggH+FM2xHpaXNVs3QogepuDaROEjQ1GsZnabrh/5oV?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: caaa7906-a0eb-4ca1-3cfa-08d90e751f97 X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2021 20:50:45.4762 (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: 0QYHWQk9X3bVX1i4+bxBL3C3WRGbzyelb+irVmUBzoKcND7Hl12w5uBsthtaIJLlKosAhatUC0kCq8MZLfY2jA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR04MB6067 X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, 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-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 20:50:48 -0000 On 5/3/2021 3:48 PM, Ken Brown wrote: > 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. Alternatively, _mq_recv could accept an _MQ_LOCK flag, which means "don't release the mutex", and then there could be an _mq_unlock function, which simply releases the mutex. Ken