From: Fam Zheng Date: Tue, 26 Dec 2017 06:53:00 +0000 (+0800) Subject: osdep: Retry SETLK upon EINTR X-Git-Tag: v2.12.0-rc0~138^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f86428a1f4f91a460ed585682af70d3e8c31dc06;p=thirdparty%2Fqemu.git osdep: Retry SETLK upon EINTR We could hit lock failure if there is a signal that makes fcntl return -1 and errno set to EINTR. In this case we should retry. Cc: qemu-stable@nongnu.org Signed-off-by: Fam Zheng Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- diff --git a/util/osdep.c b/util/osdep.c index 1231f9f8768..a73de0e1ba0 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -244,7 +244,9 @@ static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type) .l_type = fl_type, }; qemu_probe_lock_ops(); - ret = fcntl(fd, fcntl_op_setlk, &fl); + do { + ret = fcntl(fd, fcntl_op_setlk, &fl); + } while (ret == -1 && errno == EINTR); return ret == -1 ? -errno : 0; }