Commit Graph

137 Commits

Author SHA1 Message Date
Emil Mikulic 008f6f5d4e We can handle a request from accept() to close() without having to go through a
single iteration of the select() loop.

This commit re-orders the way state == DONE is handled so that keep-alive
connections can go straight back into recv_request without visiting select().
Unfortunately, this doesn't fix the keep-alive performance.
2013-04-28 19:56:51 +10:00
Emil Mikulic 5ab0496a9b Call tzset() during initialization.
truss output suggests this isn't enough to load posixrules (UTC leap
seconds data) which happens only after the first request.  =(
2013-04-28 19:56:51 +10:00
Emil Mikulic 3ed2762831 Another state transition optimization:
Go from send_header straight to send_reply.
2013-04-28 19:56:51 +10:00
Emil Mikulic 844dcc6b9d Another state transition optimization due to NBIO:
Go from recv_request to send_header without visiting select()
2013-04-28 19:56:51 +10:00
Emil Mikulic ba91f1cdb3 After accepting a connection, attempt a read straight away instead of
going through an iteration of the select() loop.
2013-04-28 19:56:50 +10:00
Emil Mikulic f3ce5d1eb9 Don't just SETFL O_NONBLOCK, first GETFL. 2013-04-28 19:56:50 +10:00
Emil Mikulic b86889f027 %Z gives UTC. Apache uses GMT instead, and wget complains about an
invalid header when it sees UTC, so switch.
2013-04-28 19:56:50 +10:00
Emil Mikulic 625dc5e473 - In decode_url()
- Use '\0' instead of 0 to hint that it's in a character context.
  - Don't realloc - this wastes more time than it saves memory.
- Don't forget to free decoded url if it's found to be unsafe!
2013-04-28 19:56:50 +10:00
Emil Mikulic ccea5116b5 Restore a check I shouldn't have removed.
We now pass all our tests again.
2013-04-28 19:56:50 +10:00
Emil Mikulic 4b90b875c6 Adapt make_safe_uri() to work in-place.
We're currently failing some tests.
2013-04-28 19:56:50 +10:00
Emil Mikulic ab1204f700 Implement (optional, compile-time) shrinking of send buffer for torture tests. 2013-04-28 19:56:50 +10:00
Emil Mikulic 94d3403c2e Remove the pidfile_path assertion entirely.
Its name changed but I didn't notice because I didn't do any DEBUG builds.
2013-04-28 19:56:50 +10:00
Emil Mikulic b307616f3d Fix some GCC warnings.
Pointed out by: Brian Lewis <bsl04@uark.edu>
Pointed out on: Wed, 27 Sep 2006 15:46:26 -0500
2013-04-28 19:56:50 +10:00
Emil Mikulic 4a405e36b1 Walking through the code - correct some comment typos. 2013-04-28 19:56:50 +10:00
Emil Mikulic c2ff18a157 [ darkhttpd-1.4 release ]
Fix a segfault in log_connection() that happens when the incoming
request is too long.

(Forgot to bump the version)
2013-04-28 19:56:50 +10:00
Emil Mikulic c9947250f2 [ darkhttpd-1.3 release ]
Also remove an unused variable.
2013-04-28 19:56:50 +10:00
Emil Mikulic 953a93d2fc Import pidfile helpers and cut them down to just the pieces we need. 2013-04-28 19:56:50 +10:00
Emil Mikulic c3166bf1d0 Implement warn() 2013-04-28 19:55:48 +10:00
Emil Mikulic 2d4fbd38cd Implement daemonize. 2013-04-28 19:55:48 +10:00
Emil Mikulic cad637254a Add mimetypes, sort them, remove lots of whitespace from the middle. 2013-04-28 19:55:48 +10:00
Emil Mikulic ff152e87ef Update copyright years. 2013-04-28 19:55:36 +10:00
Emil Mikulic 4fed6d0665 Implement --pidfile and move clean shutdown into main() 2013-04-28 19:44:12 +10:00
Emil Mikulic 42833fb312 Fix build on FreeBSD by spelling "sockin" correctly.
This has been outstanding for a long time.
2013-04-28 19:44:12 +10:00
Emil Mikulic 6c1922391f Answer requests that end in \n\n as well as the more pedantic \r\n\r\n 2013-04-28 19:44:12 +10:00
Emil Mikulic bea398d629 Add support for sendfile() on Solaris. 2013-04-28 19:44:12 +10:00
Emil Mikulic 49fb5f3fbf Fix fallback on platforms that don't have sendfile()
It was quite badly broken.
2013-04-28 19:44:12 +10:00
Emil Mikulic 2ca3cef4a3 [ darkhttpd-1.2 release ] 2013-04-28 19:44:12 +10:00
Emil Mikulic 3829ceade8 Fix (unsigned < 0) comparison. 2013-04-28 19:44:12 +10:00
Emil Mikulic 74fcaf5859 safefree -> free 2013-04-28 19:44:12 +10:00
Emil Mikulic dfe896357a Fix debugf mess. 2013-04-28 19:44:12 +10:00
Emil Mikulic b50b4f1c5a Fix signed-unsigned comparison. 2013-04-28 19:44:12 +10:00
Emil Mikulic 5cf2862f08 Manually inline acceptfilter code to remove unused arg warning on
non-FreeBSD platforms.
2013-04-28 19:44:12 +10:00
Emil Mikulic e624dbbe02 Fix err and debugf warnings. 2013-04-28 19:44:12 +10:00
Emil Mikulic 91fcb80e4a Adjust copyright and license. 2013-04-28 19:44:12 +10:00
Emil Mikulic d545127600 Track requests and bytes transferred statistics. 2013-04-28 19:44:12 +10:00
Emil Mikulic 27a35821a1 wwwroot = strdup(argv[1]) so we don't end up stripping the only existing
slash out of the commandline shown by ps(1).  And free it on shutdown.
2013-04-28 19:44:12 +10:00
Emil Mikulic 108eb4cce3 . Split usage() into many printfs() to keep GCC3 happy about ISO limits.
. Knock out the REPLY_GENERATED length assertion since ap_buf doesn't
  null-terminate strings and it's never been tripped by xasprintf()
  consumers.
. Cast rusage times when printing, and don't print too many zeroes.
2013-04-28 19:44:12 +10:00
Emil Mikulic ecb3d8adb3 Optimize generate_dir_listing():
. Split appendf() calls into a number of append() calls.
. To insert spaces, instead of sitting in a loop, use a spaces[] buffer
  and insert a chunk of it with appendl().
2013-04-28 19:44:12 +10:00
Emil Mikulic 4ce4eabdbd . Version upped to 1.1 for append buffer optimizations.
. Don't keep the apbuf strings null-terminated.
. Compile-time optimise append() if we have GCC.
2013-04-28 19:44:12 +10:00
Emil Mikulic fd4e271d57 Before exiting, getrusage() and print time spent on CPU. 2013-04-28 19:44:12 +10:00
Emil Mikulic 0f798c0d71 Merge two lines. 2013-04-28 19:44:12 +10:00
Emil Mikulic 020b4d20e2 Fix whitespace and disclaimer comment. 2013-04-28 19:44:12 +10:00
Emil Mikulic 84e59c72ac Use FALLTHROUGH instead of goto. 2013-04-28 19:44:12 +10:00
Emil Mikulic 6ab21a586e . Don't expect user to define NDEBUG. 2013-04-28 19:44:12 +10:00
Emil Mikulic 761462e4e5 . __sun__ -> __sun since Sun's CC doesn't use the former. 2013-04-28 19:44:12 +10:00
Emil Mikulic 7df4b55839 . Fix chomp()'s checking of empty strings. 2013-04-28 19:44:12 +10:00
Emil Mikulic c58880c10a . Added third BSD clause.
. Got rid of Solaris hint - it belongs in the README.
. Got rid of a tab.
2013-04-28 19:44:12 +10:00
Emil Mikulic b175db347d . Added --accf instead of compile-time NO_ACCEPTFILTER.
. Fixed const issues in dlent_cmp().
. Fixed uninitialized from/to warning.
2013-04-28 19:44:12 +10:00
Emil Mikulic 36f027c8c8 Fix two memory leaks. 2013-04-28 19:44:12 +10:00
Emil Mikulic a4be99dc3f . USE_ACCEPTFILTER -> NO_ACCEPTFILTER and document it. 2013-04-28 19:44:11 +10:00