]> code.delx.au - pulseaudio/blobdiff - src/daemon/main.c
Merge branch 'master' of ssh://rootserver/home/lennart/git/public/pulseaudio
[pulseaudio] / src / daemon / main.c
index 587fd1753f5c67783af171cfc95d215187e0eb3d..b209c514b1a5f2698c4c7bdce36c6142210c04ed 100644 (file)
@@ -405,6 +405,36 @@ int main(int argc, char *argv[]) {
     pa_log_set_level(PA_LOG_NOTICE);
     pa_log_set_flags(PA_LOG_COLORS|PA_LOG_PRINT_FILE|PA_LOG_PRINT_LEVEL, PA_LOG_RESET);
 
+#if defined(__linux__) && defined(__OPTIMIZE__)
+    /*
+       Disable lazy relocations to make usage of external libraries
+       more deterministic for our RT threads. We abuse __OPTIMIZE__ as
+       a check whether we are a debug build or not. This all is
+       admittedly a bit snake-oilish.
+    */
+
+    if (!getenv("LD_BIND_NOW")) {
+        char *rp;
+
+        /* We have to execute ourselves, because the libc caches the
+         * value of $LD_BIND_NOW on initialization. */
+
+        pa_set_env("LD_BIND_NOW", "1");
+
+        if ((rp = pa_readlink("/proc/self/exe"))) {
+
+            if (pa_streq(rp, PA_BINARY))
+                pa_assert_se(execv(rp, argv) == 0);
+            else
+                pa_log_warn("/proc/self/exe does not point to " PA_BINARY ", cannot self execute. Are you playing games?");
+
+            pa_xfree(rp);
+
+        } else
+            pa_log_warn("Couldn't read /proc/self/exe, cannot self execute. Running in a chroot()?");
+    }
+#endif
+
     if ((e = getenv("PULSE_PASSED_FD"))) {
         passed_fd = atoi(e);