Add kernel work-around for boot_id
[lttng-tools.git] / src / bin / lttng-sessiond / kernel.c
index d9e047fc3f5cdcc50a72ea68d0a7f29fa49b159b..43c6285773847739afc437de35bbb09cb0f6b0e3 100644 (file)
@@ -638,3 +638,30 @@ error_version:
 error:
        return ret;
 }
+
+/*
+ * Kernel work-arounds called at the start of sessiond main().
+ */
+int init_kernel_workarounds(void)
+{
+       FILE *fp;
+
+       /*
+        * boot_id needs to be read once before being used concurrently
+        * to deal with a Linux kernel race. A fix is proposed for
+        * upstream, but the work-around is needed for older kernels.
+        */
+       fp = fopen("/proc/sys/kernel/random/boot_id", "r");
+       if (!fp) {
+               goto end_boot_id;
+       }
+       while (!feof(fp)) {
+               char buf[37] = "";
+
+               (void) fread(buf, 1, sizeof(buf), fp);
+       }
+       fclose(fp);
+end_boot_id:
+
+       return 0;
+}
This page took 0.024277 seconds and 5 git commands to generate.