summaryrefslogtreecommitdiff
path: root/src/log.c
Commit message (Collapse)AuthorAgeFilesLines
* [build] _WIN32 shared dll build (autotools, cmake)Glenn Strauss2023-05-031-0/+6
| | | | | | | | | | | | | | | | | | | | | There are likely better and cleaner ways to do this; patches welcome. _WIN32 symbol imports and exports MS Visual Studio (_MSC_VER) does not appear to export global data symbols even when exporting all functions. Annotating any symbols with __declspec(dllexport) in any translation unit appears to change default dll symbol implict export behavior. Currently, src/Makefile.am and CMakeLists.txt take different approaches (implib versus linking against executable which has exported symbols) x-ref: (improved solutions might possibly be constructed using these docs) https://sourceware.org/binutils/docs/ld/WIN32.html https://cmake.org/cmake/help/latest/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html https://stackoverflow.com/questions/225432/export-all-symbols-when-creating-a-dll
* [core] _WIN32 log_serror() for WSAGetLastError()Glenn Strauss2023-05-031-0/+19
|
* [core] _WIN32 log_perror() with GetLastError()Glenn Strauss2023-05-031-0/+27
|
* [multiple] __MINGW32__ missing strftime() "%F %T"Glenn Strauss2023-05-031-0/+5
| | | | mingw does not support strftime() "%F %T"
* [core] _WIN32 clock ticks and timeGlenn Strauss2023-05-031-0/+15
|
* [core] _WIN32 sys-unistd.h to wrap <unistd.h>Glenn Strauss2023-05-031-1/+1
| | | | (selective implementations; not complete)
* [multiple] _WIN32 protect code w/ HAVE_SYSLOG_HGlenn Strauss2023-05-031-0/+2
|
* [core] cache format secs for high prec errlogGlenn Strauss2023-02-141-19/+26
| | | | cache formatted secs string for high precision errorlog timestamp
* [multiple] employ ck_calloc, ck_malloc shared codeGlenn Strauss2022-12-101-2/+1
| | | | | employ ck_calloc(), ck_malloc() shared code to slightly reduce code size (centralize the ck_assert() to check that memory allocation succeeded)
* [core] log_buffer_vsprintf tweaksGlenn Strauss2022-12-101-5/+8
| | | | | - use (unsigned int) instead of (size_t) - copy only remaining fragment of string if encoding needed
* [multiple] use buffer_append_char()Glenn Strauss2022-05-111-1/+1
|
* [core] quiet compiler warningGlenn Strauss2022-04-131-0/+1
|
* [core] clear shared log buffer after writesGlenn Strauss2021-10-271-0/+2
| | | | avoid repeating error trace when all fdlog_t are periodically flushed
* [multiple] __attribute_nonnull__ now takes paramsGlenn Strauss2021-10-051-5/+5
| | | | | | | | | define __attribute_nonnull__(params) with params to match recent changes in glibc development (targetting glibc 2.35 in Feb 2022) x-ref: new __attribute_nonnull__(params) conflicts with third-party https://sourceware.org/bugzilla/show_bug.cgi?id=28425
* [core] Y2038: error log high-precision timestampsGlenn Strauss2021-10-041-1/+1
| | | | | fix struct type used for error log high-precision timestamps (difference is only for 32-bit)
* [core] option: errorlog high precision timestampsGlenn Strauss2021-09-301-68/+124
| | | | | | | | | | | | | | | | | | | server.feature-flags += ("server.errorlog-high-precision" => "enable") Note: if using syslog() for errorlog, modern syslog implementations are configured separately (by an admin) for high precision timestamps; server.feature-flags has no effect on syslog-generated timestamps restructure some of log.c into smaller internal routines keep a file-scoped global log_stderrh to write to STDERR_FILENO so that an errh handle is always available for logging errors fix missing space between timestamp and filename in errorlog output (missing space in lighttpd 1.4.58 and lighttpd 1.4.59) (fixes #3105) x-ref: "missing ( in log lines from mod_auth" https://redmine.lighttpd.net/issues/3105
* [core] shared temp buffer for log_*error*()Glenn Strauss2021-09-131-3/+12
| | | | | | use shared temp buffer for preparing error log entries (each error log entry is flushed to error log; there is no persistent data buffering for error logs)
* [multiple] de-dup file and piped loggers (fixes #3101)Glenn Strauss2021-09-131-33/+15
| | | | | | | | de-dup file and piped loggers for error logs and access logs x-ref: "RFE: de-dup file and piped loggers" https://redmine.lighttpd.net/issues/3101
* [core] log_error_multiline()Glenn Strauss2021-09-081-13/+16
| | | | | | | | | rename log_error_multiline_buffer() to log_error_multiline() and take (char *)ptr and (size_t)len instead of (buffer *)b When debug printing request and response headers, print each header on separate line for readability and omit '\r' if "\r\n" ends line
* [core] change con joblist to singly-linked-listGlenn Strauss2021-09-081-0/+3
| | | | | | | | | | | avoids separate memory allocation for list of pointers adds ability to check if con is already in joblist, so do not re-add con if already in joblist since con is checked if in joblist before being added to joblist, there is no longer need for two lists and jobs can be processed before poll() for to process new events
* [core] log_clock_gettime->clock_gettime for 64-bitGlenn Strauss2021-09-041-0/+5
| | | | | map log_clock_gettime() directly to clock_gettime() for 64-bit time_t (on systems with clock_gettime())
* [core] use CLOCK_MONOTONIC_COARSE where availableGlenn Strauss2021-09-041-19/+7
| | | | | | | | | | server.c uses monotonic clock to detect change in second, so CLOCK_MONOTONIC_COARSE clock resolution (often ~1ms) is more than sufficient. (Obtaining CLOCK_MONOTONIC_COARSE can be faster than CLOCK_MONOTONIC.) reference: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_for_real_time/7/html/reference_guide/sect-posix_clocks
* [multiple] Y2038 32-bit signed time_t mitigationsGlenn Strauss2021-09-041-23/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most OS platforms have already provided solutions to Y2038 32-bit signed time_t 5 - 10 years ago (or more!) Notable exceptions are Linux i686 and FreeBSD i386. Since 32-bit systems tend to be embedded systems, and since many distros take years to pick up new software, this commit aims to provide Y2038 mitigations for lighttpd running on 32-bit systems with Y2038-unsafe 32-bit signed time_t * Y2038: lighttpd 1.4.60 and later report Y2038 safety $ lighttpd -V + Y2038 support # Y2038-SAFE $ lighttpd -V - Y2038 support (unsafe 32-bit signed time_t) # Y2038-UNSAFE * Y2038: general platform info * Y2038-SAFE: lighttpd 64-bit builds on platforms using 64-bit time_t - all major 64-bit platforms (known to this author) use 64-bit time_t * Y2038-SAFE: lighttpd 32-bit builds on platforms using 64-bit time_t - Linux x32 ABI (different from i686) - FreeBSD all 32-bit and 64-bit architectures *except* 32-bit i386 - NetBSD 6.0 (released Oct 2012) all 32-bit and 64-bit architectures - OpenBSD 5.5 (released May 2014) all 32-bit and 64-bit architectures - Microsoft Windows XP and Visual Studio 2005 (? unsure ?) Another reference suggests Visual Studio 2015 defaults to 64-bit time_t - MacOS 10.15 Catalina (released 2019) drops support for 32-bit apps * Y2038-SAFE: lighttpd 32-bit builds on platforms using 32-bit unsigned time_t - e.g. OpenVMS (unknown if lighttpd builds on this platform) * Y2038-UNSAFE: lighttpd 32-bit builds on platforms using 32-bit signed time_t - Linux 32-bit (including i686) - glibc 32-bit library support not yet available for 64-bit time_t - https://sourceware.org/glibc/wiki/Y2038ProofnessDesign - Linux kernel 5.6 on 32-bit platforms does support 64-bit time_t https://itsubuntu.com/linux-kernel-5-6-to-fix-the-year-2038-issue-unix-y2k/ - https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html "Note: at this point, 64-bit time support in dual-time configurations is work-in-progress, so for these configurations, the public API only makes the 32-bit time support available. In a later change, the public API will allow user code to choose the time size for a given compilation unit." - compiling with -D_TIME_BITS=64 currently has no effect - glibc recent (Jul 2021) mailing list discussion - https://public-inbox.org/bug-gnulib/878s2ozq70.fsf@oldenburg.str.redhat.com/T/ - FreeBSD i386 - DragonFlyBSD 32-bit * Y2038 mitigations attempted on Y2038-UNSAFE platforms (32-bit signed time_t) * lighttpd prefers system monotonic clock instead of realtime clock in places where realtime clock is not required * lighttpd treats negative time_t values as after 19 Jan 2038 03:14:07 GMT * (lighttpd presumes that lighttpd will not encounter dates before 1970 during normal operation.) * lighttpd casts struct stat st.st_mtime (and st.st_*time) through uint64_t to convert negative timestamps for comparisions with 64-bit timestamps (treating negative timestamp values as after 19 Jan 2038 03:14:07 GMT) * lighttpd provides unix_time64_t (int64_t) and * lighttpd provides struct unix_timespec64 (unix_timespec64_t) (struct timespec equivalent using unix_time64_t tv_sec member) * lighttpd provides gmtime64_r() and localtime64_r() wrappers for platforms 32-bit platforms using 32-bit time_t and lighttpd temporarily shifts the year in order to use gmtime_r() and localtime_r() (or gmtime() and localtime()) from standard libraries, before readjusting year and passing struct tm to formatting functions such as strftime() * lighttpd provides TIME64_CAST() macro to cast signed 32-bit time_t to unsigned 32-bit and then to unix_time64_t * Note: while lighttpd tries handle times past 19 Jan 2038 03:14:07 GMT on 32-bit platforms using 32-bit signed time_t, underlying libraries and underlying filesystems might not behave properly after 32-bit signed time_t overflows (19 Jan 2038 03:14:08 GMT). If a given 32-bit OS does not work properly using negative time_t values, then lighttpd likely will not work properly on that system. * Other references and blogs - https://en.wikipedia.org/wiki/Year_2038_problem - https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs - http://www.lieberbiber.de/2017/03/14/a-look-at-the-year-20362038-problems-and-time-proofness-in-various-systems/
* [core] write_all() simpler loop; better asmGlenn Strauss2021-08-271-5/+6
|
* [multiple] reduce redundant NULL buffer checksGlenn Strauss2021-08-271-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [multiple] use thread-safe strerror where availGlenn Strauss2021-08-271-4/+13
| | | | | use ck_strerror_s() to use strerror_s() or strerror_r() thread-safe and constraint-checking interfaces, where available.
* [core] consistent inclusion of sys-time.hGlenn Strauss2021-04-281-6/+0
|
* [multiple] strftime %F and %TGlenn Strauss2021-04-021-2/+2
| | | | strftime %F for %Y-%m-%d, and %T for %H:%M:%S
* [multiple] optimize primitives, buffer_extend()Glenn Strauss2021-03-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | optimize buffer_* primitives Other than buffer_string_set_length(), reallocate with one power-2 step in size (or use the requested size, if larger). This replaces the fixed BUFFER_PIECE_SIZE round-up of only 64 bytes extension each reallocation, which could lead to excessive reallocations in some scenarios. buffer_extend() convenience routine to prep for batch append (combines buffer_string_prepare_append() and buffer_commit()) mod_fastcgi, mod_scgi, mod_proxy and others now leverage buffer_extend() mod_scgi directly performs little-endian encoding of short ints http_response_write_header() optimizes writing response header, leveraging buffer_extend() modify mod_proxy to append line ends similar to how it is done in http_response_write_header() (removes one call to buffer_append_string_len())
* [multiple] add attrs from gcc -Wsuggest-attribute=Glenn Strauss2021-03-261-0/+2
|
* [multiple] prefer monotonic time for internal useGlenn Strauss2021-03-111-0/+9
| | | | | | | | Note: monotonic time does not change while VM is suspended Continue to use real time where required by HTTP protocol, for logging and for other user-visible instances, such as mod_status, as well as for external databases and caches.
* [multiple] employ http_date.h, sys-time.hGlenn Strauss2020-12-241-7/+12
| | | | | - replace use of strptime() w/ implementation specialized for HTTP dates - use thread-safe gmtime_r(), localtime_r() (replace localtime, gmtime)
* [core] remove include base.h where unusedGlenn Strauss2020-07-081-1/+0
|
* [core] inline buffer in log_error_st errhGlenn Strauss2020-07-081-8/+7
|
* [multiple] rename r to rc rv rd wr to be differentGlenn Strauss2020-07-081-26/+12
| | | | variable rename
* [multiple] extern log_epoch_secsGlenn Strauss2020-07-081-4/+5
| | | | replace srv->cur_ts
* [multiple] reduce direct use of srv->cur_tsGlenn Strauss2020-07-081-9/+9
|
* [core] log_error_multiline_buffer()Glenn Strauss2020-07-081-90/+44
| | | | replaces log_error_write_multiline_buffer()
* [multiple] prefer (connection *) to (srv *)Glenn Strauss2020-07-081-15/+0
| | | | | | | | 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] log_error, log_perror using printf-like fmtGlenn Strauss2019-04-201-0/+88
|
* [core] struct log_error_st for error loggingGlenn Strauss2019-04-201-20/+47
|
* [core] perf: simple, quick buffer_clear()Glenn Strauss2018-11-231-1/+1
| | | | | | | | | 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] perf: skip redundant prepare copy callsGlenn Strauss2018-10-251-1/+1
| | | | | | | skip redundant calls to buffer_string_prepare_copy() when simply clearing buffer is sufficient, e.g. when a blanked buffer is desired before calling buffer_append_strftime(), which internally prepares buffer for the resultant formatted string
* [core] remove some duplicative code in log.cGlenn Strauss2018-08-121-26/+9
|
* [core] reduce exposure of unistd.h, other includesGlenn Strauss2017-07-151-0/+1
| | | | reduce exposure of unistd.h, and some other include cleanup
* [core] mv log_error_{open,cycle.close} to server.cGlenn Strauss2017-07-151-208/+0
|
* [core] consolidate fork()/execve() code (#1393)Glenn Strauss2017-07-151-128/+28
| | | | | | | | (refactoring work to address issue #1393) x-ref: "access log pipe writer should restart child process if it exits" https://redmine.lighttpd.net/issues/1393
* [core] include "fdevent.h" where neededGlenn Strauss2017-03-281-0/+1
| | | | (instead of providing #include "fdevent.h" in base.h)
* [core] server.syslog-facility (use -1 for unset) (#2800)Glenn Strauss2017-03-201-3/+3
| | | | | | | | (thx philipp) x-ref: "lighttpd needs config option for syslog facility" https://redmine.lighttpd.net/issues/2800
* [core] server.syslog-facility (fixes #2800)Glenn Strauss2017-03-191-1/+64
| | | | | | | | server.syslog-facility = "daemon" x-ref: "lighttpd needs config option for syslog facility" https://redmine.lighttpd.net/issues/2800