aboutsummaryrefslogtreecommitdiff
path: root/mail/thunderbird/files/patch-bug1618914
blob: c52ac49018b25f1649c4ef96651d005981662beb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From cea8e6a01bb03bbe565c9bf5dd4f439f30ca953f Mon Sep 17 00:00:00 2001
From: Jan Beich <jbeich@FreeBSD.org>
Date: Fri, 28 Feb 2020 16:49:38 +0000
Subject: Bug 1618914 - [Wayland] Fall back to ftruncate if posix_fallocate isn't supported by filesystem.

diff --git widget/gtk/WaylandShmBuffer.cpp widget/gtk/WaylandShmBuffer.cpp
index 42eeedd3429ac..2a5c23d287413 100644
--- widget/gtk/WaylandShmBuffer.cpp
+++ widget/gtk/WaylandShmBuffer.cpp
@@ -67,36 +67,37 @@ static int WaylandAllocateShmMemory(int aSize) {
     return -1;
   }
 
   int ret = 0;
 #ifdef HAVE_POSIX_FALLOCATE
   do {
     ret = posix_fallocate(fd, 0, aSize);
   } while (ret == EINTR);
-  if (ret != 0) {
+  if (ret == 0) {
+    return fd;
+  } else if (ret != ENODEV && ret != EINVAL && ret != EOPNOTSUPP) {
     NS_WARNING(
         nsPrintfCString("posix_fallocate() fails to allocate shm memory: %s",
                         strerror(ret))
             .get());
     close(fd);
     return -1;
   }
-#else
+#endif
   do {
     ret = ftruncate(fd, aSize);
   } while (ret < 0 && errno == EINTR);
   if (ret < 0) {
     NS_WARNING(nsPrintfCString("ftruncate() fails to allocate shm memory: %s",
                                strerror(ret))
                    .get());
     close(fd);
     fd = -1;
   }
-#endif
 
   return fd;
 }
 
 /* static */
 RefPtr<WaylandShmPool> WaylandShmPool::Create(
     const RefPtr<nsWaylandDisplay>& aWaylandDisplay, int aSize) {
   RefPtr<WaylandShmPool> shmPool = new WaylandShmPool(aSize);