Welcome! Log In Create A New Profile

Advanced

Re: ngx_log_error, ngx_slprintf signal safe

Sergey Brester via nginx-devel
November 07, 2022 06:40AM
Hi,

Function ngx_slprintf is conditionally async-signal safe (unless you'd
use the same buffer, supplied as first argument, or free such buffer or
some of the arguments in signal handler, because the function is not
atomic and can be interrupted by a signal).

However regarding the function ngx_log_error (or rather
ngx_log_error_core invoked internally) it is a bit more complex (there
are still structures like log, log->connection etc used internally,
which must remain unchanged unless the function ends), but you can safe
call the function inside the handler, because it fills the buffer in
stack before logging it in one piece hereafter with function write
(being async-signal-safe corresponding POSIX) using stderr handler.

In my opinion it is safe to call both functions inside the async-signal
handler, but you should avoid to "touch" the structures and arguments
(e. g. release or modify them) that can be used in invocations of that
functions outside.

Regards,
Sergey.

05.11.2022 21:32, Nikhil Singhal wrote:

> Hi All,
>
> Wanted to know if ngx_log_error and ngx_slprintf functions are async signal safe or not. Any help would be appreciated.
>
> Regards,
> Nikhil Singhal
>
> _______________________________________________
> nginx-devel mailing list -- nginx-devel@nginx.org
> To unsubscribe send an email to nginx-devel-leave@nginx.org
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

ngx_log_error, ngx_slprintf signal safe

Nikhil Singhal 313 November 05, 2022 04:34PM

Re: ngx_log_error, ngx_slprintf signal safe

Sergey Brester via nginx-devel 106 November 07, 2022 06:40AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 225
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready