mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-30 06:46:49 -04:00
spa: varlink: Set a default read timeout for sync calls
Makes sure we don't end up blocking forever, and timeouts are treated as errors.
This commit is contained in:
parent
7fb515d3ee
commit
4f798754e5
4 changed files with 17 additions and 11 deletions
|
|
@ -153,7 +153,7 @@ done:
|
|||
|
||||
static int
|
||||
client_call_sync(void *object, const char *method, const char *params,
|
||||
char **reply)
|
||||
char **reply, int timeout)
|
||||
{
|
||||
struct client *this = SPA_CONTAINER_OF(object, struct client, client);
|
||||
struct impl *impl = this->impl;
|
||||
|
|
@ -174,6 +174,10 @@ client_call_sync(void *object, const char *method, const char *params,
|
|||
this->source->mask & ~SPA_IO_IN);
|
||||
|
||||
fcntl(this->fd, F_SETFL, fcntl(this->fd, F_GETFL) & ~O_NONBLOCK);
|
||||
if (timeout >= 0) {
|
||||
struct timeval tv = { .tv_sec = 0, .tv_usec = timeout * 1000 };
|
||||
setsockopt(this->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
}
|
||||
|
||||
buf = build_call(method, params, false, false, &len);
|
||||
|
||||
|
|
@ -201,9 +205,6 @@ client_call_sync(void *object, const char *method, const char *params,
|
|||
if (res == -EINTR)
|
||||
continue;
|
||||
|
||||
if (res == -EAGAIN || res == -EWOULDBLOCK)
|
||||
continue;
|
||||
|
||||
spa_log_error(impl->log, "Error reading from socket: %s",
|
||||
spa_strerror(res));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue