diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-02-29 17:54:05 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-02-29 17:54:05 +0000 |
commit | 94d29f742676d86484a59179b2c75fc46b7767ea (patch) | |
tree | a71c42739347a4777f68766ab272e38a4b71cf1b /sys/kern | |
parent | fdda2333fa7825d6a7461cadb6f07abd19e3ad39 (diff) | |
download | FreeBSD-src-94d29f742676d86484a59179b2c75fc46b7767ea.zip FreeBSD-src-94d29f742676d86484a59179b2c75fc46b7767ea.tar.gz |
Modify soalloc() API so that it accepts a malloc flags argument rather
than a "waitok" argument. Callers now passing M_WAITOK or M_NOWAIT
rather than 0 or 1. This simplifies the soalloc() logic, and also
makes the waiting behavior of soalloc() more clear in the calling
context.
Submitted by: sam
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_sockbuf.c | 2 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 13 | ||||
-rw-r--r-- | sys/kern/uipc_socket2.c | 2 |
3 files changed, 5 insertions, 12 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index 9f5da29..16ee01e 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -189,7 +189,7 @@ sonewconn(head, connstatus) if (head->so_qlen > 3 * head->so_qlimit / 2) return ((struct socket *)0); - so = soalloc(0); + so = soalloc(M_NOWAIT); if (so == NULL) return ((struct socket *)0); if ((head->so_options & SO_ACCEPTFILTER) != 0) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 683bc0d..d0bd8af 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -128,21 +128,14 @@ SYSCTL_INT(_kern_ipc_zero_copy, OID_AUTO, send, CTLFLAG_RW, * soalloc() returns a socket with a ref count of 0. */ struct socket * -soalloc(waitok) - int waitok; +soalloc(int mflags) { struct socket *so; #ifdef MAC int error; #endif - int flag; - if (waitok == 1) - flag = M_WAITOK; - else - flag = M_NOWAIT; - flag |= M_ZERO; - so = uma_zalloc(socket_zone, flag); + so = uma_zalloc(socket_zone, mflags | M_ZERO); if (so) { #ifdef MAC error = mac_init_socket(so, flag); @@ -195,7 +188,7 @@ socreate(dom, aso, type, proto, cred, td) if (prp->pr_type != type) return (EPROTOTYPE); - so = soalloc(1); + so = soalloc(M_WAITOK); if (so == NULL) return (ENOBUFS); diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 9f5da29..16ee01e 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -189,7 +189,7 @@ sonewconn(head, connstatus) if (head->so_qlen > 3 * head->so_qlimit / 2) return ((struct socket *)0); - so = soalloc(0); + so = soalloc(M_NOWAIT); if (so == NULL) return ((struct socket *)0); if ((head->so_options & SO_ACCEPTFILTER) != 0) |