summaryrefslogtreecommitdiff
path: root/src/plugin.c
Commit message (Collapse)AuthorAgeFilesLines
* [core] _WIN32 log_perror() with GetLastError()Glenn Strauss2023-05-031-17/+4
|
* [multiple] clang -Wstrict-prototypes for C2xGlenn Strauss2023-01-191-24/+48
| | | | | | | | | | | adjustments to compile warnings-free with recent clang changes that warn about potential behavior change for non-prototypes, including generic function pointers e.g. int(*)() x-ref: https://discourse.llvm.org/t/rfc-enabling-wstrict-prototypes-by-default-in-c/60521 https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm
* [multiple] employ ck_calloc, ck_malloc shared codeGlenn Strauss2022-12-101-8/+2
| | | | | employ ck_calloc(), ck_malloc() shared code to slightly reduce code size (centralize the ck_assert() to check that memory allocation succeeded)
* [multiple] employ ck_realloc_u32() shared codeGlenn Strauss2022-12-101-15/+8
| | | | employ ck_realloc_u32() shared code to slightly reduce code size
* [core] check for built-in plugins before dlopenGlenn Strauss2022-12-051-0/+13
|
* [core] _WIN32 impl of plugins_load()Glenn Strauss2022-12-051-68/+45
|
* [core] isolate plugins_*() funcs to main serverGlenn Strauss2022-02-191-2/+1
| | | | | (future: might rename plugin.c -> plugins.c since the functions contained within are all plugins_*())
* [core] (const char *) for srvconf.modules_dirGlenn Strauss2022-01-071-2/+2
| | | | no need to be allocated (buffer *)
* [core] run plugin cleanup hooks in reverseGlenn Strauss2021-11-051-7/+17
| | | | | run plugin cleanup hooks in reverse to balance ctor/dtor-like plugin behaviors
* [core] mark attr malloc, returns nonnullGlenn Strauss2021-09-171-0/+2
| | | | mark some core code with attributes malloc, returns nonnull
* [build] propagate HAVE_DLFCN_H in buildsGlenn Strauss2021-09-081-2/+4
|
* [core] make missing mod_deflate not a fatal errorGlenn Strauss2021-09-041-0/+12
| | | | | | | | | | | | | | | | mod_compress was removed in lighttpd 1.4.56, subsumed by mod_deflate. distros may package mod_deflate separately from the lighttpd package. However, existing configurations may reference mod_compress. lighttpd maps the reference from mod_compress to mod_deflate, but after a system is upgraded to lighttpd 1.4.56 or later, mod_compress may have been removed, and mod_deflate -- which might be a separate package -- might not be installed. lighttpd will still issue error trace about the missing mod_deflate modules, as well as about the unrecognized configuration directives (compress.* or deflate.*), but this will no longer be a fatal error.
* [multiple] reduce redundant NULL buffer checksGlenn Strauss2021-08-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a large set of code changes and results in removal of hundreds, perhaps thousands, of CPU instructions, a portion of which are on hot code paths. Most (buffer *) used by lighttpd are not NULL, especially since buffers were inlined into numerous larger structs such as request_st and chunk. In the small number of instances where that is not the case, a NULL check is often performed earlier in a function where that buffer is later used with a buffer_* func. In the handful of cases that remained, a NULL check was added, e.g. with r->http_host and r->conf.server_tag. - check for empty strings at config time and set value to NULL if blank string will be ignored at runtime; at runtime, simple pointer check for NULL can be used to check for a value that has been set and is not blank ("") - use buffer_is_blank() instead of buffer_string_is_empty(), and use buffer_is_unset() instead of buffer_is_empty(), where buffer is known not to be NULL so that NULL check can be skipped - use buffer_clen() instead of buffer_string_length() when buffer is known not to be NULL (to avoid NULL check at runtime) - use buffer_truncate() instead of buffer_string_set_length() to truncate string, and use buffer_extend() to extend Examples where buffer known not to be NULL: - cpv->v.b from config_plugin_values_init is not NULL if T_CONFIG_BOOL (though we might set it to NULL if buffer_is_blank(cpv->v.b)) - address of buffer is arg (&foo) (compiler optimizer detects this in most, but not all, cases) - buffer is checked for NULL earlier in func - buffer is accessed in same scope without a NULL check (e.g. b->ptr) internal behavior change: callers must not pass a NULL buffer to some funcs. - buffer_init_buffer() requires non-null args - buffer_copy_buffer() requires non-null args - buffer_append_string_buffer() requires non-null args - buffer_string_space() requires non-null arg
* [core] reorder hook enum for better mem localityGlenn Strauss2021-05-121-15/+15
|
* [core] merge uri_raw and uri_clean hooksGlenn Strauss2021-05-121-8/+12
| | | | | | hooks are run consecutively in http_response_prepare() merge uri_raw before uri_clean to preserve existing ordering
* [multiple] buffer_copy_path_len2() aggregateGlenn Strauss2021-04-021-2/+2
|
* [multiple] use buffer_append_* aggregatesGlenn Strauss2021-04-021-6/+4
| | | | reduces the number of round-trips into some frequently-called routines
* [core] filter out duplicate modulesGlenn Strauss2020-11-111-28/+6
| | | | filter out modules duplicated in server.modules list
* [multiple] rename connection_reset hook to requestGlenn Strauss2020-08-021-3/+3
| | | | rename connection_reset to handle_request_reset
* quiet clang analyzer scan-build warningsGlenn Strauss2020-07-081-0/+1
| | | | | | | | | | (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) x-ref: http://clang-analyzer.llvm.org/faq.html
* [multiple] split con, request (very large change)Glenn Strauss2020-07-081-10/+35
| | | | | | | | | | | | | | | | 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 connection_reset().
* [core] store subrequest_handler instead of modeGlenn Strauss2020-07-081-6/+1
| | | | store pointer to module in handler_module instead of con->mode id
* [core] store (plugin *) in p->dataGlenn Strauss2020-07-081-1/+1
| | | | (self-referential)
* [multiple] store srv->tmp_buf in tb varGlenn Strauss2020-07-081-16/+17
| | | | rather than using srv->tmp_buf directly in code modifying temp buf (tb)
* [multiple] plugin_stats arrayGlenn Strauss2020-07-081-0/+4
| | | | | | | 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)
* [multiple] connection hooks no longer get (srv *)Glenn Strauss2020-07-081-20/+21
| | | | (explicit (server *) not passed; available in con->srv)
* [multiple] prefer (connection *) to (srv *)Glenn Strauss2020-07-081-27/+28
| | | | | | | | 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)
* [core] run all trigger and sighup handlersGlenn Strauss2020-07-081-9/+22
| | | | | | (do not bail if a handler returns something other than HANDLER_GO_ON) (preserve fn signature for simplicity and compat with plugin_fn_data)
* [multiple] plugin.c handles common FREE_FUNC codeGlenn Strauss2020-07-081-7/+18
| | | | (simpler for modules; less boilerplate to cut-n-paste)
* [core] struct plugin_data_baseGlenn Strauss2020-05-231-6/+2
|
* [core] srv->plugin_slots as compact listGlenn Strauss2020-05-231-140/+183
|
* [core] const char *name in struct pluginGlenn Strauss2020-05-231-24/+16
| | | | | | | | put void *data (always used) as first member of struct plugin add int nconfig member to PLUGIN_DATA calloc() inits p->data to NULL
* [core] inline buffer as part of data_string valueGlenn Strauss2020-02-241-8/+8
| | | | (instead of value being (buffer *))
* [core] prefer uint32_t to size_t in base.hGlenn Strauss2020-02-241-31/+21
| | | | | | | 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
* [core] new worker_init hook to follow parent forkGlenn Strauss2019-04-201-0/+3
|
* [core] simpler loops to run plugin hooksGlenn Strauss2019-02-131-42/+14
|
* [core] skip plugins_call_cleanup if not init'edGlenn Strauss2019-02-131-2/+1
|
* [multiple] reduce code dup in list resizingGlenn Strauss2019-02-121-6/+1
| | | | | | | | | 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.)
* [core] perf: simple, quick buffer_clear()Glenn Strauss2018-11-231-1/+0
| | | | | | | | | 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)
* [core] some header cleanupGlenn Strauss2018-04-081-0/+1
| | | | | | | | | 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
* [core] SIGCHLD handle_waitpid hook for modulesGlenn Strauss2017-09-101-1/+14
| | | | | | | | | 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.
* [core] allow earlier plugin init for SSL/TLSGlenn Strauss2017-05-211-0/+4
| | | | | | | | 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)
* [core] remove some unused header includesGlenn Strauss2017-03-281-2/+0
| | | | remove exposure of stdio.h in buffer.h for print_backtrace(), now static
* [core] new plugin hooks to help isolate SSLGlenn Strauss2017-01-141-0/+9
| | | | | | | handle_request_env (called on demand by handlers to populate env) handle_connection_accept handle_connection_shut_wr (was handle_connection_close) handle_connection_close (now occurs at socket close())
* backport mod_deflate to lighttpd 1.4 (fixes #1824, fixes #2753)Glenn Strauss2016-09-221-0/+3
| | | | | | | | | | | | | | | | | | | | 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 x-ref: "Adding mod_deflate to 1.4.xx" https://redmine.lighttpd.net/issues/1824 "mod_deflate backport compile error if ENABLE_MMAP not defined" https://redmine.lighttpd.net/issues/2753 github: closes #67
* fix error handling for portability (NetBSD)Glenn Strauss2016-06-291-3/+7
| | | | thx joerg
* remove handle_joblist hookGlenn Strauss2016-04-181-3/+0
| | | | | | | 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.
* consistent inclusion of config.h at top of files (fixes #2073)Glenn Strauss2016-03-191-0/+2
| | | | | | From: Glenn Strauss <gstrauss@gluelogic.com> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3113 152afb58-edef-0310-8abb-c4023f1b3aa9
* [plugins] don't include dlfcn.h if not needed (fixes #2548)Stefan Bühler2016-02-281-1/+1
| | | | | | From: Stefan Bühler <stbuehler@web.de> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3087 152afb58-edef-0310-8abb-c4023f1b3aa9
* add force_assert for more allocation resultsStefan Bühler2016-01-301-0/+5
| | | | | | From: Stefan Bühler <stbuehler@web.de> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3072 152afb58-edef-0310-8abb-c4023f1b3aa9