ref => $ref,
inbox => $ibx,
path_type => '2/38', # or 'v2'
- ssoma_lock => 1, # disable for v2
+ lock_path => "$git->{git_dir}/ssoma.lock", # v2 changes this
bytes_added => 0,
}, $class
}
my $git = $self->{git};
my $git_dir = $git->{git_dir};
- my $lockfh;
- if ($self->{ssoma_lock}) {
- my $lockpath = "$git_dir/ssoma.lock";
- sysopen($lockfh, $lockpath, O_WRONLY|O_CREAT) or
- die "failed to open lock $lockpath: $!";
+ if (my $lock_path = $self->{lock_path}) {
+ sysopen(my $lockfh, $lock_path, O_WRONLY|O_CREAT) or
+ die "failed to open lock $lock_path: $!";
# wait for other processes to be done
flock($lockfh, LOCK_EX) or die "lock failed: $!\n";
+ $self->{lockfh} = $lockfh;
}
local $/ = "\n";
$out_w->autoflush(1);
$self->{in} = $in_r;
$self->{out} = $out_w;
- $self->{lockfh} = $lockfh;
$self->{pid} = $pid;
$self->{nchg} = 0;
binmode $out_w, ':raw' or die "binmode :raw failed: $!";
_update_git_info($self, 1) if delete $self->{nchg};
- $self->{ssoma_lock} or return;
+ $self->{lock_path} or return;
my $lockfh = delete $self->{lockfh} or die "BUG: not locked: $!";
flock($lockfh, LOCK_UN) or die "unlock failed: $!";
close $lockfh or die "close lock failed: $!";
sub new {
my ($class, $v2ibx, $creat) = @_;
my $dir = $v2ibx->{mainrepo} or die "no mainrepo in inbox\n";
+ my $lock_path = "$dir/inbox.lock";
unless (-d $dir) {
if ($creat) {
require File::Path;
File::Path::mkpath($dir);
+ open my $fh, '>>', $lock_path or
+ die "failed to open $lock_path: $!\n";
} else {
die "$dir does not exist\n";
}
xap_ro => undef,
partitions => $nparts,
transact_bytes => 0,
+ lock_path => "$dir/inbox.lock",
# limit each repo to 1GB or so
rotate_bytes => int((1024 * 1024 * 1024) / $PACKING_FACTOR),
};
my $im = PublicInbox::Import->new($git, undef, undef, $self->{-inbox});
$im->{bytes_added} = int($packed_bytes / $PACKING_FACTOR);
$im->{want_object_info} = 1;
- $im->{ssoma_lock} = 0;
+ $im->{lock_path} = $self->{lock_path};
$im->{path_type} = 'v2';
$self->{im} = $im;
}