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

@ -87,6 +87,7 @@ struct globals {
};
static struct globals globals;
static bool mlock_warned = false;
#define OBJECT_CHUNK 8
@ -1801,11 +1802,14 @@ static int client_node_port_use_buffers(void *object,
pw_log_warn("unknown buffer data type %d", d->type);
}
if (c->allow_mlock && mlock(d->data, d->maxsize) < 0) {
pw_log_warn(NAME" %p: Failed to mlock memory %p %u: %s", c,
if (errno != ENOMEM || !mlock_warned) {
pw_log_warn(NAME" %p: Failed to mlock memory %p %u: %s", c,
d->data, d->maxsize,
errno == ENOMEM ?
"This is not a problem but for best performance, "
"consider increasing RLIMIT_MEMLOCK" : strerror(errno));
mlock_warned |= errno == ENOMEM;
}
}
}
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUT);