Commit Graph

53 Commits

Author SHA1 Message Date
Glenn Strauss 33c8cf41db [multiple] rename connection_reset hook to request
rename connection_reset to handle_request_reset
2020-08-02 07:47:41 -04:00
Glenn Strauss 28f1867c11 quiet clang analyzer scan-build warnings
(expansion of buffer_string_lenth() inline function and CONST_BUF_LEN()
 macro, which always check for NULL, appears to cause the analyzer to
 believe that a pointer might be NULL in cases where it otherwise can
 not be NULL)

2020-07-08 22:51:32 -04:00
Glenn Strauss 7c7f8c467c [multiple] split con, request (very large change)
NB: r->tmp_buf == srv->tmp_buf (pointer is copied for quicker access)

NB: request read and write chunkqueues currently point to connection
    chunkqueues; per-request and per-connection chunkqueues are
    not distinct from one another
      con->read_queue  == r->read_queue
      con->write_queue == r->write_queue

NB: in the future, a separate connection config may be needed for
    connection-level module hooks.  Similarly, might need to have
    per-request chunkqueues separate from per-connection chunkqueues.
    Should probably also have a request_reset() which is distinct from
2020-07-08 19:54:29 -04:00
Glenn Strauss 31d9495330 [core] store subrequest_handler instead of mode
store pointer to module in handler_module instead of con->mode id
2020-07-08 19:54:29 -04:00
Glenn Strauss eea7cd3c2f [core] store (plugin *) in p->data
2020-07-08 19:54:29 -04:00
Glenn Strauss ca97505a72 [multiple] store srv->tmp_buf in tb var
rather than using srv->tmp_buf directly in code modifying temp buf (tb)
2020-07-08 19:54:28 -04:00
Glenn Strauss f24e6d696a [multiple] plugin_stats array
use global rather than passing around (server *) just for that

li_itostrn() and li_utostrn() return string length
(rather than requiring subsequent strlen() to find length)
2020-07-08 19:54:28 -04:00
Glenn Strauss 50bdb55de8 [multiple] connection hooks no longer get (srv *)
(explicit (server *) not passed; available in con->srv)
2020-07-08 19:54:28 -04:00
Glenn Strauss 010c28949c [multiple] prefer (connection *) to (srv *)
convert all log_error_write() to log_error() and pass (log_error_st *)

use con->errh in preference to srv->errh (even though currently same)

avoid passing (server *) when previously used only for logging (errh)
2020-07-08 19:54:28 -04:00
Glenn Strauss ba88ff0e93 [core] run all trigger and sighup handlers
(do not bail if a handler returns something other than HANDLER_GO_ON)

(preserve fn signature for simplicity and compat with plugin_fn_data)
2020-07-08 18:08:51 -04:00
Glenn Strauss b73949e03f [multiple] plugin.c handles common FREE_FUNC code
(simpler for modules; less boilerplate to cut-n-paste)
2020-07-08 18:08:51 -04:00
Glenn Strauss b2b41e36e3 [core] struct plugin_data_base 2020-05-23 17:59:29 -04:00
Glenn Strauss c022269547 [core] srv->plugin_slots as compact list 2020-05-23 17:59:29 -04:00
Glenn Strauss e2de4e581e [core] const char *name in struct plugin
put void *data (always used) as first member of struct plugin

add int nconfig member to PLUGIN_DATA

calloc() inits p->data to NULL
2020-05-23 17:59:29 -04:00
Glenn Strauss 601c572c39 [core] inline buffer as part of data_string value
(instead of value being (buffer *))
2020-02-24 11:15:32 -05:00
Glenn Strauss 62e97967ca [core] prefer uint32_t to size_t in base.h
even 2 billion is way larger than even extreme operating values
expected for the members in base.h

include some structs directly in struct server, rather than by ptr
2020-02-24 11:15:32 -05:00
Glenn Strauss f1e9bcb08a [core] new worker_init hook to follow parent fork 2019-04-20 02:10:28 -04:00
Glenn Strauss 13f957d283 [core] simpler loops to run plugin hooks 2019-02-13 02:07:53 -05:00
Glenn Strauss c38eddfc29 [core] skip plugins_call_cleanup if not init'ed 2019-02-13 00:42:23 -05:00
Glenn Strauss d28bac32fe [multiple] reduce code dup in list resizing
reduce code duplication in list resizing
realloc() of NULL ptr has behavior similar to malloc()

