Subject: Re: CVS commit: src/sys/kern
To: Paul Kranenburg <pk@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: source-changes
Date: 02/15/2003 13:53:38
On Fri, Feb 14, 2003 at 11:50:11PM +0200, Paul Kranenburg wrote:
> 
> Module Name:	src
> Committed By:	pk
> Date:		Fri Feb 14 21:50:11 UTC 2003
> 
> Modified Files:
> 
> 	src/sys/kern: kern_descrip.c
> 
> Log Message:
> 
> Use a mutex to protect the global list of open files.

Just curious here..   With this change you have:

	@@ -757,8 +760,13 @@
			}
			return (error);
		}
	+
	+       fp = pool_get(&file_pool, PR_WAITOK);
	+       simple_lock(&filelist_slock);
		if (nfiles >= maxfiles) {
			tablefull("file", "increase kern.maxfiles or MAXFILES");
	+               simple_unlock(&filelist_slock);
	+               pool_put(&file_pool, fp);
			return (ENFILE);
		}
		/*
	@@ -768,7 +776,6 @@
		 * the list of open files.
		 */
		nfiles++;
	-       fp = pool_get(&file_pool, PR_WAITOK);
		memset(fp, 0, sizeof(struct file));
		fp->f_iflags = FIF_LARVAL;
		if ((fq = p->p_fd->fd_ofiles[0]) != NULL) {

The pool_get() call is moved up to before the maxfiles check.  Does this
result in a leak if nfiles >= maxfiles now?

Simon.
--
Simon Burge                                   <simonb@wasabisystems.com>
NetBSD Development, Support and Service:   http://www.wasabisystems.com/