[mutter/wip/wayland] wayland: Handle error unlinking stale xwayland locks



commit 0d4fcd2d788f9af3e7541d24ae132fc9d5d42944
Author: Robert Bragg <robert linux intel com>
Date:   Mon Jan 23 13:12:30 2012 +0000

    wayland: Handle error unlinking stale xwayland locks
    
    If mutter was run as root then its possible we end up with an X lock
    file owned by root. create_lockfile() wasn't checking if there was an
    error when unlinking a stale lock file and so if we were to later run X
    not as root then we'd repeatedly try unlinking the file and trying again
    to use the same display number. Because there was also another bug where
    each attempt to create a lock file would open a new file descriptor this
    bug would lead to us running out of descriptors. We now check for errors
    when unlinking a stale lock file and also are careful to close the stale
    lock file once we have read the pid.

 src/wayland/meta-wayland.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 8113de4..c7f0a80 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -723,6 +723,7 @@ create_lockfile (int display, int *display_out)
               display++;
               continue;
           }
+          close (fd);
 
           other = strtol (pid, &end, 0);
           if (end != pid + 10)
@@ -738,8 +739,14 @@ create_lockfile (int display, int *display_out)
           if (kill (other, 0) < 0 && errno == ESRCH)
             {
               g_warning ("unlinking stale lock file %s", filename);
-              unlink (filename);
-              continue; /* try again */
+              if (unlink (filename) < 0)
+                {
+                  const char *msg = strerror (errno);
+                  g_warning ("failed to unlink stale lock file: %s", msg);
+                  display++;
+                }
+              g_free (filename);
+              continue;
           }
 
           g_free (filename);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]