libshare: nfs: retry flock() when interrupted

Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
This commit is contained in:
наб 2021-05-17 18:08:35 +02:00 committed by Brian Behlendorf
parent bdf6464c6c
commit f50697f95b

View File

@ -50,7 +50,9 @@ nfs_exports_lock(const char *name)
return (err);
}
if (flock(nfs_lock_fd, LOCK_EX) != 0) {
while ((err = flock(nfs_lock_fd, LOCK_EX)) != 0 && errno == EINTR)
;
if (err != 0) {
err = errno;
fprintf(stderr, "failed to lock %s: %s\n", name, strerror(err));
(void) close(nfs_lock_fd);