aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2012-08-10 17:00:30 +0200
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-11-09 14:05:50 +0100
commit715306f69d85f7ea21eaef4efe75b8364cfea1d5 (patch)
treef6abd1f0a94aab0d2e097b72743f7dbe9ef9deaa /drivers
parenteb12010e9af119c84e6b2214064a98681027e0e3 (diff)
downloadvexpress-lsk-715306f69d85f7ea21eaef4efe75b8364cfea1d5.tar.gz
drbd: Don't unregister socket state_change callback from within the callback
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/drbd/drbd_receiver.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 99121076bf1..14df37ccd52 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -679,21 +679,15 @@ struct accept_wait_data {
};
-static void incomming_connection(struct sock *sk)
+static void drbd_incoming_connection(struct sock *sk)
{
struct accept_wait_data *ad = sk->sk_user_data;
- struct drbd_tconn *tconn = ad->tconn;
+ void (*state_change)(struct sock *sk);
- if (sk->sk_state != TCP_ESTABLISHED)
- conn_warn(tconn, "unexpected tcp state change. sk_state = %d\n", sk->sk_state);
-
- write_lock_bh(&sk->sk_callback_lock);
- sk->sk_state_change = ad->original_sk_state_change;
- sk->sk_user_data = NULL;
- write_unlock_bh(&sk->sk_callback_lock);
-
- sk->sk_state_change(sk);
- complete(&ad->door_bell);
+ state_change = ad->original_sk_state_change;
+ if (sk->sk_state == TCP_ESTABLISHED)
+ complete(&ad->door_bell);
+ state_change(sk);
}
static int prepare_listen_socket(struct drbd_tconn *tconn, struct accept_wait_data *ad)
@@ -736,7 +730,7 @@ static int prepare_listen_socket(struct drbd_tconn *tconn, struct accept_wait_da
ad->s_listen = s_listen;
write_lock_bh(&s_listen->sk->sk_callback_lock);
ad->original_sk_state_change = s_listen->sk->sk_state_change;
- s_listen->sk->sk_state_change = incomming_connection;
+ s_listen->sk->sk_state_change = drbd_incoming_connection;
s_listen->sk->sk_user_data = ad;
write_unlock_bh(&s_listen->sk->sk_callback_lock);
@@ -759,6 +753,14 @@ out:
return -EIO;
}
+static void unregister_state_change(struct sock *sk, struct accept_wait_data *ad)
+{
+ write_lock_bh(&sk->sk_callback_lock);
+ sk->sk_state_change = ad->original_sk_state_change;
+ sk->sk_user_data = NULL;
+ write_unlock_bh(&sk->sk_callback_lock);
+}
+
static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn, struct accept_wait_data *ad)
{
int timeo, connect_int, err = 0;
@@ -789,6 +791,9 @@ static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn, struct acc
}
}
+ if (s_estab)
+ unregister_state_change(s_estab->sk, ad);
+
return s_estab;
}