mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: module-pipe-source: do not unlink fifo if it was there
If the module did not create the FIFO, then it should not remove it.
This commit is contained in:
parent
7cb7d8b15b
commit
9076e3e80b
1 changed files with 16 additions and 6 deletions
|
|
@ -51,6 +51,7 @@ struct module_pipesrc_data {
|
||||||
|
|
||||||
struct spa_audio_info_raw info;
|
struct spa_audio_info_raw info;
|
||||||
|
|
||||||
|
bool do_unlink;
|
||||||
char *filename;
|
char *filename;
|
||||||
int fd;
|
int fd;
|
||||||
int stride;
|
int stride;
|
||||||
|
|
@ -197,10 +198,9 @@ static int module_pipesource_unload(struct client *client, struct module *module
|
||||||
pw_stream_destroy(d->playback);
|
pw_stream_destroy(d->playback);
|
||||||
if (d->core != NULL)
|
if (d->core != NULL)
|
||||||
pw_core_disconnect(d->core);
|
pw_core_disconnect(d->core);
|
||||||
if (d->filename) {
|
if (d->do_unlink)
|
||||||
unlink(d->filename);
|
unlink(d->filename);
|
||||||
free(d->filename);
|
free(d->filename);
|
||||||
}
|
|
||||||
if (d->fd >= 0)
|
if (d->fd >= 0)
|
||||||
close(d->fd);
|
close(d->fd);
|
||||||
|
|
||||||
|
|
@ -233,6 +233,7 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument
|
||||||
struct spa_audio_info_raw info = { 0 };
|
struct spa_audio_info_raw info = { 0 };
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
bool do_unlink = false;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
int stride, res = 0;
|
int stride, res = 0;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
@ -299,12 +300,19 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument
|
||||||
filename = strdup(DEFAULT_FILE_NAME);
|
filename = strdup(DEFAULT_FILE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filename == NULL) {
|
||||||
|
res = -ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (mkfifo(filename, 0666) < 0) {
|
if (mkfifo(filename, 0666) < 0) {
|
||||||
if (errno != EEXIST) {
|
if (errno != EEXIST) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error("mkfifo('%s'): %s", filename, spa_strerror(res));
|
pw_log_error("mkfifo('%s'): %s", filename, spa_strerror(res));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_unlink = false;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Our umask is 077, so the pipe won't be created with the
|
* Our umask is 077, so the pipe won't be created with the
|
||||||
|
|
@ -312,6 +320,8 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument
|
||||||
*/
|
*/
|
||||||
if (chmod(filename, 0666) < 0)
|
if (chmod(filename, 0666) < 0)
|
||||||
pw_log_warn("chmod('%s'): %s", filename, spa_strerror(-errno));
|
pw_log_warn("chmod('%s'): %s", filename, spa_strerror(-errno));
|
||||||
|
|
||||||
|
do_unlink = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fd = open(filename, O_RDONLY | O_CLOEXEC | O_NONBLOCK, 0)) <= 0) {
|
if ((fd = open(filename, O_RDONLY | O_CLOEXEC | O_NONBLOCK, 0)) <= 0) {
|
||||||
|
|
@ -347,6 +357,7 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument
|
||||||
d->info = info;
|
d->info = info;
|
||||||
d->fd = fd;
|
d->fd = fd;
|
||||||
d->filename = filename;
|
d->filename = filename;
|
||||||
|
d->do_unlink = do_unlink;
|
||||||
d->stride = stride;
|
d->stride = stride;
|
||||||
|
|
||||||
pw_log_info("Successfully loaded module-pipe-source");
|
pw_log_info("Successfully loaded module-pipe-source");
|
||||||
|
|
@ -355,10 +366,9 @@ struct module *create_module_pipe_source(struct impl *impl, const char *argument
|
||||||
out:
|
out:
|
||||||
pw_properties_free(props);
|
pw_properties_free(props);
|
||||||
pw_properties_free(playback_props);
|
pw_properties_free(playback_props);
|
||||||
if (filename) {
|
if (do_unlink)
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
free(filename);
|
free(filename);
|
||||||
}
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
errno = -res;
|
errno = -res;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue