Commit Graph

112 Commits

Author SHA1 Message Date
Glenn Strauss 455dc03778 [core] prefer getxattr() instead of get_attr()
(when lighttpd is built ./configure --with-attr)
2020-07-08 22:51:31 -04:00
Glenn Strauss abe61d0445 [core] return EINVAL if stat_cache_get_entry w/o /
return EINVAL if stat_cache_get_entry() called on path w/o leading '/'
2020-07-08 19:54:30 -04:00
Glenn Strauss c752d4696e [multiple] correct misspellings in comments
  "Script for fixing spelling errors with codespell"
2020-07-08 19:54:30 -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 66bdd96d36 [core] isolate stat_cache subsystem
stat_cache.c no longer directly uses struct server *srv
2020-07-08 19:54:29 -04:00
Glenn Strauss 05cc88ddb4 [multiple] omit passing srv to fdevent_handler 2020-07-08 19:54:29 -04:00
Glenn Strauss 68d8d4c532 [multiple] stat_cache singleton 2020-07-08 19:54:28 -04:00
Glenn Strauss c8cd7cf49b [multiple] extern log_epoch_secs
replace srv->cur_ts
2020-07-08 19:54:28 -04:00
Glenn Strauss 409bba80b1 [multiple] reduce direct use of srv->cur_ts 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 0fcd51438d [core] create http chunk header on the stack
streamline code in http_chunk.c
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 2ec70f234a [core] stat_cache_path_contains_symlink use errh
use log_error() with con->errh
2020-07-08 18:08:52 -04:00
Glenn Strauss ed62e354ff [core] use config_plugin_values_init() 2020-07-08 18:08:51 -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 ad9b7e009b [core] inline buffer as part of DATA_UNSET key
(instead of key being (buffer *))
2020-02-24 11:15:32 -05:00
Glenn Strauss 83535bbef3 [core] differentiate array_get_* for ro and rw
array_get_element_klen() is now intended for read-only access
array_get_data_unset() is used by config processing for r/w access
array_get_buf_ptr() is used for r/w access to ds->value (string buffer)
2020-02-24 11:15:32 -05:00
Glenn Strauss 84fb334476 [core] disable stat_cache FAM if FAM conn closed
  "Lighttpd Stopping suddenly, no apparent reason on the logfile"
2019-09-07 12:23:20 -04:00
Glenn Strauss e20b5318d5 [core] use buffer_eq_icase_ssn func
specialized buffer_eq_icase_ssn func replace strncasecmp()
in cases where string lengths are known to be at least as
large as the len being compared case-insensitively
2019-06-06 02:48:43 -04:00
Glenn Strauss 49ed72cef4 [core] mark some more funcs w/ __attribute_pure__ 2019-06-06 02:48:43 -04:00
Glenn Strauss 146ea6bad0 [mod_webdav] invalidate parent dir in stat_cache
invalidate directory in stat_cache when a new file or dir is created
within that directory
2019-05-09 21:09:52 -04:00
Glenn Strauss 9bb01a49df [core] check if splay_tree NULL before invalidate 2019-05-08 00:54:52 -04:00
Glenn Strauss d836d20317 [stat_cache] fix compilation error for cmake 2019-05-04 18:16:01 -04:00
Glenn Strauss 84db583e3e [stat_cache] FAM: whitespace-only change
whitespace-only changes in stat_cache_handle_fdevent_in()
2019-05-04 16:36:10 -04:00
Glenn Strauss 60a4b5f118 [stat_cache] FAM: separate routine for FDEVENT_IN 2019-05-04 16:36:10 -04:00
Glenn Strauss 8cc189f4c6 [stat_cache] FAM: improve monitoring, cache 16 sec
improve FAM monitoring to use reference counting in internal cache

revalidate entries upon use after 16 sec to recover from missed events

(see comments in commit for more details about limitations)
2019-05-04 16:36:10 -04:00
Glenn Strauss f56800e86a [stat_cache] no longer stat() and open() for stat
do not open file in stat_cache_get_entry()
no longer stat() followed by open() and close() just for stat()

