Whamcloud - gitweb
Revert "New tag 2.7.53"
[fs/lustre-release.git] / lnet / lnet / lib-socket.c
index 80ca9a7..0b6fc00 100644 (file)
@@ -561,8 +561,6 @@ lnet_sock_accept(struct socket **newsockp, struct socket *sock)
        struct socket *newsock;
        int            rc;
 
-       init_waitqueue_entry(&wait, current);
-
        /* XXX this should add a ref to sock->ops->owner, if
         * TCP could be a module */
        rc = sock_create_lite(PF_PACKET, sock->type, IPPROTO_TCP, &newsock);
@@ -572,18 +570,18 @@ lnet_sock_accept(struct socket **newsockp, struct socket *sock)
        }
 
        newsock->ops = sock->ops;
-       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 */
+               init_waitqueue_entry(&wait, current);
+               add_wait_queue(sk_sleep(sock->sk), &wait);
+               set_current_state(TASK_INTERRUPTIBLE);
                schedule();
+               remove_wait_queue(sk_sleep(sock->sk), &wait);
                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;