9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] opendir/closedir in CVS sources
@ 2002-01-08 16:40 Lucio De Re
  0 siblings, 0 replies; 4+ messages in thread
From: Lucio De Re @ 2002-01-08 16:40 UTC (permalink / raw)
  To: 9fans mailing list

Using CVS "import" (thank you Russ, do you know that your efforts can - almost
- be used locally on a plan 9 system?) on a large distribution, one
runs out of, apparently, directory FDs.

Superficial inspection reveals that FDs increment as directories are
opened, but do not get reused once the directory is closed and a new
one opened.

Is it likely that APE closedir() does not release the FD?

++L


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] opendir/closedir in CVS sources
  2002-01-08 16:58 ` Lucio De Re
@ 2002-01-08 17:45   ` Lucio De Re
  0 siblings, 0 replies; 4+ messages in thread
From: Lucio De Re @ 2002-01-08 17:45 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1022 bytes --]

On Tue, Jan 08, 2002 at 06:58:31PM +0200, Lucio De Re wrote:
>
> I see things like:
>
> Opened dir '.' as 5
> N test/mkfile
> succeeded to close dir 5
> 8.out import: Importing /n/other/sys/cvs/test/9
> Opened dir '.' as 6
> N /test/9/mkfile
> succeeded to close dir 6
> 8.out import: Importing /n/other/sys/cvs/test/9/boot
> Opened dir '.' as 7
> ...
>
> from my debugging output.  One consideration is that these are freshly
> created directories, presumably following a mkdir/chdir operation.
>
I seem unable to reproduce the problem from a simple test program :-(

I attach the diffs for my test code in /sys/src/cmd/cvs/src/import.c.
If CVS exists as 8.out, the following commands should exhibit the
behaviour above:

% CVSROOT=$home/cvsroot
% mkdir $CVSROOT
% 8.out init
% cd /sys/src
% .../8.out import -mTest test ABC DEF

At this point, one can crash 8.out and remove the spurious
directories before filling up the repository.

++L
> I _do_ run out of FDs around 100.
>
> ++L

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 706 bytes --]

23,41d22
< #define	TESTING
< #ifdef	TESTING
< #undef	CVS_OPEN
< #undef	CVS_OPENDIR
<
< int CVS_OPEN (const char *path, int flags, mode_t *mode)
< {
< 	int fd = open (path, flags, mode);
< 	fprintf (stderr, "Opened '%s' as %d\n", path, fd);
< 	return fd;
< }
< DIR *CVS_OPENDIR (const char *path)
< {
< 	DIR *dirp = opendir (path);
< 	fprintf (stderr, "Opened dir '%s' as %d\n", path, dirp->dd_fd);
< 	return dirp;
< }
< #endif
<
508,514d488
< #ifdef	TESTING
< 	if (closedir (dirp) != 0) {
< 		fprintf (stderr, "failed to close dir %d - err %d\n", dirp->dd_fd, errno);
< 	} else {
< 		fprintf (stderr, "succeeded to close dir %d\n", dirp->dd_fd);
< 	}
< #else
516d489
< #endif

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] opendir/closedir in CVS sources
  2002-01-08 16:47 rob pike
@ 2002-01-08 16:58 ` Lucio De Re
  2002-01-08 17:45   ` Lucio De Re
  0 siblings, 1 reply; 4+ messages in thread
From: Lucio De Re @ 2002-01-08 16:58 UTC (permalink / raw)
  To: 9fans

On Tue, Jan 08, 2002 at 11:47:55AM -0500, rob pike wrote:
>
> > Is it likely that APE closedir() does not release the FD?
>
> Not very.
>
My conclusion, too.  What could the explanation be, then?

I see things like:

Opened dir '.' as 5
N test/mkfile
succeeded to close dir 5
8.out import: Importing /n/other/sys/cvs/test/9
Opened dir '.' as 6
N /test/9/mkfile
succeeded to close dir 6
8.out import: Importing /n/other/sys/cvs/test/9/boot
Opened dir '.' as 7
...

from my debugging output.  One consideration is that these are freshly
created directories, presumably following a mkdir/chdir operation.

I _do_ run out of FDs around 100.

++L


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] opendir/closedir in CVS sources
@ 2002-01-08 16:47 rob pike
  2002-01-08 16:58 ` Lucio De Re
  0 siblings, 1 reply; 4+ messages in thread
From: rob pike @ 2002-01-08 16:47 UTC (permalink / raw)
  To: 9fans

> Is it likely that APE closedir() does not release the FD?

Not very.

-rob

int
closedir(DIR *d)
{
	if(!d){
		errno = EBADF;
		return -1;
	}
	if(close(d->dd_fd) < 0)
		return -1;
	free(d->dirs);
	free(d);
	return 0;
}



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-01-08 17:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-08 16:40 [9fans] opendir/closedir in CVS sources Lucio De Re
2002-01-08 16:47 rob pike
2002-01-08 16:58 ` Lucio De Re
2002-01-08 17:45   ` Lucio De Re

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).