digitalmars.D.bugs - [Issue 237] New: std.stream.File.close() doesn't reset isopen flag
- d-bugmail puremagic.com (31/31) Jul 02 2006 http://d.puremagic.com/issues/show_bug.cgi?id=237
- d-bugmail puremagic.com (9/9) Jul 02 2006 http://d.puremagic.com/issues/show_bug.cgi?id=237
- d-bugmail puremagic.com (9/9) Jul 23 2006 http://d.puremagic.com/issues/show_bug.cgi?id=237
- d-bugmail puremagic.com (9/9) Apr 29 2007 http://d.puremagic.com/issues/show_bug.cgi?id=237
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 digitalmars.com ReportedBy: unknown 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] --
Jul 02 2006
http://d.puremagic.com/issues/show_bug.cgi?id=237 ------- Comment #1 from unknown simplemachines.org 2006-07-03 00:26 ------- Created an attachment (id=12) --> (http://d.puremagic.com/issues/attachment.cgi?id=12&action=view) Reset isopen flag on streams. This simply flips the isopen flag on a call to close(), thus ignoring repeated calls. -[Unknown] --
Jul 02 2006
http://d.puremagic.com/issues/show_bug.cgi?id=237 ------- Comment #2 from unknown simplemachines.org 2006-07-23 14:44 ------- I've determined that this only segfaults some of the time, so this may not indeed be the problem I'm seeing. Sorry about that. I still think, regardless, that clearing the isopen flag makes sense. I'll have to do more checking to see if there's another deeper cause for the segfaulting I was seeing. -[Unknown] --
Jul 23 2006
http://d.puremagic.com/issues/show_bug.cgi?id=237 thomas-dloop kuehne.cn changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #3 from thomas-dloop kuehne.cn 2007-04-29 02:10 ------- The isopen flag is cleared in Socket.close which is called from File.close. --
Apr 29 2007