mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-09 13:30:06 -05:00
Add pw_in_valgrind() to check running in valgrind
In valgrind we don't want to unload the plugins because then valgrind doesn't know the symbol names where things leaked. Parse the VALGRIND env variable and use this to avoid calling dlclose for a better valgrind experience.
This commit is contained in:
parent
fda9e4d5c8
commit
0471ba7fba
3 changed files with 15 additions and 2 deletions
|
|
@ -322,7 +322,7 @@ void pw_impl_module_destroy(struct pw_impl_module *module)
|
||||||
|
|
||||||
pw_properties_free(module->properties);
|
pw_properties_free(module->properties);
|
||||||
|
|
||||||
if (dlclose(impl->hnd) != 0)
|
if (!pw_in_valgrind() && dlclose(impl->hnd) != 0)
|
||||||
pw_log_warn(NAME" %p: dlclose failed: %s", module, dlerror());
|
pw_log_warn(NAME" %p: dlclose failed: %s", module, dlerror());
|
||||||
free(impl);
|
free(impl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ struct support {
|
||||||
struct registry *registry;
|
struct registry *registry;
|
||||||
struct spa_support support[MAX_SUPPORT];
|
struct spa_support support[MAX_SUPPORT];
|
||||||
uint32_t n_support;
|
uint32_t n_support;
|
||||||
|
unsigned int in_valgrind:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct registry global_registry;
|
static struct registry global_registry;
|
||||||
|
|
@ -154,6 +155,7 @@ unref_plugin(struct plugin *plugin)
|
||||||
if (--plugin->ref == 0) {
|
if (--plugin->ref == 0) {
|
||||||
spa_list_remove(&plugin->link);
|
spa_list_remove(&plugin->link);
|
||||||
pw_log_debug("unloaded plugin:'%s'", plugin->filename);
|
pw_log_debug("unloaded plugin:'%s'", plugin->filename);
|
||||||
|
if (!global_support.in_valgrind)
|
||||||
dlclose(plugin->hnd);
|
dlclose(plugin->hnd);
|
||||||
free(plugin->filename);
|
free(plugin->filename);
|
||||||
free(plugin);
|
free(plugin);
|
||||||
|
|
@ -367,6 +369,9 @@ void pw_init(int *argc, char **argv[])
|
||||||
if (support->registry != NULL)
|
if (support->registry != NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ((str = getenv("VALGRIND")))
|
||||||
|
support->in_valgrind = pw_properties_parse_bool(str);
|
||||||
|
|
||||||
if ((str = getenv("PIPEWIRE_DEBUG")))
|
if ((str = getenv("PIPEWIRE_DEBUG")))
|
||||||
configure_debug(support, str);
|
configure_debug(support, str);
|
||||||
|
|
||||||
|
|
@ -506,6 +511,12 @@ const char *pw_get_host_name(void)
|
||||||
return hname;
|
return hname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPA_EXPORT
|
||||||
|
bool pw_in_valgrind(void)
|
||||||
|
{
|
||||||
|
return global_support.in_valgrind;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get the client name
|
/** Get the client name
|
||||||
*
|
*
|
||||||
* Make a new PipeWire client name that can be used to construct a remote.
|
* Make a new PipeWire client name that can be used to construct a remote.
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,8 @@ pw_get_host_name(void);
|
||||||
const char *
|
const char *
|
||||||
pw_get_client_name(void);
|
pw_get_client_name(void);
|
||||||
|
|
||||||
|
bool pw_in_valgrind(void);
|
||||||
|
|
||||||
enum pw_direction
|
enum pw_direction
|
||||||
pw_direction_reverse(enum pw_direction direction);
|
pw_direction_reverse(enum pw_direction direction);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue