From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2124.outbound.protection.outlook.com [40.107.93.124]) by sourceware.org (Postfix) with ESMTPS id D71853857C71 for ; Sat, 22 May 2021 18:21:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D71853857C71 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=jNibX4Eys1nAfLwi+fpLQukZe1dX+NiVg4IqX55p/NAkN6mWmTbkIqvP7wT+hMK58EkozAlG41sgKlUZZtUh7IKQLNxN8a633sqeBf7WA1zgYoexJpkJr2tFmu4evECAxWyiBvKLBJZlUkeTNp4PiXtF9nSMD6b5o2vMrfzBVmxcTxM+NMl7fy7FxEDZaKvg/rotSAULodQdwcC838z1wXswzZr46toA6feWE4OdPJZJtF6cPwgroNXFZnyF2GM8rTuQkSFA1zRyUr04RpzzGd6hq53LoziPRs1qzZzw3L2M3GKaPNgn3lovQpqwSzC81CElVlJ4iwn8u7T0kxyy4g== 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=RFczTeTU2ezaguJuQkPGi4CStTBbRIQuafMK1t0WOBU=; b=Q4If9/76suIGv3TstdhSpkm3w7u7d8sQLUprqE89ljCHwj40dkMUDHuwUhzDLv7muKUNp+Hd/YCVJTse+FRVR5yd6kb2z4mFeGF64B1WHBUPQzxYpSPIx5rIemCsWXZoeEjXV95VgIjDOwIX7cl8SvxfzdrmHp5PD5N80k8Ld0iD1o0PenA+6MZtLr+tQcKDQDR85qvsubQlIqDlb4VTFmF8MtyjSe0DTiBWsJGHstfTH/zDrRoqL0nyPnYyPtMbmZZKwQ7BsAzfddouodNk7NfNLiU2jpRSmhtao0w+wG4niD6QG8YrobBv22LkfC+/1rfwblj0T6GOJLINzp3Giw== 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=RFczTeTU2ezaguJuQkPGi4CStTBbRIQuafMK1t0WOBU=; b=HfCMtrTazS8+/r4hGCoSz4grJyIDY0R4ESpNQqlk6LUwkVCpzsL1vYYvtQnctjy4nt1kQe964jS6EOs1ttayoZSieeolokHWLM3lEysPXkKJ4csHKVuyZXwkwfgEeD118ML1uKPVfwg4oS1lbdnr0UqkX+t6FHndhIFLyIR24b8= 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 BN3PR04MB2180.namprd04.prod.outlook.com (2a01:111:e400:7bb8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.27; Sat, 22 May 2021 18:21:49 +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 18:21:49 +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> <00fdcf54-2506-0490-d174-3bef56311417@cornell.edu> From: Ken Brown Message-ID: <14b72d6d-2896-e0ae-7040-d8755df66371@cornell.edu> Date: Sat, 22 May 2021 14:21:47 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 In-Reply-To: <00fdcf54-2506-0490-d174-3bef56311417@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: BL1P223CA0008.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::13) 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 BL1P223CA0008.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Sat, 22 May 2021 18:21:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef732a0a-962f-46f0-d76c-08d91d4e76da X-MS-TrafficTypeDiagnostic: BN3PR04MB2180: 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: tKcuRAi07SH/2i/PnKmEPMiGyKUYzzKMW2yqmpzrXmsRnwB3gzBk3FcgGe5h6Skwv+/ZNdOcbQ8H697N75eyXMbUPSbzBq6oVfWOn9A/fUpdngk5JxqVdfqGbgatCqI+8xaMZCNzbIhWnFDMAkCkfOpW4NvyHu5OkJMMqEZIZBJmBnjUDvnZaNuAz1zdMtIlSjKPRnCg61LxnZl//S8H25QsOj81jGqsoX3LxNj+q0rspDNIDtnnERkRC3kPDyA3vGT7bmkgm1m2jEGANs600iTXdZDuQuBeJddA40H0SuZXUT+U6cR/yW3dy92vrXl8J/e7SXEmR3OMzO69jL/qnOk8mnIV3XQiyFnrBmSv2iukkliJeltvWaltFOvR4D6fxgb4pbDEHfXvYPHISCUzHd1cBLOcU5IpewiVdpjHqGfAUqh1Hrx2NmV6UuKMXu/IF27jdzyZXca4R/61LInTlrsW8fbCf9kBhlS/GB79gEd3qso7wc2oZIdNd+I6uF4O9Q39joQ735F/yQpMoKVnijvZgn338QTrXRaQSrZe1dMRpz6LAvQsxrAJ83vCz4JiMdAE4Ax5s4j2svTk+/MLdXnrSErn0IQD71M4jC3k5rSlcDU1kY8XuYWTWOWGA6uWdEJ1E8/ZDw5+4OsS1QfrdUllpGF9/YW8TzQ9S1a/ScCmu9vwslihoZrDX/7CFYeG8qCdxqSBzrDoiSM+QzagDg== 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)(366004)(346002)(39860400002)(136003)(376002)(396003)(6916009)(26005)(5660300002)(786003)(38100700002)(38350700002)(316002)(2616005)(75432002)(31696002)(31686004)(2906002)(53546011)(16576012)(956004)(66946007)(52116002)(8676002)(16526019)(66476007)(86362001)(83380400001)(478600001)(66556008)(186003)(8936002)(36756003)(6486002)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?Windows-1252?Q?CnlgbGNwIGrNtWJTW6EZrubU1P5NAM/NY2BRF7KRgu5qMIUyVrH7c3pO?= =?Windows-1252?Q?FFO9t5IzaK1S+tUqooTl4gZUtWx1Q3N2qJq2d3ssOWsz1xxj0sMkOR+G?= =?Windows-1252?Q?nZm243NvpVDj2ok9WOvT9S1mA0Kv2hKsdulYdUovsk8iBPttCx9vURcf?= =?Windows-1252?Q?Wz7jX8akZmKOAuGO5aq1elwTpQXy0kU97+w2/KWaNQ2p5mlnVQK/DjOs?= =?Windows-1252?Q?cW5lkR00xrHAMmXIqErU9Yfr9wVati5FyyfSSu7N9QNiMuH4bwHdjIZj?= =?Windows-1252?Q?chjLMN/FoFzt5NlNeLT1aRNYO7PPfeFOdcTOhFBck39ckYS1dBZC7iEv?= =?Windows-1252?Q?Cnw+zNi5fXY9Rp4dQtT0ItBb1n0TwdRh5gd1SXumCP25blSw+1xDOypi?= =?Windows-1252?Q?xDX3VSq2LthbYynIndkDucgJXwrY0sKkUnWJTOzIlTEOkDk3vNLC9C/L?= =?Windows-1252?Q?5bwG6Qt94TA6X1POMU1x+nLzurjAJ7GHCiNFah8FTI7eMptJfBVEZlxV?= =?Windows-1252?Q?6w1Ss9JqYgZAyx/e+bZ8GSWey1PtdQno/iZ/V+ophMjvnkh8CHLgSW2H?= =?Windows-1252?Q?W/fUb0JrJWvMi8qyF1vDBLDmBlKZuugyQrYx8h8ahK/D5ByeV+HH68LX?= =?Windows-1252?Q?BTyeSnCWAAFEDaYuy7Ul8Q1HAVp9zu5ImTCXB7tp77KtvcnoKImPF9bl?= =?Windows-1252?Q?3/7tYAl3vdkUBDnk+9qd5LDd+HnaBs4eV7yvKJ35xwsGLnN+Iv3+Fweh?= =?Windows-1252?Q?AcIgf7w3s5pPx3+whuVLUa6jgI2UfINrqftAVUx9hK9AdjWRUK2dDOcR?= =?Windows-1252?Q?EXbfgt/wh3kw6/JpvWz6Bx7yadJayMqRS1ZO/ncNo/k/KmqKiu7X0Y6u?= =?Windows-1252?Q?jL+HM7Ckqri0aqYTfcGJAQxBcxLgVFog0AVRoReRpyNuVwkDR4kDu+Fq?= =?Windows-1252?Q?QxQ/0wXSYdR+S+rx6fgtjStXKNimPYVFNIVHQ58ZBpMThCYVM30LsW6k?= =?Windows-1252?Q?X4c7F7RHWX0KODOJQWOa49liLeVNnWLJMvkgTM0vMMo21ZSW/9/QNXwj?= =?Windows-1252?Q?zo4tZ46fSYvD+9tsb/nzFnziOHQwkJzC6nWaK9yeQdwLmLTnFO5CzlnZ?= =?Windows-1252?Q?tlKBg6alQrJ2uuep+2zuDeOXjawm0JPP+caVjnX9W2MVALjClj9m8j+1?= =?Windows-1252?Q?EEp3i80y0RrQdR9tYA7ZuBAQw0OBiE203zsSzrOwXGr+GKQyHHaBgeRr?= =?Windows-1252?Q?M9MXHN83RS943Shf6MQVlhDBgQ3z78YlcfXuLwjW+C0K8j3FkVZBKIBl?= =?Windows-1252?Q?UqEtSbeCx9jpb5eSFsCy+Rp2J2ir35yIM8AKczdAxseBuiw61DUvWeGk?= =?Windows-1252?Q?IZcfMB9i7uqD5JYr5fLaYXzEJ1Rzl6PdMKAm/2dNStQfD12UHq3VMBjZ?= X-OriginatorOrg: cornell.edu X-MS-Exchange-CrossTenant-Network-Message-Id: ef732a0a-962f-46f0-d76c-08d91d4e76da X-MS-Exchange-CrossTenant-AuthSource: BN7PR04MB4388.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2021 18:21:49.0732 (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: MKPb+0Duw2gczWjLdJPkfUnNAc22hrL5oFgngqSilJrV0rh98Ze9VEmmG67aWi7EcPDZEDRHGerZCQjdNzwfUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR04MB2180 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_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-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 18:21:52 -0000 On 5/22/2021 12:50 PM, Ken Brown wrote: > 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. Wait a minute.... I don't think this is a problem after all. The sender can simply include its own address in the packet it sends, as in the new AF_UNIX code. > 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.) But I'm still worried about this issue. Ken