about summary refs log tree commit homepage
path: root/ext/clogger_ext
DateCommit message (Collapse)
2024-02-01switch to TypedData macros for allocation HEAD master
This gives us memsize information and appears to fix a leak under Ruby 3.3.
2024-02-01rack 3.x compatibility
Rack::Utils::HeaderHash will be removed in rack 3.1 so these changes mostly address that. The initializer in Rack::Headers inherits from Hash, so switching to the ::[] class method to achieve the same result.
2023-05-11workaround for time(2) being non-monotonic
Apparently, time(2) may go backwards in the first 1 - 2.5ms of every second since Linux + glibc 2.31+ (and some proprietary OSes). Use clock_gettime(2) with CLOCK_REALTIME to workaround the problem at the cost of a slight performance hit(*). While git will likely use gettimeofday(2) for compatibility with proprietary OSes, gettimeofday(2) was declared obsolete in POSIX.1-2008 and we don't support proprietary OSes. (*) https://inbox.sourceware.org/libc-alpha/87ttywq0je.fsf@oldenburg.str.redhat.com/ Link: https://lore.kernel.org/git/20230319064353.686226-3-eggert@cs.ucla.edu/T/
2023-05-11use _POSIX_C_SOURCE=200809L
That's what _DEFAULT_SOURCE will set if it's respected, and we've had POSIX 2008 goodies for 15 years, now.
2022-12-25fix $request_time{9,0} for 32-bit platforms
`struct timespec' has 32-bit tv_sec and tv_nsec on 32-bit x86 GNU/Linux system, causing excessive overflow and test failures.
2022-06-16escape env['REQUEST_METHOD'] for non-strict HTTP servers
This doesn't affect most Rack HTTP servers since they have strict parsers, but is safer in case one doesn't... Influenced by CVE-2022-30123.
2021-05-24mark Rack::HeaderHash for GC.compact
With GC.compact in Ruby 3.x, Ruby-defined constants need to be explicitly marked to prevent movement: Link: https://yhbt.net/kgio-public/CAAvYYt5Z5f2rMuXO5DMpR1-6uRvu_gXKDvqcyoZ+oNcLiTH39g@mail.gmail.com/T/
2020-08-06clogger: fix _BSD_SOURCE and _SVID_SOURCE deprecation warnings
Apparently, _DEFAULT_SOURCE is now the recommended macro to define for _BSD_SOURCE and _SVID_SOURCE features.
2020-08-03Added optional POWER argument to $response_time
This argument allows for conversion of response_time to microsecond or nanosecond by multiplying by a power of 10, up to a limit of 9. Defaults to 0 so backwards compatible.
2017-05-21Update respond_to? calls for second argument.
Rack (since v2) has started explicitly listing the second (optional) argument for respond_to?, which matches the underlying Ruby spec. This patch fixes the calls in both C and Ruby approaches. [ew: add test, use rb_obj_respond_to if available]
2017-02-15ext: reduce frozen string marking overhead
Using rb_global_variable excessively can be expensive since it uses a singly-linked list to track addresses. Since these strings are all frozen and constant, put them into an array instead and only mark the array as a global to improve locality. Ruby 1.9+ has rb_gc_register_mark_object but it is not part of the documented, public API, so we're not using it, yet.
2017-01-17clogger.c: comment to explain the lack of GC guard
If I (the person who wrote this) spent a minute figuring out why it wasn't needed, somebody else might, too. Save someone else a minute.
2016-07-28ext: avoid clobbering existing system functions
These defines may cause incompatibilities if Ruby or other system headers decide to clobber these. It's also confusing to override existing, well-known-and-standardized functions.
2015-01-13ext: get rid of noisy and unnecessary cast
2014-05-12remove :to_io support
:to_io never was a Rack extension, and ends up breaking the case where an SSL socket is proxied. The role of :to_io in IO-like objects is to aid IO.select and like methods.
2014-02-15use rb_thread_call_without_gvl for Ruby 2+
rb_thread_blocking_region is deprecated and will be removed
2014-02-15remove each_id, it was never used
2014-02-15prevent potential premature GC in byte_xs
If we convert an object to string, there is a potential the compiler may optimize away the converted string if escaping is needed. Prevent that with RB_GC_GUARD.
2014-02-15use RB_GC_GUARD instead of volatile
RB_GC_GUARD is more explicit in intent.
2014-02-15remove unused RARRAY_PTR macro
We do not need it anymore
2014-02-15blocking_helpers: remove fstat wrapper
The fstat syscall should never take long, even on sockets and slow FSes.
2013-09-26ext: avoid RARRAY_PTR usage for RGenGC in Ruby 2.1.0
I have not benchmarked this, but this is unlikely to be a bottleneck at all in older Rubies. It results in a smaller binary, too, which will help with icache bloat. This should also improve performance under Rubinius, too.
2012-11-06ext: enable C extension under Ruby 2.0.0
Ruby 2.0.0preview1 is out, and we happen to be compatible (with some harmless linker/build warnings)
2012-11-02avoid calling "<<" on env["rack.errors"]
Rack::Lint::ErrorWrapper forbids the "<<" method. This fallback only comes into play when no log destination (via :logger or :path) is specified and is rarely an issue in real setups.
2011-12-05escape individual cookie values from $cookie_*
These values are untrusted, so if any client sends them to us we must escape them.
2011-12-05escape bytes in the 0x7F-0xFF range, too
This matches the behavior of nginx 1.0.9
2011-07-20ext: note we rely on GVL for reentrancy detection
Nothing wrong with the GVL in Ruby 1.9.3; but we'll need to modify our code if it's removed for C extensions.
2011-06-22ext: fix portability defines for some installs
Some Ruby installs muck up headers/#defines and cause weirdness. We now explicitly define _BSD_SOURCE and include #stdio.h
2011-04-19$time_local and $time_utc are locale-independent
This doesn't apply to people that use strftime()-formats, but that's a minority.
2011-04-16add support for $time_iso8601 format
This appeared in nginx 0.9.6
2011-03-21extconf: unnecessary dir_config statement
Braindamage from back in the day when I didn't understand mkmf
2011-03-16fix documentation of Clogger.new for :path
Oops
2011-03-13avoid potential RString -> C-string conversions
Unlikely, but it may make a difference somewhere...
2011-03-13release GVL for filesystem operations
While local filesystems are usually very fast, we are pessimistic and should prepare for worst-case scenarios. This can use rb_thread_io_blocking_region() under Ruby 1.9.3dev.
2011-03-13ext: ensure path is a valid C string
Unlikely, but some app could pass '\0' into us
2011-03-04ext: avoid potentially unsafe casts with C API
Rubinius may be pickier about what a VALUE is, so we can't safely cast any C address into VALUEs.
2011-01-21delegate method_missing calls to the response body
Since we delegated response_to?, we also need to delegate method_missing to the response body in case there are non-standard methods defined outside of Rack.
2011-01-21pass along "to_io" calls to the body
This optimization is used by Rainbows! to pass IO objects to the response body.
2011-01-14handle abitrarily long time formats in C extension
In case some folks need to use insanely long time formats, we'll support them.
2011-01-14RDoc fixups
call-seq is needed to make C functions look good
2011-01-14remove dead RSTRUCT* compatibility macros
The Clogger::ToPath proxy struct class is gone and so is our need to access it.
2011-01-14remove Clogger::ToPath proxy class
We can just make Clogger#respond_to? smarter and forward everything except :close to the body we're proxying.
2011-01-14another try to fix systems without CLOCK_MONOTONIC
Fix a reversed typedef and also deal with the case where CLOCK_MONOTONIC is a function call and not a constant macro.
2011-01-14another workaround for systems with broken CLOCK_MONOTONIC
This should also detect cases where CLOCK_MONOTONIC is available at build but not at runtime.
2011-01-12attempt to support broken/crazy systems
clock_gettime() is not available on some systems and/or CLOCK_MONOTONIC. This is totally broken considering the POSIX standard was 10 years ago, now. Nothing in gnulib, either, wtf?! http://www.gnu.org/software/gnulib/manual/html_node/clock_005fgettime.html
2011-01-12remove unused function (obj_fileno)
2010-12-25add support for Rubinius
RSTRUCT_PTR access is unlikely to ever happen for Rubinius, so we'll just make a method dispatch and leave the faster code for Ruby 1.8 and 1.9.
2010-12-24fix #include ordering under FreeBSD 7.2
ruby.h doesn't seem to like being included after time.h
2010-12-24use clock_gettime for time resolution
This lets us use CLOCK_MONOTONIC so we are not affected by system clock changes. We still convert to microseconds instead of nanoseconds for (pure)-Ruby 1.8 code compatibility. There is also little need for nanosecond timer resolution in log files (microsecond is not needed, even).
2010-12-24accept a new :path argument in initialize
This lessens confusion for people configuring Clogger in config.ru, since "File" could be mistaken for Rack::File and "::File" needs to be specified.