From: Gustavo Padovan <gustavo@padovan.org>
To: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>,
linux-bluetooth@vger.kernel.org,
Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Subject: Re: [RFC 1/8] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c
Date: Thu, 24 May 2012 13:56:11 -0300 [thread overview]
Message-ID: <20120524165611.GB3105@joana> (raw)
In-Reply-To: <20120524093557.GJ24715@aemeltch-MOBL1>
Hi Andrei,
* Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com> [2012-05-24 12:35:59 +0300]:
> Hi Gustavo,
>
> On Wed, May 23, 2012 at 10:12:37PM -0300, Gustavo Padovan wrote:
> > void l2cap_chan_close(struct l2cap_chan *chan, int reason)
> > {
> > struct l2cap_conn *conn = chan->conn;
> > @@ -583,12 +549,8 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
> >
> > switch (chan->state) {
> > case BT_LISTEN:
> > - lock_sock(sk);
> > - l2cap_chan_cleanup_listen(sk);
> > -
> > - __l2cap_state_change(chan, BT_CLOSED);
> > - sock_set_flag(sk, SOCK_ZAPPED);
> > - release_sock(sk);
> > + if (chan->ops->finalize)
> > + chan->ops->finalize(chan->data, 0);
>
> Looks like you are handling all cases so this can be put outside of
> switch.
No, I'm not, look to the BT_CONNECTED/BT_CONFIG option.
>
> > break;
> >
> > case BT_CONNECTED:
> > @@ -630,9 +592,8 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
> > break;
> >
> > default:
> > - lock_sock(sk);
> > - sock_set_flag(sk, SOCK_ZAPPED);
> > - release_sock(sk);
> > + if (chan->ops->finalize)
> > + chan->ops->finalize(chan->data, 0);
> > break;
> > }
> > }
> > @@ -3416,7 +3377,9 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
> >
> > /* Check if we already have channel with that dcid */
> > if (__l2cap_get_chan_by_dcid(conn, scid)) {
> > - sock_set_flag(sk, SOCK_ZAPPED);
> > + if (chan->ops->finalize)
> > + chan->ops->finalize(chan->data, 0);
> > +
> > chan->ops->close(chan->data);
> > goto response;
> > }
> > diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> > index 4d36605..0302cb4 100644
> > --- a/net/bluetooth/l2cap_sock.c
> > +++ b/net/bluetooth/l2cap_sock.c
> > @@ -872,6 +872,25 @@ static int l2cap_sock_release(struct socket *sock)
> > return err;
> > }
> >
> > +static void l2cap_sock_cleanup_listen(struct sock *parent)
> > +{
> > + struct sock *sk;
> > +
> > + BT_DBG("parent %p", parent);
> > +
> > + /* Close not yet accepted channels */
> > + while ((sk = bt_accept_dequeue(parent, NULL))) {
> > + struct l2cap_chan *chan = l2cap_pi(sk)->chan;
> > +
> > + l2cap_chan_lock(chan);
> > + __clear_chan_timer(chan);
> > + l2cap_chan_close(chan, ECONNRESET);
> > + l2cap_chan_unlock(chan);
> > +
> > + l2cap_sock_kill(sk);
> > + }
> > +}
> > +
> > static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data)
> > {
> > struct sock *sk, *parent = data;
> > @@ -931,6 +950,49 @@ static void l2cap_sock_close_cb(void *data)
> > l2cap_sock_kill(sk);
> > }
> >
> > +static void l2cap_sock_finalize_cb(void *data, int err)
> > +{
> > + struct sock *sk = data;
>
> Why we cannot just use l2cap_sock_finalize_cb(struct sock *sk, int err)
> what is the reason for extra assignment?
Because we want to be generic here, we don't know who else will use finalize()
so we need to keep a void * here.
>
> I also think finalize is not good name since it does not mean what is
> actually finalized.
And it is not, I failed to come with a better name here. The initial one was
delete, even worse.
Gustavo
next prev parent reply other threads:[~2012-05-24 16:56 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-24 1:12 [RFC 0/8] Another step in l2cap_core/sock separation Gustavo Padovan
2012-05-24 1:12 ` [RFC 1/8] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Gustavo Padovan
2012-05-24 1:12 ` [RFC 2/8] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
2012-05-24 1:12 ` [RFC 3/8] Bluetooth: Add l2cap_chan->ops->ready() Gustavo Padovan
2012-05-24 1:12 ` [RFC 4/8] Bluetooth: Use l2cap_chan_ready() in LE path Gustavo Padovan
2012-05-24 1:12 ` [RFC 5/8] Bluetooth: Use chan->state instead of sk->sk_state Gustavo Padovan
2012-05-24 1:12 ` [RFC 6/8] Bluetooth: Move check for backlog size to l2cap_sock.c Gustavo Padovan
2012-05-24 1:12 ` [RFC 7/8] Bluetooth: Create DEFER_SETUP flag in conf_state Gustavo Padovan
2012-05-24 1:12 ` [RFC 8/8] Bluetooth: Add chan->ops->authorize Gustavo Padovan
2012-05-24 6:02 ` [RFC 1/3] Bluetooth: check for already existent channel before create new one Gustavo Padovan
2012-05-24 6:02 ` [RFC 2/3] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
2012-05-24 6:02 ` [RFC 3/3] Blueooth: Remove parent socket usage from l2cap_core.c Gustavo Padovan
2012-05-24 6:32 ` Gustavo Padovan
2012-05-24 7:00 ` [RFC 1/2] Bluetooth: Create chan->ops->set_err() Gustavo Padovan
2012-05-24 7:00 ` [RFC 2/2] Bluetooth: Remove last usage of sk->sk_state_change() Gustavo Padovan
2012-05-24 8:30 ` Andrei Emeltchenko
2012-05-24 17:06 ` Gustavo Padovan
2012-05-24 8:26 ` [RFC 1/2] Bluetooth: Create chan->ops->set_err() Andrei Emeltchenko
2012-05-24 17:04 ` Gustavo Padovan
2012-05-24 17:18 ` Mat Martineau
2012-05-25 7:07 ` Andrei Emeltchenko
2012-05-24 9:22 ` [RFC 3/3] Blueooth: Remove parent socket usage from l2cap_core.c Andrei Emeltchenko
2012-05-24 9:24 ` [RFC 2/3] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Andrei Emeltchenko
2012-05-24 17:09 ` Gustavo Padovan
2012-05-24 17:36 ` Mat Martineau
2012-05-24 9:27 ` [RFC 1/3] Bluetooth: check for already existent channel before create new one Andrei Emeltchenko
2012-05-24 9:55 ` [RFC 8/8] Bluetooth: Add chan->ops->authorize Andrei Emeltchenko
2012-05-24 17:08 ` Gustavo Padovan
2012-05-24 17:10 ` Mat Martineau
2012-05-24 9:50 ` [RFC 7/8] Bluetooth: Create DEFER_SETUP flag in conf_state Andrei Emeltchenko
2012-05-24 17:01 ` Gustavo Padovan
2012-05-24 9:45 ` [RFC 6/8] Bluetooth: Move check for backlog size to l2cap_sock.c Andrei Emeltchenko
2012-05-24 16:57 ` Gustavo Padovan
2012-05-24 9:39 ` [RFC 3/8] Bluetooth: Add l2cap_chan->ops->ready() Andrei Emeltchenko
2012-05-24 10:23 ` Andrei Emeltchenko
2012-05-24 11:17 ` Ulisses Furquim
2012-05-24 11:30 ` Andrei Emeltchenko
2012-05-24 11:31 ` Ulisses Furquim
2012-05-24 11:37 ` Andrei Emeltchenko
2012-05-24 17:48 ` Mat Martineau
2012-05-24 17:53 ` Ulisses Furquim
2012-05-24 18:48 ` Vinicius Costa Gomes
2012-05-24 9:38 ` [RFC 2/8] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Andrei Emeltchenko
2012-05-24 9:35 ` [RFC 1/8] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Andrei Emeltchenko
2012-05-24 16:56 ` Gustavo Padovan [this message]
2012-05-24 17:14 ` Gustavo Padovan
2012-05-24 17:25 ` Vinicius Costa Gomes
2012-05-24 6:12 ` [RFC 0/8] Another step in l2cap_core/sock separation Gustavo Padovan
2012-05-24 10:02 ` Andrei Emeltchenko
2012-05-24 16:43 ` Gustavo Padovan
2012-05-24 17:55 ` Mat Martineau
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=20120524165611.GB3105@joana \
--to=gustavo@padovan.org \
--cc=andrei.emeltchenko.news@gmail.com \
--cc=gustavo.padovan@collabora.co.uk \
--cc=linux-bluetooth@vger.kernel.org \
/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