This is my simple implementaion of multithreaded small web daemon. It uses sendfile() syscall, epoll()(but in blocking mode), dynamic queues.
One queue is used for incoming requests, the second one is for sending replies to client in dedicated thread. Serves only static pages.
Features:
- Multithreaded
- My own dynamic queues implementation
- To improve performance it implemented with using sendfile(), epoll syscalls
- My own HTTP protocol parsing implementation
- Supports jpg, png, pdf, mpeg, html MIMEs. Easy to add new types
- Serves only static files
Run:
./swd -c <path to conf file>
conf file:
port = 8080; rootdir =/var/www/; listen =127.0.0.1; workers =2;
where
port
is a listening port
rootdir
is a directory to search files
listen
- is an address to listen to
workers
is a number of worker threads to process requests and number of sender threads
Directory error_pages
must be placed into rootdir
.
TODO:
- implement
HEAD
method - implement index page searching(specifying index page in conf file)
- graceful reload daemon by signal (
kill -SIGUSR1
, for example) - create and dedicate HTTP library
Running server is available at http://denis.ilmen-tau.ru/index.html