Lighttpd and the wonders of strace

I ran Lighttpd under strace today whilst debugging a problem with mod_deflate and I found two mis-configurations just from watching the system calls it was making. In case anyone is interested, this is what I found.

Firstly, I’d enabled the system.use-noatime option but I could see that it was failing to set this mode when opening a file to serve:


open("/home/john/.../newsniffer.css", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_NOATIME) = -1 EPERM (Operation not permitted)
open("/home/john/.../newsniffer.css", O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 40

I realised that Lighty drops privileges on start-up, and the O_NOATIME option is privileged. No biggie, but a wasted system call is a wasted system call, so I disabled the option. To my surprise, this fixed the blank/empty page problem I was having with mod_deflate. Clearly a bug, but now I can file a slightly more helpful bug report (this is the Lighttpd dev trunk btw).

Secondly, I’d always assumed (having read it somewhere, I’m sure) that Lighttpd selected the most efficient event-handler available on the operating system – on my Linux 2.6 system this would be epoll, but strace showed Lighttp using regular poll:


poll([{fd=4, events=POLLIN}, {fd=5, events=POLLIN}, {fd=-1}, {fd=-1}, {fd=-1}, {fd=-1}], 6, 1000) = 0

So, I explicitly configured it with server.event-handler = "linux-sysepoll" and now strace shows me:


epoll_wait(39, {}, 4096, 1000)          = 0

I’ve always found the strace tool very useful, but sometimes I forget and take it for granted. I love you strace tool.

This entry was posted in GNU/Linux, Tech and tagged , , , . Bookmark the permalink.

One Response to Lighttpd and the wonders of strace

  1. andrew says:

    Right said, John. strace saved so many of my days too. Tools like that really make the difference and one should never forget.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>