[Issue 237] New: std.stream.File.close() doesn't reset isopen flag
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jul 2 22:24:48 PDT 2006
http://d.puremagic.com/issues/show_bug.cgi?id=237
Summary: std.stream.File.close() doesn't reset isopen flag
Product: D
Version: 0.162
Platform: All
OS/Version: All
Status: NEW
Severity: minor
Priority: P3
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: unknown at simplemachines.org
I had a code segment like this:
File f = new File(filename);
scope (exit)
{
f.close();
delete f;
}
However, this hang on Linux. I discovered that the deconstructor for File
calls close() - which I was already calling. If I only close, or I only
delete... it works.
But, if I close... and later the garbage collector picks it up, I could
theoretically get a hang anywhere... one I couldn't reproduce. That would be
bad.
AFAICT, this is simply because close() is always trying to close the open
handle every time it's called. Meaning, calling close() twice in a row is not
allowed.
The fix is simple. Will attach.
-[Unknown]
--
More information about the Digitalmars-d-bugs
mailing list