user/dev discussion of public-inbox itself
 help / color / Atom feed
a397ee0612e90d8f007847c7b2e0604824f386ef blob 2009 bytes (raw)

 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 
# Copyright (C) 2019 all contributors <meta@public-inbox.org>
# Licensed the same as Danga::Socket (and Perl5)
# License: GPL-1.0+ or Artistic-1.0-Perl
#  <https://www.gnu.org/licenses/gpl-1.0.txt>
#  <https://dev.perl.org/licenses/artistic.html>
use strict;
use warnings;
use Test::More;
use PublicInbox::Syscall qw(:epoll);
my $cls = 'PublicInbox::DSPoll';
use_ok $cls;
my $p = $cls->new;

my ($r, $w, $x, $y);
pipe($r, $w) or die;
pipe($x, $y) or die;
is(epoll_ctl($p, EPOLL_CTL_ADD, fileno($r), EPOLLIN), 0, 'add EPOLLIN');
my $events = [];
my $n = epoll_wait($p, 9, 0, $events);
is_deeply($events, [], 'no events set');
is($n, 0, 'nothing ready, yet');
is(epoll_ctl($p, EPOLL_CTL_ADD, fileno($w), EPOLLOUT|EPOLLONESHOT), 0,
	'add EPOLLOUT|EPOLLONESHOT');
$n = epoll_wait($p, 9, -1, $events);
is($n, 1, 'got POLLOUT event');
is($events->[0]->[0], fileno($w), '$w ready');

$n = epoll_wait($p, 9, 0, $events);
is($n, 0, 'nothing ready after oneshot');
is_deeply($events, [], 'no events set after oneshot');

syswrite($w, '1') == 1 or die;
for my $t (0..1) {
	$n = epoll_wait($p, 9, $t, $events);
	is($events->[0]->[0], fileno($r), "level-trigger POLLIN ready #$t");
	is($n, 1, "only event ready #$t");
}
syswrite($y, '1') == 1 or die;
is(epoll_ctl($p, EPOLL_CTL_ADD, fileno($x), EPOLLIN|EPOLLONESHOT), 0,
	'EPOLLIN|EPOLLONESHOT add');
is(epoll_wait($p, 9, -1, $events), 2, 'epoll_wait has 2 ready');
my @fds = sort(map { $_->[0] } @$events);
my @exp = sort((fileno($r), fileno($x)));
is_deeply(\@fds, \@exp, 'got both ready FDs');

# EPOLL_CTL_DEL doesn't matter for kqueue, we do it in native epoll
# to avoid a kernel-wide lock; but its not needed for native kqueue
# paths so DSKQXS makes it a noop (as did Danga::Socket::close).
SKIP: {
	if ($cls ne 'PublicInbox::DSPoll') {
		skip "$cls doesn't handle EPOLL_CTL_DEL", 2;
	}
	is(epoll_ctl($p, EPOLL_CTL_DEL, fileno($r), 0), 0, 'EPOLL_CTL_DEL OK');
	$n = epoll_wait($p, 9, 0, $events);
	is($n, 0, 'nothing ready after EPOLL_CTL_DEL');
};

done_testing;
debug log:

solving a397ee06 ...
found a397ee06 in https://80x24.org/public-inbox.git

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox