diff options
author | Eric Wong <e@80x24.org> | 2023-10-04 03:49:26 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-04 17:46:41 +0000 |
commit | dba2f9999053aa2bbe2682bfe94ceae829f1f59c (patch) | |
tree | df81bf4f955dda694c6970f96140790e41d25e22 | |
parent | c9408ccab6c9e1a17805d0f162b02f54753595ee (diff) | |
download | public-inbox-dba2f9999053aa2bbe2682bfe94ceae829f1f59c.tar.gz |
treewide: use PublicInbox::Lock->new
This gets rid of a few bare bless statements and helps ensure we properly load Lock.pm before using it.
-rw-r--r-- | lib/PublicInbox/LEI.pm | 2 | ||||
-rw-r--r-- | lib/PublicInbox/LeiMirror.pm | 2 | ||||
-rw-r--r-- | lib/PublicInbox/TestCommon.pm | 7 | ||||
-rw-r--r-- | t/solver_git.t | 3 | ||||
-rw-r--r-- | t/v2mirror.t | 2 |
5 files changed, 8 insertions, 8 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index d611f5c3..a5a6d321 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -1311,7 +1311,7 @@ sub lazy_start { my ($sock_dir) = ($path =~ m!\A(.+?)/[^/]+\z!); $errors_log = "$sock_dir/errors.log"; my $addr = pack_sockaddr_un($path); - my $lk = bless { lock_path => $errors_log }, 'PublicInbox::Lock'; + my $lk = PublicInbox::Lock->new($errors_log); umask(077) // die("umask(077): $!"); $lk->lock_acquire; socket($listener, AF_UNIX, SOCK_SEQPACKET, 0) or die "socket: $!"; diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index c99bafc3..9d8a8963 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -873,7 +873,7 @@ sub v2_done { # called via OnDestroy return if $self->{dry_run} || !keep_going($self); my $dst = $self->{cur_dst} // $self->{dst}; require PublicInbox::Lock; - my $lk = bless { lock_path => "$dst/inbox.lock" }, 'PublicInbox::Lock'; + my $lk = PublicInbox::Lock->new("$dst/inbox.lock"); my $lck = $lk->lock_for_scope($$); _write_inbox_config($self); require PublicInbox::MultiGit; diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 7d0eb2c4..32213fde 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -742,8 +742,7 @@ sub setup_public_inboxes () { return @ret if -f $stamp; require PublicInbox::Lock; - my $lk = bless { lock_path => "$test_home/setup.lock" }, - 'PublicInbox::Lock'; + my $lk = PublicInbox::Lock->new("$test_home/setup.lock"); my $end = $lk->lock_for_scope; return @ret if -f $stamp; @@ -798,7 +797,7 @@ sub create_coderepo ($$;@) { my $err = $!; -d $dir or xbail "mkdir($dir): $err"; } - my $lk = bless { lock_path => "$dir/creat.lock" }, 'PublicInbox::Lock'; + my $lk = PublicInbox::Lock->new("$dir/creat.lock"); my $scope = $lk->lock_for_scope; my $tmpdir = delete $opt{tmpdir}; if (!-f "$dir/creat.stamp") { @@ -830,7 +829,7 @@ sub create_inbox ($$;@) { my $err = $!; -d $dir or xbail "mkdir($dir): $err"; } - my $lk = bless { lock_path => "$dir/creat.lock" }, 'PublicInbox::Lock'; + my $lk = PublicInbox::Lock->new("$dir/creat.lock"); $opt{inboxdir} = File::Spec->rel2abs($dir); $opt{name} //= $ident; my $scope = $lk->lock_for_scope; diff --git a/t/solver_git.t b/t/solver_git.t index f8cafa5e..4f09e05b 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -223,7 +223,8 @@ SKIP: { }; my %bin = (big => $big_size, small => 1); my %oid; # (small|big) => OID - my $lk = bless { lock_path => $l }, 'PublicInbox::Lock'; + require PublicInbox::Lock; + my $lk = PublicInbox::Lock->new($l); my $acq = $lk->lock_for_scope; my $stamp = "$binfoo/stamp-"; if (open my $fh, '<', $stamp) { diff --git a/t/v2mirror.t b/t/v2mirror.t index 88b67bc1..b8824182 100644 --- a/t/v2mirror.t +++ b/t/v2mirror.t @@ -335,7 +335,7 @@ SKIP: { chomp $oldrev; my ($base) = ($0 =~ m!\b([^/]+)\.[^\.]+\z!); my $wt = "t/data-gen/$base.pre-manifest-$oldrev"; - my $lk = bless { lock_path => __FILE__ }, 'PublicInbox::Lock'; + my $lk = PublicInbox::Lock->new(__FILE__); $lk->lock_acquire; my $psgi = "$wt/app.psgi"; if (!-f $psgi) { # checkout a pre-manifest.js.gz version |