public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: Gustavo Padovan <gustavo@padovan.org>
Cc: linux-bluetooth@vger.kernel.org,
	Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Subject: Re: [PATCH 09/12] Bluetooth: check for already existent channel before create new one
Date: Fri, 25 May 2012 10:32:19 +0300	[thread overview]
Message-ID: <20120525073217.GE3089@aemeltch-MOBL1> (raw)
In-Reply-To: <1337900389-30915-9-git-send-email-gustavo@padovan.org>

Hi Gustavo,

On Thu, May 24, 2012 at 07:59:49PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> 
> Move this check to before the channel time creation simplifies the code
> and avoid memory allocation if the channel already exist.
> 
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> 

> ---
>  net/bluetooth/l2cap_core.c |   13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 7719508..0df7f49 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -3340,21 +3340,16 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
>  
>  	result = L2CAP_CR_NO_MEM;
>  
> +	/* Check if we already have channel with that dcid */
> +	if (__l2cap_get_chan_by_dcid(conn, scid))
> +		goto response;
> +
>  	chan = pchan->ops->new_connection(pchan->data);
>  	if (!chan)
>  		goto response;
>  
>  	sk = chan->sk;
>  
> -	/* Check if we already have channel with that dcid */
> -	if (__l2cap_get_chan_by_dcid(conn, scid)) {
> -		if (chan->ops->teardown)
> -			chan->ops->teardown(chan->data, 0);
> -
> -		chan->ops->close(chan->data);
> -		goto response;
> -	}
> -
>  	hci_conn_hold(conn->hcon);
>  
>  	bacpy(&bt_sk(sk)->src, conn->src);
> -- 
> 1.7.10.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2012-05-25  7:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24 22:59 [PATCH 01/12] Bluetooth: Remove extra l2cap_state_change(BT_CONNECTED) Gustavo Padovan
2012-05-24 22:59 ` [PATCH 02/12] Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.c Gustavo Padovan
2012-05-24 22:59 ` [PATCH 03/12] Bluetooth: Add l2cap_chan->ops->ready() Gustavo Padovan
2012-05-24 22:59 ` [PATCH 04/12] Bluetooth: Use l2cap_chan_ready() in LE path Gustavo Padovan
2012-05-24 22:59 ` [PATCH 05/12] Bluetooth: Use chan->state instead of sk->sk_state Gustavo Padovan
2012-05-24 22:59 ` [PATCH 06/12] Bluetooth: Move check for backlog size to l2cap_sock.c Gustavo Padovan
2012-05-25  7:17   ` Andrei Emeltchenko
2012-05-24 22:59 ` [PATCH 07/12] Bluetooth: Create DEFER_SETUP flag in conf_state Gustavo Padovan
2012-05-24 22:59 ` [PATCH 08/12] Bluetooth: Add chan->ops->defer() Gustavo Padovan
2012-05-25  7:29   ` Andrei Emeltchenko
2012-05-24 22:59 ` [PATCH 09/12] Bluetooth: check for already existent channel before create new one Gustavo Padovan
2012-05-24 23:05   ` [PATCH 10/12] Bluetooth: Move bt_accept_enqueue() call to l2cap_sock.c Gustavo Padovan
2012-05-24 23:05     ` [PATCH 11/12] Bluetooth: Remove parent socket usage from l2cap_core.c Gustavo Padovan
2012-05-24 23:05     ` [PATCH 12/12] Bluetooth: Used void * as parameter in alloc_skb() Gustavo Padovan
2012-05-25  7:32   ` Andrei Emeltchenko [this message]

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=20120525073217.GE3089@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=gustavo@padovan.org \
    --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