[Haskell-cafe] hGetLine problem

Jules Bean jules at jellybean.co.uk
Thu Dec 9 11:19:20 EST 2004


On 9 Dec 2004, at 15:30, Michael Walter wrote:
> I continued toying with my toy web server, and I'm "sometimes" getting
> "Invalid argument" errors in hGetLine for a handle I retrieved from
> Network.listenOn.
>

My first guess would be that hGetLine would return invalid argument if 
it was called on a handle which represents a file which is now closed. 
However, testing in GHCI suggests that returns "illegal operation 
(handle is closed)". Could be different for network sockets, I suppose.

> "Sometimes", because it works fine in the browser, except when I
> reload very frequently -- maybe it's related to some concurrency
> issues (I'm using forkIO to spawn off the handler process from the
> main server loop). When I wanted to benchmark the server using "ab"
> (Apache Benchmark), it didn't even "survive" one request but Fail'ed
> using that error message - "<handle: n>: hGetLine: Invalid argument".
>
> I tried adjusting the buffering mode.
>
> Do you have any ideas?
>

Sounds like a double-close error or something like that. Hard to say 
without seeing the code. Can you make a minimal example?

Jules



More information about the Haskell-Cafe mailing list