[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.