X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Flnet%2Flib-socket.c;h=83d67901ceaedc4f478ca1e1649bf5ebec9fd83a;hb=47b7b319783f27023b0cefe54a2a2eea678284f2;hp=80ca9a7586af4a3158e8727ff960350bf93827dd;hpb=0b868add80281c085ce1b297d1cb078deaab802a;p=fs%2Flustre-release.git diff --git a/lnet/lnet/lib-socket.c b/lnet/lnet/lib-socket.c index 80ca9a7..83d6790 100644 --- a/lnet/lnet/lib-socket.c +++ b/lnet/lnet/lib-socket.c @@ -27,7 +27,7 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, 2014, Intel Corporation. + * Copyright (c) 2012, 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -35,6 +35,9 @@ */ #define DEBUG_SUBSYSTEM S_LNET +#ifdef HAVE_COMPAT_RDMA +#include +#endif #include #include #include @@ -89,8 +92,8 @@ lnet_sock_ioctl(int cmd, unsigned long arg) sock_filp = sock_alloc_file(sock, 0); # endif #endif - if (!sock_filp) { - rc = -ENOMEM; + if (IS_ERR(sock_filp)) { + rc = PTR_ERR(sock_filp); sock_release(sock); goto out; } @@ -554,6 +557,13 @@ lnet_sock_listen(struct socket **sockp, return rc; } +#ifndef HAVE_SK_SLEEP +static inline wait_queue_head_t *sk_sleep(struct sock *sk) +{ + return sk->sk_sleep; +} +#endif + int lnet_sock_accept(struct socket **newsockp, struct socket *sock) { @@ -561,8 +571,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 +580,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;