Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3450635ybb; Mon, 13 Apr 2020 08:19:29 -0700 (PDT) X-Google-Smtp-Source: APiQypLWEQFr6RL35QuepV7XDkSoD1apC/QbHVKUZlUQ0DmEPKZf5QJsgo8QoVXY5WXoW+JCIv/T X-Received: by 2002:a50:950a:: with SMTP id u10mr5764302eda.45.1586791169109; Mon, 13 Apr 2020 08:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586791169; cv=none; d=google.com; s=arc-20160816; b=WEMzqfyMwdBEU3Sq5OTEBR6YqABZlFy04ZynSSbty34hK1TWqHvS70uW6ssaCbC4bG WSg1I4uNt6HYclJic8oJrLUGpQUe7LN21bowjixJFwoRYKFl5oqTbv5D7xv9WxtQAjCL azwv6ar4xjknv8LwbchTOEKlEmNukxPMKhqhMMA4AcjqhA4xdqg+PYGwvRQ/c6ByeWba BMDi4XWCgKKTEbFdnXHcQ0Rug77wIlsQ9+Hhy6nsbvUjLD4NIuDb6HUX+J2cNHCXZGLr 05k9sYBEy8wq4fsEJTDohwk8KbKaBdtprYaT+9AQSBOV52Mc1KzsGk0YYpljcyOBYJvA Xc9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ilaMHxzfZVxXfDLWtcZLBUj208g0dYwsTx+UXD78WzE=; b=DeJ9fqBUwJPYkI3VCIulAmsE5GI7ggffWFLpZ2SAMj3WG9PmpAMTk6u6Usqbh3cqsE LdURPZ4Jd3G++EY7bLUPNG8O4A6mhkVrrmZ8c5/qmDAEZ7+ChtxUql5t3Y4SSmCM9Nh0 hxfRW1+z+gkAadGoHBZ86qZepPDvnq9+6izVSrbX+tqanxTshpIJd4c0fdGoxAmnZGY+ muwMjS7CaKA9/UpsGj7Dc4giHq3OO78gEJNx6Q9uv6zVkU48ww9ri7rw44RSYwtYofxa Wv5NQ8UFLl3rvJgBdt7O/7ba1HUQCh4D14cJFJjM82NfuU8KVA3iU5EDlLeY+JF42PjK w6CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pMnkHfQS; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nb6si6554353ejb.255.2020.04.13.08.18.48; Mon, 13 Apr 2020 08:19:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pMnkHfQS; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730146AbgDMNsN (ORCPT + 99 others); Mon, 13 Apr 2020 09:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730085AbgDMNsM (ORCPT ); Mon, 13 Apr 2020 09:48:12 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C02FC0A3BDC for ; Mon, 13 Apr 2020 06:48:12 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id d17so3295895wrg.11 for ; Mon, 13 Apr 2020 06:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ilaMHxzfZVxXfDLWtcZLBUj208g0dYwsTx+UXD78WzE=; b=pMnkHfQSZDPADzT11CBpobJfBDOaZQt11Xu3L4Y69SBtPou5MwxHn7eJSFO4pHn3zX SpHzG+LBkt9hZ9GI1B8q6gXexaZLVgxs+VCgMq7k2TwDeym3sdosTpqrYRJDTrCNwVr2 jDLnek2IjY1HiLjpcdFX6QgSybV4+8o8UZ8dStLIHQR+wP/DU0Uj+prOb+tkLdkUlcb+ ZOMVuUqjYS2pjTxePSYsFsytBVDcjiChmM8MqLNTz6Txb8s6B6+unzYWuNPopafPcrA9 QgKYUWQDYbQLmQrjygPrVSb8+qEkSyt/1EpYgDWx8JIYaWFAaxJYzmVIk9SqZSkkIDO5 rD4Q== 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=ilaMHxzfZVxXfDLWtcZLBUj208g0dYwsTx+UXD78WzE=; b=A0kpCpoV7Sk6PCqX3wVtrXlfrJBMKopHPpEOU6kq1eLSTBAmq694tpZDCxCB2DQDR+ 0Z62yqhHzLi5+XfDmkFycqbgldv4lt0Diigo6oXnnFU4T4CmIQZaQwOvDC1IF+1WumvL UUGzaKwuAEBeopbiDLPRpRaXjQ4ALEDXBIRSGrCRzixIPCX3eGrlpQlaMhOaCNucvEJ4 Z8rEmJ4oD6UaT7LR/kMSKIlOgp/VYIPn4yBE5V2uwBUXa2Rgu//HKcRhTqT9xFhl/qTj 3Rf3FAUjODAMjYUI6GGA4ZnhLr0G2iGx3AVBWgw49dh9oqaWHO9NeAw3uwwPRnYxySWN y14A== X-Gm-Message-State: AGi0PuY8y1qUsQwycqypmjxNeQntAG02pkt10oU8ACiHmTdC6BIHnPrZ ps8cAHKwFSn6oVqRjP7D4mThcHIaCNOev/Y3T+fSp7/sJwn1ng== X-Received: by 2002:adf:ec02:: with SMTP id x2mr18738818wrn.365.1586785690406; Mon, 13 Apr 2020 06:48:10 -0700 (PDT) MIME-Version: 1.0 References: <20200316123914.Bluez.v1.1.I2c83372de789a015c1ee506690bb795ee0b0b0d9@changeid> <14E46BF4-0688-4A0B-AE84-46C4426C5E9A@holtmann.org> In-Reply-To: From: Archie Pusaka Date: Mon, 13 Apr 2020 21:47:59 +0800 Message-ID: Subject: Re: [Bluez PATCH v1] input: disconnect intr channel before ctrl channel To: Marcel Holtmann Cc: Luiz Augusto von Dentz , linux-bluetooth Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Marcel, Luiz, I found out that shutdown second parameter is passed as the "how" parameter in l2cap_sock_shutdown() [1]. Currently the value of the parameter is unused, but I think we can assign it to sk->sk_shutdown. Therefore, we can differentiate whether we are interested to wait for the disconnection reply or not, by supplying SHUT_RDWR and SHUT_WR, respectively. Do you think this is a sound idea? [1] https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/net/bluetooth/l2cap_sock.c#n1267 Thanks, Archie On Wed, 18 Mar 2020 at 20:41, Archie Pusaka wrote: > > > > I see, we shutdown the socket immediately since the socket API itself > > > don't seem to have a concept of disconnect syscall not sure if other > > > values could be passed to shutdown second parameter to indicate we > > > want to actually wait it to be disconnected. > > I don't think the second parameter matters, I tried every possible > valid values and intr_watch_cb is still called without waiting for the > response. > > > > > in a blocking synchronous system call world we have SO_LINGER for that. In the world of asynchronous IO handling (what we do), we need to check what is the right way of handling this. > > > > I spot this piece of code [1] which utilizes getsockopt to query > socket connection information from the kernel space to the user space. > We can use a similar method to query whether (sk->sk_state == > BT_CLOSED), which is only true when we get the response. > What do you think? > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/tree/net/bluetooth/l2cap_sock.c#n476