k0001 / pipes-network

Use network sockets together with the Haskell pipes library.
http://hackage.haskell.org/package/pipes-network
Other
24 stars 8 forks source link

`fromSocketTimeout(N)` broken EOF handling? #29

Closed NicolasT closed 10 years ago

NicolasT commented 10 years ago

After making a seemingly trivial change from fromSocket to fromSocketTimeout in an application, my app started to consume 100% CPU after a client connected and disconnected.

When checking what was going on using strace, I noticed lots of read (or recvmsg, can't remember exactly) calls returning 0 bytes, denoting EOF.

When checking the pipes-network code, I saw the fromSocket code correctly detects a 0-length read, then closes the producer. Turns out the functions with timeout enabled don't, they pass the (empty) bytestring downstream and loop.

I believe that's a bug?

k0001 commented 10 years ago

@NicolasT thanks for catching this! It is certainly a bug, and your diagnostic seems accurate. I'll fix it right away.

k0001 commented 10 years ago

@NicolasT this should be fixed by https://github.com/k0001/pipes-network/commit/ad5a52d836891a5e9bf08861cba4212008fe8b6c

Do you mind if I add your name to the PEOPLE file as a small “thank you”?

k0001 commented 10 years ago

I'm closing this, please reopen if the issue is still present.

NicolasT commented 10 years ago

Thanks for the swift response & fix. I don't mind any thank you, but don't feel obliged either ;-)

Thanks,

Nicolas

k0001 commented 10 years ago

Just so you know, I'll delay shipping this to Hackage a bit because I want to go over the list of open issues and fix some of them.