pipewire: mem: log if close() fails

If a file descriptor is expected to be closed by the associated `pw_memblock`,
and closing fails, then that usually signals a more serious issue in the memory
accounting. So add a log message when that happens.
This commit is contained in:
Barnabás Pőcze 2026-03-10 12:24:31 +01:00
parent d33066cdd7
commit 5c67ab2a7a

View file

@ -15,6 +15,7 @@
#include <sys/syscall.h>
#include <sys/stat.h>
#include <spa/utils/cleanup.h>
#include <spa/utils/list.h>
#include <spa/buffer/buffer.h>
@ -856,8 +857,10 @@ void pw_memblock_free(struct pw_memblock *block)
}
if (block->fd != -1 && !(block->flags & PW_MEMBLOCK_FLAG_DONT_CLOSE)) {
pw_log_debug("%p: close fd:%d", pool, block->fd);
close(block->fd);
int fd = spa_steal_fd(block->fd);
pw_log_debug("%p: block:%p close fd:%d", pool, block, fd);
if (close(fd) < 0)
pw_log_error("%p: block:%p close fd:%d failed: %m", pool, block, fd);
}
spa_hook_list_clean(&b->listener_list);