public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob 80a235e9aa82ff43d9ea806759cdb6c814fc7f85 969 bytes (raw)
$ git show HEAD:lib/PublicInbox/CidxComm.pm	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Waits for initial comm(1) output for PublicInbox::CodeSearchIdx.
# The initial output from `comm' can take a while to generate because
# it needs to wait on:
# `git cat-file --batch-all-objects --batch-check --unordered | sort'
# We still rely on blocking reads, here, since comm should be fast once
# it's seeing input.  (`--unordered | sort' is intentional for HDDs)
package PublicInbox::CidxComm;
use v5.12;
use parent qw(PublicInbox::DS);
use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);

sub new {
	my ($cls, $rd, $cidx, $drs) = @_;
	my $self = bless { cidx => $cidx, drs => $drs }, $cls;
	$self->SUPER::new($rd, EPOLLIN|EPOLLONESHOT);
}

sub event_step {
	my ($self) = @_;
	my $rd = $self->{sock} // return warn('BUG?: no {sock}');
	$self->close; # EPOLL_CTL_DEL
	delete($self->{cidx})->cidx_read_comm($rd, delete $self->{drs});
}

1;

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git