mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-08 13:30:08 -05:00
connection: add do_close flag to connect_fd
Make pw_remote_connect_fd() not automatically close the provided fd but let the caller take care of that. This allows us to reuse the fd in pipewiresrc. Fixes #155
This commit is contained in:
parent
5850044599
commit
216b641ebb
5 changed files with 13 additions and 11 deletions
|
|
@ -570,7 +570,7 @@ static const struct pw_protocol_native_connection_events conn_events = {
|
|||
.need_flush = on_need_flush,
|
||||
};
|
||||
|
||||
static int impl_connect_fd(struct pw_protocol_client *client, int fd)
|
||||
static int impl_connect_fd(struct pw_protocol_client *client, int fd, bool do_close)
|
||||
{
|
||||
struct client *impl = SPA_CONTAINER_OF(client, struct client, this);
|
||||
struct pw_remote *remote = client->remote;
|
||||
|
|
@ -589,14 +589,15 @@ static int impl_connect_fd(struct pw_protocol_client *client, int fd)
|
|||
impl->source = pw_loop_add_io(remote->core->main_loop,
|
||||
fd,
|
||||
SPA_IO_IN | SPA_IO_HUP | SPA_IO_ERR,
|
||||
true, on_remote_data, impl);
|
||||
do_close, on_remote_data, impl);
|
||||
if (impl->source == NULL)
|
||||
goto error_close;
|
||||
|
||||
return 0;
|
||||
|
||||
error_close:
|
||||
close(fd);
|
||||
if (do_close)
|
||||
close(fd);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ int pw_protocol_native_connect_local_socket(struct pw_protocol_client *client,
|
|||
goto error_close;
|
||||
}
|
||||
|
||||
res = pw_protocol_client_connect_fd(client, fd);
|
||||
res = pw_protocol_client_connect_fd(client, fd, true);
|
||||
|
||||
done_callback(data, res);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue