summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d59a9cb)
Since Perl exposes O_NONBLOCK as a constant, we can safely make
SFD_NONBLOCK a constant, too. This is not the case for
SFD_CLOEXEC, since O_CLOEXEC is not exposed by Perl despite
being used internally in the interpreter.
use IO::KQueue;
use Errno qw(EAGAIN);
use PublicInbox::Syscall qw(EPOLLONESHOT EPOLLIN EPOLLOUT EPOLLET
use IO::KQueue;
use Errno qw(EAGAIN);
use PublicInbox::Syscall qw(EPOLLONESHOT EPOLLIN EPOLLOUT EPOLLET
- EPOLL_CTL_ADD EPOLL_CTL_MOD EPOLL_CTL_DEL $SFD_NONBLOCK);
+ EPOLL_CTL_ADD EPOLL_CTL_MOD EPOLL_CTL_DEL SFD_NONBLOCK);
our @EXPORT_OK = qw(epoll_ctl epoll_wait);
sub EV_DISPATCH () { 0x0080 }
our @EXPORT_OK = qw(epoll_ctl epoll_wait);
sub EV_DISPATCH () { 0x0080 }
sub TIEHANDLE { # similar to signalfd()
my ($class, $signo, $flags) = @_;
my $self = $class->new;
sub TIEHANDLE { # similar to signalfd()
my ($class, $signo, $flags) = @_;
my $self = $class->new;
- $self->{timeout} = ($flags & $SFD_NONBLOCK) ? 0 : -1;
+ $self->{timeout} = ($flags & SFD_NONBLOCK) ? 0 : -1;
my $kq = $self->{kq};
$kq->EV_SET($_, EVFILT_SIGNAL, EV_ADD) for @$signo;
$self;
my $kq = $self->{kq};
$kq->EV_SET($_, EVFILT_SIGNAL, EV_ADD) for @$signo;
$self;
STDOUT->autoflush(1);
STDERR->autoflush(1);
use PublicInbox::DS qw(now);
STDOUT->autoflush(1);
STDERR->autoflush(1);
use PublicInbox::DS qw(now);
-use PublicInbox::Syscall qw($SFD_NONBLOCK);
+use PublicInbox::Syscall qw(SFD_NONBLOCK);
require PublicInbox::Listener;
use PublicInbox::EOFpipe;
use PublicInbox::Sigfd;
require PublicInbox::Listener;
use PublicInbox::EOFpipe;
use PublicInbox::Sigfd;
# this calls epoll_create:
PublicInbox::Listener->new($_, $tls_cb || $post_accept)
} @listeners;
# this calls epoll_create:
PublicInbox::Listener->new($_, $tls_cb || $post_accept)
} @listeners;
- my $sigfd = PublicInbox::Sigfd->new($sig, $SFD_NONBLOCK);
+ my $sigfd = PublicInbox::Sigfd->new($sig, SFD_NONBLOCK);
local %SIG = (%SIG, %$sig) if !$sigfd;
if (!$sigfd) {
# wake up every second to accept signals if we don't
local %SIG = (%SIG, %$sig) if !$sigfd;
if (!$sigfd) {
# wake up every second to accept signals if we don't
use IO::Handle ();
use Sys::Syslog qw(syslog openlog);
use PublicInbox::Config;
use IO::Handle ();
use Sys::Syslog qw(syslog openlog);
use PublicInbox::Config;
-use PublicInbox::Syscall qw($SFD_NONBLOCK EPOLLIN EPOLLONESHOT);
+use PublicInbox::Syscall qw(SFD_NONBLOCK EPOLLIN EPOLLONESHOT);
use PublicInbox::Sigfd;
use PublicInbox::DS qw(now dwaitpid);
use PublicInbox::Spawn qw(spawn run_die);
use PublicInbox::Sigfd;
use PublicInbox::DS qw(now dwaitpid);
use PublicInbox::Spawn qw(spawn run_die);
USR1 => \&noop,
USR2 => \&noop,
};
USR1 => \&noop,
USR2 => \&noop,
};
- my $sigfd = PublicInbox::Sigfd->new($sig, $SFD_NONBLOCK);
+ my $sigfd = PublicInbox::Sigfd->new($sig, SFD_NONBLOCK);
local %SIG = (%SIG, %$sig) if !$sigfd;
if ($sigfd) { # TODO: use inotify/kqueue to detect unlinked sockets
PublicInbox::DS->SetLoopTimeout(5000);
local %SIG = (%SIG, %$sig) if !$sigfd;
if ($sigfd) { # TODO: use inotify/kqueue to detect unlinked sockets
PublicInbox::DS->SetLoopTimeout(5000);
package PublicInbox::Sigfd;
use strict;
use parent qw(PublicInbox::DS);
package PublicInbox::Sigfd;
use strict;
use parent qw(PublicInbox::DS);
-use PublicInbox::Syscall qw(signalfd EPOLLIN EPOLLET $SFD_NONBLOCK);
+use PublicInbox::Syscall qw(signalfd EPOLLIN EPOLLET SFD_NONBLOCK);
use POSIX qw(:signal_h);
use IO::Handle ();
use POSIX qw(:signal_h);
use IO::Handle ();
} else {
return; # wake up every second to check for signals
}
} else {
return; # wake up every second to check for signals
}
- if ($flags & $SFD_NONBLOCK) { # it can go into the event loop
+ if ($flags & SFD_NONBLOCK) { # it can go into the event loop
$self->SUPER::new($io, EPOLLIN | EPOLLET);
} else { # master main loop
$self->{sock} = $io;
$self->SUPER::new($io, EPOLLIN | EPOLLET);
} else { # master main loop
$self->{sock} = $io;
EPOLLIN EPOLLOUT EPOLLET
EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
EPOLLONESHOT EPOLLEXCLUSIVE
EPOLLIN EPOLLOUT EPOLLET
EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
EPOLLONESHOT EPOLLEXCLUSIVE
- signalfd $SFD_NONBLOCK);
+ signalfd SFD_NONBLOCK);
our %EXPORT_TAGS = (epoll => [qw(epoll_ctl epoll_create epoll_wait
EPOLLIN EPOLLOUT
EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
our %EXPORT_TAGS = (epoll => [qw(epoll_ctl epoll_create epoll_wait
EPOLLIN EPOLLOUT
EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
);
my $SFD_CLOEXEC = 02000000; # Perl does not expose O_CLOEXEC
);
my $SFD_CLOEXEC = 02000000; # Perl does not expose O_CLOEXEC
-our $SFD_NONBLOCK = O_NONBLOCK;
+sub SFD_NONBLOCK () { O_NONBLOCK }
our $no_deprecated = 0;
if ($^O eq "linux") {
our $no_deprecated = 0;
if ($^O eq "linux") {
use PublicInbox::Config;
use PublicInbox::DS;
use PublicInbox::Sigfd;
use PublicInbox::Config;
use PublicInbox::DS;
use PublicInbox::Sigfd;
-use PublicInbox::Syscall qw($SFD_NONBLOCK);
+use PublicInbox::Syscall qw(SFD_NONBLOCK);
my $do_scan = 1;
GetOptions('scan!' => \$do_scan, # undocumented, testing only
'help|h' => \(my $show_help)) or do { print STDERR $help; exit 1 };
my $do_scan = 1;
GetOptions('scan!' => \$do_scan, # undocumented, testing only
'help|h' => \(my $show_help)) or do { print STDERR $help; exit 1 };
# --no-scan is only intended for testing atm, undocumented.
PublicInbox::DS::requeue($scan) if $do_scan;
# --no-scan is only intended for testing atm, undocumented.
PublicInbox::DS::requeue($scan) if $do_scan;
- my $sigfd = PublicInbox::Sigfd->new($sig, $SFD_NONBLOCK);
+ my $sigfd = PublicInbox::Sigfd->new($sig, SFD_NONBLOCK);
local %SIG = (%SIG, %$sig) if !$sigfd;
if (!$sigfd) {
PublicInbox::Sigfd::sig_setmask($oldset);
local %SIG = (%SIG, %$sig) if !$sigfd;
if (!$sigfd) {
PublicInbox::Sigfd::sig_setmask($oldset);
use IO::Handle;
use POSIX qw(:signal_h);
use Errno qw(ENOSYS);
use IO::Handle;
use POSIX qw(:signal_h);
use Errno qw(ENOSYS);
-use PublicInbox::Syscall qw($SFD_NONBLOCK);
+use PublicInbox::Syscall qw(SFD_NONBLOCK);
require_ok 'PublicInbox::Sigfd';
SKIP: {
require_ok 'PublicInbox::Sigfd';
SKIP: {
- my $nbsig = PublicInbox::Sigfd->new($sig, $SFD_NONBLOCK);
- ok($nbsig, 'Sigfd->new $SFD_NONBLOCK works');
+ my $nbsig = PublicInbox::Sigfd->new($sig, SFD_NONBLOCK);
+ ok($nbsig, 'Sigfd->new SFD_NONBLOCK works');
is($nbsig->wait_once, undef, 'nonblocking ->wait_once');
ok($! == Errno::EAGAIN, 'got EAGAIN');
kill('HUP', $$) or die "kill $!";
is($nbsig->wait_once, undef, 'nonblocking ->wait_once');
ok($! == Errno::EAGAIN, 'got EAGAIN');
kill('HUP', $$) or die "kill $!";