]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xap_helper: retry flock on EINTR
authorEric Wong <e@80x24.org>
Wed, 4 Oct 2023 03:49:29 +0000 (03:49 +0000)
committerEric Wong <e@80x24.org>
Wed, 4 Oct 2023 17:46:45 +0000 (17:46 +0000)
While signals are currently blocked in these helpers,
they may not always be...

lib/PublicInbox/XapHelper.pm
lib/PublicInbox/xap_helper.h

index 8c2b86d60b4886b97e06fa610a4887d2472d076c..f90b283d930b7a1dfac48a285ef8f0beaf474f2a 100644 (file)
@@ -109,9 +109,9 @@ sub dump_roots_iter ($$$) {
 sub dump_roots_flush ($$) {
        my ($req, $fh) = @_;
        if ($req->{wbuf} ne '') {
-               flock($fh, LOCK_EX) or die "flock: $!";
+               until (flock($fh, LOCK_EX)) { die "LOCK_EX: $!" if !$!{EINTR} }
                print { $req->{0} } $req->{wbuf} or die "print: $!";
-               flock($fh, LOCK_UN) or die "flock: $!";
+               until (flock($fh, LOCK_UN)) { die "LOCK_UN: $!" if !$!{EINTR} }
                $req->{wbuf} = '';
        }
 }
index 5f04316c9cee0e720663fc40cf02bb3759523abb..a78a3f7690ba29844bd99084d21713deed4b5284 100644 (file)
@@ -441,7 +441,8 @@ static bool dump_roots_flush(struct req *req, struct dump_roots_tmp *drt)
        }
        drt->wbuf.fp = NULL;
        if (!drt->wbuf.len) goto done_free;
-       if (flock(drt->root2id_fd, LOCK_EX)) {
+       while (flock(drt->root2id_fd, LOCK_EX)) {
+               if (errno == EINTR) continue;
                perror("LOCK_EX");
                return false;
        }
@@ -456,7 +457,8 @@ static bool dump_roots_flush(struct req *req, struct dump_roots_tmp *drt)
                        return false;
                }
        } while (drt->wbuf.len);
-       if (flock(drt->root2id_fd, LOCK_UN)) {
+       while (flock(drt->root2id_fd, LOCK_UN)) {
+               if (errno == EINTR) continue;
                perror("LOCK_UN");
                return false;
        }