khttpd, the first http accellerator
built into the Linux kernel, is very fast, especially at serving
small files. However, it appears to have some stability problems.
It is fairly easy to cause a server running khttpd on some versions of linux
As of 2.4.17, it looks like you have to run with only 1 thread, and
avoid quickly cycling it up and down, to have any hope of stability -- and
even then, abruptly terminating client connections causes
an oops fairly frequently.
In 2.4.17, in my initial testing with khttpd, I couldn't fetch .http files
from khttpd because DecodeHeader was getting -EFAULT
back from sock_recvmsg! Here's the scenario:
This same problem can be triggered by bringing khttpd up and down in a loop.
Here's a test script to do that, and
a not-very-enlightening crash traceback.
- khttpd starts. InitWaitHeaders is called, which allocates Buffer in waitheaders.c.
- Operator stops khttpd. StopWaitingForHeaders is called, which frees Buffer in waitheaders.c.
- Operator restarts khttpd. *InitWaitHeaders is not called again*. When WaitForHeaders gets
a header, it calls DecodeHeader, which calls sock_recvmsg with Buffer as a buffer, which
causes an EFAULT as the buffer has not been allocated.
Another minor problem was found by the Stanford checker: a value
that cannot be NULL was being checked against NULL.
Here are patches to fix up khttpd:
I submitted the first of these to khttpd-users, but have not asked Marcello to apply the
to the 2.4 kernel. I probably should.