Bluetooth: Block SCO disconnect operation on BT_CLOSED state.

Have maximum blocking time for shutdown operation as DISCONNECT_TIMEOUT.
During this period when SCO connection closes, the userspace will be
updated on the close operation. Existing approach of immidiate return
on shutdown call can cause synchronization issues on SCO state between
kernel and userspace. This happens when disconnect operation takes
more time at kernel space.

Change-Id: Id9e6a61c2c3d4ba2cf6da574fc49bc6894a8f96a
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
This commit is contained in:
Srinivas Krovvidi
2012-08-01 18:21:37 +05:30
committed by Stephen Boyd
parent 00ff7aefbd
commit 3e9123ed07
2 changed files with 9 additions and 1 deletions

View File

@@ -812,6 +812,9 @@ static int sco_sock_shutdown(struct socket *sock, int how)
if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
err = bt_sock_wait_state(sk, BT_CLOSED,
sk->sk_lingertime);
else
err = bt_sock_wait_state(sk, BT_CLOSED,
SCO_DISCONN_TIMEOUT);
}
release_sock(sk);
return err;
@@ -833,6 +836,11 @@ static int sco_sock_release(struct socket *sock)
lock_sock(sk);
err = bt_sock_wait_state(sk, BT_CLOSED, sk->sk_lingertime);
release_sock(sk);
} else {
lock_sock(sk);
err = bt_sock_wait_state(sk, BT_CLOSED,
SCO_DISCONN_TIMEOUT);
release_sock(sk);
}
sock_orphan(sk);