From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFCv0] Bluetooth: Change locking logic in sock send
Date: Fri, 27 Apr 2012 16:40:06 +0300 [thread overview]
Message-ID: <1335534006-1216-1-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1204261647490.13179@mathewm-linux>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use chan_lock instead of lock_sock when sending L2CAP pkts.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/bluetooth.h | 2 --
net/bluetooth/l2cap_sock.c | 8 ++++----
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 2fb268f..90678a9 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -256,12 +256,10 @@ static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk,
{
struct sk_buff *skb;
- release_sock(sk);
if ((skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err))) {
skb_reserve(skb, BT_SKB_RESERVE);
bt_cb(skb)->incoming = 0;
}
- lock_sock(sk);
if (!skb && *err)
return NULL;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 0f30785..e622072 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -716,16 +716,16 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
if (msg->msg_flags & MSG_OOB)
return -EOPNOTSUPP;
- lock_sock(sk);
-
if (sk->sk_state != BT_CONNECTED) {
- release_sock(sk);
return -ENOTCONN;
}
+ l2cap_chan_lock(chan);
+
err = l2cap_chan_send(chan, msg, len, sk->sk_priority);
- release_sock(sk);
+ l2cap_chan_unlock(chan);
+
return err;
}
--
1.7.9.5
next prev parent reply other threads:[~2012-04-27 13:40 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-25 23:36 [RFC 0/8] ERTM state machine changes, part 2 Mat Martineau
2012-04-25 23:36 ` [RFC 1/8] Bluetooth: Improve ERTM sequence number offset calculation Mat Martineau
2012-04-26 6:39 ` Marcel Holtmann
2012-04-26 7:10 ` Andrei Emeltchenko
2012-04-26 23:35 ` Mat Martineau
2012-04-27 2:19 ` Gustavo Padovan
2012-04-25 23:36 ` [RFC 2/8] Bluetooth: Initialize new l2cap_chan structure members Mat Martineau
2012-04-26 6:38 ` Marcel Holtmann
2012-04-26 22:03 ` Mat Martineau
2012-04-25 23:36 ` [RFC 3/8] Bluetooth: Remove duplicate structure members from bt_skb_cb Mat Martineau
2012-04-26 6:39 ` Marcel Holtmann
2012-04-27 3:22 ` Gustavo Padovan
2012-04-25 23:36 ` [RFC 4/8] Bluetooth: Move recently-added ERTM header packing functions Mat Martineau
2012-04-26 6:40 ` Marcel Holtmann
2012-04-27 3:26 ` Gustavo Padovan
2012-04-25 23:36 ` [RFC 5/8] Bluetooth: Move recently-added ERTM header unpacking functions Mat Martineau
2012-04-26 6:40 ` Marcel Holtmann
2012-04-27 3:26 ` Gustavo Padovan
2012-04-25 23:36 ` [RFC 6/8] Bluetooth: Lock the L2CAP channel when sending Mat Martineau
2012-04-26 6:41 ` Marcel Holtmann
2012-04-26 8:22 ` Andrei Emeltchenko
2012-04-26 23:48 ` Mat Martineau
2012-04-27 13:40 ` Andrei Emeltchenko [this message]
2012-04-25 23:36 ` [RFC 7/8] Bluetooth: Refactor L2CAP ERTM and streaming transmit segmentation Mat Martineau
2012-04-26 6:43 ` Marcel Holtmann
2012-04-25 23:36 ` [RFC 8/8] Bluetooth: Add Code Aurora Forum copyright Mat Martineau
2012-04-26 6:44 ` 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=1335534006-1216-1-git-send-email-Andrei.Emeltchenko.news@gmail.com \
--to=andrei.emeltchenko.news@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).