Note that if initial size == 0, then code used to adjust size
must be += x to ensure the size is non-zero for reallocation.
(Multiplying 0 * x, e.g. power-2 resizing, will result in 0.)
2019-02-12 22:36:04 -05:00
Glenn Strauss f69bd9cdb8 [core] perf: simple, quick buffer_clear()
quickly clear buffer instead of buffer_string_set_length(b, 0) or
buffer_reset(b).  Avoids free() of large buffers about to be reused,
or buffers that are module-scoped, persistent, and reused.

(buffer_reset() should still be used with buffers in connection *con
 when the data in the buffers is supplied by external, untrusted source)
2018-11-23 00:37:38 -05:00
Glenn Strauss 04d76e7afd [core] some header cleanup
provide standard types in first.h instead of base.h
provide lighttpd types in base_decls.h instead of settings.h
reduce headers exposed by headers for core data structures
  do not expose <pcre.h> or <stdlib.h> in headers
move stat_cache_entry to stat_cache.h
reduce use of "server.h" and "base.h" in headers
2018-04-08 22:22:23 -04:00
Glenn Strauss 9030cfaecf [core] SIGCHLD handle_waitpid hook for modules
centralize most waitpid() handling in core server, with hooks for
modules to be informed of pid and status when a process exits.

This enables faster discovery (and restart) of exited processes,
and also allows for lighttpd to manage backend processes in the
parent (master) process when server.max-worker > 0.
2017-09-10 16:24:34 -04:00
Glenn Strauss 8af9e71ccc [core] allow earlier plugin init for SSL/TLS
If lighttpd is started privileged, then SSL/TLS modules need to be
initialized prior to chroot (optional) and prior to dropping privileges
in order to be able to read sensitive files such as private certificates

