*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
* 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) 2015, 2016, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
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;
}
nalloc = 16; /* first guess at max interfaces */
toobig = 0;
for (;;) {
- if (nalloc * sizeof(*ifr) > PAGE_CACHE_SIZE) {
+ if (nalloc * sizeof(*ifr) > PAGE_SIZE) {
toobig = 1;
- nalloc = PAGE_CACHE_SIZE/sizeof(*ifr);
+ nalloc = PAGE_SIZE / sizeof(*ifr);
CWARN("Too many interfaces: only enumerating "
"first %d\n", nalloc);
}
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)
{
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);
}
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;