More source ref fixes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2020-08-07 10:54:30 +10:00
parent bc9b129e95
commit 6d46c55df3
2 changed files with 7 additions and 5 deletions

View file

@ -704,10 +704,11 @@ int
ei_set_connection(struct ei *ei, int fd)
{
struct source *source = source_add_autoclose(ei->sink, fd, connection_dispatch, ei);
ei->source = source_ref(source);
if (!ei->source)
if (!source)
return -ENOMEM;
ei->source = source_ref(source);
return 0;
}

View file

@ -104,6 +104,7 @@ static void
eis_client_destroy(struct eis_client *client)
{
free(client->name);
source_remove(client->source);
source_unref(client->source);
list_remove(&client->link);
}
@ -596,9 +597,9 @@ eis_client_new(struct eis *eis, int fd)
list_init(&client->devices);
list_append(&eis->clients, &client->link);
client->source = source_add_autoclose(eis->sink, fd,
client_dispatch, client);
struct source *s = source_add_autoclose(eis->sink, fd,
client_dispatch, client);
client->source = source_ref(s);
client->state = EIS_CLIENT_STATE_HELLO;
int rc = client_send_hello(client);
if (rc != 0)