diff options
author | Marek Chalupa <mchqwerty@gmail.com> | 2016-04-25 11:33:00 +0200 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2016-04-25 15:29:40 -0400 |
commit | f48b0534f110397246809d279225afedb28aa233 (patch) | |
tree | 3783e0e7ddc06f3b44aa50242eb09b725039a92f | |
parent | 4cc32880737c2d3e568fdb4867b2dba10fb3998a (diff) |
xwayland-shm: fortify fallocate against EINTR
If posix_fallocate or ftruncate is interrupted by signal while working,
we return -1 as fd and the allocation process returns BadAlloc error.
That causes xwayland clients to abort with 'BadAlloc (insufficient
resources for operation)' even when there's a lot of resources
available.
Fix it by trying again when we get EINTR.
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
-rw-r--r-- | hw/xwayland/xwayland-shm.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/hw/xwayland/xwayland-shm.c b/hw/xwayland/xwayland-shm.c index e8545b3be..c199e5efb 100644 --- a/hw/xwayland/xwayland-shm.c +++ b/hw/xwayland/xwayland-shm.c @@ -140,14 +140,20 @@ os_create_anonymous_file(off_t size) return -1; #ifdef HAVE_POSIX_FALLOCATE - ret = posix_fallocate(fd, 0, size); + do { + ret = posix_fallocate(fd, 0, size); + } while (ret == EINTR); + if (ret != 0) { close(fd); errno = ret; return -1; } #else - ret = ftruncate(fd, size); + do { + ret = ftruncate(fd, size); + } while (ret == -1 && errno == EINTR); + if (ret < 0) { close(fd); return -1; |