callers should open() file to validate readability (and then reuse fd)
2019-05-04 13:48:22 -04:00
Glenn Strauss 57470365a2 [stat_cache] interfaces to invalidate entries 2019-05-04 13:48:22 -04:00
Glenn Strauss f89f9191f4 [stat_cache] FAM: funcs to invalidate entries 2019-05-04 13:48:22 -04:00
Glenn Strauss c7eaa502ec [stat_cache] FAM: ignore event with no valid match 2019-05-04 13:48:22 -04:00
Glenn Strauss 18faa0910c [stat_cache] FAM: check hash collision before add
skip monitoring new entry if there is a hash collision in stat_cache
data structure associated with FAM
2019-05-04 13:48:22 -04:00
Glenn Strauss 8772e85cea [stat_cache] FAM: ignore follow-symlink config
no distinction needs to be made whether or not server.follow-symlink set
2019-05-04 13:48:22 -04:00
Glenn Strauss 1971da13db [stat_cache] FAM: improve handling modified file 2019-05-04 13:48:22 -04:00
Glenn Strauss 38ce790657 [stat_cache] FAM: use entry hash index as userdata
Upon receipt of FAM event, validate that entry exists in splaytree
instead of blindly accessing memory through the pointer returned in
userdata by FAM
2019-05-04 13:48:22 -04:00
Glenn Strauss a3d171526a [stat_cache] FAM: check FAMNextEvent() return code 2019-05-04 13:48:22 -04:00
Glenn Strauss cc49703372 [stat_cache] FAM: reduce string copying 2019-05-04 13:48:22 -04:00
Glenn Strauss a50b72c356 [stat_cache] remove splaytree ins/del debug code
remove debug code around for splaytree_insert() and splaytree_delete()
in stat_cache.c
2019-05-04 13:48:22 -04:00
Glenn Strauss 47d006ae47 [stat_cache] pass age param for stat cache cleanup 2019-05-04 13:48:22 -04:00
Glenn Strauss baa5f04335 [stat_cache] store entries without trailing slash
(no more duplication of dir entries with and without trailing slash)
2019-05-04 13:48:22 -04:00
Glenn Strauss 020a83c265 [stat_cache] separate symlink pol from data struct
separate symlink polily from internal data structures
no more dup entires in splaytree for allowing/disallowing symlinks

hash name to provided len
2019-05-04 13:48:11 -04:00
Glenn Strauss 73bfee6308 [stat_cache] separate func for symlink policy chk
Note: historical ToC-ToU race condition still exists in implementation
server.follow-symlink = "disable" is not recommended (default: "enable")
2019-04-29 18:11:15 -04:00
Glenn Strauss a15f40a569 [core] replace open() with fdevent_open_cloexec()
fdevent_open_cloexec() opens files O_BINARY for consistency,
and with O_NONBLOCK, so that the server will not block if the
target file to open is a fifo.
2019-04-20 02:10:28 -04:00
Glenn Strauss 37bd124ae4 [core] pass conf.follow_symlink in more places 2019-03-10 23:22:58 -04:00
Glenn Strauss 9113011d5b [core] pass (fdnode *) for registered fdevent fd
inline fdevent_fdnode_interest()
avoid array lookup for (fdnode *) for various ops
2019-03-07 00:32:17 -05:00
Glenn Strauss 800e9b7349 [core] remove fde_ndx member outside fdevents
(isolated to fdevent framework internals)
2019-03-07 00:32:17 -05:00
Glenn Strauss 7d4ecd01e8 [core] perf: incremental hash of pathname w/o copy 2018-12-26 00:31:19 -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 e0dbff4750 [core] slightly simpler flag append to string 2018-11-12 21:56:05 -05:00
Glenn Strauss bbf01a3a6c [core] reset var if FAMMonitorDirectory() fails
do not read fam_dir->version if FAMMonitorDirectory() fails
2018-08-12 14:43:22 -04: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