While signals are currently blocked in these helpers,
they may not always be...
---
 lib/PublicInbox/XapHelper.pm | 4 ++--
 lib/PublicInbox/xap_helper.h | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/XapHelper.pm b/lib/PublicInbox/XapHelper.pm
index 8c2b86d6..f90b283d 100644
--- a/lib/PublicInbox/XapHelper.pm
+++ b/lib/PublicInbox/XapHelper.pm
@@ -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} = '';
        }
 }
diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h
index 5f04316c..a78a3f76 100644
--- a/lib/PublicInbox/xap_helper.h
+++ b/lib/PublicInbox/xap_helper.h
@@ -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;
        }

Reply via email to