diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index f9852412f..2d9f09094 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -327,6 +327,7 @@ static struct pw_client *client_new(struct server *s, int fd) struct pw_properties *props; char buffer[1024]; struct protocol_data *d = pw_protocol_get_user_data(protocol); + int res; props = pw_properties_new(PW_KEY_PROTOCOL, "protocol-native", 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), fd, SPA_IO_ERR | SPA_IO_HUP, true, connection_data, this); - if (this->source == NULL) + if (this->source == NULL) { + res = -errno; goto cleanup_client; + } this->connection = pw_protocol_native_connection_new(protocol->core, fd); - if (this->connection == NULL) + if (this->connection == NULL) { + res = -errno; goto cleanup_client; + } 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); + if ((res = pw_client_register(client, NULL)) < 0) + goto cleanup_client; return client; cleanup_client: pw_client_destroy(client); + errno = -res; exit: return NULL; } diff --git a/src/pipewire/client.c b/src/pipewire/client.c index ea487b1a9..6f58d938a 100644 --- a/src/pipewire/client.c +++ b/src/pipewire/client.c @@ -343,9 +343,6 @@ struct pw_client *pw_client_new(struct pw_core *core, pw_core_emit_check_access(core, this); - if ((res = pw_client_register(this, NULL)) < 0) - goto error_clear_array; - return this; error_clear_array: