I was looking at the code yesterday and I noticed the changes that had
been made in send_file, when there was the problem with the file size.
I saw that the server dynamically allocates req->size memory (WITHOUT
checking for errors ) and then sends it all in one go. This approach is
wrong for a number of reasons:
1. req->size may be really big. If we want to serve a file 100MB big
(which is a realistic scenario), this means we should allocate a 100MB
variable. Problems: The machine we're running on may not have 100MB
RAM, and to boot, even if it does, how many concurrent 100MB requests
can we serve? Few.
2. No error checking was performed and it is extremely likely to fail,
given the size of the memory we may ask for.
3. Dynamic allocation is slow. Checking whether the memory was
allocated adds one more if() test.
I fixed the problem and now everything should be faster than before and
more robust.
Pandis
Send instant messages to your online friends http://uk.messenger.yahoo.com
|