pulse-server: use the new timer-queue for timeouts

Use the timer queue for scheduling stream and object data timeouts.

This avoids allocating timerfds for these timeouts and the timer queue
can handle many timeouts more efficiently.
This commit is contained in:
Wim Taymans 2025-09-18 13:55:43 +02:00
parent 38cb14d39d
commit ca713c08ee
5 changed files with 14 additions and 32 deletions

View file

@ -40,7 +40,7 @@ static int parse_frac(struct pw_properties *props, const char *key,
return 0;
}
static void create_stream_timeout(void *user_data, uint64_t expirations)
static void create_stream_timeout(void *user_data)
{
struct stream *stream = user_data;
@ -52,9 +52,6 @@ static void create_stream_timeout(void *user_data, uint64_t expirations)
stream->killed = false;
stream_free(stream);
} else {
pw_loop_destroy_source(stream->impl->main_loop, stream->timer);
stream->timer = NULL;
}
}
@ -109,9 +106,8 @@ struct stream *stream_new(struct client *client, enum stream_type type, uint32_t
/* Time out if we don't get a link and can't send a reply to create in 35s. Client will time out in
* 30s and clean up its stream anyway. */
struct timespec create_timeout = { .tv_sec = 35, .tv_nsec = 0 };
stream->timer = pw_loop_add_timer(stream->impl->main_loop, create_stream_timeout, stream);
pw_loop_update_timer(stream->impl->main_loop, stream->timer, &create_timeout, NULL, false);
pw_timer_queue_add(stream->impl->timer_queue, &stream->timer, NULL,
35 * SPA_NSEC_PER_SEC, create_stream_timeout, stream);
return stream;
@ -130,10 +126,7 @@ void stream_free(struct stream *stream)
pw_log_debug("client %p: stream %p channel:%d", client, stream, stream->channel);
if (stream->timer) {
pw_loop_destroy_source(stream->impl->main_loop, stream->timer);
stream->timer = NULL;
}
pw_timer_queue_cancel(&stream->timer);
if (stream->drain_tag)
reply_error(client, -1, stream->drain_tag, -ENOENT);