(thx m4t)
2017-05-21 21:31:05 -04:00
Glenn Strauss a53f662a30 [core] remove some unused header includes
remove exposure of stdio.h in buffer.h for print_backtrace(), now static
2017-03-28 02:17:33 -04:00
Glenn Strauss cb7ed13621 [core] new plugin hooks to help isolate SSL
handle_request_env        (called on demand by handlers to populate env)
handle_connection_shut_wr (was handle_connection_close)
handle_connection_close   (now occurs at socket close())
2017-01-14 01:06:16 -05:00
Glenn Strauss cb1a3c6299 backport mod_deflate to lighttpd 1.4 (fixes #1824, fixes #2753)
lots of fixes and improvements

limitations: see comments at top of mod_deflate.c

missing functionality: encode streaming response
  (module currently requires response be collected before being sent)

potential functionality: addition of compressed file cache would
  allow mod_deflate to fully supplant mod_compress in lighttpd 1.4.x

  "Adding mod_deflate to 1.4.xx"
  "mod_deflate backport compile error if ENABLE_MMAP not defined"

github: closes #67
2016-09-22 13:36:04 -04:00
Glenn Strauss eefb94bb39 fix error handling for portability (NetBSD)
thx joerg
2016-06-29 08:20:12 -04:00
Glenn Strauss 7f942ce09a remove handle_joblist hook
remove handle_joblist hook and remove the hooks defined in
mod_fastcgi and mod_scgi.  The calls made to fdevent management
are redundant.  If the calls were actually needed, then
mod_proxy would have needed a handle_joblist handler, too.
2016-04-18 06:19:03 -04:00
Glenn Strauss 8abd06a7ff consistent inclusion of config.h at top of files (fixes #2073)
From: Glenn Strauss <>

git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2016-03-19 15:14:35 +00:00
Stefan Bühler 02594f107a [plugins] don't include dlfcn.h if not needed (fixes #2548)
From: Stefan Bühler <>

git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2016-02-28 12:12:05 +00:00
Stefan Bühler 566cf8decb add force_assert for more allocation results
From: Stefan Bühler <>

git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2016-01-30 13:59:07 +00:00
Stefan Bühler b66fa2cb68 [plugins] when modules are linked statically still only load the modules given in the config
- previously it would load all modules in some fixed order
- also warn when mod_magnet or mod_trigger_b4_dl are compiled without
  needed dependencies
- mod_trigger_b4_dl fails in plugin_init when dependencies are missing

From: Stefan Bühler <>

git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2015-08-29 09:28:01 +00:00
Stefan Bühler 6afad87d2e fix buffer, chunk and http_chunk API
* remove unused structs and functions
    (buffer_array, read_buffer)
  * change return type from int to void for many functions,
    as the return value (indicating error/success) was never checked,
    and the function would only fail on programming errors and not on
    invalid input; changed functions to use force_assert instead of
    returning an error.
  * all "len" parameters now are the real size of the memory to be read.
    the length of strings is given always without the terminating 0.
  * the "buffer" struct still counts the terminating 0 in ->used,
    provide buffer_string_length() to get the length of a string in a
    unset config "strings" have used == 0, which is used in some places
    to distinguish unset values from "" (empty string) values.
  * most buffer usages should now use it as string container.
  * optimise some buffer copying by "moving" data to other buffers
  * use (u)intmax_t for generic int-to-string functions
  * remove unused enum values: UNUSED_CHUNK, ENCODING_UNSET
  * converted BUFFER_APPEND_SLASH to inline function (no macro feature
  * refactor: create chunkqueue_steal: moving (partial) chunks into another
  * http_chunk: added separate function to terminate chunked body instead of
    magic handling in http_chunk_append_mem().
    http_chunk_append_* now handle empty chunks, and never terminate the
    chunked body.

From: Stefan Bühler <>

git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2015-02-08 12:37:10 +00:00
Stefan Bühler 6e724c0573 Only print a warning for now if you try to load a module twice
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2010-08-11 21:10:15 +00:00
Stefan Bühler 614bb7538d Add check to stop loading plugins twice
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2010-08-05 22:55:18 +00:00
Stefan Bühler 22e8b456a9 Fix header inclusion order, always include "config.h" before any system header
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2009-10-11 14:31:42 +00:00
Stefan Bühler 52861d77df Replace buffer_{append,copy}_string with the _len variant where possible (#1732, thx crypt)

git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2008-07-30 19:38:32 +00:00
Stefan Bühler 5a9992b106 Fixed many warnings (compare (un)signed, unused vars, and initialize with zero)
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2008-04-29 11:03:26 +00:00
Marcus Rückert 53ab644ead - merged -r1090:1091 => add --with-webdav-locks
- open modules with 'RTLD_NOW|RTLD_GLOBAL'
  this fixes the problems with luafilesystems and missing symbols

git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2006-10-09 13:50:29 +00:00
Marcus Rückert 8cd1471cb3 - white space cleanup part 2 this time 1.4 ;)
i hope it helps with merging stuff back to 1.5

git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2006-10-04 13:26:23 +00:00
Jan Kneschke a5e280fd4b added static building of lighttpd
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2006-01-04 23:31:32 +00:00
Jan Kneschke 4c91a14c4d added a static target to scons which compiles lighttpd staticly (incl. mod_access as test)
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2006-01-03 12:53:12 +00:00
Jan Kneschke 0ed6b72923 darix asked for this version of the type cast
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2005-11-11 12:53:45 +00:00
Jan Kneschke b4d9d061c8 either remove include config.h or covered it in HAVE_CONFIG_H
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2005-09-24 12:06:04 +00:00
Xuefer b37a95855f fix bug triggered by [680]. reset "used"
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2005-09-03 03:08:13 +00:00
Jan Kneschke 15dc40cd36 removed the 'make distcheck' hack as we have -m now ([640], [630])
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2005-08-29 14:11:47 +00:00
Jan Kneschke c7ec5012e0 added -m to set the location of the modules
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2005-08-27 14:43:45 +00:00
Jan Kneschke f926c361f9 ..physical_path is gone and has ben replaced by subrequest_start
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2005-08-15 09:46:23 +00:00
Jan Kneschke 75c3a8393a added include_shell option to configfiles (merged the rest of the trunk changesets)
git-svn-id: svn:// 152afb58-edef-0310-8abb-c4023f1b3aa9
2005-08-09 06:42:33 +00:00