From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/3] lock: get rid of PID guard
Date: Mon, 1 Apr 2024 06:49:36 +0000 [thread overview]
Message-ID: <20240401064938.2334883-2-e@80x24.org> (raw)
In-Reply-To: <20240401064938.2334883-1-e@80x24.org>
PID guards for OnDestroy will be the default in an upcoming
change. In the meantime, LeiMirror was the only user and
didn't actually need it.
---
lib/PublicInbox/LeiMirror.pm | 2 +-
lib/PublicInbox/Lock.pm | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index 5353ae61..4e3e1d1c 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -856,7 +856,7 @@ sub v2_done { # called via OnDestroy
my $dst = $self->{cur_dst} // $self->{dst};
require PublicInbox::Lock;
my $lk = PublicInbox::Lock->new("$dst/inbox.lock");
- my $lck = $lk->lock_for_scope($$);
+ my $lck = $lk->lock_for_scope;
_write_inbox_config($self);
require PublicInbox::MultiGit;
my $mg = PublicInbox::MultiGit->new($dst, 'all.git', 'git');
diff --git a/lib/PublicInbox/Lock.pm b/lib/PublicInbox/Lock.pm
index ddaf3312..2a5a0f30 100644
--- a/lib/PublicInbox/Lock.pm
+++ b/lib/PublicInbox/Lock.pm
@@ -41,9 +41,9 @@ sub lock_release {
# caller must use return value
sub lock_for_scope {
- my ($self, @single_pid) = @_;
+ my ($self) = @_;
lock_acquire($self) or return; # lock_path not set
- PublicInbox::OnDestroy->new(@single_pid, \&lock_release, $self);
+ PublicInbox::OnDestroy->new(\&lock_release, $self);
}
sub lock_acquire_fast {
@@ -58,9 +58,9 @@ sub lock_release_fast {
# caller must use return value
sub lock_for_scope_fast {
- my ($self, @single_pid) = @_;
+ my ($self) = @_;
lock_acquire_fast($self) or return; # lock_path not set
- PublicInbox::OnDestroy->new(@single_pid, \&lock_release_fast, $self);
+ PublicInbox::OnDestroy->new(\&lock_release_fast, $self);
}
1;
next prev parent reply other threads:[~2024-04-01 6:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 6:49 [PATCH 0/3] treewide: getpid() syscall reduction Eric Wong
2024-04-01 6:49 ` Eric Wong [this message]
2024-04-01 6:49 ` [PATCH 2/3] treewide: avoid getpid() for OnDestroy checks Eric Wong
2024-04-01 6:49 ` [PATCH 3/3] treewide: avoid getpid for more ownership checks Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240401064938.2334883-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).