[mutter/wip/carlosg/xwayland-on-demand: 11/16] wayland: Refactor code setting up the display socket



commit e8949292c10445d8b9e193a049588a8a839d81d2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 26 00:37:57 2019 +0200

    wayland: Refactor code setting up the display socket
    
    So it may be reused when we need to open those again.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/709

 src/wayland/meta-xwayland.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 03f492fe4..333cd3064 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -397,6 +397,32 @@ meta_xwayland_override_display_number (int number)
   display_number_override = number;
 }
 
+static gboolean
+open_display_sockets (MetaXWaylandManager *manager,
+                      int                  display_index,
+                      gboolean            *fatal)
+{
+  int abstract_fd, unix_fd;
+
+  abstract_fd = bind_to_abstract_socket (display_index,
+                                         fatal);
+  if (abstract_fd < 0)
+    return FALSE;
+
+  unix_fd = bind_to_unix_socket (display_index);
+  if (unix_fd < 0)
+    {
+      *fatal = FALSE;
+      close (abstract_fd);
+      return FALSE;
+    }
+
+  manager->abstract_fd = abstract_fd;
+  manager->unix_fd = unix_fd;
+
+  return TRUE;
+}
+
 static gboolean
 choose_xdisplay (MetaXWaylandManager *manager)
 {
@@ -418,8 +444,7 @@ choose_xdisplay (MetaXWaylandManager *manager)
           return FALSE;
         }
 
-      manager->abstract_fd = bind_to_abstract_socket (display, &fatal);
-      if (manager->abstract_fd < 0)
+      if (!open_display_sockets (manager, display, &fatal))
         {
           unlink (lock_file);
 
@@ -430,20 +455,11 @@ choose_xdisplay (MetaXWaylandManager *manager)
             }
           else
             {
-              g_warning ("Failed to bind abstract socket");
+              g_warning ("Failed to bind X11 socket");
               return FALSE;
             }
         }
 
-      manager->unix_fd = bind_to_unix_socket (display);
-      if (manager->unix_fd < 0)
-        {
-          unlink (lock_file);
-          close (manager->abstract_fd);
-          display++;
-          continue;
-        }
-
       break;
     }
   while (1);


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