Headers: Fix #170: sr->headers._extra_rows keeps invalid reference

Found a specific condition in Monkey core where after send
the headers, if the field sr->headers._extra_rows is set and
then freed, its not marked as NULL. If sub sequent calls
from the Plugin API takes place and this field is validated,
it fails in a segmentation fault.

This patch set the structure field to NULL after is freed.

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
lib: do not left stage30 until all content is sent

If for some reason the send() call returns -1 because the socket
is not yet ready to receive more data (due to non-blocking mode),
the routine should not stop working and should try to send the
information over and over until is fully served.

This is not an expected behavior in a non-blocking server, but is
a temporal fix until the 'pending buffers' interface is implemented.

This problem was found due to #170.

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
configure: Conditionally set -O2

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
request: If mk_file_get_info returns -1, size is not set. Found by valgrind

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
dirlisting: Mem-optimize mk_f_list, 112 -> 88 bytes

The theoretical maximum of the strftime string is somewhere around 18 bytes.
Make it 24 to have some extra, and to be a nicely cacheable multiple.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
dirlisting: Remove unnecessary variable

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
dirlisting: Use case-insensitive sort

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
dirlisting: Fix failure in big directories

Dirlisting is not designed to support event-based working, it is one-shot.

So in a big directory, writev would return EAGAIN (EWOULDBLOCK) after
having written a partial entry.

This would then confuse the client in chunked mode (you promise X bytes but
only send less), which closes the connection, leaving you with a partial listing.

With this patch, dirlisting succeeds in a dir with 23k entries.
Without, it fails in a dir with little over 1k entries.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
dirlisting/guineo: Compact the theme

This saves about 270kb (29%) in a dir of about 3k entries, while looking the same.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>