]> Sergey Matveev's repositories - public-inbox.git/commitdiff
skeleton: barrier init requires a lock
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 19 Mar 2018 08:14:40 +0000 (08:14 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 19 Mar 2018 08:16:34 +0000 (08:16 +0000)
Writing to the main skeleton pipe requires a lock since it's
shared with partition processes.

lib/PublicInbox/SearchIdxSkeleton.pm

index beb17b9f8316b1ad230d041d84fd56f8fe2ea226..51a88fda36b8a9e008c35223d314a4b6efd4528e 100644 (file)
@@ -149,9 +149,12 @@ sub index_skeleton_real ($$) {
 # write to the subprocess
 sub barrier_init {
        my ($self, $nparts) = @_;
-       my $w = $_[0]->{w};
-       print $w "barrier_init $nparts\n" or die "failed to write: $!";
-       $w->flush or die "failed to flush: $!";
+       my $w = $self->{w};
+       my $err;
+       $self->_lock_acquire;
+       print $w "barrier_init $nparts\n" or $err = "failed to write: $!\n";
+       $self->_lock_release;
+       die $err if $err;
 }
 
 sub barrier_wait {