staging/lustre: Don't call blocking funcitons when !RUNNABLE
authorOleg Drokin <green@linuxhacker.ru>
Sun, 8 Mar 2015 00:24:29 +0000 (19:24 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Mar 2015 09:35:44 +0000 (10:35 +0100)
Move setting of TASK_INTERRUPTIBLE just around schedule call in
libcfs_sock_accept.

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c

index cd2fc01dea4cfb446851a47a61bd40e0ea412a3b..f2462e7f04bc40dd4b4dd3798eecdad08b52f3ff 100644 (file)
@@ -543,19 +543,17 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
 
        newsock->ops = sock->ops;
 
-       set_current_state(TASK_INTERRUPTIBLE);
-       add_wait_queue(sk_sleep(sock->sk), &wait);
-
        rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
        if (rc == -EAGAIN) {
                /* Nothing ready, so wait for activity */
+               set_current_state(TASK_INTERRUPTIBLE);
+               add_wait_queue(sk_sleep(sock->sk), &wait);
                schedule();
+               remove_wait_queue(sk_sleep(sock->sk), &wait);
+               set_current_state(TASK_RUNNING);
                rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
        }
 
-       remove_wait_queue(sk_sleep(sock->sk), &wait);
-       set_current_state(TASK_RUNNING);
-
        if (rc != 0)
                goto failed;