From: Marcel Holtmann <marcel@holtmann.org>
To: Vladimir Davydov <vdavydov@parallels.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Network Development <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Gustavo F. Padovan" <gustavo@padovan.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Linux Bluetooth mailing list <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH] bluetooth: never linger on process exit
Date: Thu, 17 Jul 2014 12:05:26 +0200 [thread overview]
Message-ID: <2ECFA3A4-C890-4512-86CD-B17EFDB57663@holtmann.org> (raw)
In-Reply-To: <1405412728-4706-1-git-send-email-vdavydov@parallels.com>
Hi Vladimir,
please always include linux-bluetooth@vger.kernel.org since otherwise it might be missed in the massive amount of emails that is LKML.
> If the current process is exiting, lingering on socket close will make
> it unkillable, so we should avoid it.
>
> Reproducer:
>
> #include <sys/types.h>
> #include <sys/socket.h>
>
> #define BTPROTO_L2CAP 0
> #define BTPROTO_SCO 2
> #define BTPROTO_RFCOMM 3
>
> int main()
> {
> int fd;
> struct linger ling;
>
> fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
> //or: fd = socket(PF_BLUETOOTH, SOCK_DGRAM, BTPROTO_L2CAP);
> //or: fd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
>
> ling.l_onoff = 1;
> ling.l_linger = 1000000000;
> setsockopt(fd, SOL_SOCKET, SO_LINGER, &ling, sizeof(ling));
>
> return 0;
> }
>
> Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: Gustavo Padovan <gustavo@padovan.org>
> Cc: Johan Hedberg <johan.hedberg@gmail.com>
> ---
> net/bluetooth/l2cap_sock.c | 3 ++-
> net/bluetooth/rfcomm/sock.c | 3 ++-
> net/bluetooth/sco.c | 6 ++++--
> 3 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> index e1378693cc90..d0fd8b04f2e6 100644
> --- a/net/bluetooth/l2cap_sock.c
> +++ b/net/bluetooth/l2cap_sock.c
> @@ -1111,7 +1111,8 @@ static int l2cap_sock_shutdown(struct socket *sock, int how)
> l2cap_chan_close(chan, 0);
> lock_sock(sk);
>
> - if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
> + if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime &&
> + !(current->flags & PF_EXITING))
> err = bt_sock_wait_state(sk, BT_CLOSED,
> sk->sk_lingertime);
> }
The only other example of using PF_EXITING I found is net/ipv4/af_inet.c and if this is the preferred way of handling this, the patch looks fine to me.
Regards
Marcel
next prev parent reply other threads:[~2014-07-17 10:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-15 8:25 Vladimir Davydov
2014-07-17 10:05 ` Marcel Holtmann [this message]
2014-07-17 10:16 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ECFA3A4-C890-4512-86CD-B17EFDB57663@holtmann.org \
--to=marcel@holtmann.org \
--cc=davem@davemloft.net \
--cc=gustavo@padovan.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vdavydov@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®