Changeset View
Changeset View
Standalone View
Standalone View
www/firefox/files/patch-bug1618914
[Wayland] Fall back to ftruncate if posix_fallocate isn't supported by filesystem. | [Wayland] Fall back to ftruncate if posix_fallocate isn't supported by filesystem. | ||||
diff --git widget/gtk/WindowSurfaceWayland.cpp widget/gtk/WindowSurfaceWayland.cpp | diff --git widget/gtk/WindowSurfaceWayland.cpp widget/gtk/WindowSurfaceWayland.cpp | ||||
index 9a73326399bd5..9e42a7f1c5d18 100644 | index 9a73326399bd5..9e42a7f1c5d18 100644 | ||||
--- widget/gtk/WindowSurfaceWayland.cpp | --- widget/gtk/WindowSurfaceWayland.cpp | ||||
+++ widget/gtk/WindowSurfaceWayland.cpp | +++ widget/gtk/WindowSurfaceWayland.cpp | ||||
@@ -235,23 +235,24 @@ | @@ -222,19 +222,20 @@ static int WaylandAllocateShmMemory(int aSize) { | ||||
#ifdef HAVE_POSIX_FALLOCATE | |||||
do { | do { | ||||
ret = posix_fallocate(fd, 0, aSize); | ret = posix_fallocate(fd, 0, aSize); | ||||
} while (ret == EINTR); | } while (ret == EINTR); | ||||
- if (ret != 0) { | - if (ret != 0) { | ||||
+ if (ret == 0) { | + if (ret == 0) { | ||||
+ return fd; | + return fd; | ||||
+ } else if (ret != EINVAL && ret != EOPNOTSUPP) { | + } else if (ret != EINVAL && ret != EOPNOTSUPP) { | ||||
close(fd); | close(fd); | ||||
MOZ_CRASH_UNSAFE_PRINTF( | MOZ_CRASH("posix_fallocate() fails to allocate shm memory"); | ||||
"posix_fallocate() fails on %s size %d error code %d\n", filename, | |||||
aSize, ret); | |||||
} | } | ||||
-#else | -#else | ||||
+#endif | +#endif | ||||
do { | do { | ||||
ret = ftruncate(fd, aSize); | ret = ftruncate(fd, aSize); | ||||
} while (ret < 0 && errno == EINTR); | } while (ret < 0 && errno == EINTR); | ||||
if (ret < 0) { | if (ret < 0) { | ||||
close(fd); | close(fd); | ||||
MOZ_CRASH_UNSAFE_PRINTF("ftruncate() fails on %s size %d error code %d\n", | MOZ_CRASH("ftruncate() fails to allocate shm memory"); | ||||
filename, aSize, ret); | |||||
} | } | ||||
-#endif | -#endif | ||||
return fd; | return fd; | ||||
} | } | ||||
@@ -265,7 +266,7 @@ bool WaylandShmPool::Resize(int aSize) { | @@ -265,7 +266,7 @@ bool WaylandShmPool::Resize(int aSize) { | ||||
do { | do { | ||||
errno = posix_fallocate(mShmPoolFd, 0, aSize); | errno = posix_fallocate(mShmPoolFd, 0, aSize); | ||||
} while (errno == EINTR); | } while (errno == EINTR); | ||||
- if (errno != 0) return false; | - if (errno != 0) return false; | ||||
+ if (errno != 0 && errno != EINVAL && errno != EOPNOTSUPP) return false; | + if (errno != 0 && errno != EINVAL && errno != EOPNOTSUPP) return false; | ||||
#endif | #endif | ||||
wl_shm_pool_resize(mShmPool, aSize); | wl_shm_pool_resize(mShmPool, aSize); |