aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/rfcomm
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-09-16 06:05:19 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-09-18 18:02:59 -0400
commite793dcf082c847bd2b742c781252c20cbec37986 (patch)
tree887bbd39d57da0418c41f5bd37f19ca7d1e4f347 /net/bluetooth/rfcomm
parent69c4e4e8b4ca8440e5cbb66219a179e73f7b9e9a (diff)
Bluetooth: Fix waiting for clearing of BT_SK_SUSPEND flag
In the case of blocking sockets we should not proceed with sendmsg() if the socket has the BT_SK_SUSPEND flag set. So far the code was only ensuring that POLLOUT doesn't get set for non-blocking sockets using poll() but there was no code in place to ensure that blocking sockets do the right thing when writing to them. This patch adds a new bt_sock_wait_ready helper function to sleep in the sendmsg call if the BT_SK_SUSPEND flag is set, and wake up as soon as it is unset. It also updates the L2CAP and RFCOMM sendmsg callbacks to take advantage of this new helper function. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/rfcomm')
-rw-r--r--net/bluetooth/rfcomm/sock.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 30b3721dc6d7..072938dc527d 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -544,7 +544,7 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
544 struct sock *sk = sock->sk; 544 struct sock *sk = sock->sk;
545 struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc; 545 struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
546 struct sk_buff *skb; 546 struct sk_buff *skb;
547 int sent = 0; 547 int sent;
548 548
549 if (test_bit(RFCOMM_DEFER_SETUP, &d->flags)) 549 if (test_bit(RFCOMM_DEFER_SETUP, &d->flags))
550 return -ENOTCONN; 550 return -ENOTCONN;
@@ -559,6 +559,10 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
559 559
560 lock_sock(sk); 560 lock_sock(sk);
561 561
562 sent = bt_sock_wait_ready(sk, msg->msg_flags);
563 if (sent)
564 goto done;
565
562 while (len) { 566 while (len) {
563 size_t size = min_t(size_t, len, d->mtu); 567 size_t size = min_t(size_t, len, d->mtu);
564 int err; 568 int err;
@@ -594,6 +598,7 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
594 len -= size; 598 len -= size;
595 } 599 }
596 600
601done:
597 release_sock(sk); 602 release_sock(sk);
598 603
599 return sent; 604 return sent;