diff options
author | Neil Brown <neilb@suse.de> | 2005-09-13 04:25:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-13 11:22:32 -0400 |
commit | 939bb7ef901b2537aa5b4cd819f9c1b25c6a5710 (patch) | |
tree | 53bbc1a416577780096913113608a832f4e72cba /net | |
parent | 73aea4ecd38ebeff9e322f738057f4ae2c32a3ee (diff) |
[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: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/svcsock.c | 83 |
1 files changed, 39 insertions, 44 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 51885b5f744e..30ec3efc48a6 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -512,15 +512,14 @@ svc_sock_setbufsize(struct socket *sock, unsigned int snd, unsigned int rcv) | |||
512 | static void | 512 | static void |
513 | svc_udp_data_ready(struct sock *sk, int count) | 513 | svc_udp_data_ready(struct sock *sk, int count) |
514 | { | 514 | { |
515 | struct svc_sock *svsk = (struct svc_sock *)(sk->sk_user_data); | 515 | struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data; |
516 | 516 | ||
517 | if (!svsk) | 517 | if (svsk) { |
518 | goto out; | 518 | dprintk("svc: socket %p(inet %p), count=%d, busy=%d\n", |
519 | dprintk("svc: socket %p(inet %p), count=%d, busy=%d\n", | 519 | svsk, sk, count, test_bit(SK_BUSY, &svsk->sk_flags)); |
520 | svsk, sk, count, test_bit(SK_BUSY, &svsk->sk_flags)); | 520 | set_bit(SK_DATA, &svsk->sk_flags); |
521 | set_bit(SK_DATA, &svsk->sk_flags); | 521 | svc_sock_enqueue(svsk); |
522 | svc_sock_enqueue(svsk); | 522 | } |
523 | out: | ||
524 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 523 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) |
525 | wake_up_interruptible(sk->sk_sleep); | 524 | wake_up_interruptible(sk->sk_sleep); |
526 | } | 525 | } |
@@ -540,7 +539,7 @@ svc_write_space(struct sock *sk) | |||
540 | } | 539 | } |
541 | 540 | ||
542 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) { | 541 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) { |
543 | printk(KERN_WARNING "RPC svc_write_space: some sleeping on %p\n", | 542 | dprintk("RPC svc_write_space: someone sleeping on %p\n", |
544 | svsk); | 543 | svsk); |
545 | wake_up_interruptible(sk->sk_sleep); | 544 | wake_up_interruptible(sk->sk_sleep); |
546 | } | 545 | } |
@@ -692,31 +691,29 @@ svc_udp_init(struct svc_sock *svsk) | |||
692 | static void | 691 | static void |
693 | svc_tcp_listen_data_ready(struct sock *sk, int count_unused) | 692 | svc_tcp_listen_data_ready(struct sock *sk, int count_unused) |
694 | { | 693 | { |
695 | struct svc_sock *svsk; | 694 | struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data; |
696 | 695 | ||
697 | dprintk("svc: socket %p TCP (listen) state change %d\n", | 696 | dprintk("svc: socket %p TCP (listen) state change %d\n", |
698 | sk, sk->sk_state); | 697 | sk, sk->sk_state); |
699 | 698 | ||
700 | if (sk->sk_state != TCP_LISTEN) { | 699 | /* |
701 | /* | 700 | * This callback may called twice when a new connection |
702 | * This callback may called twice when a new connection | 701 | * is established as a child socket inherits everything |
703 | * is established as a child socket inherits everything | 702 | * from a parent LISTEN socket. |
704 | * from a parent LISTEN socket. | 703 | * 1) data_ready method of the parent socket will be called |
705 | * 1) data_ready method of the parent socket will be called | 704 | * when one of child sockets become ESTABLISHED. |
706 | * when one of child sockets become ESTABLISHED. | 705 | * 2) data_ready method of the child socket may be called |
707 | * 2) data_ready method of the child socket may be called | 706 | * when it receives data before the socket is accepted. |
708 | * when it receives data before the socket is accepted. | 707 | * In case of 2, we should ignore it silently. |
709 | * In case of 2, we should ignore it silently. | 708 | */ |
710 | */ | 709 | if (sk->sk_state == TCP_LISTEN) { |
711 | goto out; | 710 | if (svsk) { |
712 | } | 711 | set_bit(SK_CONN, &svsk->sk_flags); |
713 | if (!(svsk = (struct svc_sock *) sk->sk_user_data)) { | 712 | svc_sock_enqueue(svsk); |
714 | printk("svc: socket %p: no user data\n", sk); | 713 | } else |
715 | goto out; | 714 | printk("svc: socket %p: no user data\n", sk); |
716 | } | 715 | } |
717 | set_bit(SK_CONN, &svsk->sk_flags); | 716 | |
718 | svc_sock_enqueue(svsk); | ||
719 | out: | ||
720 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 717 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) |
721 | wake_up_interruptible_all(sk->sk_sleep); | 718 | wake_up_interruptible_all(sk->sk_sleep); |
722 | } | 719 | } |
@@ -727,18 +724,17 @@ svc_tcp_listen_data_ready(struct sock *sk, int count_unused) | |||
727 | static void | 724 | static void |
728 | svc_tcp_state_change(struct sock *sk) | 725 | svc_tcp_state_change(struct sock *sk) |
729 | { | 726 | { |
730 | struct svc_sock *svsk; | 727 | struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data; |
731 | 728 | ||
732 | dprintk("svc: socket %p TCP (connected) state change %d (svsk %p)\n", | 729 | dprintk("svc: socket %p TCP (connected) state change %d (svsk %p)\n", |
733 | sk, sk->sk_state, sk->sk_user_data); | 730 | sk, sk->sk_state, sk->sk_user_data); |
734 | 731 | ||
735 | if (!(svsk = (struct svc_sock *) sk->sk_user_data)) { | 732 | if (!svsk) |
736 | printk("svc: socket %p: no user data\n", sk); | 733 | printk("svc: socket %p: no user data\n", sk); |
737 | goto out; | 734 | else { |
735 | set_bit(SK_CLOSE, &svsk->sk_flags); | ||
736 | svc_sock_enqueue(svsk); | ||
738 | } | 737 | } |
739 | set_bit(SK_CLOSE, &svsk->sk_flags); | ||
740 | svc_sock_enqueue(svsk); | ||
741 | out: | ||
742 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 738 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) |
743 | wake_up_interruptible_all(sk->sk_sleep); | 739 | wake_up_interruptible_all(sk->sk_sleep); |
744 | } | 740 | } |
@@ -746,15 +742,14 @@ svc_tcp_state_change(struct sock *sk) | |||
746 | static void | 742 | static void |
747 | svc_tcp_data_ready(struct sock *sk, int count) | 743 | svc_tcp_data_ready(struct sock *sk, int count) |
748 | { | 744 | { |
749 | struct svc_sock * svsk; | 745 | struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data; |
750 | 746 | ||
751 | dprintk("svc: socket %p TCP data ready (svsk %p)\n", | 747 | dprintk("svc: socket %p TCP data ready (svsk %p)\n", |
752 | sk, sk->sk_user_data); | 748 | sk, sk->sk_user_data); |
753 | if (!(svsk = (struct svc_sock *)(sk->sk_user_data))) | 749 | if (svsk) { |
754 | goto out; | 750 | set_bit(SK_DATA, &svsk->sk_flags); |
755 | set_bit(SK_DATA, &svsk->sk_flags); | 751 | svc_sock_enqueue(svsk); |
756 | svc_sock_enqueue(svsk); | 752 | } |
757 | out: | ||
758 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 753 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) |
759 | wake_up_interruptible(sk->sk_sleep); | 754 | wake_up_interruptible(sk->sk_sleep); |
760 | } | 755 | } |