From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA8BFC35242 for ; Sat, 8 Feb 2020 20:20:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C945E21741 for ; Sat, 8 Feb 2020 20:20:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=scylladb-com.20150623.gappssmtp.com header.i=@scylladb-com.20150623.gappssmtp.com header.b="ItKHRS4m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727473AbgBHUUv (ORCPT ); Sat, 8 Feb 2020 15:20:51 -0500 Received: from mail-lf1-f49.google.com ([209.85.167.49]:35518 "EHLO mail-lf1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727471AbgBHUUv (ORCPT ); Sat, 8 Feb 2020 15:20:51 -0500 Received: by mail-lf1-f49.google.com with SMTP id z18so1573311lfe.2 for ; Sat, 08 Feb 2020 12:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scylladb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xSbq2cHDOXvrbtGkDvl6O+nkS/90uIV9Uwlskixzqw4=; b=ItKHRS4mr0GXdj0NJemBoY7T8r3L271J6enD+MtCHkDpgSFlTyNGATzTKR0NbyvkzR Vqp4hHx+aZMXCiW3xL7yOz5Q3eNj3zbICF9mt8nemkf+yI8W21fj+EaTF81L9R9fasS5 c2bom/0QejyYdrXoOS8bxlTeGYRWA0lR6CEAOftVYHbRyxEh3QSQYk8BIv4jVTBTU5Y/ PBrsNG0deB0/13qQEPDip2b1AmpkYxFub5Ilddghbys+9KBqtp45L62qHuHNLpR32EYP qqmES46xzuch2Fdja3V93z/iA1qnpHDCE/qXyXgv1VJVVm3Ahijpbe/oha7bkhglLh+A nzSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xSbq2cHDOXvrbtGkDvl6O+nkS/90uIV9Uwlskixzqw4=; b=mtbGmlQrosPFQDdjvRxixTJkEeR4r3A6iOd6NKrQtfEy243hfGfkd9KVlTsp96djon 8S3kkT42EurdXuSHQGSlT891JhFA0tVayidddPydiu+iQCuWgDZN7s8ZleHGF2G9iOKE qxZt+VcVRUqnAR7HsNbMKWflH4fFpM1HLRXPd5cQ8BTmvvPREjbXKOUnw2R6vSpO64NG Y1eaf+tJ9Tz72t4vHBvEda+CGWvui29HsWF93fw+4s0GdUtZBrJFzzYFe8fX5xxmfGh4 sDq10/PJQLJ+Mip/svQQdyBw2jyZLXAPrQcLGtK/9vkLDjgpmO5fWASXErOUxmED4Uht d/Qw== X-Gm-Message-State: APjAAAU5j4CUayw0e1cu0eiyA3mtyVoeGXlRG+IvuKGFewYZ7dV4t6W+ 4BtA+PXvlE/iK1TwPvsRdblXnoGOlJrDnMHhd70cKGZ75VY= X-Google-Smtp-Source: APXvYqzneSiy08XdaomIBIabZVkIUGQTV7zjimsLC8ZNzRSWzrE44OcEiBVh2k0a0sh12/cv/co8zdDG8gx1kyl9BWs= X-Received: by 2002:a19:c014:: with SMTP id q20mr2608087lff.208.1581193248923; Sat, 08 Feb 2020 12:20:48 -0800 (PST) MIME-Version: 1.0 References: <9ec6cbf7-0f0b-f777-8507-199e8837df94@scylladb.com> In-Reply-To: From: Glauber Costa Date: Sat, 8 Feb 2020 15:20:37 -0500 Message-ID: Subject: Re: shutdown not affecting connection? To: Avi Kivity Cc: Pavel Begunkov , io-uring@vger.kernel.org, Jens Axboe Content-Type: multipart/mixed; boundary="000000000000ec8c8a059e163d26" Sender: io-uring-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org --000000000000ec8c8a059e163d26 Content-Type: text/plain; charset="UTF-8" > > > > Perhaps you can reduce the > > problem to a small C reproducer? > > > That was my intended next step, yes s***, I didn't resist and I had to explain to my wife that no, I don't like io_uring more than I like her. But here it is. This is a modification of test/connect.c. I added a pthread comparison example that should achieve the same sequence of events: - try to sync connect - wait a bit - shutdown I added a fixed wait for pthread to make sure that shutdown is not called before connect. For io_uring, the shutdown is configurable with the program argument. This works just fine if I sleep before shutdown (as I would expect from a race). This hangs every time if I don't. Unless I am missing something I don't think this is the expected behavior --000000000000ec8c8a059e163d26 Content-Type: text/x-csrc; charset="US-ASCII"; name="connect.c" Content-Disposition: attachment; filename="connect.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k6e1mhwl0 LyoKICogQ2hlY2sgdGhhdCBJT1JJTkdfT1BfQ09OTkVDVCB3b3Jrcywgd2l0aCBhbmQgd2l0aG91 dCBvdGhlciBzaWRlCiAqIGJlaW5nIG9wZW4uCiAqLwojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1 ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CgojaW5jbHVkZSA8ZXJybm8uaD4KI2lu Y2x1ZGUgPGZjbnRsLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4KI2luY2x1ZGUgPHBvbGwuaD4KI2lu Y2x1ZGUgPHN5cy9zb2NrZXQuaD4KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4KI2luY2x1ZGUgPG5l dGluZXQvdGNwLmg+CgojaW5jbHVkZSAibGlidXJpbmcuaCIKCiNpbmNsdWRlIDxwd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