summaryrefslogtreecommitdiff
path: root/net/ax25/ax25_std_timer.c
diff options
context:
space:
mode:
authorJeroen Vreeken <pe1rxq@amsat.org>2003-08-20 22:04:47 -0700
committerDavid S. Miller <davem@nuts.ninka.net>2003-08-20 22:04:47 -0700
commit350a19f5521c19471977af0918293db38f6dae94 (patch)
tree28539bfaf6cb3a8591e1ec2e2aaef2a4ade984cd /net/ax25/ax25_std_timer.c
parent658dcd3b0d4340b434353cb8a2b4125bfabb923d (diff)
[AX25]: Fix ax25_cb locking.
- ax25_cb's use refcounting - the ax25_cb list uses hlists - Lots of socket locking.
Diffstat (limited to 'net/ax25/ax25_std_timer.c')
-rw-r--r--net/ax25/ax25_std_timer.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/net/ax25/ax25_std_timer.c b/net/ax25/ax25_std_timer.c
index efcfe1d27525..066897bc0749 100644
--- a/net/ax25/ax25_std_timer.c
+++ b/net/ax25/ax25_std_timer.c
@@ -33,14 +33,25 @@
void ax25_std_heartbeat_expiry(ax25_cb *ax25)
{
+ struct sock *sk=ax25->sk;
+
+ if (sk)
+ bh_lock_sock(sk);
+
switch (ax25->state) {
case AX25_STATE_0:
/* Magic here: If we listen() and a new link dies before it
is accepted() it isn't 'dead' so doesn't get removed. */
- if (!ax25->sk || sock_flag(ax25->sk, SOCK_DESTROY) ||
- (ax25->sk->sk_state == TCP_LISTEN &&
- sock_flag(ax25->sk, SOCK_DEAD))) {
- ax25_destroy_socket(ax25);
+ if (!sk || sock_flag(sk, SOCK_DESTROY) ||
+ (sk->sk_state == TCP_LISTEN &&
+ sock_flag(sk, SOCK_DEAD))) {
+ if (sk) {
+ sock_hold(sk);
+ ax25_destroy_socket(ax25);
+ bh_unlock_sock(sk);
+ sock_put(sk);
+ } else
+ ax25_destroy_socket(ax25);
return;
}
break;
@@ -50,9 +61,9 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)
/*
* Check the state of the receive buffer.
*/
- if (ax25->sk != NULL) {
- if (atomic_read(&ax25->sk->sk_rmem_alloc) <
- (ax25->sk->sk_rcvbuf / 2) &&
+ if (sk != NULL) {
+ if (atomic_read(&sk->sk_rmem_alloc) <
+ (sk->sk_rcvbuf / 2) &&
(ax25->condition & AX25_COND_OWN_RX_BUSY)) {
ax25->condition &= ~AX25_COND_OWN_RX_BUSY;
ax25->condition &= ~AX25_COND_ACK_PENDING;
@@ -62,6 +73,9 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)
}
}
+ if (sk)
+ bh_unlock_sock(sk);
+
ax25_start_heartbeat(ax25);
}
@@ -94,6 +108,7 @@ void ax25_std_idletimer_expiry(ax25_cb *ax25)
ax25_stop_t3timer(ax25);
if (ax25->sk != NULL) {
+ bh_lock_sock(ax25->sk);
ax25->sk->sk_state = TCP_CLOSE;
ax25->sk->sk_err = 0;
ax25->sk->sk_shutdown |= SEND_SHUTDOWN;
@@ -101,6 +116,7 @@ void ax25_std_idletimer_expiry(ax25_cb *ax25)
ax25->sk->sk_state_change(ax25->sk);
sock_set_flag(ax25->sk, SOCK_DEAD);
}
+ bh_unlock_sock(ax25->sk);
}
}