mirror of
https://passt.top/passt
synced 2025-05-25 10:35:35 +02:00
log: setlogmask(0) can actually result in a system call, don't use it
Before commit 32d07f5e59
("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 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.
Now that we rely on log_mask in early stages, before setlogmask() is
called, we need to initialise that variable to the special LOG_EMERG
mask value right away: define LOG_EARLY to make this clearer, and,
while at it, group conditions in vlogmsg() into something more terse.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
78901eeae3
commit
7ee4e17267
2 changed files with 12 additions and 13 deletions
7
passt.c
7
passt.c
|
@ -251,9 +251,6 @@ int main(int argc, char **argv)
|
|||
|
||||
__openlog(log_name, 0, LOG_DAEMON);
|
||||
|
||||
/* Meaning we don't know yet: log everything. LOG_EMERG is unused */
|
||||
__setlogmask(LOG_MASK(LOG_EMERG));
|
||||
|
||||
c.epollfd = epoll_create1(EPOLL_CLOEXEC);
|
||||
if (c.epollfd == -1) {
|
||||
perror("epoll_create1");
|
||||
|
@ -322,8 +319,8 @@ int main(int argc, char **argv)
|
|||
if (isolate_prefork(&c))
|
||||
die("Failed to sandbox process, exiting");
|
||||
|
||||
/* Once the log mask is not LOG_EMERG, we will no longer
|
||||
* log to stderr if there was a log file specified.
|
||||
/* Once the log mask is not LOG_EARLY, we will no longer log to stderr
|
||||
* if there was a log file specified.
|
||||
*/
|
||||
if (c.debug)
|
||||
__setlogmask(LOG_UPTO(LOG_DEBUG));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue