Skip to content

logger: minor performance improvement to avoid syscall done by isatty

Working in this bug, I realized that sometimes a ioctl syscall is done by pipewire when running simple tools. The ioctl syscall is done by isatty(3) function.

For instance, running ffmpeg, I got next backtrace:

#0  __GI___tcgetattr (fd=2, termios_p=termios_p@entry=0x7fffffffdbf0) at ../sysdeps/unix/sysv/linux/tcgetattr.c:38
#1  0x00007ffff4c2c9a0 in __isatty (fd=<optimized out>) at ../sysdeps/posix/isatty.c:27
#2  0x00007ffff7fa8c4a in impl_init (factory=<optimized out>, handle=0x5555555e2ca8, info=<optimized out>, support=<optimized out>, n_support=<optimized out>) at ../pipewire/spa/plugins/support/logger.c:373
#3  0x00007ffff1b91cb4 in load_spa_handle (lib=<optimized out>, factory_name=0x7ffff1bb8c92 "support.log", info=0x7fffffffddd0, n_support=0, support=0x7ffff1bfe4b8 <global_support.lto_priv+88>) at ../pipewire/src/pipewire/pipewire.c:262
#4  0x00007ffff1baba13 in add_interface.constprop.0 (factory_name=<optimized out>, type=0x7ffff1bb8032 "Spa:Pointer:Interface:Log", info=<optimized out>, support=<optimized out>) at ../pipewire/src/pipewire/pipewire.c:340
#5  0x00007ffff1b92788 in pw_init (argc=argc@entry=0x0, argv=argv@entry=0x0) at ../pipewire/src/pipewire/pipewire.c:617
#6  0x00007ffff78d90e2 in reg () at ../pipewire/pipewire-jack/src/pipewire-jack.c:7199
#7  0x00007ffff7fcd1be in call_init (env=0x7fffffffe388, argv=0x7fffffffe378, argc=1, l=<optimized out>) at dl-init.c:74
#8  call_init (l=<optimized out>, argc=1, argv=0x7fffffffe378, env=0x7fffffffe388) at dl-init.c:26
#9  0x00007ffff7fcd2ac in _dl_init (main_map=0x7ffff7ffe2e0, argc=1, argv=0x7fffffffe378, env=0x7fffffffe388) at dl-init.c:121
#10 0x00007ffff7fe3bc0 in _dl_start_user () at /lib64/ld-linux-x86-64.so.2

The change is a minor optimization to avoid the isatty call if it is not needed.

Merge request reports