Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
100% CPU usage during slow file serve #53
Problem: when serving a large file which client reads slowly Snap uses 100% CPU.
I don't know exactly if this is reproducible in general so let me explain my setup. I've created a default project (with "snap init") and not made any changes. I then start a server and let my client request a file. The client is a UPnP device which sends a GET request with a range header (requesting all bytes). However, the device reads data very slowly effectively keeping the session going for a long time (this is a device that plays music files so "long time" means something like 4 minutes). During this time snap uses 100% of the CPU.
I'm guessing the problem can be reproduced by creating a client which requests a file without actually reading from the socket. However, before I start spending time on debugging this I thought I'd report the problem.
I'm on Mac OS X 10.6.6, GHC 6.12.3 and "snap --version" says 0.3.1.1.
I just had a look to see if I could recreate this problem with a simple test program that opens a socket and reads slowly (every couple of seconds) but Snap behaves well under this situation. So the problem is somehow related to how the UPnP device is reading from the socket.
This will require some serious investigation. I'll report back if I find some way of reproducing with a test program.