OLD | NEW |
1 /* | 1 /* |
2 RFCOMM implementation for Linux Bluetooth stack (BlueZ). | 2 RFCOMM implementation for Linux Bluetooth stack (BlueZ). |
3 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com> | 3 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com> |
4 Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org> | 4 Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org> |
5 | 5 |
6 This program is free software; you can redistribute it and/or modify | 6 This program is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License version 2 as | 7 it under the terms of the GNU General Public License version 2 as |
8 published by the Free Software Foundation; | 8 published by the Free Software Foundation; |
9 | 9 |
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | 10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 skb_queue_tail(&sk->sk_receive_queue, skb); | 75 skb_queue_tail(&sk->sk_receive_queue, skb); |
76 sk->sk_data_ready(sk, skb->len); | 76 sk->sk_data_ready(sk, skb->len); |
77 | 77 |
78 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) | 78 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) |
79 rfcomm_dlc_throttle(d); | 79 rfcomm_dlc_throttle(d); |
80 } | 80 } |
81 | 81 |
82 static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err) | 82 static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err) |
83 { | 83 { |
84 struct sock *sk = d->owner, *parent; | 84 struct sock *sk = d->owner, *parent; |
| 85 unsigned long flags; |
| 86 |
85 if (!sk) | 87 if (!sk) |
86 return; | 88 return; |
87 | 89 |
88 BT_DBG("dlc %p state %ld err %d", d, d->state, err); | 90 BT_DBG("dlc %p state %ld err %d", d, d->state, err); |
89 | 91 |
| 92 local_irq_save(flags); |
90 bh_lock_sock(sk); | 93 bh_lock_sock(sk); |
91 | 94 |
92 if (err) | 95 if (err) |
93 sk->sk_err = err; | 96 sk->sk_err = err; |
94 | 97 |
95 sk->sk_state = d->state; | 98 sk->sk_state = d->state; |
96 | 99 |
97 parent = bt_sk(sk)->parent; | 100 parent = bt_sk(sk)->parent; |
98 if (parent) { | 101 if (parent) { |
99 if (d->state == BT_CLOSED) { | 102 if (d->state == BT_CLOSED) { |
100 sock_set_flag(sk, SOCK_ZAPPED); | 103 sock_set_flag(sk, SOCK_ZAPPED); |
101 bt_accept_unlink(sk); | 104 bt_accept_unlink(sk); |
102 } | 105 } |
103 parent->sk_data_ready(parent, 0); | 106 parent->sk_data_ready(parent, 0); |
104 } else { | 107 } else { |
105 if (d->state == BT_CONNECTED) | 108 if (d->state == BT_CONNECTED) |
106 rfcomm_session_getaddr(d->session, &bt_sk(sk)->src, NULL
); | 109 rfcomm_session_getaddr(d->session, &bt_sk(sk)->src, NULL
); |
107 sk->sk_state_change(sk); | 110 sk->sk_state_change(sk); |
108 } | 111 } |
109 | 112 |
110 bh_unlock_sock(sk); | 113 bh_unlock_sock(sk); |
| 114 local_irq_restore(flags); |
111 | 115 |
112 if (parent && sock_flag(sk, SOCK_ZAPPED)) { | 116 if (parent && sock_flag(sk, SOCK_ZAPPED)) { |
113 /* We have to drop DLC lock here, otherwise | 117 /* We have to drop DLC lock here, otherwise |
114 * rfcomm_sock_destruct() will dead lock. */ | 118 * rfcomm_sock_destruct() will dead lock. */ |
115 rfcomm_dlc_unlock(d); | 119 rfcomm_dlc_unlock(d); |
116 rfcomm_sock_kill(sk); | 120 rfcomm_sock_kill(sk); |
117 rfcomm_dlc_lock(d); | 121 rfcomm_dlc_lock(d); |
118 } | 122 } |
119 } | 123 } |
120 | 124 |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 | 1171 |
1168 void __exit rfcomm_cleanup_sockets(void) | 1172 void __exit rfcomm_cleanup_sockets(void) |
1169 { | 1173 { |
1170 debugfs_remove(rfcomm_sock_debugfs); | 1174 debugfs_remove(rfcomm_sock_debugfs); |
1171 | 1175 |
1172 if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) | 1176 if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) |
1173 BT_ERR("RFCOMM socket layer unregistration failed"); | 1177 BT_ERR("RFCOMM socket layer unregistration failed"); |
1174 | 1178 |
1175 proto_unregister(&rfcomm_proto); | 1179 proto_unregister(&rfcomm_proto); |
1176 } | 1180 } |
OLD | NEW |