]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchIdxPart.pm
v2writable: cleanup unused pipes in partitions
[public-inbox.git] / lib / PublicInbox / SearchIdxPart.pm
index 5582d672d0de343b19dfc297446056ed8217407c..64e5263657160430ecec3de2fa88d06adec3f155 100644 (file)
@@ -14,10 +14,7 @@ sub new {
        my $pid = fork;
        defined $pid or die "fork failed: $!\n";
        if ($pid == 0) {
-               foreach my $other (@{$v2writable->{idx_parts}}) {
-                       my $other_w = $other->{w} or next;
-                       close $other_w or die "close other failed: $!\n";
-               }
+               $v2writable->atfork_child;
                $v2writable = undef;
                close $w;
 
@@ -74,4 +71,8 @@ sub index_raw {
        $w->flush or die "failed to flush: $!\n";
 }
 
+sub atfork_child {
+       close $_[0]->{w} or die "failed to close write pipe: $!\n";
+}
+
 1;