From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2135.outbound.protection.outlook.com [40.107.100.135]) by sourceware.org (Postfix) with ESMTPS id 6BE3E3858024 for ; Sat, 22 May 2021 16:50:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6BE3E3858024 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=SuR8ICSfFmXYQjayVbon4mI57kGzftXG6T6U/7hVQJ/QP2Z8L6/oBRLsO/vMdlb7s3mNu3mc+BsR2BQ2KEh+bFWW2tH4jgnsW6QJmQCnscHHOl7VX2Il5dViqHAh0psgV3qfFNIOlSpubiuB4TRzi1Tdo2ErxGduiwohJaLwRX6WL64VD/tfypZudsQ7BCwuJocmz3o9yTDbOZYRal6I95cTW+XN6Yl1lD4MU0qw8ogZdbG1SXtkhwRoBU68DTqrFbBCA8JRhuciJ0FKq7zEzXgYCtJyPfzfEvqqjKee1f/zeOuNbXJFLCktTYcLquFNvOGm0uov8yMxxBf0rKOaCg== 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=adO3zU+Cou0ThYa4dWn371uupommSHLer6/9NW95Pgo=; b=d3JTxCFrPNCVV2U4y6whOPwX2VvN8lojulgloisFkYKQCvVdXqNiuZ1FoAm64syZAP185L75Kn7ISUkyH2Ni0TFI2bPl8mCHoth4qKgMMzsrzR4I3JNJ4NTT70PTWttdtacrEIFarhgTWGT4G7tjhd+3Ghrq3kHsgjbcifMlluFnfrWhFwIKMbNmkckEO0aUScikqQ5YBxpiUrBumv5Lx8vulyzSg294f0O2Bw/0N+w4DIQsdg48yxWWhI194e4M3ifiXpEoSN8W7KRVcq9wTuqR9lfVpmb8oKG4vNsQCuWbC6vNKJa+MFjq/iorwHgRBhyUoD1RontvAlhqNsgr+A== 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=adO3zU+Cou0ThYa4dWn371uupommSHLer6/9NW95Pgo=; b=GUV+nZvfgpRjJfNtP0lHmHJeR+4q3RxTNtlx5cOt0KFQ+LVWZRj3hmqcTKEXK/UPbmlDIsS3kFQFyTGx4UtdUUk1e125Gz/Fm89Q8pUKjOiZG7zUJNwD4IftU8javmy5w6LMTYnOvUMM8b1+YC9LZ2xq1HyvgvJt7x/rtIFLa48= 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 BN6PR04MB0660.namprd04.prod.outlook.com (2603:10b6:404:d9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Sat, 22 May 2021 16:50:24 +0000 Received: from BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::d452:659e:43f2:812b]) by BN7PR04MB4388.namprd04.prod.outlook.com ([fe80::d452:659e:43f2:812b%7]) with mapi id 15.20.4129.033; Sat, 22 May 2021 16:50:24 +0000 Subject: Re: The unreliability of AF_UNIX datagram sockets To: cygwin-developers@cygwin.com References: <58da34ac-f2b6-d8b2-e872-834cfcb1ab51@cornell.edu> <16e13907-8702-2ca2-a28e-f37f4f7f880c@cornell.edu> From: Ken Brown Message-ID: <00fdcf54-2506-0490-d174-3bef56311417@cornell.edu> Date: Sat, 22 May 2021 12:50:21 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [2603:7081:7e41:6a00:1499:4269:48f4:2341] X-ClientProxiedBy: MN2PR20CA0058.namprd20.prod.outlook.com (2603:10b6:208:235::27) 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:1499:4269:48f4:2341] (2603:7081:7e41:6a00:1499:4269:48f4:2341) by MN2PR20CA0058.namprd20.prod.outlook.com (2603:10b6:208:235::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.26 via Frontend Transport; Sat, 22 May 2021 16:50:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f71c1fe6-863b-4e33-d44a-08d91d41b18e X-MS-TrafficTypeDiagnostic: BN6PR04MB0660: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: trmOO6sY/e8tLKNQjOzt0NcO2rjAL+xPmpjX1EBjKHR2XFbTl9JGC3qhWLk8SuEkyJWc3H9ldXgw+4ac+fsQFt0zxy6QR+160mFD0zhJC8n/obH40Mg2+csswAsN/Y2tRd38XqQMFQSuALGPN4IevXnTLsA6iEmZqy/sAKfGKUQfTnUd8uHqJIm0kRhSbkzu0S6abWxOX6QU/mzDEavUxUEuxE5rqMVtfUqqC8/jAQIOT0duYKcslu7cdDQWYynvu5ZuF57Jyn9ek7NO1lPWPz6bDM5QtL7s3oQuP4EoaanBjA5TCPwrO4ZqtfN0RISrx4ZH6xsHqVSgWZwYI400K8/x0kg/bikso6eUBjRzg2Puza8PjpLfmVZvf2kfC/HeRc8a23iB1YTe402lXNY0vV8vrgYn4X6TJbdk+WWHJwSlUyaQXfv33hGTB9ua7skuB6T0dbz9FJRVg16+fsu94DiLyKR+e5Rgx5g8YZHDiirSeqg7oR0R1mS1lA6v0HJA3Eeq7Shq3BXppyPaH037QQ5RRfsY8mxauu6Tu1CKAfg39FhpTbCDndvfaZ3LYlkUlNQLnAf+pik7QtY7mSBqlb/J/OcB08qeCkwuI6DcIBX2PW022OjZnqmLuDTU8pbGI5ZFxcfrQY7zw2J5C6V5wlUctuGwg6itvlIAdeLCfmU3b2dtN75GAxL3Ib7Ulqkx 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)(366004)(396003)(39860400002)(346002)(31696002)(66556008)(83380400001)(66476007)(6486002)(66946007)(316002)(36756003)(8676002)(31686004)(86362001)(786003)(478600001)(8936002)(2906002)(16526019)(52116002)(2616005)(6916009)(75432002)(5660300002)(53546011)(38100700002)(186003)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?Windows-1252?Q?sm4gDZp381s36S5CAArw6V2QQ+qrnaHnbAnptO+LIx/Ul+x7yplT9ekc?= =?Windows-1252?Q?YB+3p15fg2aAvGZYEhizq0RMnnOtJh6QRgjKOKRbt7KP7HpOS2zflU7O?= =?Windows-1252?Q?LSWAbzcQCADr1BiWHPVWD764K0P0yPa7NI3EEwZi5jCLaZCoBRCVCQ5H?= =?Windows-1252?Q?CQezRq2+W2IoCWnSLwAktA6eLONEkSLWibfAfXm12Ov0iVrkq2Oz4cWV?= =?Windows-1252?Q?1StDZl87y/fdDo5h2bQUG1VVIPZE5eeI+WKLoKdpa4V734422HUytF4C?= =?Windows-1252?Q?fEM099VLjuSpgCxLZD90wNgd1OD4uBbqJYxQyqcvjKWoWbMJuvNT0lD0?= =?Windows-1252?Q?mKW3sAjC8GwVAhDhtn6KWds9dd+Ag1dwDja+MxpWmfQWk3OoUXz/j8J5?= =?Windows-1252?Q?78rYYWK5vP1TtO9xySEswbSn+eQI8Ay3knnekdvePyWsfoDGkr/HTtDX?= =?Windows-1252?Q?7KbXooqikfnPreLCXA/XXjsU05tvpplRZnrkfa/P23J3IaXGVpA51NA4?= =?Windows-1252?Q?8P7pB2/rah+D2JGnIEeXpDwE/jCK3x90Zjup3JqUTYg1eKBihaH0hFT6?= =?Windows-1252?Q?x3lWY1Q7jurOILxVomsgSZFwKvsh+giTQxEs3Dkb2O8jQZvYamFSzJ1W?= =?Windows-1252?Q?2zrmIVmcKLRKR0hqh0sYj9XVezR21KvofAHd7ymuTG6Jw0KK557o+6js?= =?Windows-1252?Q?CNAUtszxfS+YJDdLjr0DClS8/blrEaRDjC+D8G/0+IJIUd8dACUQOXHb?= =?Windows-1252?Q?puNOYtdbTC4tdiV3UZyCMR4ph2SgQT7FKwtDWWSBZd5hcQZHCd9ksFso?= =?Windows-1252?Q?H2rW978cUHGZlHKYxO4YIt+P4Z+pYpCKYLMH6SCsaG9S2Tob8KrKkGnz?= =?Windows-1252?Q?pzrwwBcynSAMTMXLCzviW1XD3J6PfR2o729Yw1il0e2z3e4BbVWqRGTl?= =?Windows-1252?Q?aa5fAQSqKlVZYaK3IZODUHncG1o/CzOCbYJn4Tp6VhToFpsgjV+KuGlC?= =?Windows-1252?Q?f58inUcnMtJvtCK20Z9TrYEoa87JmGlUoZAni/WT+BeWEbW25+S+VJ6h?= =?Windows-1252?Q?+pBkDREIG6v4FIqWn88EqcjXy/HKpcAK9UyTfgCnEE9HSbbPJTWoMWQ/?= =?Windows-1252?Q?hfNc7oJkdYrmJnYDSOKahNo2+DoiZIifiXV8maUsN5saAjXO9rOfzp14?= =?Windows-1252?Q?567eY2DaM0wM+ieEQYP557KObjM/FSbGKVOdiFxa7lWFUpReNUF5UYjs?= =?Windows-1252?Q?5Kg0hl1+vSB+ch8l5wbDlukbvwyvGQgGNh9bW1/g0SVJlUAPWjDHtxjM?= =?Windows-1252?Q?wlteBz2tCJRLgnb3Ew+a0o46AK88Q6m8f+2Td4M3KK1YcnbetD4Kr7kD?= =?Windows-1252?Q?r7I9+zHoh5y5njK8imUfeA97Vol4BCb3Xak0DUt7UcP5UFF8OHyevTXG?= =?Windows-1252?Q?urmn54N5jOXh0hOCmBxKDxm9VTbnPX/zlyQc4IMlMoY12TgxoJS4NxPd?= =?Windows-1252?Q?/XDMfFRs?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: f71c1fe6-863b-4e33-d44a-08d91d41b18e X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2021 16:50:23.9742 (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: Jpb099JAnyItltVp2tRt/aKWZeij5/9ImtSZsR2bV1oXs+1VU1ZpTBTg7WADG0YW/1JrbFQRc6e1fkuPxtXIRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR04MB0660 X-Spam-Status: No, score=-3.1 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: Sat, 22 May 2021 16:50:29 -0000 On 5/22/2021 11:49 AM, Corinna Vinschen wrote: > On May 21 17:54, Ken Brown wrote: >> On 5/20/2021 3:25 PM, Corinna Vinschen wrote: >>> On May 20 09:46, Ken Brown wrote: >>>> On 4/29/2021 7:05 AM, Corinna Vinschen wrote: >>>>> I think it should be possible to switch to STREAM sockets to emulate >>>>> DGRAM semantics. Our advantage is that this is all local. For all >>>>> practical purposes there's no chance data gets really lost. Windows has >>>>> an almost indefinite send buffer. >>>>> >>>>> If you look at the STREAM as a kind of tunneling layer for getting DGRAM >>>>> messages over the (local) line, the DGRAM content could simply be >>>>> encapsulated in a tunnel packet or frame, basically the same way the >>>>> new, boring AF_UNIX code does it. A DGRAM message encapsulated in a >>>>> STREAM message always has a header which at least contains the length of >>>>> the actual DGRAM message. So when the peer reads from the socket, it >>>>> always only reads the header until it's complete. Then it knows how >>>>> much payload is expected and then it reads until the payload has been >>>>> received. >>>> >>>> I think I'd like to go ahead and try to do this DGRAM emulation in the >>>> current (AF_LOCAL) code. It shouldn't be too hard, and it would solve the >>>> unreliability problem while we look for a better way to handle AF_UNIX >>>> sockets. >>> >>> Yeah, sounds like the way to go for now. >> >> Unfortunately, I ran into a problem. Trying to emulate DGRAM sockets in >> STREAM sockets breaks the DGRAM send/recv semantics. For example, >> WSARecvFrom won't return the source address. > > It doesn't anyway, does it? I mean, this is entirely local and the > source address is, basically, the same socket. From the Winsock point of view, the sending socket is an AF_INET socket, whose name is a struct sockaddr_in (the crucial data being the port number). fhandler_socket_local::recv_internal then converts the sockaddr_in of the sender to an abstract sockaddr_un that encodes the port number, so that the receiver can send back a reply. Aside from this issue, there's also the fact that all the send/recv functions when applied to STREAM sockets expect the socket to be connected. But if we're using STREAM sockets to emulate DGRAM sockets, they typically won't be connected. (And "connected" means something different for DGRAMs anyway.) Ken