[5.02/5.02.1] hGetContents problem
Simon Marlow
simonmar at microsoft.com
Wed Nov 14 05:30:04 EST 2001
> A small program (which I haven't been able to strip down to a
> minimal *failing* version ;) repeatedly opens sockets and does the
> following (I tested with all permutations of hSetBuffering):
>
> Socket.connectTo ...
> hPutStrLn h "Data"
> hPutStr h d
> debug Io "Reading..:"
> c <- hGetContents h
> debug Io "."
> print c
> debug Io "*"
>
> After several loops, the program fails with:
>
> Io: "Reading..:"
> Io: "."
>
> Fail: failed
> Action: lazyRead
> Handle: {loc=<socket: 0>,type=semi-closed,binary=True,buffering=none}
> Reason: Bad file descriptor
> File: <socket: 0>
Hmm, interesting bug. I think I know what the reason is, but a proper
fix will require some thought. The attached patch should get you going,
but it has one undesirable effect: a semi-closed Handle won't be closed
immediately after all the data has been read from it, it'll only be
closed when the finalizer eventually runs.
Cheers,
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff
Type: application/octet-stream
Size: 7326 bytes
Desc: diff
Url : http://www.haskell.org/pipermail/glasgow-haskell-bugs/attachments/20011114/4d0e0b46/diff.obj
More information about the Glasgow-haskell-bugs
mailing list