[gtk+/gtk-3-8] broadway: Ensure we allocate shm surface space early



commit db98346844ad14b1455b39530d2a14ab1e622bf7
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Apr 3 15:50:54 2013 +0200

    broadway: Ensure we allocate shm surface space early
    
    This is nicer then getting random sigbus later

 gdk/broadway/gdkbroadway-server.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gdk/broadway/gdkbroadway-server.c b/gdk/broadway/gdkbroadway-server.c
index adc28a0..f5df46a 100644
--- a/gdk/broadway/gdkbroadway-server.c
+++ b/gdk/broadway/gdkbroadway-server.c
@@ -582,6 +582,13 @@ _gdk_broadway_server_create_surface (int                 width,
   res = ftruncate (fd, data->data_size);
   g_assert (res != -1);
 
+  res = posix_fallocate (fd, 0, data->data_size);
+  if (res != 0)
+    {
+      shm_unlink (data->name);
+      g_error ("Not enough shared memory for window surface");
+    }
+
   data->data = mmap(0, data->data_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 
   (void) close(fd);
 


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