mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-12 23:50:35 -04:00
modules: loop_add_io with close=true owns the fd
We should not close the fd when loop_add_io with close=true fails because the fd is already closed.
This commit is contained in:
parent
eec372ba9d
commit
8907d0860b
6 changed files with 9 additions and 20 deletions
|
|
@ -902,7 +902,6 @@ int stream_activate(struct stream *stream, uint16_t index, uint64_t now)
|
||||||
if (stream->source == NULL) {
|
if (stream->source == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("stream %p: can't create source: %m", stream);
|
pw_log_error("stream %p: can't create source: %m", stream);
|
||||||
close(fd);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1017,10 +1016,8 @@ int stream_activate_virtual(struct stream *stream, uint16_t index)
|
||||||
|
|
||||||
stream->source = pw_loop_add_io(server->impl->loop, fd,
|
stream->source = pw_loop_add_io(server->impl->loop, fd,
|
||||||
SPA_IO_IN, true, on_socket_data, stream);
|
SPA_IO_IN, true, on_socket_data, stream);
|
||||||
if (stream->source == NULL) {
|
if (stream->source == NULL)
|
||||||
close(fd);
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pw_stream_set_active(stream->stream, true);
|
pw_stream_set_active(stream->stream, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -1079,7 +1079,6 @@ static int create_netjack2_socket(struct impl *impl)
|
||||||
if (impl->setup_socket == NULL) {
|
if (impl->setup_socket == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("can't create setup source: %m");
|
pw_log_error("can't create setup source: %m");
|
||||||
close(fd);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -761,12 +761,10 @@ static struct server *create_server(struct impl *impl, const char *address)
|
||||||
if (server->source == NULL) {
|
if (server->source == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("%p: can't create server source: %m", impl);
|
pw_log_error("%p: can't create server source: %m", impl);
|
||||||
goto error_close;
|
goto error;
|
||||||
}
|
}
|
||||||
return server;
|
return server;
|
||||||
|
|
||||||
error_close:
|
|
||||||
close(fd);
|
|
||||||
error:
|
error:
|
||||||
server_free(server);
|
server_free(server);
|
||||||
errno = -res;
|
errno = -res;
|
||||||
|
|
|
||||||
|
|
@ -1197,10 +1197,8 @@ static int setup_apple_session(struct impl *impl)
|
||||||
impl->ctrl_source = pw_loop_add_io(impl->loop, fd,
|
impl->ctrl_source = pw_loop_add_io(impl->loop, fd,
|
||||||
SPA_IO_IN, true, on_ctrl_io, impl);
|
SPA_IO_IN, true, on_ctrl_io, impl);
|
||||||
|
|
||||||
if (impl->ctrl_source == NULL) {
|
if (impl->ctrl_source == NULL)
|
||||||
close(fd);
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
|
|
||||||
if ((fd = make_socket(&impl->data_addr, impl->data_len,
|
if ((fd = make_socket(&impl->data_addr, impl->data_len,
|
||||||
impl->mcast_loop, impl->ttl, impl->ifname)) < 0)
|
impl->mcast_loop, impl->ttl, impl->ifname)) < 0)
|
||||||
|
|
@ -1208,10 +1206,8 @@ static int setup_apple_session(struct impl *impl)
|
||||||
|
|
||||||
impl->data_source = pw_loop_add_io(impl->data_loop, fd,
|
impl->data_source = pw_loop_add_io(impl->data_loop, fd,
|
||||||
SPA_IO_IN, true, on_data_io, impl);
|
SPA_IO_IN, true, on_data_io, impl);
|
||||||
if (impl->data_source == NULL) {
|
if (impl->data_source == NULL)
|
||||||
close(fd);
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -693,9 +693,8 @@ static void stream_open_connection(void *data, int *result)
|
||||||
impl->source = pw_loop_add_io(impl->data_loop, fd,
|
impl->source = pw_loop_add_io(impl->data_loop, fd,
|
||||||
SPA_IO_IN, true, on_rtp_io, impl);
|
SPA_IO_IN, true, on_rtp_io, impl);
|
||||||
if (impl->source == NULL) {
|
if (impl->source == NULL) {
|
||||||
pw_log_error("can't create io source: %m");
|
|
||||||
close(fd);
|
|
||||||
res = -errno;
|
res = -errno;
|
||||||
|
pw_log_error("can't create io source: %m");
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -525,7 +525,7 @@ invalid_version:
|
||||||
|
|
||||||
static int listen_start(struct impl *impl)
|
static int listen_start(struct impl *impl)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd, res;
|
||||||
|
|
||||||
if (impl->source != NULL)
|
if (impl->source != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -534,16 +534,16 @@ static int listen_start(struct impl *impl)
|
||||||
|
|
||||||
if ((fd = make_socket((const struct sockaddr *)&impl->src_addr,
|
if ((fd = make_socket((const struct sockaddr *)&impl->src_addr,
|
||||||
impl->src_len, impl->ifname)) < 0) {
|
impl->src_len, impl->ifname)) < 0) {
|
||||||
pw_log_error("failed to create socket: %m");
|
pw_log_error("failed to create socket: %s", spa_strerror(fd));
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->source = pw_loop_add_io(impl->data_loop, fd,
|
impl->source = pw_loop_add_io(impl->data_loop, fd,
|
||||||
SPA_IO_IN, true, on_vban_io, impl);
|
SPA_IO_IN, true, on_vban_io, impl);
|
||||||
if (impl->source == NULL) {
|
if (impl->source == NULL) {
|
||||||
|
res = -errno;
|
||||||
pw_log_error("can't create io source: %m");
|
pw_log_error("can't create io source: %m");
|
||||||
close(fd);
|
return res;
|
||||||
return -errno;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue