pulse-server: use invalid id for unused connect_tag

Because 0 happens to be the first tag and can cause confusion.
This commit is contained in:
Wim Taymans 2020-11-06 16:08:13 +01:00
parent a2549fc638
commit 96599f74e7

View file

@ -518,12 +518,26 @@ static void manager_sync(void *data)
{
struct client *client = data;
if (client->connect_tag) {
pw_log_info(NAME" %p: manager sync", client);
if (client->connect_tag != SPA_ID_INVALID) {
reply_set_client_name(client, client->connect_tag);
client->connect_tag = 0;
client->connect_tag = SPA_ID_INVALID;
}
}
static struct stream *find_stream(struct client *client, uint32_t id)
{
union pw_map_item *item;
pw_array_for_each(item, &client->streams.items) {
struct stream *s = item->data;
if (!pw_map_item_is_free(item) &&
s->id == id)
return s;
}
return NULL;
}
static uint32_t get_event_and_id(struct client *client, struct pw_manager_object *o, uint32_t *id)
{
uint32_t event = 0, res_id = o->id;
@ -635,23 +649,11 @@ static const struct pw_manager_events manager_events = {
.metadata = manager_metadata,
};
static struct stream *find_stream(struct client *client, uint32_t id)
{
union pw_map_item *item;
pw_array_for_each(item, &client->streams.items) {
struct stream *s = item->data;
if (!pw_map_item_is_free(item) &&
s->id == id)
return s;
}
return NULL;
}
static int do_set_client_name(struct client *client, uint32_t command, uint32_t tag, struct message *m)
{
struct impl *impl = client->impl;
const char *name = NULL;
int res, changed = 0;
int res = 0, changed = 0;
if (client->version < 13) {
if (message_get(m,
@ -687,11 +689,11 @@ static int do_set_client_name(struct client *client, uint32_t command, uint32_t
client->connect_tag = tag;
pw_manager_add_listener(client->manager, &client->manager_listener,
&manager_events, client);
res = 0;
} else {
if (changed)
pw_core_update_properties(client->core, &client->props->dict);
if (client->connect_tag == SPA_ID_INVALID)
res = reply_set_client_name(client, tag);
}
return res;
@ -4235,6 +4237,7 @@ on_connect(void *data, int fd, uint32_t mask)
client->impl = impl;
client->server = server;
client->connect_tag = SPA_ID_INVALID;
spa_list_append(&server->clients, &client->link);
pw_map_init(&client->streams, 16, 16);
spa_list_init(&client->free_messages);