delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/09/24/13:06:16

From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <10109241701.AA15359@clio.rice.edu>
Subject: Re: The Perl/FD issue: update
To: djgpp-workers AT delorie DOT com
Date: Mon, 24 Sep 2001 12:01:28 -0500 (CDT)
Cc: eliz AT is DOT elta DOT co DOT il (Eli Zaretskii)
In-Reply-To: <Pine.SUN.3.91.1010924120559.25254E-100000@is> from "Eli Zaretskii" at Sep 24, 2001 12:06:48 PM
X-Mailer: ELM [version 2.5 PL2]
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Another possibility is to add to `_close' or to `close' code which
> will walk FILE objects and if it finds one that uses the handle being
> closed, it will mark that FILE object as unused, like `fclose' does.
> The disadvantage of this is that it slows down `_close'/`close', and
> doesn't catch code which closes the handle via `__dpmi_int' or
> `int86'.

This seems reasonable since we just scan our file structures (no 
interrupts).  Closing with direct interrupts should be rare.  It
fixes the problems and is probably the fastest solution.  Could we 
leave the FILE object used but just set the handle to -1, just in
case the user re-uses the FILE object?  I'm not worried about the 
small memory loss in this rare situation.

> Yet another possibility would be to modify `__alloc_file' to test the
> handle in each FILE object when it looks for an empty slot: if the
> handle is invalid, it could consider the FILE object unused, even if
> its flags say otherwise, and reuse that slot.  To see if the handle is
> invalid, we could lseek(fd, SEEK_CUR, 0L), for example.

This also seems reasonable, but I would rather use some of the fd_props
structures to try and do this instead of a bunch of new interrupts
which might break something.  If we had to lseek I would choose the 
close() option above.  We can do several thousand operations internally
for the cost of one interrupt.

What about having a back link pointer in the fd_props to file structure?
If it's used then close() would not need to scan?

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019