Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4384441ybb; Tue, 14 Apr 2020 06:19:43 -0700 (PDT) X-Google-Smtp-Source: APiQypLvDiLSucpZJG/TUF6BkBLU1IeeS2JohO4YVtIzvd148ioB3dK3QPhORpo3k0gpXBHkU5px X-Received: by 2002:aa7:daca:: with SMTP id x10mr6275169eds.59.1586870383675; Tue, 14 Apr 2020 06:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586870383; cv=none; d=google.com; s=arc-20160816; b=n3A1fi9Bz0qTUcVEXxunFoFkRGMw0Tgf2W7vlUioImbq1GPxBbPe0IkUynCLYQGbEu 7x392/EsqZGDMXmdsjfJrWyGl+cKiCD6uPHxdbTqnMLoEVjXZ8KGZAWp3MqoOvJTK4oU i2IrGjWXYjNJvn0XWjhVZ6DlHH57ksIAeh2XEbuEFluVdGhSeHDzvtpFZR2Yd/t6oPtP G0lYhIEWwg1yhTEVsy29kqKixfRcJ/dQHKZ50LSnYkERSjzZss29JzL4qBufH18TYiDs 3R/jIDhbGP/2dPVM4Z3lz82rbCQDZOIKGqs7aNbmAU1wl5vN2Z8OtuQKg1F8KQ7m5lPE geGA== 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=G/gbJ9Pr+EPLUwQJR8woeoN7yCQBLMMliIHRcFFuyZE=; b=k+EK28m51XPrNryq3bZueK+2NfxCpxVb+zj0+pnys0Z2W79aVofsdWGXIg6dePwiyk ZXi1IQUdwymd6dB6uJtZ3oA2qLspeb4uS7iwuKuACVpID0CeM0rvuv2hku3nb3rqsyqF LMrqKBVuTn8PxL5MJiBaNiiBudefIhE2A0obvOXuXNwTrfmPkSsAbaQaB9UgMf4VI/Eh R4ZrHCOn6liW06uYI4fDwLwcjTwAxBbZIFPkuUsiUOvtFk6sLSO2OgMTXJA3FtApbc1X lG0dCxTmq3cbkYU8a5YhfKtHo4sDRBIQCwJB7+6NflUDlCFTS9ij5KWkyKCqKB1iBYCu +tgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JZwUzrS3; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d25si8406347edn.519.2020.04.14.06.19.00; Tue, 14 Apr 2020 06:19:43 -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=@gmail.com header.s=20161025 header.b=JZwUzrS3; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731276AbgDMQK5 (ORCPT + 99 others); Mon, 13 Apr 2020 12:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731261AbgDMQK5 (ORCPT ); Mon, 13 Apr 2020 12:10:57 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A57AC0A3BDC for ; Mon, 13 Apr 2020 09:10:57 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id i27so6682653ota.7 for ; Mon, 13 Apr 2020 09:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G/gbJ9Pr+EPLUwQJR8woeoN7yCQBLMMliIHRcFFuyZE=; b=JZwUzrS3zag21Y7abyS5wRVpDtkD+PU4uNv8ym3VQkYVTMauQXXyKY3UOJtudLHWIH L07cS/ITX8qr2eyDuXKNN1k3lCY5+8c2x/AgmTOw5GpImGcGzqPWh3e32K2JnbGwA7uf XWIu10V0S8f5gWEOqFD3c6Su7PvWjQQmmF3A0J7JU94J80QSsQ2bIELWNoCNnIIX8qcn PUIxK9ljqbU6++sM+uoIaNq9zst55bas+NlI23S/Qpr42Qjc0SWj7looOBEsun6Ds0gX QSmF0CgUQx2p40nq+F452atwKvXWypprIAfatFD0bqsQnY2jneKyq6lWILmldfx0aqgZ eS+w== 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=G/gbJ9Pr+EPLUwQJR8woeoN7yCQBLMMliIHRcFFuyZE=; b=NA087PfiWvDJGsQ5l7PH33DUs+RaUE/HgHwCETTC6ESwBahGWyj0PvIXSlgJBrTvpV Ycx8CsoAHdgF+Rvk3NFJaF+J+cWl5IWtSXFIKaxoT8748Z1OGz/Xdbhp3Q9vosewDMl2 +puTfQOhkv5hIQaF87Tpa+3rYlj8lP0HA4JBwr4ABbqZVqZl6lvTh91+i5PQBbu57mOj j7taPD5YkKuqh+Yso5tP66B/xu7N8lfk8MLuGpAQMpWmk1V6zx0DutBu6BxWpEpbe7iq 2YE/fusbrmypQSra0K4IcQBzkU8dvIViuDlnh8E8vKuWjLY9CiLIyeaqP96yZ8RFFC+/ gTag== X-Gm-Message-State: AGi0PuZuU+Omh0FrEEu/W9LNeMoaHi8JCV6GfVFedHe4G80nVVwishcT 4OgyBNZvgPk4jSmF68M/UCyM+e+8vcsKdbu3We9eOrzuK8E= X-Received: by 2002:a05:6830:154c:: with SMTP id l12mr7840688otp.79.1586794256132; Mon, 13 Apr 2020 09:10:56 -0700 (PDT) MIME-Version: 1.0 References: <20200316123914.Bluez.v1.1.I2c83372de789a015c1ee506690bb795ee0b0b0d9@changeid> <14E46BF4-0688-4A0B-AE84-46C4426C5E9A@holtmann.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Mon, 13 Apr 2020 09:10:44 -0700 Message-ID: Subject: Re: [Bluez PATCH v1] input: disconnect intr channel before ctrl channel To: Archie Pusaka Cc: Marcel Holtmann , 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 Archie, On Mon, Apr 13, 2020 at 6:48 AM Archie Pusaka wrote: > > 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 That was what I meant on my reply, that way we can detect if the has been shutdown on both directions or not, so in case of SHUT_WR it shall on indicate POLL_HUP if the userspace is polling with POLL_OUT, thus POLL_IN would still wait for the disconnect to complete, I guess this is worth the shot since this does not introduce any new APIs, but we might want to introduce a test to l2cap-tester to cover this functionality. > 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 -- Luiz Augusto von Dentz