[project @ 2001-11-14 11:39:29 by simonmar]
authorsimonmar <unknown>
Wed, 14 Nov 2001 11:39:29 +0000 (11:39 +0000)
committersimonmar <unknown>
Wed, 14 Nov 2001 11:39:29 +0000 (11:39 +0000)
commit9bd3b5f37a3eda096e575f21b3c746acf5ace7ca
tree150d31d2e41785a690929c78646bf9c1b0739ecd
parent01bd67ae7b70d9207867c422e1d335e535a64b27
[project @ 2001-11-14 11:39:29 by simonmar]
Change the way we do finalization for duplex handles.  Previously, we
arranged that the read side pointed to the right side via a special
handle type (ReadSideHandle _), and the finalizer points to the write
side.  This turned out to interact badly with hGetContents, which
likes to explicitly close the read side of the handle after it reads
EOF or gets an error, which resulted in double-closes for duplex
handles.

Now we store the pointer from the read side to the write side in the
Handle structure itself, so it doesn't get lost when hGetContents
changes the handle type to SemiClosedHandle.  Furthermore, in hClose
we no longer close the file descriptor associated with the read side
of a duplex handle - the actual close will have to wait until the
finalizer runs, because someone might still be using the write side.

Thanks to Volker Stolz for pointing out the problem.
ghc/lib/std/PrelHandle.hs
ghc/lib/std/PrelIOBase.lhs