On Fri, Feb 02, 2024 at 12:32:57AM +0100, Stefano
Brivio wrote:
Before commit 32d07f5e59f2 ("passt, pasta:
Completely avoid dynamic
memory allocation"), we didn't store the current log mask in a
variable, and we fetched it using setlogmask(0) wherever needed.
But after that commit, we can just use our log_mask copy instead. And
we should: with recent glibc versions, setlogmask(0) actually results
in a system call, which causes a substantial overhead with high
transfer rates: we use setlogmask(0) even to decide we don't want to
print debug messages.
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
The basic idea looks fine to me, but there's a curly edge case. At
present vlogmsg() works ok before __openlog(), sending the message to
stderr. We rely on this because there are die() calls before our
__openlog(), which go via err() -> vlogmsg().
With this change, before the first __setlogmask(), which occurs right
after the __openlog() then log_mask is initialized to zero. Which
means, AFAICT, that we'll suppress all error messages before that
point, which isn't great.
Oops, right, thanks for pointing this out. I had a vague memory of some
side benefit of setlogmask(0) with this regard but I couldn't really
remember and gave up on it -- it was exactly this.
I'm re-posting this with a static initialisation of log_mask now.
--
Stefano