From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 634681FAEB for ; Mon, 19 Mar 2018 08:15:01 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 08/27] skeleton: barrier init requires a lock Date: Mon, 19 Mar 2018 08:14:40 +0000 Message-Id: <20180319081459.10645-9-e@80x24.org> In-Reply-To: <20180319081459.10645-1-e@80x24.org> References: <20180319081459.10645-1-e@80x24.org> List-Id: Writing to the main skeleton pipe requires a lock since it's shared with partition processes. --- lib/PublicInbox/SearchIdxSkeleton.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/SearchIdxSkeleton.pm b/lib/PublicInbox/SearchIdxSkeleton.pm index beb17b9..51a88fd 100644 --- a/lib/PublicInbox/SearchIdxSkeleton.pm +++ b/lib/PublicInbox/SearchIdxSkeleton.pm @@ -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 { -- EW