client: don't register in client_new()

Don't register in client_new() to make it possible to do other things
on the client before registering. Register the client in protocol-native
after we set up the events etc.
This commit is contained in:
Wim Taymans 2019-11-19 15:59:45 +01:00
parent 5f65f1cbbe
commit e18a24493a
2 changed files with 10 additions and 5 deletions

View file

@ -327,6 +327,7 @@ static struct pw_client *client_new(struct server *s, int fd)
struct pw_properties *props; struct pw_properties *props;
char buffer[1024]; char buffer[1024];
struct protocol_data *d = pw_protocol_get_user_data(protocol); struct protocol_data *d = pw_protocol_get_user_data(protocol);
int res;
props = pw_properties_new(PW_KEY_PROTOCOL, "protocol-native", NULL); props = pw_properties_new(PW_KEY_PROTOCOL, "protocol-native", NULL);
if (props == NULL) if (props == NULL)
@ -366,12 +367,16 @@ static struct pw_client *client_new(struct server *s, int fd)
this->source = pw_loop_add_io(pw_core_get_main_loop(core), this->source = pw_loop_add_io(pw_core_get_main_loop(core),
fd, SPA_IO_ERR | SPA_IO_HUP, true, fd, SPA_IO_ERR | SPA_IO_HUP, true,
connection_data, this); connection_data, this);
if (this->source == NULL) if (this->source == NULL) {
res = -errno;
goto cleanup_client; goto cleanup_client;
}
this->connection = pw_protocol_native_connection_new(protocol->core, fd); this->connection = pw_protocol_native_connection_new(protocol->core, fd);
if (this->connection == NULL) if (this->connection == NULL) {
res = -errno;
goto cleanup_client; goto cleanup_client;
}
pw_map_init(&this->compat_v2.types, 0, 32); pw_map_init(&this->compat_v2.types, 0, 32);
@ -382,11 +387,14 @@ static struct pw_client *client_new(struct server *s, int fd)
pw_client_add_listener(client, &this->client_listener, &client_events, this); pw_client_add_listener(client, &this->client_listener, &client_events, this);
if ((res = pw_client_register(client, NULL)) < 0)
goto cleanup_client;
return client; return client;
cleanup_client: cleanup_client:
pw_client_destroy(client); pw_client_destroy(client);
errno = -res;
exit: exit:
return NULL; return NULL;
} }

View file

@ -343,9 +343,6 @@ struct pw_client *pw_client_new(struct pw_core *core,
pw_core_emit_check_access(core, this); pw_core_emit_check_access(core, this);
if ((res = pw_client_register(this, NULL)) < 0)
goto error_clear_array;
return this; return this;
error_clear_array: error_clear_array: