warn about lock just once

This commit is contained in:
Wim Taymans 2020-11-14 21:21:20 +01:00
parent 80e063c6bc
commit f42da492f9
4 changed files with 36 additions and 19 deletions

View file

@ -45,6 +45,7 @@
#define MAX_IO 32
/** \cond */
static bool mlock_warned = false;
struct buffer {
uint32_t id;
@ -645,12 +646,15 @@ client_node_port_use_buffers(void *object,
bid->mem = mm;
if (data->allow_mlock && mlock(mm->ptr, mm->size) < 0)
pw_log(data->warn_mlock ? SPA_LOG_LEVEL_WARN : SPA_LOG_LEVEL_DEBUG,
"Failed to mlock memory %p %u: %s",
mm->ptr, mm->size,
errno == ENOMEM ?
"This is not a problem but for best performance, "
"consider increasing RLIMIT_MEMLOCK" : strerror(errno));
if (errno != ENOMEM || !mlock_warned) {
pw_log(data->warn_mlock ? SPA_LOG_LEVEL_WARN : SPA_LOG_LEVEL_DEBUG,
"Failed to mlock memory %p %u: %s",
mm->ptr, mm->size,
errno == ENOMEM ?
"This is not a problem but for best performance, "
"consider increasing RLIMIT_MEMLOCK" : strerror(errno));
mlock_warned |= errno == ENOMEM;
}
size = sizeof(struct spa_buffer);
for (j = 0; j < buffers[i].buffer->n_metas; j++)