summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authordsl <dsl@NetBSD.org>2004-03-03 22:00:34 +0000
committerdsl <dsl@NetBSD.org>2004-03-03 22:00:34 +0000
commit1288fac2ba074efdc8d6fd01e709c8670ff42c1a (patch)
tree8921ef4afd0bbde2d3774d874159fe7318c61705 /sys
parent08230af71c597846f4c479d142bf14d169464fa8 (diff)
No need to initialise [rw]pipe twice.
Initialise locks before trying to allocate pipe buffer, when allocate fails we'll not explode trying to acquire the locks when tidying up.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/sys_pipe.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index afd948c13bd..bf0a27db01f 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_pipe.c,v 1.52 2004/03/03 21:35:52 christos Exp $ */
+/* $NetBSD: sys_pipe.c,v 1.53 2004/03/03 22:00:34 dsl Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.52 2004/03/03 21:35:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.53 2004/03/03 22:00:34 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -216,7 +216,7 @@ sys_pipe(l, v, retval)
register_t *retval;
{
struct file *rf, *wf;
- struct pipe *rpipe = NULL, *wpipe = NULL;
+ struct pipe *rpipe, *wpipe;
int fd, error;
struct proc *p;
@@ -323,15 +323,15 @@ pipe_create(pipep, allockva)
memset(pipe, 0, sizeof(struct pipe));
pipe->pipe_state = PIPE_SIGNALR;
- if (allockva && (error = pipespace(pipe, PIPE_SIZE)))
- return (error);
-
PIPE_TIMESTAMP(&pipe->pipe_ctime);
pipe->pipe_atime = pipe->pipe_ctime;
pipe->pipe_mtime = pipe->pipe_ctime;
simple_lock_init(&pipe->pipe_slock);
lockinit(&pipe->pipe_lock, PRIBIO | PCATCH, "pipelk", 0, 0);
+ if (allockva && (error = pipespace(pipe, PIPE_SIZE)))
+ return (error);
+
return (0);
}