From 56c88fa187ea72314142cb0eadc01042db0031e6 Mon Sep 17 00:00:00 2001 From: ru Date: Mon, 26 Feb 2007 10:45:21 +0000 Subject: [PATCH] Don't block on the socket zone limit during the socket() call which can easily lock up a system otherwise; instead, return ENOBUFS as documented in a manpage, thus reverting us to the FreeBSD 4.x behavior. Reviewed by: rwatson MFC after: 2 weeks --- sys/kern/uipc_socket.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index a8d27366554b..eaf45a0157b1 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -257,15 +257,15 @@ SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL); * soalloc() returns a socket with a ref count of 0. */ static struct socket * -soalloc(int mflags) +soalloc(void) { struct socket *so; - so = uma_zalloc(socket_zone, mflags | M_ZERO); + so = uma_zalloc(socket_zone, M_NOWAIT | M_ZERO); if (so == NULL) return (NULL); #ifdef MAC - if (mac_init_socket(so, mflags) != 0) { + if (mac_init_socket(so, M_NOWAIT) != 0) { uma_zfree(socket_zone, so); return (NULL); } @@ -351,7 +351,7 @@ socreate(dom, aso, type, proto, cred, td) if (prp->pr_type != type) return (EPROTOTYPE); - so = soalloc(M_WAITOK); + so = soalloc(); if (so == NULL) return (ENOBUFS); @@ -416,7 +416,7 @@ sonewconn(head, connstatus) if (over) #endif return (NULL); - so = soalloc(M_NOWAIT); + so = soalloc(); if (so == NULL) return (NULL); if ((head->so_options & SO_ACCEPTFILTER) != 0)