summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2013-04-20 10:12:34 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2013-04-23 09:32:52 +0530
commit508c60fff158961fcba2eba831523c3904dcb8ea (patch)
treee9a289781ec92bcbd982e516bd021e69dd09ef5f
parentbb7f83567b60c17e4744a1c7eb6a4e83d924b00f (diff)
pulsecore: Make run-from-build not readlink() on every call
Since this is no longer only defined in debug builds, let's make sure that there is no impact if this is indavertently called repeatedly at startup.
-rw-r--r--src/pulsecore/core-util.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index cca66bcf..da8266b3 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -3211,12 +3211,14 @@ void pa_reset_personality(void) {
pa_bool_t pa_run_from_build_tree(void) {
char *rp;
- pa_bool_t b = FALSE;
+ static pa_bool_t b = FALSE;
- if ((rp = pa_readlink("/proc/self/exe"))) {
- b = pa_startswith(rp, PA_BUILDDIR);
- pa_xfree(rp);
- }
+ PA_ONCE_BEGIN {
+ if ((rp = pa_readlink("/proc/self/exe"))) {
+ b = pa_startswith(rp, PA_BUILDDIR);
+ pa_xfree(rp);
+ }
+ } PA_ONCE_END;
return b;
}