Commit 939bb7ef authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] Code cleanups in calbacks in svcsock

Change a printk(KERN_WARNING to dprintk, and it is really only interesting
when trying to debug a problem, and can occur normally without error.

Remove various gratuitous gotos in surrounding code, and remove some
type-cast assignments from inside 'if' conditionals, as that is just
obscuring what it going on.
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 73aea4ec
...@@ -512,15 +512,14 @@ svc_sock_setbufsize(struct socket *sock, unsigned int snd, unsigned int rcv) ...@@ -512,15 +512,14 @@ svc_sock_setbufsize(struct socket *sock, unsigned int snd, unsigned int rcv)
static void static void
svc_udp_data_ready(struct sock *sk, int count) svc_udp_data_ready(struct sock *sk, int count)
{ {
struct svc_sock *svsk = (struct svc_sock *)(sk->sk_user_data); struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
if (!svsk) if (svsk) {
goto out;
dprintk("svc: socket %p(inet %p), count=%d, busy=%d\n", dprintk("svc: socket %p(inet %p), count=%d, busy=%d\n",
svsk, sk, count, test_bit(SK_BUSY, &svsk->sk_flags)); svsk, sk, count, test_bit(SK_BUSY, &svsk->sk_flags));
set_bit(SK_DATA, &svsk->sk_flags); set_bit(SK_DATA, &svsk->sk_flags);
svc_sock_enqueue(svsk); svc_sock_enqueue(svsk);
out: }
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
wake_up_interruptible(sk->sk_sleep); wake_up_interruptible(sk->sk_sleep);
} }
...@@ -540,7 +539,7 @@ svc_write_space(struct sock *sk) ...@@ -540,7 +539,7 @@ svc_write_space(struct sock *sk)
} }
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) { if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) {
printk(KERN_WARNING "RPC svc_write_space: some sleeping on %p\n", dprintk("RPC svc_write_space: someone sleeping on %p\n",
svsk); svsk);
wake_up_interruptible(sk->sk_sleep); wake_up_interruptible(sk->sk_sleep);
} }
...@@ -692,12 +691,11 @@ svc_udp_init(struct svc_sock *svsk) ...@@ -692,12 +691,11 @@ svc_udp_init(struct svc_sock *svsk)
static void static void
svc_tcp_listen_data_ready(struct sock *sk, int count_unused) svc_tcp_listen_data_ready(struct sock *sk, int count_unused)
{ {
struct svc_sock *svsk; struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
dprintk("svc: socket %p TCP (listen) state change %d\n", dprintk("svc: socket %p TCP (listen) state change %d\n",
sk, sk->sk_state); sk, sk->sk_state);
if (sk->sk_state != TCP_LISTEN) {
/* /*
* This callback may called twice when a new connection * This callback may called twice when a new connection
* is established as a child socket inherits everything * is established as a child socket inherits everything
...@@ -708,15 +706,14 @@ svc_tcp_listen_data_ready(struct sock *sk, int count_unused) ...@@ -708,15 +706,14 @@ svc_tcp_listen_data_ready(struct sock *sk, int count_unused)
* when it receives data before the socket is accepted. * when it receives data before the socket is accepted.
* In case of 2, we should ignore it silently. * In case of 2, we should ignore it silently.
*/ */
goto out; if (sk->sk_state == TCP_LISTEN) {
} if (svsk) {
if (!(svsk = (struct svc_sock *) sk->sk_user_data)) {
printk("svc: socket %p: no user data\n", sk);
goto out;
}
set_bit(SK_CONN, &svsk->sk_flags); set_bit(SK_CONN, &svsk->sk_flags);
svc_sock_enqueue(svsk); svc_sock_enqueue(svsk);
out: } else
printk("svc: socket %p: no user data\n", sk);
}
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
wake_up_interruptible_all(sk->sk_sleep); wake_up_interruptible_all(sk->sk_sleep);
} }
...@@ -727,18 +724,17 @@ svc_tcp_listen_data_ready(struct sock *sk, int count_unused) ...@@ -727,18 +724,17 @@ svc_tcp_listen_data_ready(struct sock *sk, int count_unused)
static void static void
svc_tcp_state_change(struct sock *sk) svc_tcp_state_change(struct sock *sk)
{ {
struct svc_sock *svsk; struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
dprintk("svc: socket %p TCP (connected) state change %d (svsk %p)\n", dprintk("svc: socket %p TCP (connected) state change %d (svsk %p)\n",
sk, sk->sk_state, sk->sk_user_data); sk, sk->sk_state, sk->sk_user_data);
if (!(svsk = (struct svc_sock *) sk->sk_user_data)) { if (!svsk)
printk("svc: socket %p: no user data\n", sk); printk("svc: socket %p: no user data\n", sk);
goto out; else {
}
set_bit(SK_CLOSE, &svsk->sk_flags); set_bit(SK_CLOSE, &svsk->sk_flags);
svc_sock_enqueue(svsk); svc_sock_enqueue(svsk);
out: }
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
wake_up_interruptible_all(sk->sk_sleep); wake_up_interruptible_all(sk->sk_sleep);
} }
...@@ -746,15 +742,14 @@ svc_tcp_state_change(struct sock *sk) ...@@ -746,15 +742,14 @@ svc_tcp_state_change(struct sock *sk)
static void static void
svc_tcp_data_ready(struct sock *sk, int count) svc_tcp_data_ready(struct sock *sk, int count)
{ {
struct svc_sock * svsk; struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
dprintk("svc: socket %p TCP data ready (svsk %p)\n", dprintk("svc: socket %p TCP data ready (svsk %p)\n",
sk, sk->sk_user_data); sk, sk->sk_user_data);
if (!(svsk = (struct svc_sock *)(sk->sk_user_data))) if (svsk) {
goto out;
set_bit(SK_DATA, &svsk->sk_flags); set_bit(SK_DATA, &svsk->sk_flags);
svc_sock_enqueue(svsk); svc_sock_enqueue(svsk);
out: }
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
wake_up_interruptible(sk->sk_sleep); wake_up_interruptible(sk->sk_sleep);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment