]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchIdxPart.pm
v2writable: support "barrier" operation to avoid reforking
[public-inbox.git] / lib / PublicInbox / SearchIdxPart.pm
index 6d8cb2a7e93748814eb0a24932735dc736f294ff..dd7ace67adcf04b09abb9d217676c4d53f8da3ba 100644 (file)
@@ -49,6 +49,11 @@ sub partition_worker_loop ($$$) {
                } elsif ($line eq "close\n") {
                        $self->_xdb_release;
                        $xdb = $txn = undef;
+               } elsif ($line eq "barrier\n") {
+                       $xdb->commit_transaction if $txn;
+                       $txn = undef;
+                       print { $self->{skeleton}->{w} } "barrier $part\n" or
+                                       die "write failed to skeleton: $!\n";
                } else {
                        chomp $line;
                        my ($len, $artnum, $oid, $mid0) = split(/ /, $line);
@@ -81,4 +86,11 @@ sub atfork_child {
        close $_[0]->{w} or die "failed to close write pipe: $!\n";
 }
 
+# called by V2Writable:
+sub barrier {
+       my $w = $_[0]->{w};
+       print $w "barrier\n" or die "failed to print: $!";
+       $w->flush or die "failed to flush: $!";
+}
+
 1;