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
This commit is contained in:
ru 2007-02-26 10:45:21 +00:00
parent 5023c1b4ee
commit 56c88fa187

View File

@ -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. * soalloc() returns a socket with a ref count of 0.
*/ */
static struct socket * static struct socket *
soalloc(int mflags) soalloc(void)
{ {
struct socket *so; struct socket *so;
so = uma_zalloc(socket_zone, mflags | M_ZERO); so = uma_zalloc(socket_zone, M_NOWAIT | M_ZERO);
if (so == NULL) if (so == NULL)
return (NULL); return (NULL);
#ifdef MAC #ifdef MAC
if (mac_init_socket(so, mflags) != 0) { if (mac_init_socket(so, M_NOWAIT) != 0) {
uma_zfree(socket_zone, so); uma_zfree(socket_zone, so);
return (NULL); return (NULL);
} }
@ -351,7 +351,7 @@ socreate(dom, aso, type, proto, cred, td)
if (prp->pr_type != type) if (prp->pr_type != type)
return (EPROTOTYPE); return (EPROTOTYPE);
so = soalloc(M_WAITOK); so = soalloc();
if (so == NULL) if (so == NULL)
return (ENOBUFS); return (ENOBUFS);
@ -416,7 +416,7 @@ sonewconn(head, connstatus)
if (over) if (over)
#endif #endif
return (NULL); return (NULL);
so = soalloc(M_NOWAIT); so = soalloc();
if (so == NULL) if (so == NULL)
return (NULL); return (NULL);
if ((head->so_options & SO_ACCEPTFILTER) != 0) if ((head->so_options & SO_ACCEPTFILTER) != 0)