Module Name: src Committed By: rmind Date: Tue Apr 5 09:02:23 UTC 2011
Modified Files: src/sys/kern: kern_proc.c Log Message: sysctl_kern_proc_args: fix the deadlock (hi joerg!). To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/sys/kern/kern_proc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.173 src/sys/kern/kern_proc.c:1.174 --- src/sys/kern/kern_proc.c:1.173 Sat Mar 5 01:52:18 2011 +++ src/sys/kern/kern_proc.c Tue Apr 5 09:02:23 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.173 2011/03/05 01:52:18 matt Exp $ */ +/* $NetBSD: kern_proc.c,v 1.174 2011/04/05 09:02:23 rmind Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.173 2011/03/05 01:52:18 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.174 2011/04/05 09:02:23 rmind Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -1940,8 +1940,11 @@ goto out_locked; } - rw_enter(&p->p_reflock, RW_READER); + error = rw_tryenter(&p->p_reflock, RW_READER) ? 0 : EBUSY; mutex_exit(p->p_lock); + if (error) { + goto out_locked; + } mutex_exit(proc_lock); if (type == KERN_PROC_NARGV || type == KERN_PROC_NENV) {