From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 2F2C91F574 for ; Wed, 4 Oct 2023 03:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1696391376; bh=XNzaxWEqceQxvRL/Hql3v0Ta64MOS12T8xMVX6gyuAQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nwSq6vL1YY7cLfdDR3ev3fG1tDnSsanqm10N1qMZvDwZWsNcbqXzZhH5K8mHRvlCs 3B0h0FJXq/9ByE1SdfjTaF1m5aj2OPzBYFglNGacIwq0o36vumtgoZUICgus9Ow7LI UzoX026tRHNm6YChnnJsnLsZQ3jeks1ohyHhv1+A= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 17/21] xap_helper: retry flock on EINTR Date: Wed, 4 Oct 2023 03:49:29 +0000 Message-ID: <20231004034933.3343930-18-e@80x24.org> In-Reply-To: <20231004034933.3343930-1-e@80x24.org> References: <20231004034933.3343930-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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; }