Instead of missing NULL check in pipe_create, let the pipe_ctor to wait

on buffer allocation.  The other allocation is simply an optimization,
so leave it as is.
This commit is contained in:
enami 2009-02-06 23:04:57 +00:00
parent 60b229d2eb
commit e1be06d405
1 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_pipe.c,v 1.106 2009/02/01 18:23:04 ad Exp $ */
/* $NetBSD: sys_pipe.c,v 1.107 2009/02/06 23:04:57 enami Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.106 2009/02/01 18:23:04 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.107 2009/02/06 23:04:57 enami Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -199,10 +199,9 @@ pipe_ctor(void *arg, void *obj, int flags)
memset(pipe, 0, sizeof(struct pipe));
if (arg != NULL) {
/* Preallocate space. */
va = uvm_km_alloc(kernel_map, PIPE_SIZE, 0, UVM_KMF_PAGEABLE);
if (va == 0) {
return ENOMEM;
}
va = uvm_km_alloc(kernel_map, PIPE_SIZE, 0,
UVM_KMF_PAGEABLE | UVM_KMF_WAITVA);
KASSERT(va != 0);
pipe->pipe_kmem = va;
atomic_add_int(&amountpipekva, PIPE_SIZE);
}
@ -340,6 +339,7 @@ pipe_create(struct pipe **pipep, pool_cache_t cache, kmutex_t *mutex)
int error;
pipe = pool_cache_get(cache, PR_WAITOK);
KASSERT(pipe != NULL);
*pipep = pipe;
error = 0;
getmicrotime(&pipe->pipe_ctime);