This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [cpp patch]: Stop leaking file descriptors
Zack Weinberg wrote:
> The change to open_file is the proper fix for the bug, but the change to
> stack_include_file should be unnecessary. The file never stays open
> past the end of read_include_file, or that's the way it's supposed to
>
> If you get no aborts in a full bootstrap and testsuite run, then go
> ahead and check in the change to open_file only.
Ok,
I committed the attached, which has a couple more cases that were
necessary in open_file. booted and tested on sparc-sun-solaris2.7
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-11-03 Nathan Sidwell <nathan@codesourcery.com>
* cppfiles.c (open_file): If already read, then don't reopen.
Immediatly close an empty file.
Index: cppfiles.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppfiles.c,v
retrieving revision 1.84
diff -c -3 -p -r1.84 cppfiles.c
*** cppfiles.c 2000/10/30 22:28:59 1.84
--- cppfiles.c 2000/11/03 14:42:44
*************** open_file (pfile, filename)
*** 145,153 ****
if (file->fd == -2)
return 0;
! /* -1 indicates a file we've opened previously, and since closed. */
! if (file->fd != -1)
! return file;
}
else
{
--- 145,157 ----
if (file->fd == -2)
return 0;
! /* Don't reopen an idempotent file. */
! if (DO_NOT_REREAD (file))
! return file;
!
! /* Don't reopen one which is already loaded. */
! if (file->buffer != NULL)
! return file;
}
else
{
*************** open_file (pfile, filename)
*** 181,187 ****
{
/* Mark a regular, zero-length file never-reread now. */
if (S_ISREG (file->st.st_mode) && file->st.st_size == 0)
! file->cmacro = NEVER_REREAD;
return file;
}
--- 185,195 ----
{
/* Mark a regular, zero-length file never-reread now. */
if (S_ISREG (file->st.st_mode) && file->st.st_size == 0)
! {
! file->cmacro = NEVER_REREAD;
! close (file->fd);
! file->fd = -1;
! }
return file;
}